Advertisement
Meneer_Jansen

Add a joystick to 'The C64' or modify one.

Jan 1st, 2021 (edited)
1,711
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.80 KB | None | 0 0
  1. https://pastebin.com/44vJWEBq
  2.  
  3. Add a joystick to 'The C64' or modify one.
  4.  
  5.  
  6. o==========o
  7. | Contents |
  8. o==========o
  9.  
  10. A. Determine numbers
  11.  
  12. B. gamecontrollerdb.txt
  13.  
  14. C. Examples
  15. 1. TheC64 joystick
  16. 2. iBuffalo SNES controller clone
  17. 3. Monster Joysticks converter
  18. 4. Atari CX40+ Wireless
  19.  
  20. X. References
  21.  
  22.  
  23.  
  24.  
  25.  
  26.  
  27. o======================o
  28. | A. Determine numbers |
  29. o======================o
  30.  
  31. 1. Linux: use 'dmesg' (clear = 'dmesg -C').
  32.  
  33. Example for the Monsterjoysticks DB9 to USB converter (for my Atari 2600 joystick) [1]:
  34.  
  35. hid-generic 0003:16C0:27DC.000D: input,hidraw5: USB HID v1.01 Joystick [Monster Joysticks MJ2DB9]
  36.  
  37. Example iBuffalo gamepad clone of SNES controller:
  38.  
  39. hid-generic 0003:0583:2060.000F: input,hidraw5: USB HID v1.10 Joystick [USB,2-axis 8-button gamepad ]
  40.  
  41. Example THEC64 joystick:
  42.  
  43. hid-generic 0003:1C59:0024.0011: input,hidraw5: USB HID v1.10 Joystick [ THEC64 Joystick THEC64 Joystick ]
  44.  
  45. 2. Info from the THEC64 using X-Windows mod (in hex) for the Monster Joysticks MJ2DB9:
  46.  
  47. Input driver version: 1.0.1
  48. Input device ID: bus: 3, vendor: 16C0, product: 27DC, version: 101
  49.  
  50. So the fourth number (000D_hex) isn't used...
  51.  
  52. 3. Use in Linux (RESTORE = Tab):
  53.  
  54. jstest /dev/input/js0
  55.  
  56. to determine the numbers of the axis and the buttons.
  57.  
  58.  
  59.  
  60. o=========================o
  61. | B. gamecontrollerdb.txt |
  62. o=========================o
  63.  
  64. 1. Start THEC64 w/ X-Windows mod [2].
  65.  
  66. 2. Backup
  67.  
  68. /media/the64/ui/data/gamecontrollerdb.txt
  69.  
  70. or, if not present
  71.  
  72. /usr/share/the64/ui/data/gamecontrollerdb.txt
  73.  
  74. to the USB stick.
  75.  
  76. 3. Edit this file. You must make an SDL2 mapping for this joystick because there is none in the world yet...
  77.  
  78. 4. The entries beginning with an "a" are axis and those with a "b" are buttons. The Atari has an X and a Y axis (a0 and a1) and one Fire button (b0). In Linux one can determine these w/ "jstest /dev/input/js0".
  79.  
  80. 5. Now determine the UID of the controller. Dmesg in Linux gave us for the ID's:
  81.  
  82. 0003:16C0:27DC.000D
  83.  
  84. The ID's in gamecontrollerdb.txt are in lowbyte/highbyte form. So, for instance, the hexadecimal number 16C0 becomes C016 in gamecontrollerdb.txt.
  85.  
  86. 6. The lowbyte/highbyte numbers are followed by four zero's. The file 'gamecontrollerdb.txt' uses the first 3 hex numbers from Dmesg (i.e. bus ID, vendor ID and product ID's) and as a forth the HID version/input driver version (in this case 0101), also followed by 4 0's. The fourth ID from Dmesg (in this case 000D) is discarded.
  87.  
  88. 7. So we now have:
  89.  
  90. 0003:16C0:27DC 0101 --> 0300 0000 C016 0000 DC27 0000 0101 0000
  91. = 03000000C0160000DC27000001010000 (32 numbers)
  92.  
  93. 8. I advise to use the SDL2 terms "lefttrigger" or "leftshoulder" for the Fire button (this is why the SNES controller uses a weird mapping) and "leftx" or
  94. "dpleft" for the stick. See examples below. Should work...
  95.  
  96. It's something like this (see the tables in chapter "C. Examples"):
  97.  
  98. Firebutton:
  99.  
  100. lefttrigger:b0
  101. ^ ^
  102. | |_____ Linux (button number 0)
  103. |
  104. |_____________ gamecontrollerdb.txt (SDL2 terminology?)
  105.  
  106.  
  107. Joystick axis:
  108.  
  109. leftx:a0,lefty:a1
  110. ^ ^
  111. | |__ Linux (x-axis = a0; y-axix = a1)
  112. |
  113. |______ gamecontrollerdb.txt (SDL2 terminology?)
  114. (there probably is no right x/y)
  115.  
  116. 9. So now we have:
  117.  
  118. 03000000c0160000dc27000001010000,Monster Joysticks MJ2DB9,a:b1,b:b4,back:b6,leftx:a0,lefty:a1,leftshoulder:b0,rightshoulder:b5,start:b7,x:b3,y:b2,platform:Linux,
  119.  
  120. 10. Note: the file is CaSe SeNsItIvE!!!!
  121.  
  122. 11. Should work now.
  123.  
  124.  
  125.  
  126. o=============o
  127. | C. Examples |
  128. o=============o
  129.  
  130. 1. TheC64 joystick
  131. ~~~~~~~~~~~~~~~~~~
  132. ID in gamecontrollerdb.txt:
  133. 03000000591c00002300000010010000
  134. a:b4,b:b5,back:b6,lefttrigger:b0,leftx:a0,lefty:a1,righttrigger:b1,start:b7,x:b3,y:b2
  135.  
  136. ________________________________________________________________________
  137. gamecontrollerdb: Linux: The C64 joystick: TheC64
  138. ________________________________________________________________________
  139. leftx a0 Joy x-axis
  140. lefty a1 Joy y-axis
  141. lefttrigger b0 Left fire button (!)
  142. righttrigger b1 Right fire button (!)
  143.  
  144. a b4 Little round button a Folder up
  145. b b5 Little round button b Run
  146. back b6 Little round button c Fast loader on/off
  147. start b7 Little round button d Menu
  148. x, y b2, b3 Little triangle buttons for vir. kbd.
  149. _________________________________________________________________________
  150. Remark: on the The C64 joystick the big round fire buttons are
  151. actually shoulder (trigger) buttons!
  152.  
  153. The C64 fire button may be called "lefttrigger" or "leftshoulder". They are probably terms from SDL2. Possibilities appear to be (source code 'The C64' firmware):
  154.  
  155. static tsf_input_name_t input_name_map[] = {
  156. { INPUT_X, 1, "x"},
  157. { INPUT_Y, 1, "y"},
  158. { INPUT_A, 1, "a"},
  159. { INPUT_B, 1, "b"},
  160. { INPUT_BACK, 4, "back"},
  161. { INPUT_GUIDE, 5, "guide"},
  162. { INPUT_START, 5, "start"},
  163. { INPUT_DIG_LEFT, 6, "dpleft"},
  164. { INPUT_DIG_RIGHT, 7, "dpright"},
  165. { INPUT_DIG_UP, 4, "dpup"},
  166. { INPUT_DIG_DOWN, 6, "dpdown"},
  167. { INPUT_SHLD_LEFT, 12, "leftshoulder"},
  168. { INPUT_TRIG_LEFT, 11, "lefttrigger"},
  169. { INPUT_SHLD_RIGHT, 13, "rightshoulder"},
  170. { INPUT_TRIG_RIGHT, 12, "righttrigger"},
  171. { INPUT_STICK_LEFT, 9, "leftstick"},
  172. { INPUT_STICK_RIGHT, 10, "rightstick"},
  173. { INPUT_AXIS_LEFT_X, 5, "leftx"},
  174. { INPUT_AXIS_LEFT_Y, 5, "lefty"},
  175. { INPUT_AXIS_RIGHT_X, 6, "rightx"},
  176. { INPUT_AXIS_RIGHT_Y, 6, "righty"}
  177.  
  178.  
  179.  
  180. 2. iBuffalo SNES controller clone
  181. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  182. ID in gamecontrollerdb.txt: 03000000830500006020000010010000
  183. a:b1,b:b0,back:b6,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,leftshoulder:b4,rightshoulder:b5,start:b7,x:b3,y:b2
  184.  
  185. ________________________________________________________
  186. gamecontrollerdb: iBuffalo controller: Linux:
  187. ________________________________________________________
  188. a,b B, A (!) b1, b0
  189. x, y X, Y b2, b3
  190. leftshoulder Left shoulder b4
  191. rightshoulder Right shoulder b5
  192. back (= c) Select b6
  193. start (= d) Start b7
  194. dpleft & R D-Pad L & R -a0, +a0
  195. dpup & D D-Pad U & D
  196. ________________________________________________________
  197. Remark: so the shoulder buttons of the iBuffalo are mapped to the fire button in a Commodore computer (which sucks!).
  198.  
  199.  
  200. 3. Monster Joysticks converter
  201. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  202. ID in gamecontrollerdb.txt: 03000000591c00002300000010010000
  203. a:b4,b:b5,back:b6,lefttrigger:b0,leftx:a0,lefty:a1,righttrigger:b1,start:b7,x:b3,y:b2
  204.  
  205.  
  206. 4. Atari CX40+ Wireless
  207. ~~~~~~~~~~~~~~~~~~~~~~~
  208. See separate text file. Entry is:
  209.  
  210. 030000006a0e00001140000011010000, Retro Games LTD Atari CX Wireless Controller,leftx:a0,lefty:a1,lefttrigger:b0,platform:Linux,
  211.  
  212.  
  213.  
  214. o===============o
  215. | X. References |
  216. o===========e====o
  217.  
  218. [1] Determine joystick particulars:
  219. https://thec64community.online/thread/4/modding-thec64-mini?page=1&scrollTo=8
  220.  
  221. [2] About X-Windows mod:
  222. https://thec64community.online/thread/487/thec64-windows-mod
  223.  
  224. [3] Forum entry 'bout terms to use in gamecontrollerdb.txt:
  225. https://thec64community.online/thread/470/db9-adapter-problem-after-upgrade?page=2
  226.  
  227. [4] Joystick bugs and quirks:
  228. https://thec64community.online/thread/840/joystick-bugs-quirks
  229.  
  230. [5] My Lemon64 forum post:
  231. www.lemon64.com/forum/viewtopic.php?t=75792
  232.  
  233.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement