USB Gamepads - please help
| Author | Message | ||||
| matherp Guru Joined: 11/12/2012 Location: United KingdomPosts: 10850 |
If you can run any of the USB variants of the firmware and have any sort of Gamepad please help get it supported by MMBasic Here are USB variants of V6.00.00b12 PicoMiteUSBV6.00.02b12.zip If you load this firmware and plug your gamepad in you may see a message "Generic Gamepad Connected on channel 3". If so then your gamepad is supported and should work properly. If not then we need to add your gamepad to the configuration so please do the following. Unplug the gamepad and reboot. Then run the attached Basic program following the instructions exactly. If this works then you should get a printout with some C configuration code and then a (long) Basic command. These are listings of two files gamepad.txt and gamepadsetup.bas which will be saved on the A: drive. Post the contents of gamepad.txt to this thread and I will add the configuration to the MMBasic firmware To use your gamepad in the interim do the following: Unplug the gamepad Reboot Run the program gamepadsetup.bas plug in your gamepad and it should now be recognised and work. Note that the configuration will last until the Pico is rebooted so after each reboot you will need to run the program again WITHOUT the gamepad plugged in. Do While Inkey$<>"":Loop Print "Make sure the gamepad is unplugged" Print "press a key when ready" Do While Inkey$ = "" : Loop Gamepad monitor Print "Plug in the gampad and make sure no buttons are pressed" Pause 2000 Print "press a key when ready" Do While Inkey$ = "" : Loop nothing$=DEVICE(gamepad 3,raw) Open "gamepad.txt" For output As #1 Open "gamepadsetup.bas" For output As #2 Print #1,"{" Print #1," .vid=0x"+Hex$(MM.Info(usb vid 3))+","; Print #1,".pid=0x"+Hex$(MM.Info(usb pid 3))+"," Print #2, "gamepad configure &H"+Hex$(MM.Info(usb vid 3))+",&H"; Print #2, Hex$(MM.Info(usb pid 3))+","; Print "We are now going to step through the 16 possible buttons on the gamepad" Print "If your gamepad does not have the button requested just press any key to continue" button "R1" button "START" button "HOME" button "SELECT" button "L1" button "DOWN" button "RIGHT" button "UP" button "LEFT" button "R2" button "X" button "A" button "Y" button "B" button "L2" button "TOUCH" Print #1,"}," Close 1 Close 2 List "gamepad.txt" List "gamepadsetup.bas" End ' Sub button name$ Local code$=".b_"+name$ Print "" Print "Press and hold the "+name$+" button then press any key" Do While Inkey$ = "" : Loop b$=DEVICE(gamepad 3,raw) If b$<> nothing$ Then changed nothing$,b$,code$+"={" Do b$= DEVICE(gamepad 3,raw) Loop Until b$=nothing$ Else If Instr(code$,"TOUCH") Then Print #1," "+code$+"={255,0}" Print #2,"255,0" Else Print #1," "+code$+"={255,0}," Print #2,"255,0,"; EndIf EndIf End Sub ' Sub changed last$,now$,code$ Local inp%,outp%,baseline%,i%, bit%, up% For i%=1 To Len(last$) Inp%=Asc(Mid$(last$,i%,1)) Outp%=Asc(Mid$(now$,i%,1)) baseline%=Asc(Mid$(nothing$,i%,1)) If inp%<>outp% Then Print #1," "+code$; If baseline%>=&H7f And baseline%<=&H81 Then If bits(inp%,outp%) Then Print #1,Str$(i%-1)+","+Str$(Choice(outp%>inp%,192,64)); Print #2,Str$(i%-1)+","+Str$(Choice(outp%>inp%,192,64)); EndIf Else If bits(inp%,outp%)=1 Then bitchanged inp%, outp%, bit%, up% Print #1,Str$(i%-1)+","+Str$(Choice(up%=1,bit%+128,bit%)); Print #2,Str$(i%-1)+","+Str$(Choice(up%=1,bit%+128,bit%)); EndIf If Instr(code$,"TOUCH") Then Print #1,"}" Print #2,"" Else Print #1,"}," Print #2,","; EndIf EndIf Next End Sub ' Sub bitchanged a%,b%,bn%,which% Local i%,j%=a% Xor b% For bn%=0 To 7 If j% And (1<<bn%) Then If a% And (1<<bn%) Then which%=1 Else which%=2 Exit Sub EndIf Next End Sub ' Function bits(a%,b%) As integer Local n%=0,i%=a% Xor b% Do While(i%) Inc n%,i% And 1 i%=i%>>1 Loop bits=n% End Function Example operation Make sure the gamepad is unplugged press a key when ready Plug in the gampad and make sure no buttons are pressed press a key when ready Generic Gamepad Connected on channel 3 081F,E401 00,00,00,00,00,00,00,00 7F,7F,00,80,80,0F,00,00 We are now going to step through the 16 possible buttons on the gamepad If your gamepad does not have the button requested just press any key to continue Press and hold the R1 button then press any key 081F,E401 7F,7F,00,80,80,0F,00,00 7F,7F,00,80,80,0F,02,00 081F,E401 7F,7F,00,80,80,0F,02,00 7F,7F,00,80,80,0F,00,00 Press and hold the START button then press any key 081F,E401 7F,7F,00,80,80,0F,00,00 7F,7F,00,80,80,0F,20,00 081F,E401 7F,7F,00,80,80,0F,20,00 7F,7F,00,80,80,0F,00,00 Press and hold the HOME button then press any key Press and hold the SELECT button then press any key 081F,E401 7F,7F,00,80,80,0F,00,00 7F,7F,00,80,80,0F,10,00 081F,E401 7F,7F,00,80,80,0F,10,00 7F,7F,00,80,80,0F,00,00 Press and hold the L1 button then press any key 081F,E401 7F,7F,00,80,80,0F,00,00 7F,7F,00,80,80,0F,01,00 081F,E401 7F,7F,00,80,80,0F,01,00 7F,7F,00,80,80,0F,00,00 Press and hold the DOWN button then press any key 081F,E401 7F,7F,00,80,80,0F,00,00 7F,FF,00,80,80,0F,00,00 081F,E401 7F,FF,00,80,80,0F,00,00 7F,7F,00,80,80,0F,00,00 Press and hold the RIGHT button then press any key 081F,E401 7F,7F,00,80,80,0F,00,00 FF,7F,00,80,80,0F,00,00 081F,E401 FF,7F,00,80,80,0F,00,00 7F,7F,00,80,80,0F,00,00 Press and hold the UP button then press any key 081F,E401 7F,7F,00,80,80,0F,00,00 7F,00,00,80,80,0F,00,00 081F,E401 7F,00,00,80,80,0F,00,00 7F,7F,00,80,80,0F,00,00 Press and hold the LEFT button then press any key 081F,E401 7F,7F,00,80,80,0F,00,00 00,7F,00,80,80,0F,00,00 081F,E401 00,7F,00,80,80,0F,00,00 7F,7F,00,80,80,0F,00,00 Press and hold the R2 button then press any key Press and hold the X button then press any key 081F,E401 7F,7F,00,80,80,0F,00,00 7F,7F,00,80,80,1F,00,00 081F,E401 7F,7F,00,80,80,1F,00,00 7F,7F,00,80,80,0F,00,00 Press and hold the A button then press any key 081F,E401 7F,7F,00,80,80,0F,00,00 7F,7F,00,80,80,2F,00,00 081F,E401 7F,7F,00,80,80,2F,00,00 7F,7F,00,80,80,0F,00,00 Press and hold the Y button then press any key 081F,E401 7F,7F,00,80,80,0F,00,00 7F,7F,00,80,80,8F,00,00 081F,E401 7F,7F,00,80,80,8F,00,00 7F,7F,00,80,80,0F,00,00 Press and hold the B button then press any key 081F,E401 7F,7F,00,80,80,0F,00,00 7F,7F,00,80,80,4F,00,00 081F,E401 7F,7F,00,80,80,4F,00,00 7F,7F,00,80,80,0F,00,00 Press and hold the L2 button then press any key Press and hold the TOUCH button then press any key { .vid=0x81F,.pid=0xE401, .b_R1={6,1}, .b_START={6,5}, .b_HOME={255,0}, .b_SELECT={6,4}, .b_L1={6,0}, .b_DOWN={1,192}, .b_RIGHT={0,192}, .b_UP={1,64}, .b_LEFT={0,64}, .b_R2={255,0}, .b_X={5,4}, .b_A={5,5}, .b_Y={5,7}, .b_B={5,6}, .b_L2={255,0}, .b_TOUCH={255,0} }, gamepad configure &H81F,&HE401,6,1,6,5,255,0,6,4,6,0,1,192,0,192,1,64,0,64,255,0,5,4,5,5,5,7,5,6,255,0,255,0 |
||||