Update of /cvsroot/win32forth/win32forth/src/lib
In directory sc8-pr-cvs9.sourceforge.net:/tmp/cvs-serv32332/src/lib
Modified Files:
Joystick.f
Log Message:
Jos: Optimized and extended the code.
Index: Joystick.f
===================================================================
RCS file: /cvsroot/win32forth/win32forth/src/lib/Joystick.f,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** Joystick.f 30 May 2006 09:40:48 -0000 1.2
--- Joystick.f 10 Jun 2006 11:41:09 -0000 1.3
***************
*** 35,38 ****
--- 35,40 ----
+ (( \ Not needed joyinfo is on the stack
+
:struct joyinfo
UINT wXpos /* x position */
***************
*** 42,46 ****
;struct
! sizeof joyinfo mkstruct: *lpjoyinfo
--- 44,48 ----
;struct
! sizeof joyinfo mkstruct: *lpjoyinfo \ ))
***************
*** 76,87 ****
Result JOYERR_NOERROR if successful or one of the following error values.
! Value Description
! MMSYSERR_NODRIVER The joystick driver is not present.
! MMSYSERR_INVALPARAM An invalid parameter was passed.
Windows 95/98/Me: The specified joystick identifier is invalid.
!
! MMSYSERR_BADDEVICEID Windows 95/98/Me: The specified joystick identifier is invalid.
! JOYERR_UNPLUGGED The specified joystick is not connected to the system.
! JOYERR_PARMS Windows NT/2000/XP: The specified joystick identifier is invalid.
--- 78,89 ----
Result JOYERR_NOERROR if successful or one of the following error values.
! Value Description
! MMSYSERR_NODRIVER The joystick driver is not present.
! MMSYSERR_INVALPARAM An invalid parameter was passed.
Windows 95/98/Me: The specified joystick identifier is invalid.
!
! MMSYSERR_BADDEVICEID Windows 95/98/Me: The specified joystick identifier is invalid.
! JOYERR_UNPLUGGED The specified joystick is not connected to the system.
! JOYERR_PARMS Windows NT/2000/XP: The specified joystick identifier is invalid.
***************
*** 94,109 ****
))
! : GetJoystickInfo ( id -- x y z buttons )
! *lpjoyinfo [ sizeof joyinfo ] literal erase
! *lpjoyinfo swap Call joyGetPos drop
! struct, *lpjoyinfo joyinfo wXpos @
! struct, *lpjoyinfo joyinfo wYpos @
! struct, *lpjoyinfo joyinfo wZpos @
! struct, *lpjoyinfo joyinfo wButtons @
! ;
! 15 constant MaxJoysticks
! : FindFirstJoyStick ( - *lpjoycapsa ID ) \ ID should be <= MaxJoysticks
*lpjoycapsa [ sizeof JOYCAPSA ] literal 2dup erase swap MaxJoysticks 0
do 2dup i Call joyGetDevCaps 0=
--- 96,106 ----
))
! : GetJoystickInfo ( id -- x y z buttons )
! >r 0 0 0 0 sp@ r> Call joyGetPos drop 4reverse
! ;
! : MaxJoysticks ( - #MaxJoysticks ) call joyGetNumDevs ;
! : FindFirstJoyStick ( - *lpjoycapsa ID ) \ ID should be <= MaxJoysticks
*lpjoycapsa [ sizeof JOYCAPSA ] literal 2dup erase swap MaxJoysticks 0
do 2dup i Call joyGetDevCaps 0=
***************
*** 111,123 ****
then
loop
! ;
\s Tests and demo:
! : JoystickTest ( - ) \ Move the joystick and press some buttons
FindFirstJoyStick nip dup MaxJoysticks <
! if begin cr dup GetJoystickInfo dup>r . . . . 20 ms
! r> 1 =
until \ the fire button has been pressed
drop ." The fire button has been pressed."
--- 108,123 ----
then
loop
! ;
+ : JoystickSetup ( - )
+ z" control joy.cpl" zEXEC-CMD abort" Can't use the setup in the control panel"
+ ;
\s Tests and demo:
! : JoystickTest ( - ) \ Move the joystick and press some buttons
FindFirstJoyStick nip dup MaxJoysticks <
! if begin cr dup GetJoystickInfo dup>r .s 4drop 20 ms
! r> JOY_BUTTON1 =
until \ the fire button has been pressed
drop ." The fire button has been pressed."
|