Advertisement
Meneer_Jansen

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

Jan 1st, 2021 (edited)
1,275
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.11 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. THEC64 joystick
  16. iBuffalo SNES controller clone
  17. Monster Joysticks converter
  18.  
  19. X. References
  20.  
  21.  
  22.  
  23.  
  24.  
  25.  
  26. o======================o
  27. | A. Determine numbers |
  28. o======================o
  29.  
  30. 1. Linux: use 'dmesg'. Example for the Monsterjoysticks DB9 to USB converter (for my Atari 2600 joystick) [1]:
  31.  
  32. hid-generic 0003:16C0:27DC.000D: input,hidraw5: USB HID v1.01 Joystick [Monster Joysticks MJ2DB9]
  33.  
  34. Example iBuffalo gamepad clone of SNES controller:
  35.  
  36. hid-generic 0003:0583:2060.000F: input,hidraw5: USB HID v1.10 Joystick [USB,2-axis 8-button gamepad ]
  37.  
  38. Example THEC64 joystick:
  39.  
  40. hid-generic 0003:1C59:0024.0011: input,hidraw5: USB HID v1.10 Joystick [ THEC64 Joystick THEC64 Joystick ]
  41.  
  42. 2. Info from the THEC64 using X-Windows mod (in hex) for the Monster Joysticks MJ2DB9:
  43.  
  44. Input driver version: 1.0.1
  45. Input device ID: bus: 3, vendor: 16C0, product: 27DC, version: 101
  46.  
  47. So the fourth number (000D_hex) isn't used...
  48.  
  49. 3. Use in Linux:
  50.  
  51. jstest /dev/input/js0
  52.  
  53. to determine the numbers of the axis and the buttons.
  54.  
  55.  
  56.  
  57. o=========================o
  58. | B. gamecontrollerdb.txt |
  59. o=========================o
  60.  
  61. 1. Start THEC64 w/ X-Windows mod [2].
  62.  
  63. 2. Backup
  64.  
  65. /usr/share/the64/ui/data/gamecontrollerdb.txt
  66.  
  67. to the USB stick.
  68.  
  69. Wait a minute. Appears to be the folder (?!):
  70.  
  71. /media/the64/ui/data/gamecontrollerdb.txt
  72.  
  73. 3. Edit this file. You must make an SDL2 mapping for this joystick because there is none in the world yet...
  74.  
  75. 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".
  76.  
  77. 5. Now determine the UID of the controller. Dmesg in Linux gave us for the ID's:
  78.  
  79. 0003:16C0:27DC.000D
  80.  
  81. The ID's in gamecontrollerdb.txt are in lowbyte/highbyte form. So, for instance, the hexadecimal number 16C0 becomes C016 in gamecontrollerdb.txt.
  82.  
  83. 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.
  84.  
  85. 7. So we now have:
  86.  
  87. 0003:16C0:27DC 0101 --> 0300 0000 C016 0000 DC27 0000 0101 0000
  88. = 03000000C0160000DC27000001010000 (32 numbers)
  89.  
  90. 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 "dpleft" for the stick. See examples below. Should work...
  91.  
  92. 9. So now we have:
  93.  
  94. 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,
  95.  
  96. 10. Note: the file is CaSe SeNsItIvE!!!!
  97.  
  98. 11. Should work now.
  99.  
  100.  
  101.  
  102. o=============o
  103. | C. Examples |
  104. o=============o
  105.  
  106. THEC64 joystick
  107. ~~~~~~~~~~~~~~~
  108. ID in gamecontrollerdb.txt: 03000000591c00002300000010010000
  109. a:b4,b:b5,back:b6,lefttrigger:b0,leftx:a0,lefty:a1,righttrigger:b1,start:b7,x:b3,y:b2
  110.  
  111. ________________________________________________________________
  112. gamecontrollerdb: Linux: The C64 joystick:
  113. ________________________________________________________________
  114. leftx a0 Joy x-axis
  115. lefty a1 Joy y-axis
  116. lefttrigger b0 Left fire button (!)
  117. righttrigger b1 Right fire button (!)
  118. a,b b4, b5 Little round button 1 and 2 (a & b)
  119. (= Folder up & Run in C64 menu)
  120. back b6 Little round button 3 (= c)
  121. (= Fast Loader disable in C64 menu)
  122. start b7 Little round button 4 (= d)
  123. (= Menu/return in C64 menu)
  124. x, y b3, b2 Right & Left little triangle
  125. _______________________________________________________________
  126. Remark: on the The C64 joystick the big round fire buttons are
  127. actually shoulder (trigger) buttons!
  128.  
  129. 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):
  130.  
  131. static tsf_input_name_t input_name_map[] = {
  132. { INPUT_X, 1, "x"},
  133. { INPUT_Y, 1, "y"},
  134. { INPUT_A, 1, "a"},
  135. { INPUT_B, 1, "b"},
  136. { INPUT_BACK, 4, "back"},
  137. { INPUT_GUIDE, 5, "guide"},
  138. { INPUT_START, 5, "start"},
  139. { INPUT_DIG_LEFT, 6, "dpleft"},
  140. { INPUT_DIG_RIGHT, 7, "dpright"},
  141. { INPUT_DIG_UP, 4, "dpup"},
  142. { INPUT_DIG_DOWN, 6, "dpdown"},
  143. { INPUT_SHLD_LEFT, 12, "leftshoulder"},
  144. { INPUT_TRIG_LEFT, 11, "lefttrigger"},
  145. { INPUT_SHLD_RIGHT, 13, "rightshoulder"},
  146. { INPUT_TRIG_RIGHT, 12, "righttrigger"},
  147. { INPUT_STICK_LEFT, 9, "leftstick"},
  148. { INPUT_STICK_RIGHT, 10, "rightstick"},
  149. { INPUT_AXIS_LEFT_X, 5, "leftx"},
  150. { INPUT_AXIS_LEFT_Y, 5, "lefty"},
  151. { INPUT_AXIS_RIGHT_X, 6, "rightx"},
  152. { INPUT_AXIS_RIGHT_Y, 6, "righty"}
  153.  
  154.  
  155.  
  156.  
  157.  
  158. iBuffalo SNES controller clone
  159. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  160. ID in gamecontrollerdb.txt: 03000000830500006020000010010000
  161. a:b1,b:b0,back:b6,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,leftshoulder:b4,rightshoulder:b5,start:b7,x:b3,y:b2
  162.  
  163. ________________________________________________________
  164. gamecontrollerdb: iBuffalo controller: Linux:
  165. ________________________________________________________
  166. leftshoulder Left shoulder b4
  167. rightshoulder Right shoulder b5
  168. a,b B, A (!) b1, b0
  169. x, y X, Y b2, b3
  170. back (= c) Select b6
  171. start (= d) Start b7
  172. dpleft & R D-Pad L & R -a0, +a0
  173. dpup & D D-Pad U & D
  174. ________________________________________________________
  175. Remark: so the shoulder buttons of the iBuffalo are mapped to the fire button in a Commodore computer (which sucks!).
  176.  
  177.  
  178. Monster Joysticks converter
  179. ~~~~~~~~~~~~~~~~~~~~~~~~~~~
  180. 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,
  181.  
  182.  
  183.  
  184.  
  185. o===============o
  186. | X. References |
  187. o===============o
  188.  
  189. [1] Determine joystick particulars:
  190. https://thec64community.online/thread/4/modding-thec64-mini?page=1&scrollTo=8
  191.  
  192. [2] About X-Windows mod:
  193. https://thec64community.online/thread/487/thec64-windows-mod
  194.  
  195. [3] Forum entry 'bout terms to use in gamecontrollerdb.txt:
  196. https://thec64community.online/thread/470/db9-adapter-problem-after-upgrade?page=2
  197.  
  198. [4] Joystick bugs and quirks:
  199. https://thec64community.online/thread/840/joystick-bugs-quirks
  200.  
  201. [5] My Lemon64 forum post:
  202. https://www.lemon64.com/forum/viewtopic.php?t=75792&hilit=monster+joysticks
  203.  
  204.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement