balthisar / cncjs-pendant-gamepad

Use a Videogame Controller as a CNCjs Pendant
MIT License
11 stars 6 forks source link

Mapping for a DS3 like gamepad #1

Open AnTeBiOss opened 2 years ago

AnTeBiOss commented 2 years ago

Thank you for help me to connect my gamepad

My pad works on, it is connected and react with cncjs as well. But no buttons are correctly mapped.

Could you help me to do it ?

AnTeBiOss commented 2 years ago

When i rune in SIMULATOR mode with -vvv:

pi@raspberrypi:~/cncjs-pendant-gamepad $ bin/cncjs-pendant-gamepad.js -p /dev/ttyUSB0 -b 115200 -t grbl simulate -vvv run 
cncjs-pendant-gamepad is currently running. Stop running with Control-C
Use 'cncjs-pendant-gamepad --help' if you're expecting to see something else here.
CNCpad trace CLI       Creating the GamepadController instance.
CNCpad  info GAMEPAD   attach Sony PLAYSTATION(R)3 Controller (id 0)
CNCpad trace CLI       Starting the main connector service.
CNCpad  info SIMULATOR Attempting connect to ws://localhost:8000
CNCpad  info SIMULATOR Sending open request for /dev/ttyUSB0 at baud rate 115200
CNCpad  info SIMULATOR Connection to /dev/ttyUSB0 successful.
CNCpad  info SIMULATOR Ready to listen for message 'connect' from the socket.
CNCpad  info SIMULATOR Ready to listen for message 'error' from the socket.
CNCpad  info SIMULATOR Ready to listen for message 'close' from the socket.
CNCpad  info SIMULATOR Ready to listen for message 'serialport:open' from the socket.
CNCpad  info SIMULATOR Ready to listen for message 'serialport:close' from the socket.
CNCpad  info SIMULATOR Ready to listen for message 'serialport:error' from the socket.
CNCpad  info SIMULATOR Ready to listen for message 'serialport:read' from the socket.
CNCpad  info SIMULATOR Ready to listen for message 'serialport:write' from the socket.
CNCpad  info SIMULATOR Ready to listen for message 'controller:settings' from the socket.
CNCpad  info SIMULATOR Ready to listen for message 'controller:state' from the socket.
CNCpad  info SIMULATOR Ready to listen for message 'workflow:state' from the socket.
CNCpad trace CLI       Starting the actions service.
CNCpad  info SIMULATOR Ready to listen for message 'serialport:read' from the socket.

I'm trying to make a keymap in chord with my gamepad :)

AnTeBiOss commented 2 years ago

Here i have done my keymap :

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

A | press { id: 0, num: 0, button: 'KEYCODE_BUTTON_X' } -- | -- B | press { id: 0, num: 1, button: 'KEYCODE_BUTTON_A' } X | press { id: 0, num: 3, button: 'KEYCODE_BUTTON_Y' } Y | press { id: 0, num: 2, button: 'KEYCODE_BUTTON_B' } L1 | press { id: 0, num: 4, button: 'KEYCODE_BUTTON_L1' } R1 | press { id: 0, num: 5, button: 'KEYCODE_BUTTON_R1' } L2 | press { id: 0, num: 6, button: 'KEYCODE_BUTTON_LTRIGGER' }   | move { id: 0, axis: 2, value: 1, button: 'AXIS_Z' } R2 | press { id: 0, num: 7, button: 'KEYCODE_BUTTON_RTRIGGER' }   | move { id: 0, axis: 5, value: 1, button: 'AXIS_RZ' } Start | press { id: 0, num: 9, button: 'KEYCODE_BUTTON_START' } Select | press { id: 0, num: 8, button: 'KEYCODE_BACK' } Home | press { id: 0, num: 10, button: 'KEYCODE_BUTTON_THUMBL' }   | Left Thumb Enabled:true, Right Thumb Enabled:false ▲ | press { id: 0, num: 13, button: 'KEYCODE_BUTTON_TOUCHPAD' } ► | press { id: 0, num: 16, button: undefined } ▼ | press { id: 0, num: 14, button: undefined } ◄ | press { id: 0, num: 15, button: undefined } LS ▲▼ | move { id: 0, axis: 1, value: -0.3333333134651184, button: 'AXIS_X' } LS ◄ ► | move { id: 0, axis: 0, value: 0.20000004768371582, button: 'AXIS_Y' } RS ▲▼ | move { id: 0, axis: 4, value: -0.270588219165802, button: 'AXIS_RTRIGGER' } RS ◄ ► | move { id: 0, axis: 3, value: 0.2705882787704468, button: 'AXIS_LTRIGGER' } LS clic | press { id: 0, num: 11, button: 'KEYCODE_BUTTON_THUMBR' }   | Left Thumb Enabled:false, Right Thumb Enabled:true RS Clic | press { id: 0, num: 12, button: 'KEYCODE_HOME' }

With the hope it is well enough.

Thanks by advance

AnTeBiOss commented 2 years ago

I have tried to add this in gamepad_controler.ts without success :

'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',
      '10': 'KEYCODE_BUTTON_THUMBL',
      '11': 'KEYCODE_BUTTON_THUMBR',
      '12': 'KEYCODE_HOME',
      '13': 'KEYCODE_BUTTON_TOUCHPAD'
    },

    'axes': {
      '0': 'AXIS_Y',
      '1': 'AXIS_X',
      '2': 'AXIS_Z',
      '3': 'AXIS_LTRIGGER', // note: also activates the button.
      '4': 'AXIS_RTRIGGER', // note: also activates the button.
      '5': 'AXIS_RZ',
      '6': 'AXIS_HAT_X',
      '7': 'AXIS_HAT_Y'
    }
  },
AnTeBiOss commented 2 years ago

Even a Microsoft X-Box 360 pad do not work :/