Тест подключенных джойстиков

Программа проверяет подключенные устройства (джойстики) и читает нажатия их клавиш.

Платформы: Windows , Linux , Dos
Автор: Quiet Snow

Dim x As Single
Dim y As Single
Dim buttons As Integer
Dim result As Integer
Dim ijoy As Integer

Dim Kb As String

Dim JoyID As Integer
Dim JoyExist(15) As Integer
Dim Joys As Integer
Dim JoyOrder(15) As Integer
Dim TekJoy As Integer

'  Смотрим сколько джойстиков в системе

For JoyID = 0 To 15
    If Getjoystick(JoyID, buttons, x, y) Then 
    Else
        JoyExist(JoyID) = -1 
        Joys = Joys + 1
        JoyOrder(Joys) = JoyID
    End If
Next

'  Выходим если не нашли
If Joys = 0 Then
    Print "Sorry, you're don't have joystick(s) in system!"
    Sleep
    End
End If


'  Выводим кнопки выбранного джойстика
TekJoy = 1
Width 80, 60
Do: Kb = Inkey

If (Kb = "-") And TekJoy > 1 Then TekJoy = TekJoy - 1
If (Kb = "+" Or Kb = "=") And TekJoy < Joys Then TekJoy = TekJoy + 1

result = Getjoystick(JoyOrder(TekJoy), buttons, x, y)

Locate 1,1
Print
Print " Press [+]/[-] for change joystick."
Print
Print "Joystick #: "; TekJoy
Print ;"result:";result;" x:" ;x;" y:";y;" Buttons:";buttons,"","",""

'Эта линия позволит проверить какие нажатия кнопок произведены от 1 до 27.
For ijoy = 0 To 26 
    If (buttons And (1 Shl ijoy)) Then 
        Print "Button "; ijoy; " pressed.    "
    Else 
        Print "Button "; ijoy; " not pressed."
    End If
Next
Loop Until Kb = Chr(27)