Browse Source

samples: fixes for gamepad samples

rdb 7 years ago
parent
commit
447316c706

+ 3 - 3
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:

+ 3 - 3
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:

+ 4 - 2
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

+ 3 - 3
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: