From 447316c7065bd1bf3a2845eefea2d5f89ec7b677 Mon Sep 17 00:00:00 2001 From: rdb Date: Fri, 30 Nov 2018 20:13:13 +0100 Subject: [PATCH] samples: fixes for gamepad samples --- samples/gamepad/flightstick.py | 6 +++--- samples/gamepad/gamepad.py | 6 +++--- samples/gamepad/mappingGUI.py | 6 ++++-- samples/gamepad/steeringWheel.py | 6 +++--- 4 files changed, 13 insertions(+), 11 deletions(-) diff --git a/samples/gamepad/flightstick.py b/samples/gamepad/flightstick.py index 0a06c52585..4520cfefb2 100644 --- a/samples/gamepad/flightstick.py +++ b/samples/gamepad/flightstick.py @@ -38,7 +38,7 @@ class App(ShowBase): # Is there a gamepad connected? self.flightStick = None - devices = self.devices.getDevices(InputDevice.DC_flight_stick) + devices = self.devices.getDevices(InputDevice.DeviceClass.flight_stick) if devices: self.connect(devices[0]) @@ -74,7 +74,7 @@ class App(ShowBase): # We're only interested if this is a flight stick and we don't have a # flight stick yet. - if device.device_class == InputDevice.DC_flight_stick and not self.flightStick: + if device.device_class == InputDevice.DeviceClass.flight_stick and not self.flightStick: print("Found %s" % (device)) self.flightStick = device @@ -98,7 +98,7 @@ class App(ShowBase): self.flightStick = None # Do we have any other gamepads? Attach the first other gamepad. - devices = self.devices.getDevices(InputDevice.DC_flight_stick) + devices = self.devices.getDevices(InputDevice.DeviceClass.flight_stick) if devices: self.connect(devices[0]) else: diff --git a/samples/gamepad/gamepad.py b/samples/gamepad/gamepad.py index c684c01253..8679a74187 100644 --- a/samples/gamepad/gamepad.py +++ b/samples/gamepad/gamepad.py @@ -63,7 +63,7 @@ class App(ShowBase): # Is there a gamepad connected? self.gamepad = None - devices = self.devices.getDevices(InputDevice.DC_gamepad) + devices = self.devices.getDevices(InputDevice.DeviceClass.gamepad) if devices: self.connect(devices[0]) @@ -99,7 +99,7 @@ class App(ShowBase): # We're only interested if this is a gamepad and we don't have a # gamepad yet. - if device.device_class == InputDevice.DC_gamepad and not self.gamepad: + if device.device_class == InputDevice.DeviceClass.gamepad and not self.gamepad: print("Found %s" % (device)) self.gamepad = device @@ -123,7 +123,7 @@ class App(ShowBase): self.gamepad = None # Do we have any other gamepads? Attach the first other gamepad. - devices = self.devices.getDevices(InputDevice.DC_gamepad) + devices = self.devices.getDevices(InputDevice.DeviceClass.gamepad) if devices: self.connect(devices[0]) else: diff --git a/samples/gamepad/mappingGUI.py b/samples/gamepad/mappingGUI.py index 84f26a9f60..17896c33a6 100644 --- a/samples/gamepad/mappingGUI.py +++ b/samples/gamepad/mappingGUI.py @@ -83,6 +83,8 @@ class ChangeActionDialog(object): self.__command = command + self.attachedDevices = [] + # Initialize the DirectGUI stuff. self.dialog = OkCancelDialog( dialogName="dlg_device_input", @@ -293,7 +295,7 @@ class MappingGUIDemo(ShowBase): devices = base.devices.getDevices() for device in devices: base.attachInputDevice(device) - self.attachedDevices = devices + self.attachedDevices = devices # Disable regular button events on all button event throwers, and # instead broadcast a generic event. @@ -324,7 +326,7 @@ class MappingGUIDemo(ShowBase): def watchControls(self, task): # move through all devices and all it's controls for device in self.attachedDevices: - if device.device_class == InputDevice.DC_mouse: + if device.device_class == InputDevice.DeviceClass.mouse: # Ignore mouse axis movement, or the user can't even navigate # to the OK/Cancel buttons! continue diff --git a/samples/gamepad/steeringWheel.py b/samples/gamepad/steeringWheel.py index 65e5aa63f4..09b0d9d167 100644 --- a/samples/gamepad/steeringWheel.py +++ b/samples/gamepad/steeringWheel.py @@ -35,7 +35,7 @@ class App(ShowBase): # Is there a steering wheel connected? self.wheel = None - devices = self.devices.getDevices(InputDevice.DC_steering_wheel) + devices = self.devices.getDevices(InputDevice.DeviceClass.steering_wheel) if devices: self.connect(devices[0]) @@ -79,7 +79,7 @@ class App(ShowBase): # We're only interested if this is a steering wheel and we don't have a # wheel yet. - if device.device_class == InputDevice.DC_steering_wheel and not self.wheel: + if device.device_class == InputDevice.DeviceClass.steering_wheel and not self.wheel: print("Found %s" % (device)) self.wheel = device @@ -103,7 +103,7 @@ class App(ShowBase): self.wheel = None # Do we have any steering wheels? Attach the first other steering wheel. - devices = self.devices.getDevices(InputDevice.DC_steering_wheel) + devices = self.devices.getDevices(InputDevice.DeviceClass.steering_wheel) if devices: self.connect(devices[0]) else: