Trap events with getHat in game control plus


#1

Hi, i want to know if there’s a way to trap events with the dpad button in the game control plus library. i can trap events with buttons, for example the key A of the xbox controller might look like this: xbox.getButton("a").plug(this, "my_function", ControlIO.ON_PRESS);
but i don’t know how to make it the dpad key works, i would expect something like this, in where i specify the key that i’m using, but no. xbox.getHat("navigation").right().plug(this, "other_function", ControlIO.ON_PRESS);


#2

@quark Hi, first of all thank you for this awesome library, and second sorry for tagging you but i still don’t know how to make this works. Greetings!


#3

I have no problem with members tagging me, sometimes I end up missing a post about one of my libraries. :smile:

OK, the ‘hat’ is the four position switch found on the top af a joystick handle. There is no hat on an xbox controller, at least not on mine.


#4

Thanks for reply!, and the only way that I can have access to the functionality of the directional pad button is calling it as a hat button. For example, I called that dpad “navigation” and this works for it xbox.getHat("navigation").right().pressed()


#5

Or, how can i have access to the directions from the dpad and trap events? i tried using the getButton function, but it doesn’t works for this button, or probably i’m missing something.
Greetings!


#6

Plug your controller into the USB port and run the configurator example sketch that comes with the library. In the window that opens select your controller. A new window opens and lists all the IO devices it finds and has indicators that light up when you operate the controller so you can see their names.

Also I suggest you look at the videos on my website.