| |
|
|
|
Source wurde al 15.07.2007 de el MMJ-Quellcodesammlung (Dietmar Horn) en el Babyklappe en XProfan.Com abgelegt:
Joystickinformationen abfragen
+----------------------------------------------------------+
| joystick.prf |
| Autor: Sebastian König |
| email: feedback@sekoenig.de |
| Homepage: http://www.sekoenig.de |
| Mit PROFAN² el Joystick abfragen |
+----------------------------------------------------------+
--Benötigte Características
DEF JoySetCapture(4) !WINMM,joySetCapture
DEF JoyReleaseCapture(1) !WINMM,joyReleaseCapture
DEF JoyGetPos(2) !WINMM,joyGetPos
--Deklarationen
declarar JOYINFO# Struktur con Joystickinformationen
Struktur JOYINFO:
UINT wXpos;
UINT wYpos;
UINT wZpos;
UINT wButtons;
Ende
declarar joyButton%
declarar joyX%,joyY%,joyZ%
declarar x%,y%,z%,b%
declarar joyError%
--Neues Ventana
windowstyle 24
window 0,0-%maxX,%maxY
windowtitle Joystick abfragen
--Joystick Capture en unser Ventana principal
conjunto, todos 100 Millisekunden Daten
obtener
let joyError%=JoySetCapture(%hwnd,0,100,0)
if @neq(joyError%,0)
messagebox(Fehler!,Joystick,48)
end
endif
dim JOYINFO#,16 Struktur dimensionieren
textcolor 0,-1
drawtext 230,300,Über Systemmenu final
drawtext 30,100,X-Achse:
drawtext 30,130,Y-Achse:
drawtext 30,160,Z-Achse:
drawtext 30,210,Button:
let X%=@createtext(%hwnd,...,100,100,80,20)
let y%=@createtext(%hwnd,...,100,130,80,20)
let z%=@createtext(%hwnd,...,100,160,80,20)
let b%=@createtext(%hwnd,...,100,210,80,20)
mientras que 1
JoyGetPos(0,JOYINFO#) Joystickdaten einlesen
let joyX%=@long(JOYINFO#,0) X-Koordinate
let joyY%=@long(JOYINFO#,4) Y-Koordinate
let joyZ%=@long(JOYINFO#,8) Z-Koordinate
let joyButton%=@long(JOYINFO#,12) Buttons:
1 = Button A
2 = Button B
4 = Button C
8 = Button D
usw...
SetText x%,@Str$(joyX%)
SetText y%,@Str$(joyY%)
SetText z%,@Str$(joyZ%)
SetText b%,@str$(joyButton%)
wend
JoyReleaseCapture(0) Capture liberación
disponer joyPos# Speicher liberación
end
|
|
|
| |
|
|