samples: fixes for gamepad samples

This commit is contained in:
rdb 2018-11-30 20:13:13 +01:00
parent 29170278e9
commit 447316c706
4 changed files with 13 additions and 11 deletions

View File

@ -38,7 +38,7 @@ class App(ShowBase):
# Is there a gamepad connected? # Is there a gamepad connected?
self.flightStick = None self.flightStick = None
devices = self.devices.getDevices(InputDevice.DC_flight_stick) devices = self.devices.getDevices(InputDevice.DeviceClass.flight_stick)
if devices: if devices:
self.connect(devices[0]) 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 # We're only interested if this is a flight stick and we don't have a
# flight stick yet. # 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)) print("Found %s" % (device))
self.flightStick = device self.flightStick = device
@ -98,7 +98,7 @@ class App(ShowBase):
self.flightStick = None self.flightStick = None
# Do we have any other gamepads? Attach the first other gamepad. # 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: if devices:
self.connect(devices[0]) self.connect(devices[0])
else: else:

View File

@ -63,7 +63,7 @@ class App(ShowBase):
# Is there a gamepad connected? # Is there a gamepad connected?
self.gamepad = None self.gamepad = None
devices = self.devices.getDevices(InputDevice.DC_gamepad) devices = self.devices.getDevices(InputDevice.DeviceClass.gamepad)
if devices: if devices:
self.connect(devices[0]) 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 # We're only interested if this is a gamepad and we don't have a
# gamepad yet. # 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)) print("Found %s" % (device))
self.gamepad = device self.gamepad = device
@ -123,7 +123,7 @@ class App(ShowBase):
self.gamepad = None self.gamepad = None
# Do we have any other gamepads? Attach the first other gamepad. # 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: if devices:
self.connect(devices[0]) self.connect(devices[0])
else: else:

View File

@ -83,6 +83,8 @@ class ChangeActionDialog(object):
self.__command = command self.__command = command
self.attachedDevices = []
# Initialize the DirectGUI stuff. # Initialize the DirectGUI stuff.
self.dialog = OkCancelDialog( self.dialog = OkCancelDialog(
dialogName="dlg_device_input", dialogName="dlg_device_input",
@ -324,7 +326,7 @@ class MappingGUIDemo(ShowBase):
def watchControls(self, task): def watchControls(self, task):
# move through all devices and all it's controls # move through all devices and all it's controls
for device in self.attachedDevices: 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 # Ignore mouse axis movement, or the user can't even navigate
# to the OK/Cancel buttons! # to the OK/Cancel buttons!
continue continue

View File

@ -35,7 +35,7 @@ class App(ShowBase):
# Is there a steering wheel connected? # Is there a steering wheel connected?
self.wheel = None self.wheel = None
devices = self.devices.getDevices(InputDevice.DC_steering_wheel) devices = self.devices.getDevices(InputDevice.DeviceClass.steering_wheel)
if devices: if devices:
self.connect(devices[0]) 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 # We're only interested if this is a steering wheel and we don't have a
# wheel yet. # 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)) print("Found %s" % (device))
self.wheel = device self.wheel = device
@ -103,7 +103,7 @@ class App(ShowBase):
self.wheel = None self.wheel = None
# Do we have any steering wheels? Attach the first other steering wheel. # 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: if devices:
self.connect(devices[0]) self.connect(devices[0])
else: else: