View: 3345|Reply: 46

HID Keyboard Joystick on orangepi zero

[Copy link]

1

threads

2

posts

11

credits

Novice

Rank: 1

credits
11
Published in 2022-5-25 14:35:33 | Show all floors |Read mode
How to use an orange pi zero as a keyboard and joystick.

The joystick is a copy of the teensy extreme joystick 128 buttons 23 axis/sliders and 4 hats, microsoft does recognise this.

First make sure ethernet or WIFI works and you cna ssh in a user.


In /etc/modprobe.d/blacklist-orangepizero.conf add

blacklist g_serial
blacklist usb_f_acm

In /etc/modules add

libcomposite
usb_f_hid


reboot


After reboot from a user account run the following script using sudo,
  1. #!/bin/bash

  2. set -x

  3. # Create gadget
  4. mkdir /sys/kernel/config/usb_gadget/mykeyboard
  5. cd /sys/kernel/config/usb_gadget/mykeyboard

  6. # Add basic information
  7. echo 0x0100 > bcdDevice # Version 1.0.0
  8. echo 0x0200 > bcdUSB # USB 2.0
  9. echo 0x00 > bDeviceClass
  10. echo 0x00 > bDeviceProtocol
  11. echo 0x00 > bDeviceSubClass
  12. echo 0x08 > bMaxPacketSize0
  13. echo 0x0104 > idProduct # Keyboard Joystick Composite Gadget
  14. echo 0x1d6b > idVendor # Linux Foundation

  15. # Create English locale
  16. mkdir strings/0x409

  17. echo "My manufacturer" > strings/0x409/manufacturer
  18. echo "My keyboard joystick" > strings/0x409/product
  19. echo "0123456789" > strings/0x409/serialnumber

  20. # Create HID function
  21. mkdir functions/hid.usb0
  22. mkdir functions/hid.usb1

  23. echo 1 > functions/hid.usb0/protocol
  24. echo 8 > functions/hid.usb0/report_length # 8-byte reports
  25. echo 1 > functions/hid.usb0/subclass

  26. # Write report descriptor
  27. echo "05010906a101050719e029e71500250175019508810275089501810175019503050819012903910275019505910175089506150026ff00050719002aff008100c0" | xxd -r -ps > functions/hid.usb0/report_desc

  28. echo 0 > functions/hid.usb1/protocol
  29. echo 64 > functions/hid.usb1/report_length # 64-byte reports
  30. echo 1 > functions/hid.usb1/subclass

  31. # Write report descriptor
  32. echo "05010904A1011500250175019580050919012980810205010901A100150027FFFF000075109517093009310932093309340935093609360936093609360936093609360936093609360936093609360936093609368102C0150025073500463B01750495046514050109390939093909398142C0" | xxd -r -ps > functions/hid.usb1/report_desc

  33. # Create configuration
  34. mkdir configs/c.1
  35. mkdir configs/c.1/strings/0x409

  36. echo 0x80 > configs/c.1/bmAttributes
  37. echo 200 > configs/c.1/MaxPower # 200 mA
  38. echo "Composite configuration" > configs/c.1/strings/0x409/configuration

  39. # Link HID function to configuration
  40. ln -s functions/hid.usb0 configs/c.1

  41. ln -s functions/hid.usb1 configs/c.1

  42. # Enable gadget
  43. ls /sys/class/udc > UDC
Copy code






1

threads

2

posts

11

credits

Novice

Rank: 1

credits
11
 Author| Published in 2022-5-29 14:06:50 | Show all floors
New set of report descriptors
1. N key keyboard in 2 reports has f13-f24
2. Joystick with 64 buttons 12 axis 4 hats
3. Dual xbox style gamepads in 2 reports

  1. #!/bin/bash

  2. set -x

  3. # Create gadget
  4. mkdir /sys/kernel/config/usb_gadget/mykeyboard
  5. cd /sys/kernel/config/usb_gadget/mykeyboard

  6. # Add Device Descriptor information
  7. echo 0x0100 > bcdDevice # Version 1.0.0
  8. echo 0x0200 > bcdUSB # USB 2.0
  9. echo 0x00 > bDeviceClass
  10. echo 0x00 > bDeviceProtocol
  11. echo 0x00 > bDeviceSubClass
  12. echo 0x22 > bMaxPacketSize0
  13. echo 0x6969 > idProduct # Keyboard Joystick Composite Gadget
  14. echo 0x1d6b > idVendor # Linux Foundation

  15. # Create English locale
  16. mkdir strings/0x409

  17. echo "Languid" > strings/0x409/manufacturer
  18. echo "keyboard, joystick, dual gamepad"> strings/0x409/product
  19. echo "0123456789" > strings/0x409/serialnumber

  20. # Create configuration descriptor
  21. mkdir configs/c.1
  22. mkdir configs/c.1/strings/0x409

  23. echo 0x80 > configs/c.1/bmAttributes
  24. echo 200 > configs/c.1/MaxPower # 200 mA
  25. echo 0 > configs/c.1/iConfiguration
  26. echo "Composite configuration" > configs/c.1/strings/0x409/configuration

  27. # Create HID endpoints

  28. # Create keyboard
  29. keyboard() {
  30. # Create interface descriptor information
  31. mkdir functions/hid.usb0
  32. echo 1 > functions/hid.usb0/protocol
  33. echo 8 > functions/hid.usb0/report_length # 8-byte reports
  34. echo 0 > functions/hid.usb0/subclass

  35. # Write report descriptor, keyboard 2 parts ID:1,2
  36. echo "05010906a1018501050719e029e71425017501950881021904293b95388102c005010906a10185020507193c29651425017501952a810219672973950d810295098102c0" | xxd -r -ps > functions/hid.usb0/report_desc

  37. ln -s functions/hid.usb0 configs/c.1
  38. }

  39. # Create extreme joystick
  40. joystick() {
  41. # Create interface descriptor information
  42. mkdir functions/hid.usb1
  43. echo 0 > functions/hid.usb1/protocol
  44. echo 34 > functions/hid.usb1/report_length # 34-byte reports
  45. echo 0 > functions/hid.usb1/subclass

  46. # Write report descriptor, stolen from teensy forum extreme joystick
  47. # Write 64 bytes to the following endpoint in the same order as listed
  48. # buttons 64 so 64/8 = 8 bytes
  49. # axis and sliders 12 for x,y,z,R(x),R(y),R(z),Slider*6 so 12*2 = 24 bytes
  50. # hats 4 so 4*.5 = 2 bytes
  51. echo "05010904a1010509142501750195401901294081020b01000100a01427ffff0000751095060b300001000b310001000b320001000b330001000b340001000b350001008102c00b01000100a01427ffff0000751095060b360001000b360001000b360001000b360001000b360001000b360001008102c00b01000100a014250734463b017504950465140b390001000b390001000b390001000b390001008142c0c0" | xxd -r -ps > functions/hid.usb1/report_desc

  52. ln -s functions/hid.usb1 configs/c.1
  53. }

  54. # Create dual gamepad, index by "Report ID"
  55. gamepad() {
  56. # Create interface descriptor information
  57. mkdir functions/hid.usb2
  58. echo 0 > functions/hid.usb2/protocol
  59. echo 7 > functions/hid.usb2/report_length # 7-byte report includes Report ID
  60. echo 0 > functions/hid.usb2/subclass

  61. # Write report descriptor, stolen from some guys tutorial on
  62. # doing composite report ID thing, microsoft shows both devices
  63. # Format..
  64. # report id, need to include or it won't work
  65. # buttons
  66. # buttons
  67. # X
  68. # Y
  69. # Z
  70. # R(x)
  71. echo "05010905A101A100850105091901291015002501951075018102050109300931093209331581257F750895048102C0C005010905A101A100850205091901291015002501951075018102050109300931093209331581257F750895048102C0C0" | xxd -r -ps > functions/hid.usb2/report_desc

  72. ln -s functions/hid.usb2 configs/c.1
  73. }

  74. # Link HID function to configuration
  75. keyboard
  76. joystick
  77. gamepad

  78. # Enable gadget
  79. ls /sys/class/udc > UDC
Copy code

0

threads

17

posts

408

credits

Forbidden to speak

credits
408
Published in 2022-8-27 15:08:45 | Show all floors
Tips: Disabled or deleted by author , the content is blocked

0

threads

4

posts

12

credits

Novice

Rank: 1

credits
12
Published in 2023-8-3 10:29:53 | Show all floors
To control the HID keyboard on the Orange Pi Zero, you need to use the Evdev library in Python. This library allows you to communicate The Password Game with HID devices such as keyboards, mice, and other input devices.

0

threads

7

posts

30

credits

Novice

Rank: 1

credits
30
Published in 2023-8-7 11:23:28 | Show all floors
This post was finally edited by lorde at 2023-8-7 11:24

Make sure that Ethernet melon playground or Wi-Fi is working, and you can SSH into the Orange Pi Zero as a user.

0

threads

3

posts

10

credits

Novice

Rank: 1

credits
10
Published in 2023-8-7 11:45:49 | Show all floors
It's important to mention that this process involves making low-level changes to the kernel modules and can potentially affect the functionality of your Orange Pi. Additionally, mapquest directions using the Orange Pi Zero as both a keyboard and a joystick involves dealing with USB HID (Human Interface Device) emulation, which might require some programming or scripting knowledge to create the appropriate configuration.

0

threads

3

posts

10

credits

Novice

Rank: 1

credits
10
Published in 2023-8-8 09:46:19 | Show all floors
The script sets up slope game the necessary kernel configuration for the USB gadget. It creates a new gadget folder under /sys/kernel/config/usb_gadget and populates it with configuration files.

0

threads

18

posts

58

credits

Registered member

Rank: 2

credits
58
Published in 2023-8-15 15:15:11 | Show all floors
I have learned many new and interesting things The Password Game from reading your post and hope you will post more interesting information in the near future.

0

threads

7

posts

20

credits

Novice

Rank: 1

credits
20
Published in 2023-8-29 11:54:12 | Show all floors
The music selection in fnf online is nothing short of spectacular, featuring an eclectic mix of genres that cater to all tastes.

0

threads

24

posts

62

credits

Registered member

Rank: 2

credits
62
Published in 2023-9-12 12:28:23 | Show all floors
It's crucial to note that this method involves making low-level modifications to the kernel modules, which may have an impact on how well your Orange Pi functions. Additionally, using the Orange Pi Zero as a keyboard and joystick requires dealing with USB HID (Human Interface Device) emulation, which may need for some programming or scripting expertise to generate the proper configuration. io games
You need to log in before you can reply login | Register

Points Rule

Quick reply Top Return list