Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 10:48 26 Nov 2024 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : PETSCII game drivers for USB SNES, PS3 and PS4

Author Message
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 9115
Posted: 06:26pm 27 Feb 2024
Copy link to clipboard 
Print this post

Attached are drivers for the SNES, PS3 and PS4 controllers for PETSCII and presumably other things. These work on both the PicoMiteUSB and PicoMiteVGAUSB versions. Tested on V5.09.00b3

 Dim CTRL_DRIVER$ = Choice(LCD_DISPLAY, "ctrl_gamemite$", "ctrl_none$")
 ' Uncomment one of these to override controller:
 ' CTRL_DRIVER$ = "ctrl_atari_a$"      ' Atari Joystick on PicoGAME port A
 ' CTRL_DRIVER$ = "ctrl_nes_a$"        ' NES gamepad on PicoGAME port A
 ' CTRL_DRIVER$ = "ctrl_wii_classic$"  ' Wii Classic controller
  CTRL_DRIVER$ = "ctrl_snes$"         ' SNES USB gamepad
 ' CTRL_DRIVER$ = "ctrl_ps$"           'PS3 and PS4 USB controllers
 If Call(CTRL_DRIVER$, 1) <> "" Then Error


 ' Controller driver for PS3 and PS4 USB controllers.
Function ctrl_ps$(init)
 Static integer usbchannel=0  'stores the  channel of the first usb controller
 If Not init Then
   Local bits, i, s$
   bits = DEVICE(gamepad usbchannel, b)
   If bits Then
     Select Case bits
         Case &h0001 : s$ = "toggle-item"   ' R shoulder button
         Case &h0002 : s$ = "use-item"      ' Start
         Case &h0004 : s$ = "map"           ' Home
         Case &h0008 : s$ = "escape"        ' Select
         Case &h0010 : s$ = "toggle-weapon" ' L shoulder button
         Case &h0020 : s$ = "fire-down"     ' Cursor down
         Case &h0040 : s$ = "fire-right"    ' Cursor right
         Case &h0080 : s$ = "fire-up"       ' Cursor up
         Case &h0100 : s$ = "fire-left"     ' Cursor left
         Case &h0800 : s$ = "move"          ' Button A
         Case &h2000 : s$ = "search"        ' Button B
     End Select
   Else
     ' Right analog joystick.
     Select Case DEVICE(gamepad usbchannel, RY)
         Case < 50  : s$ = "up"
         Case > 205 : s$ = "down"
     End Select
     Select Case DEVICE(gamepad usbchannel, RX)
         Case < 50  : s$ = "left"
         Case > 205 : s$ = "right"
     End Select
   EndIf
   ctrl_ps$ = s$
   Exit Function
 Else
   For i=1 To 4
     If MM.Info(usb i)=128 Or MM.Info(usb i)=129 Then
       usbchannel=i
       Print usbchannel
       Exit For
     EndIf
   Next
   If usbchannel=0 Then Error ("PS Controller not found")
 EndIf
End Function

 ' Controller driver for SNES USB gamepad.
Function ctrl_snes$(init)
 Static integer usbchannel=0  'stores the  channel of the first usb controller
 If Not init Then
   Local bits, i, s$
   bits = DEVICE(gamepad usbchannel, b)
   If bits Then
     Select Case bits
         Case &h0001 : s$ = "toggle-item"   ' R shoulder button
         Case &h0002 : s$ = "use-item"      ' Start
         Case &h0004 : s$ = "map"           ' Home
         Case &h0008 : s$ = "escape"        ' Select
         Case &h0010 : s$ = "toggle-weapon" ' L shoulder button
         Case &h0020 : s$ = "down"     ' Cursor down
         Case &h0040 : s$ = "right"    ' Cursor right
         Case &h0080 : s$ = "up"       ' Cursor up
         Case &h0100 : s$ = "left"     ' Cursor left
         Case &h1020 : s$ = "fire-down"     ' Cursor down + Y
         Case &h1040 : s$ = "fire-right"    ' Cursor right + Y
         Case &h1080 : s$ = "fire-up"       ' Cursor up + Y
         Case &h1100 : s$ = "fire-left"     ' Cursor left + Y
         Case &h0800 : s$ = "move"          ' Button A
         Case &h2000 : s$ = "search"        ' Button B
     End Select
   EndIf
   ctrl_snes$ = s$
   Exit Function
 Else
   For i=1 To 4
     If MM.Info(usb i)=130 Then
       usbchannel=i
       Exit For
     EndIf
   Next
   If usbchannel=0 Then Error ("SNES Controller not found")
 EndIf
End Function

Edited 2024-02-28 04:32 by matherp
 
Print this page


To reply to this topic, you need to log in.

© JAQ Software 2024