getJoyStickInfo via API (Windows only)

Share your advanced PureBasic knowledge/code with the community.
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

getJoyStickInfo via API (Windows only)

Post by BackupUser »

Code updated for 5.20+

Restored from previous forum. Originally posted by Rings.

Easy codesnippet to retrieve Joystickinfo
(you don't need any DirectX lib's)

Code: Select all

; Get Joystick info without using DirectX
; written by Siegried Rings April,4th, 2002
; using winmm.dll, only Windows!
; good if you want to measure something
; (0-5 Volt) with the analog gameport

joy.JOYINFO
joyID = 0

If OpenWindow(0, 100, 120, 300, 200, "Joystick Native Windows-API",
              #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
  StringGadget(0, 20, 25, 200, 20, "")
  Repeat
    EventID = WaitWindowEvent()
    Delay(5)
    Result = joyGetPos_(joyId, joy)
    SetGadgetText(0, "JoyInfo: " + Str(joy\wXpos) + ":" + Str(joy\wYpos) + ":" + 
                                   Str(joy\wZpos) + ":" + Str(joy\wButtons))
  Until EventID = #PB_Event_CloseWindow
EndIf
Its a long way to the top if you wanna .....CodeGuru