USB Gamepads - please help


Author Message
ManiB
Senior Member

Joined: 12/10/2019
Location: Germany
Posts: 141
Posted: 11:59am 28 Feb 2025      

My testprogram works using raw$ = DEVICE(gamepad 3, raw).

How can i use btn% = DEVICE(gamepad 3, B) ?

-----
Rem THEGAMEPAD on RP2040-PICO-PC Olimex board
Rem PicoMiteHDMI MMBasic USB RP2350A Edition V6.00.02b14
Rem option reset olimexusb

raw$ = ""
old$ = ""
direction$ = ""

Do
Rem GAMEPAD read
Rem btn% = DEVICE(gamepad 3, B)
raw$ = DEVICE(gamepad 3, raw)
If old$ <> raw$ Then
   old$ = raw$

   xAxis% = Asc(Mid$(raw$, 1, 1))
   yAxis% = Asc(Mid$(raw$, 2, 1))

   direction$ = ""
   If xAxis% = &HFF Then direction$ = direction$ + "RIGHT"
   If xAxis% = &H00 Then direction$ = direction$ + "LEFT"
   If yAxis% = &HFF Then direction$ = direction$ + "DOWN"
   If yAxis% = &H00 Then direction$ = direction$ + "UP"
   Print xAxis%, yAxis%, direction$
   Print "-----"
EndIf
Loop While Inkey$=""

Print "ready..."