Repository navigation
GXDeviceInputDetect
boxgaming edited this page Sep 29, 2026
·
2 revisions
GXDeviceInputDetect deviceInput As GXDeviceInput
Waits for an input from the keyboard, mouse or game controller and populates the specified deviceInput.
Wait for the user to trigger a supported input event and display the details to the screen.
'$Include: 'gx.bi'
Print "Waiting for input..."
Do
Dim di As GXDeviceInput
GXDeviceInputDetect di
Cls
Print "Device #: " + Str$(di.deviceId)
Print "Device Name: " + GXDeviceName(di.deviceId)
Print "Device Type: " + GXDeviceTypeName(di.deviceType)
Print "Input Type: " + GXInputTypeName(di.inputType)
Print "Input Id: " + Str$(di.inputId)
If di.deviceType = GXDEVICE_KEYBOARD Then
Print "Key Name: " + GXKeyButtonName(di.inputId)
End If
Print "Input Value: " + Str$(di.inputValue)
Print
Loop
Sub GXOnGameEvent (e As GXEvent): End Sub
'$Include: 'gx.bm'Prompt the user to select desired inputs for actions. Then display a corresponding message when any input is triggered.
'$Include: 'gx.bi'
GXSceneCreate 500, 300
GXFrameRate 10
Dim Shared dleft As GXDeviceInput
Print "Press Left... ";
GXDeviceInputDetect dleft
PrintDeviceInput dleft
Dim Shared dright As GXDeviceInput
Print "Press Right...";
GXDeviceInputDetect dright
PrintDeviceInput dright
Dim Shared djump As GXDeviceInput
Print "Press Jump...";
GXDeviceInputDetect djump
PrintDeviceInput djump
GXSleep 1
GXSceneStart
System
Sub GXOnGameEvent (e As GXEvent)
Dim ldown As Integer
Select Case e.event
Case GXEVENT_UPDATE
If GXKeyDown(GXKEY_ESC) Then GXSceneStop
Case GXEVENT_DRAWSCREEN
GXDrawText GXFONT_DEFAULT, 10, 10, "Press one or more mapped inputs:"
If GXDeviceInputTest(dleft) Then
GXDrawText GXFONT_DEFAULT, 100, 100, "Left"
End If
If GXDeviceInputTest(dright) Then
GXDrawText GXFONT_DEFAULT, 150, 100, "Right"
End If
If GXDeviceInputTest(djump) Then
GXDrawText GXFONT_DEFAULT, 125, 125, "Jump"
End If
End Select
End Sub
Sub PrintDeviceInput (di As GXDeviceInput)
Print GXDeviceName(di.deviceId) + " : ";
Print GXInputTypeName(di.inputType) + " : ";
Print Str$(di.inputId) + " : ";
If di.deviceType = GXDEVICE_KEYBOARD Then
Print " [ "; GXKeyButtonName(di.inputId); " ]";
Else
Print ;
End If
Print " : "; di.inputValue
Print
End Sub
'$Include: 'gx.bm'© 2022-2026 boxgaming