Esempio n. 1
0
/* CENTRY */
void APIENTRY
glutJoystickFunc(GLUTjoystickCB joystickFunc, int pollInterval)
{
#ifdef _WIN32
  if (joystickFunc && (pollInterval > 0)) {
    if (__glutCurrentWindow->entryState == WM_SETFOCUS) {
      MMRESULT result;

      /* Capture joystick focus if current window has
  	 focus now. */
      result = joySetCapture(__glutCurrentWindow->win,
        JOYSTICKID1, 0, TRUE);
      if (result == JOYERR_NOERROR) {
        (void) joySetThreshold(JOYSTICKID1, pollInterval);
      }
    }
    __glutCurrentWindow->joyPollInterval = pollInterval;
  } else {
    /* Release joystick focus if current window has
       focus now. */
    if (__glutCurrentWindow->joystick
      && (__glutCurrentWindow->joyPollInterval > 0)
      && (__glutCurrentWindow->entryState == WM_SETFOCUS)) {
      (void) joyReleaseCapture(JOYSTICKID1);
    }
    __glutCurrentWindow->joyPollInterval = 0;
  }
  __glutCurrentWindow->joystick = joystickFunc;
#else
  /* XXX No support currently for X11 joysticks. */
#endif
}
Esempio n. 2
0
void wxJoystick::SetMovementThreshold(int threshold)
{
    UINT thresh = threshold;
    joySetThreshold(m_joystick, thresh);
}
Esempio n. 3
0
int joy_init(int joyid) //HH: added joyid parameter
{
	int i;
        int temp_axis[JOY_NUM_AXES];       //changed - orulz
	JOYCAPS pjc;

	if (FindArg( "-nojoystick" ))
		return 0;

	atexit(joy_close);	//HH: we are a bit lazy :). Errors are ignored, so we are even double-lazy :)

	joy_flush();
	memset(&joystick, 0, sizeof(joystick));

	for (i=0; i<MAX_BUTTONS; i++)
		joystick.buttons[i].last_state = 0;

	if ( !joy_installed )   {
                joy_present = 0;
                joy_installed = 1;
                joystick.max_timer = 65536;
                joystick.read_count = 0;
                joystick.last_value = 0;
	}


	joystick.present_mask = JOY_ALL_AXIS;		// Assume they're all present
        joystick.present_mask = joystick_read_raw_axis( JOY_ALL_AXIS, temp_axis );

	if ( joystick.present_mask & 3 )
		joy_present = 1;
	else
		joy_present = 0;

	
	//HH: Main Win32 joystick initialization, incl. reading cal. stuff

	if (joyGetDevCaps(joyid, &pjc, sizeof(pjc))!=JOYERR_NOERROR) {
		return 0;
	}

	if (joySetThreshold(joyid, pjc.wXmax/256)!=JOYERR_NOERROR) {
		return 0;
	}

        joystick.max_timer      = pjc.wPeriodMax;
	joystick.axis_min[0]	= pjc.wXmin;
	joystick.axis_min[1]	= pjc.wYmin;
//orulz:
//        joystick.axis_min[2]    = pjc.wZmin;
//        //HH: joystick.axis_min[3]  = pov-stuff
//        joystick.axis_min[4]    = pjc.wRmin;
//        joystick.axis_min[5]    = pjc.wUmin;
//        joystick.axis_min[6]    = pjc.wVmin;
        joystick.axis_min[2]    = pjc.wRmin;
        joystick.axis_min[3]    = pjc.wZmin;
        joystick.axis_min[4]    = pjc.wUmin;
        joystick.axis_min[5]    = pjc.wVmin;

	joystick.axis_max[0]	= pjc.wXmax;
	joystick.axis_max[1]	= pjc.wYmax;
//orulz:
//        joystick.axis_max[2]    = pjc.wZmax;
//        //HH: joystick.axis_max[3]  = pov-stuff
//        joystick.axis_max[4]    = pjc.wRmax;
//        joystick.axis_max[5]    = pjc.wUmax;
//        joystick.axis_max[6]    = pjc.wVmax;
        joystick.axis_max[2]    = pjc.wRmax;
        joystick.axis_max[3]    = pjc.wZmax;
        joystick.axis_max[4]    = pjc.wUmax;
        joystick.axis_max[5]    = pjc.wVmax;

        joystick.axis_center[0]	= hh_average(pjc.wXmax,pjc.wXmin);
	joystick.axis_center[1]	= hh_average(pjc.wYmax,pjc.wYmin);
//orulz:
//        joystick.axis_center[2] = hh_average(pjc.wZmax,pjc.wZmin);
//        joystick.axis_center[3] = JOY_POVCENTERED;
//        joystick.axis_center[4] = hh_average(pjc.wRmax,pjc.wRmin);
//        joystick.axis_center[5] = hh_average(pjc.wUmax,pjc.wUmin);
//        joystick.axis_center[6] = hh_average(pjc.wVmax,pjc.wVmin);
        joystick.axis_center[2] = hh_average(pjc.wRmax,pjc.wRmin);
        joystick.axis_center[3] = hh_average(pjc.wZmax,pjc.wZmin);
        joystick.axis_center[4] = hh_average(pjc.wUmax,pjc.wUmin);
        joystick.axis_center[5] = hh_average(pjc.wVmax,pjc.wVmin);

	joystick.present_mask = JOY_1_X_AXIS | JOY_1_Y_AXIS;
	if (pjc.wCaps & JOYCAPS_HASZ)	joystick.present_mask |= JOY_1_Z_AXIS;
//        if (pjc.wCaps & JOYCAPS_HASPOV) joystick.present_mask |= JOY_1_POV;
	if (pjc.wCaps & JOYCAPS_HASR)	joystick.present_mask |= JOY_1_R_AXIS;
	if (pjc.wCaps & JOYCAPS_HASU)	joystick.present_mask |= JOY_1_U_AXIS;
	if (pjc.wCaps & JOYCAPS_HASV)	joystick.present_mask |= JOY_1_V_AXIS;

	return joy_present;
}
Esempio n. 4
0
int joy95_init_stick(int joy, int spjoy)
{
	UINT 			joyid;
	MMRESULT 	mmresult;
	char 			joyname[256];

	if (!joy_installed) 		  
		return 0;

	switch (SpecialDevice)
	{
		case TACTILE_CYBERNET:
		//@@	joystick.present_mask = JOY_1_X_AXIS | JOY_1_Y_AXIS | JOY_1_Z_AXIS | JOY_1_POV;
		//@@	joystick.has_pov = 1;
			break;

		case TACTILE_IMMERSION:
			mprintf((0, "Joystick name= I-Force compatible device.\n"));
			break;
	}

//	if (spjoy) return 1;

	joystick.joyid = 0;

	if (joy == 1) joystick.joyid = joyid = JOYSTICKID1;
	else 
		return 0;

	mmresult = joyGetDevCaps(joyid, &WinJoyCaps, sizeof(WinJoyCaps));
	if (mmresult != JOYERR_NOERROR) {
		mprintf((1, "Attempt to get Joystick %d caps failed.\n", joy));
 		return 0;
	}
   mprintf ((0,"Joystick name=%s\n",WinJoyCaps.szPname));

//	Tell our Window App. about this joystick.
	joySetThreshold(joyid, WinJoyCaps.wXmax/256);
	mmresult = joySetCapture(GetLibraryWindow(), 
						joyid, 
						JOY_POLL_RATE, 
						FALSE);

	if (mmresult != JOYERR_NOERROR) {
 		mprintf((1, "Unable to capture joystick %d. Error=%d\n", joy,mmresult));
		return 0;
	}

//	Get raw axis' min and max.
	joystick.threshold 			= WinJoyCaps.wXmax/256;
	joystick.max_timer 			= WinJoyCaps.wPeriodMax;

	joystick.threshold 			= WinJoyCaps.wXmax/256;
	joystick.max_timer 			= WinJoyCaps.wPeriodMax;
	joystick.axis_min[0]			= WinJoyCaps.wXmin;
	joystick.axis_min[1]			= WinJoyCaps.wYmin;
	joystick.axis_min[2]			= WinJoyCaps.wZmin;
	joystick.axis_min[4]			= WinJoyCaps.wRmin;
	joystick.axis_min[5]			= WinJoyCaps.wUmin;
	joystick.axis_min[6]			= WinJoyCaps.wVmin;
	joystick.axis_max[0]			= WinJoyCaps.wXmax;
	joystick.axis_max[1]			= WinJoyCaps.wYmax;
	joystick.axis_max[2]			= WinJoyCaps.wZmax;
	joystick.axis_max[4]			= WinJoyCaps.wRmax;
	joystick.axis_max[5]			= WinJoyCaps.wUmax;
	joystick.axis_max[6]			= WinJoyCaps.wVmax;
	joystick.axis_center[0]			= (WinJoyCaps.wXmax-WinJoyCaps.wXmin)/2;
	joystick.axis_center[1]			= (WinJoyCaps.wYmax-WinJoyCaps.wYmin)/2;
	joystick.axis_center[2]			= (WinJoyCaps.wZmax-WinJoyCaps.wZmin)/2;
	joystick.axis_center[4]			= (WinJoyCaps.wRmax-WinJoyCaps.wRmin)/2;
	joystick.axis_center[5]			= (WinJoyCaps.wUmax-WinJoyCaps.wUmin)/2;
	joystick.axis_center[6]			= (WinJoyCaps.wVmax-WinJoyCaps.wVmin)/2;

	joystick.present_mask = JOY_1_X_AXIS | JOY_1_Y_AXIS;
	
	if (WinJoyCaps.wCaps & JOYCAPS_HASPOV) {
		joystick.has_pov = 1;
		joystick.present_mask |= JOY_1_POV;
	}
	else joystick.has_pov = 0;

	if (WinJoyCaps.wCaps & JOYCAPS_HASZ) 
		joystick.present_mask |= JOY_1_Z_AXIS;
	if (WinJoyCaps.wCaps & JOYCAPS_HASR) 
		joystick.present_mask |= JOY_1_R_AXIS;
	if (WinJoyCaps.wCaps & JOYCAPS_HASU)
		joystick.present_mask |= JOY_1_U_AXIS;
	if (WinJoyCaps.wCaps & JOYCAPS_HASV) 
		joystick.present_mask |= JOY_1_V_AXIS;

	joy95_get_name(JOYSTICKID1, joyname, 255);
	if (!strcmpi(joyname, "CH Flightstick Pro") || FindArg("-ordinaljoy")) {
		CHStickHack = 1;
	}
	else CHStickHack = 0;

			
	return 1;
}