Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PS3 : HAT X- X+ Y- Y+ are buttons, not axes #3

Open
mathojojo opened this issue Aug 11, 2022 · 1 comment
Open

PS3 : HAT X- X+ Y- Y+ are buttons, not axes #3

mathojojo opened this issue Aug 11, 2022 · 1 comment

Comments

@mathojojo
Copy link

Hello,

I could make my PS3 controller work on CNCjs with your gamepad pendant. Thank you.

There is just a problem with HAT buttons. Your gamepad.ts configuration file is considering them as Axes. It might be the case on most controller, I don't know. But on the PS3 Controller, X-, X+, Y- and Y+ are 4 differents buttons, not 2 axes.

So I can't use the hat, and Z axe can only be controlled with the Y- Y+ Hat buttons.

Can you fix it, or give me a way to make it work anyway ?

Thank you

@mathojojo
Copy link
Author

mathojojo commented Aug 11, 2022

  // This is the mapping for the PS3 controller
  //This controller has 6 axes (0 to 5) and 17 buttons (0 to 16)
  'Sony PLAYSTATION(R)3 Controller': {

    'buttons': {
      '3': 'KEYCODE_BUTTON_X',
      '0': 'KEYCODE_BUTTON_A',
      '1': 'KEYCODE_BUTTON_B',
      '2': 'KEYCODE_BUTTON_Y',
      '4': 'KEYCODE_BUTTON_L1',
      '5': 'KEYCODE_BUTTON_R1',
      '6': 'KEYCODE_BUTTON_LTRIGGER', // note: ALSO activates the axis.
      '7': 'KEYCODE_BUTTON_RTRIGGER', // note: ALSO activates the axis.
      '8': 'KEYCODE_BACK',
      '9': 'KEYCODE_BUTTON_START',
      '11': 'KEYCODE_BUTTON_THUMBL',
      '12': 'KEYCODE_BUTTON_THUMBR',
      '10': 'KEYCODE_HOME',
      '13': 'KEYCODE_BUTTON_HAT_X_PLUS',
      '14': 'KEYCODE_BUTTON_HAT_X_MINUS',
      '15': 'KEYCODE_BUTTON_HAT_Y_PLUS',
      '16': 'KEYCODE_BUTTON_HAT_Y_MINUS'
    },

I added 4 keys (13, 14, 15 and 16) accordingly to the PS3 controller HAT direction buttons. But of course, they won't be executed as the code doesn't know them.

And this is the answer for jstest /dev/input/js0 :
Joystick (Sony PLAYSTATION(R)3 Controller) has 6 axes (X, Y, Z, Rx, Ry, Rz) and 17 buttons (BtnA, BtnB, BtnX, BtnY, BtnTL, BtnTR, BtnTL2, BtnTR2, BtnSelect, BtnStart, BtnMode, BtnThumbL, BtnThumbR, (null), (null), (null), (null)).

The last 4 buttons seems to not have names, but they are the 13, 14, 15 and 16 hat pad buttons.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant