andrewfstratton / quando

Visual Programming for Digitally Interactive Exhibits
10 stars 7 forks source link

Control Pico as DirectInput Gamepad #480

Open andrewfstratton opened 8 months ago

andrewfstratton commented 8 months ago

Fix:

Tried

- https://circuitpython-joystickxl.readthedocs.io/en/latest/start.html

For TinyGo see https://github.com/tinygo-org/tinygo/blob/release/src/examples/hid-joystick/main.go

minimal tests/code

TODO:

  1. Try on steam or games
    • check with directinput ~and Xinput~
      • can map through steam to xinput
      • use usb hid with steam allows mouse and keyboard as well but requires a device (though no modifications needed)

REF

Badger20240 appears to have USB\VID_03F0&PID_0C67

Pico has Pico C SDK Product ID - not Micro/CircuitPython?!

Mapping of Buttons (according to web gamepadtester) -as B0..B16, i.e

0..3 A B X Y 4..7 LB RB HOME LT - 0..1.0, i.e. analogue button N/A RT - 0..1.0, i.e. analogue button 8..11 Select (left) Start (right) L Stick Press R Stick Press 12..15 ^ v < >

  1. CRASH?! rpico.js won't pass invalid button

DONE

  1. reset presses gamepad button every 2 seconds for 1 second
  2. badger button a/b/c presses gamepad buttons A B X
  3. message from PC is shown on display
    • OR can blink on/off led - reliably
  4. message passes true/false as value 1/0
  5. handle 1 to press and 0 to release for an identified button
  6. handle either
  7. Create razor based tester with android Needs https
  8. Try on separate PC with controller
    • no longer true for simple use needs chrome insecure setting in chrome://flags
  9. Send button as B to press and b to release
  10. message pass axis val as 0..1
    • need to map to -32767..32767
    • convert in rpico.gamepad_axis before sending to server
    • n.b. map to non 0 so 0+ have 1 added so empty/corrupted can be detected
      • so rpico needs to map back as well, i.e. 1..65536 maps to -32767..32767
  11. handle val to trigger/stick
  12. Need to be recognised properly by Windows:
    • axis - send as XYZ and xyz (for rotation)
    • trigger - see previous - possibly using 1..255 with 128 as middle
    • Hat -send as button
  13. Can't have any other hid connection at same time - so can't send message over USB For games (and windows) may need to be an XBox 360 controller - see https://github.com/fluffymadness/tinyusb-xinput and GP2040 (CE)?