AREXPORT bool ArJoyHandler::init(void) { myPhysMax = 1; myLastZ = 0; // first see if we can talk to the first joystick if (joyGetDevCaps(JOYSTICKID1,&myJoyCaps,sizeof(myJoyCaps)) == JOYERR_NOERROR && joyGetPos(JOYSTICKID1,&myJoyInfo) != JOYERR_UNPLUGGED) { myJoyID = JOYSTICKID1; // So far, it seems that the x range is the same as that of y and // z, so only one is used myPhysMax = myJoyCaps.wXmax - myJoyCaps.wXmin; myInitialized = true; startCal(); endCal(); return true; } // we couldn't talk to the first one so try the second one else if (joyGetDevCaps(JOYSTICKID2,&myJoyCaps,sizeof(myJoyCaps)) == JOYERR_NOERROR && joyGetPos(JOYSTICKID2,&myJoyInfo) != JOYERR_UNPLUGGED) { myJoyID = JOYSTICKID2; // So far, it seems that the x range is the same as that of y and // z, so only one is used myPhysMax = myJoyCaps.wXmax - myJoyCaps.wXmin; myInitialized = true; startCal(); endCal(); return true; } // we couldn't talk to either one else { myInitialized = false; return false; } // Just to prevent any possible divide-by-zeros... if (myPhysMax == 0) { myPhysMax = 1; } getData(); }
bool ArJoyHandler::init(void) { int i; myLastOpenTry.setToNow(); myJoyNumber = 0; if (myUseOld) { myOldJoyDesc = ArUtil::fopen("/dev/js0", "r"); if(myOldJoyDesc > 0) ArLog::log(ArLog::Verbose, "ArJoyHandler: Opened /dev/js0 (old Linux device name scheme)"); } else { for (i = 0; i < 32; i++) { sprintf(myJoyNameTemp, "/dev/input/js%d", i); if ((myJoyDesc = ArUtil::open(myJoyNameTemp, O_RDONLY | O_NONBLOCK)) > 0) { ArLog::log(ArLog::Verbose, "ArJoyHandler: Opened %s", myJoyNameTemp); break; } } } if ((myUseOld && myOldJoyDesc != NULL) || (!myUseOld && myJoyDesc > 0)) { myPhysMax = 255; myInitialized = true; startCal(); endCal(); getData(); return true; } else { myJoyNumber = -1; myPhysMax = 255; myInitialized = false; getData(); return false; } }
AREXPORT bool ArJoyHandler::init(void) { myPhysMax = 1; myLastZ = 0; // first see if we can talk to the first joystick if (joyGetDevCaps(JOYSTICKID1,&myJoyCaps,sizeof(myJoyCaps)) == JOYERR_NOERROR && joyGetPos(JOYSTICKID1,&myJoyInfo) != JOYERR_UNPLUGGED) { myJoyID = JOYSTICKID1; // So far, it seems that the x range is the same as that of y and // z, so only one is used myPhysMax = myJoyCaps.wXmax - myJoyCaps.wXmin; /* ArLog::log(ArLog::Normal, "caps 0x%x numAxes %d maxAxes %d %s", myJoyCaps.wCaps, myJoyCaps.wNumAxes, myJoyCaps.wMaxAxes, myJoyCaps.szPname); ArLog::log(ArLog::Normal, "xMin %d xMax %d yMin %d yMax %d zMin %d zMax %d rMin %d rMax %d uMin %d uMax %d", myJoyCaps.wXmin, myJoyCaps.wXmax, myJoyCaps.wYmin, myJoyCaps.wYmax, myJoyCaps.wRmin, myJoyCaps.wRmax, myJoyCaps.wZmin, myJoyCaps.wZmax, myJoyCaps.wUmin, myJoyCaps.wUmax); */ myInitialized = true; startCal(); endCal(); return true; } // we couldn't talk to the first one so try the second one else if (joyGetDevCaps(JOYSTICKID2,&myJoyCaps,sizeof(myJoyCaps)) == JOYERR_NOERROR && joyGetPos(JOYSTICKID2,&myJoyInfo) != JOYERR_UNPLUGGED) { myJoyID = JOYSTICKID2; // So far, it seems that the x range is the same as that of y and // z, so only one is used myPhysMax = myJoyCaps.wXmax - myJoyCaps.wXmin; /* ArLog::log(ArLog::Normal, "2 caps 0x%x numAxes %d maxAxes %d %s", myJoyCaps.wCaps, myJoyCaps.wNumAxes, myJoyCaps.wMaxAxes, myJoyCaps.szPname); ArLog::log(ArLog::Normal, "2 xMin %d xMax %d yMin %d yMax %d zMin %d zMax %d rMin %d rMax %d uMin %d uMax %d", myJoyCaps.wXmin, myJoyCaps.wXmax, myJoyCaps.wYmin, myJoyCaps.wYmax, myJoyCaps.wRmin, myJoyCaps.wRmax, myJoyCaps.wZmin, myJoyCaps.wZmax, myJoyCaps.wUmin, myJoyCaps.wUmax); */ myInitialized = true; startCal(); endCal(); return true; } // we couldn't talk to either one else { myInitialized = false; return false; } // Just to prevent any possible divide-by-zeros... if (myPhysMax == 0) { myPhysMax = 1; } getData(); }