2 /* Copyright (c) Mark J. Kilgard, 1997, 1998. */
4 /* This program is freely distributable without licensing fees
5 and is provided without guarantee or warrantee expressed or
6 implied. This program is -not- in the public domain. */
14 #include <mmsystem.h> /* Win32 Multimedia API header. */
22 glutJoystickFunc(GLUTjoystickCB joystickFunc
, int pollInterval
)
25 if (joystickFunc
&& (pollInterval
> 0)) {
26 if (__glutCurrentWindow
->entryState
== WM_SETFOCUS
) {
29 /* Capture joystick focus if current window has
31 result
= joySetCapture(__glutCurrentWindow
->win
,
32 JOYSTICKID1
, 0, TRUE
);
33 if (result
== JOYERR_NOERROR
) {
34 (void) joySetThreshold(JOYSTICKID1
, pollInterval
);
37 __glutCurrentWindow
->joyPollInterval
= pollInterval
;
39 /* Release joystick focus if current window has
41 if (__glutCurrentWindow
->joystick
42 && (__glutCurrentWindow
->joyPollInterval
> 0)
43 && (__glutCurrentWindow
->entryState
== WM_SETFOCUS
)) {
44 (void) joyReleaseCapture(JOYSTICKID1
);
46 __glutCurrentWindow
->joyPollInterval
= 0;
48 __glutCurrentWindow
->joystick
= joystickFunc
;
50 /* XXX No support currently for X11 joysticks. */
55 glutForceJoystickFunc(void)
58 if (__glutCurrentWindow
->joystick
) {
63 /* Poll the joystick. */
64 jix
.dwSize
= sizeof(jix
);
65 jix
.dwFlags
= JOY_RETURNALL
;
66 res
= joyGetPosEx(JOYSTICKID1
,&jix
);
67 if (res
== JOYERR_NOERROR
) {
69 /* Convert to int for scaling. */
74 #define SCALE(v) ((int) ((v - 32767)/32.768))
76 __glutCurrentWindow
->joystick(jix
.dwButtons
,
77 SCALE(x
), SCALE(y
), SCALE(z
));
81 /* XXX No support currently for X11 joysticks. */