35 #include "gldrv/gl_include.h"
36 #if (GLUT_API_VERSION >= 4 || GLUT_XLIB_IMPLEMENTATION >= 13)
38 #define NO_SDL_JOYSTICK
76 joystick_exponent ) );
79 static bool JoyStickToggle =
true;
82 JoyStickToggle =
false;
87 JoyStickToggle = !JoyStickToggle;
93 joystick[0]->joy_axis[i] = 0.0;
97 if (joystick[0]->nr_of_axes > 0)
99 if (x < minx) minx = x;
100 if (x > maxx) maxx = x;
102 joystick[0]->
joy_axis[0] = ( (float) x-( ( (
float) (maxx+minx) )/2.0 ) )/( ( (float) (maxx-minx) )/2.0 );
103 if (joystick[0]->nr_of_axes > 1)
104 if (y < miny) miny = y;
105 if (y > maxy) maxy = y;
106 joystick[0]->
joy_axis[1] = ( (float) y-( ( (
float) (maxy+miny) )/2.0 ) )/( ( (float) (maxy-miny) )/2.0 );
107 if (joystick[0]->nr_of_axes > 2)
108 if (z < minz) minz = z;
109 if (z > maxz) maxz = z;
110 joystick[0]->
joy_axis[2] = ( (float) z-( ( (
float) (maxz+minz) )/2.0 ) )/( ( (float) (maxz-minz) )/2.0 );
142 #ifndef NO_SDL_JOYSTICK
146 printf(
"The names of the joysticks are:\n" );
150 printf(
"setting joystick functionality:: joystick online" );
157 #ifndef NO_SDL_JOYSTICK
160 printf(
" %s\n", SDL_JoystickName( i ) );
165 printf(
"Glut detects %d joystick", i+1 );
198 #if defined (NO_SDL_JOYSTICK)
209 joy = SDL_JoystickOpen( which );
211 printf(
"warning: no joystick nr %d\n", which );
229 #endif //we have GLUT
233 void JoyStick::InitMouse(
int which )
264 void JoyStick::GetMouse(
float &x,
float &y,
float &z,
int &buttons )
266 int def_mouse_sens = 1;
272 if ( 0 && (_dx || _dy) )
273 printf(
"x:%d y:%d\n", _dx, _dy );
279 static std::list< mouseData > md;
280 std::list< mouseData >::iterator i = md.begin();
282 float lasttime = ttime-game_options.
mouse_blur;
283 int avg = (_dx || _dy) ? 1 : 0;
286 for (; i != md.end();) {
287 if ( (*i).time >= lasttime ) {
291 if ( (ldx >= 0)*_dx*ldx == (_dx >= 0)*_dx*ldx ) {
296 if ( (ldy >= 0)*_dy*ldy == (_dy >= 0)*_dy*ldy ) {
304 }
else if ( ( i = md.erase( i ) ) == md.end() ) {
309 md.push_back(
mouseData( _dx, _dy, ttime ) );
339 GetMouse( x, y, z, buttons );
343 #ifndef NO_SDL_JOYSTICK
344 #if defined (HAVE_SDL)
345 int numaxes = SDL_JoystickNumAxes( joy );
348 for (a = 0; a < numaxes; a++)
349 axi[a] = SDL_JoystickGetAxis( joy, a );
353 int butt = SDL_JoystickGetButton( joy, i );
360 joy_axis[a] = ( (
float) axi[a]/32768.0 );
365 glutForceJoystickFunc();
371 #endif //we have no joystick