Capturing Joystick button presses
-
Hello all! I'm attempting to create what's effectively a keybinding dialog box (ie: capture a keypress to store for later use).
My dialog widget - which extends QDialog - has this eventFilter function set up:
def eventFilter(self, watched: QObject | None, event: QEvent | None) -> bool: events = [ QEvent.Type.KeyRelease, QEvent.Type.KeyPress, QEvent.Type.Wheel, QEvent.Type.MouseButtonPress, QEvent.Type.MouseButtonRelease, ] if watched is self and event.type() in events: print("{0} - Key `{1}` | Button `{2}`".format( event.type().name, event.key() if hasattr(event, 'key') and callable(getattr(event, 'key')) else "", event.button() if hasattr(event, 'button') and callable(getattr(event, 'button')) else "", )) return super().eventFilter(watched, event)
It's mostly there, I can see keyboard presses, mouse presses, wheel scrolling:
But I also would like to be able to capture joystick inputs too, and I'm just not seeing those come through or any event types that look like them.
I have a "controller" (in this case a button box) that is set up and recognized in Windows:
How can I capture these specific button-press-events emitting from joysticks/controllers?
I'm sure there is an answer out there I apologize I'm having trouble finding it, most of my searches have yielded results towards replicating a joystick rather than using one as input. Perhaps I'm just trying to use Qt as a hammer for a problem that isn't nail shaped after all lol.
Happy to add any more details if they will help, thanks y'all for any help in advance!