History

Add joystickWithName for PrioVR

Ryan Huffman committed 12 years ago

Commit 42479b11 parent a24b5c22 files · +20 −20Browse files

Showing the changes to interface/src/scripting/JoystickScriptingInterface.cpp (1 of 2 files). Show all

Unified · Split

interface/src/scripting/JoystickScriptingInterface.cpp+13−12
@@ -78,6 +78,19 @@ const QObjectList JoystickScriptingInterface::getAllJoysticks() const { · 77 unmodified lines
7878 return objectList;
7979 }
8080
81+Joystick* JoystickScriptingInterface::joystickWithName(const QString& name) {
82+#ifdef HAVE_SDL2
83+ QMap<SDL_JoystickID, Joystick*>::iterator iter = _openJoysticks.begin();
84+ while (iter != _openJoysticks.end()) {
85+ if (iter.value()->getName() == name) {
86+ return iter.value();
87+ }
88+ iter++;
89+ }
90+#endif
91+ return NULL;
92+}
93+
8194 void JoystickScriptingInterface::update() {
8295 #ifdef HAVE_SDL2
8396 if (_isInitialized) {
@@ -111,15 +124,3 @@ void JoystickScriptingInterface::update() { · 27 unmodified lines
111124 }
112125 #endif
113126 }
114−
115−#ifdef HAVE_SDL2
116−
117−SDL_Joystick* JoystickScriptingInterface::openSDLJoystickWithName(const QString& name) {
118− // we haven't opened a joystick with this name yet - enumerate our SDL devices and see if it exists
119− int joystickCount = SDL_NumJoysticks();
120−
121−
122− return NULL;
123−}
124−
125−#endif