import arcade
import warnings
from pyglet.input import Controller
from arcade.experimental.controller_window import ControllerView, ControllerWindow
from arcade import Window, View, ControllerManager, InputManager
class MyControllerView(View):
def __init__(self):
super().__init__()
self.ims = []
self.cm = ControllerManager()
self.cm.push_handlers(self)
# bind to existing controllers
for controller in self.cm.get_controllers():
self.on_connect(controller)
self.default_input = InputManager(allow_keyboard=True)
self.default_input.new_action("left")
self.default_input.new_action("right")
self.default_input.new_action("up")
self.default_input.new_action("down")
self.default_input.add_action_input("left", arcade.ControllerButtons.DPAD_LEFT)
self.default_input.add_action_input("right", arcade.ControllerButtons.DPAD_RIGHT)
self.default_input.add_action_input("up", arcade.ControllerButtons.DPAD_UP)
self.default_input.add_action_input("down", arcade.ControllerButtons.DPAD_DOWN)
self.default_input.new_action("a")
self.default_input.new_action("b")
self.default_input.new_action("x")
self.default_input.new_action("y")
self.default_input.add_action_input("a", arcade.ControllerButtons.BOTTOM_FACE)
self.default_input.add_action_input("b", arcade.ControllerButtons.RIGHT_FACE)
self.default_input.add_action_input("x", arcade.ControllerButtons.LEFT_FACE)
self.default_input.add_action_input("y", arcade.ControllerButtons.TOP_FACE)
def on_action(self, action, state):
print(f"action: {action}, state: {state}")
def on_connect(self, controller: Controller):
print(f"connected to controller: {controller}")
self.ims.append(InputManager.from_existing(self.default_input, controller))
def on_disconnect(self, controller: Controller):
pass
def on_update(self, delta_time: float) -> bool | None:
for im in self.ims:
im.update()
if __name__ == '__main__':
Window().run(MyControllerView())
Pressing dpad should print out directions like for the buttons.
Only buttons trigger an action.
Reproduce
Pressing dpad should print out directions like for the buttons.
Actual behavior
Only buttons trigger an action.