Skip to content

Commit 447316c

Browse files
committed
samples: fixes for gamepad samples
1 parent 2917027 commit 447316c

File tree

4 files changed

+13
-11
lines changed

4 files changed

+13
-11
lines changed

samples/gamepad/flightstick.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def __init__(self):
3838

3939
# Is there a gamepad connected?
4040
self.flightStick = None
41-
devices = self.devices.getDevices(InputDevice.DC_flight_stick)
41+
devices = self.devices.getDevices(InputDevice.DeviceClass.flight_stick)
4242
if devices:
4343
self.connect(devices[0])
4444

@@ -74,7 +74,7 @@ def connect(self, device):
7474

7575
# We're only interested if this is a flight stick and we don't have a
7676
# flight stick yet.
77-
if device.device_class == InputDevice.DC_flight_stick and not self.flightStick:
77+
if device.device_class == InputDevice.DeviceClass.flight_stick and not self.flightStick:
7878
print("Found %s" % (device))
7979
self.flightStick = device
8080

@@ -98,7 +98,7 @@ def disconnect(self, device):
9898
self.flightStick = None
9999

100100
# Do we have any other gamepads? Attach the first other gamepad.
101-
devices = self.devices.getDevices(InputDevice.DC_flight_stick)
101+
devices = self.devices.getDevices(InputDevice.DeviceClass.flight_stick)
102102
if devices:
103103
self.connect(devices[0])
104104
else:

samples/gamepad/gamepad.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ def __init__(self):
6363

6464
# Is there a gamepad connected?
6565
self.gamepad = None
66-
devices = self.devices.getDevices(InputDevice.DC_gamepad)
66+
devices = self.devices.getDevices(InputDevice.DeviceClass.gamepad)
6767
if devices:
6868
self.connect(devices[0])
6969

@@ -99,7 +99,7 @@ def connect(self, device):
9999

100100
# We're only interested if this is a gamepad and we don't have a
101101
# gamepad yet.
102-
if device.device_class == InputDevice.DC_gamepad and not self.gamepad:
102+
if device.device_class == InputDevice.DeviceClass.gamepad and not self.gamepad:
103103
print("Found %s" % (device))
104104
self.gamepad = device
105105

@@ -123,7 +123,7 @@ def disconnect(self, device):
123123
self.gamepad = None
124124

125125
# Do we have any other gamepads? Attach the first other gamepad.
126-
devices = self.devices.getDevices(InputDevice.DC_gamepad)
126+
devices = self.devices.getDevices(InputDevice.DeviceClass.gamepad)
127127
if devices:
128128
self.connect(devices[0])
129129
else:

samples/gamepad/mappingGUI.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@ def __init__(self, action, button_geom, command):
8383

8484
self.__command = command
8585

86+
self.attachedDevices = []
87+
8688
# Initialize the DirectGUI stuff.
8789
self.dialog = OkCancelDialog(
8890
dialogName="dlg_device_input",
@@ -293,7 +295,7 @@ def changeMapping(self, action):
293295
devices = base.devices.getDevices()
294296
for device in devices:
295297
base.attachInputDevice(device)
296-
self.attachedDevices = devices
298+
self.attachedDevices = devices
297299

298300
# Disable regular button events on all button event throwers, and
299301
# instead broadcast a generic event.
@@ -324,7 +326,7 @@ def changeMapping(self, action):
324326
def watchControls(self, task):
325327
# move through all devices and all it's controls
326328
for device in self.attachedDevices:
327-
if device.device_class == InputDevice.DC_mouse:
329+
if device.device_class == InputDevice.DeviceClass.mouse:
328330
# Ignore mouse axis movement, or the user can't even navigate
329331
# to the OK/Cancel buttons!
330332
continue

samples/gamepad/steeringWheel.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def __init__(self):
3535

3636
# Is there a steering wheel connected?
3737
self.wheel = None
38-
devices = self.devices.getDevices(InputDevice.DC_steering_wheel)
38+
devices = self.devices.getDevices(InputDevice.DeviceClass.steering_wheel)
3939
if devices:
4040
self.connect(devices[0])
4141

@@ -79,7 +79,7 @@ def connect(self, device):
7979

8080
# We're only interested if this is a steering wheel and we don't have a
8181
# wheel yet.
82-
if device.device_class == InputDevice.DC_steering_wheel and not self.wheel:
82+
if device.device_class == InputDevice.DeviceClass.steering_wheel and not self.wheel:
8383
print("Found %s" % (device))
8484
self.wheel = device
8585

@@ -103,7 +103,7 @@ def disconnect(self, device):
103103
self.wheel = None
104104

105105
# Do we have any steering wheels? Attach the first other steering wheel.
106-
devices = self.devices.getDevices(InputDevice.DC_steering_wheel)
106+
devices = self.devices.getDevices(InputDevice.DeviceClass.steering_wheel)
107107
if devices:
108108
self.connect(devices[0])
109109
else:

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy