//-------------------------------------------------------------------// JoyStickInfoList LinuxJoyStick::_scanJoys() { JoyStickInfoList joys; //Search through all of the event devices.. and identify which ones are joysticks //xxx move this to InputManager, as it can also scan all other events for(int i = 0; i < OIS_MAX_DEVICES; ++i ) { std::stringstream s; s << "/dev/input/event" << i; int fd = open( s.str().c_str(), O_RDONLY |O_NONBLOCK ); try { JoyStickInfo js; if( EventUtils::isJoyStick(fd, js) ) joys.push_back(js); else close(fd); } catch(...) { close(fd); break; } } return joys; }
//-------------------------------------------------------------------// JoyStickInfoList LinuxJoyStick::_scanJoys() { JoyStickInfoList joys; //Search through all of the event devices.. and identify which ones are joysticks //xxx move this to InputManager, as it can also scan all other events for(int i = 0; i < 64; ++i ) { stringstream s; s << "/dev/input/event" << i; int fd = open( s.str().c_str(), O_RDWR |O_NONBLOCK ); if(fd == -1) continue; #ifdef OIS_LINUX_JOY_DEBUG cout << "Opening " << s.str() << "..." << endl; #endif try { JoyStickInfo js; if( EventUtils::isJoyStick(fd, js) ) { joys.push_back(js); #ifdef OIS_LINUX_JOY_DEBUG cout << "=> Joystick added to list." << endl; #endif } else { #ifdef OIS_LINUX_JOY_DEBUG cout << "=> Not a joystick." << endl; #endif close(fd); } } catch(...) { #ifdef OIS_LINUX_JOY_DEBUG cout << "Exception caught!!" << endl; #endif close(fd); } } return joys; }