bool App::setup () { // Set up the input manager input_manager = OIS::InputManager::createInputSystem(window.getSystemHandle()); // Joystick cout << input_manager->getNumberOfDevices(OIS::OISJoyStick) << " joysticks" << endl; OIS::DeviceList::iterator it = input_manager->listFreeDevices().begin(); OIS::DeviceList::iterator end = input_manager->listFreeDevices().end(); for (; it!=end; it++) { cout << it->first << ", " << it->second << endl; } joystick = static_cast<OIS::JoyStick*>(input_manager->createInputObject(OIS::OISJoyStick, true)); joystick->setEventCallback(this); return true; }
JNIEXPORT jobjectArray JNICALL Java_com_badlogic_gdx_controllers_desktop_ois_Ois_getJoystickNames(JNIEnv* env, jobject object, jlong inputManagerPtr) { //@line:75 OIS::InputManager* inputManager = (OIS::InputManager*)inputManagerPtr; OIS::DeviceList map = inputManager->listFreeDevices(); int joystickCount = inputManager->getNumberOfDevices(OIS::OISJoyStick); jobjectArray names = (jobjectArray)env->NewObjectArray(joystickCount, env->FindClass("java/lang/String"), env->NewStringUTF("")); int index = 0; for (OIS::DeviceList::iterator i = map.begin(); i != map.end(); ++i) { if (i->first != OIS::OISJoyStick) continue; env->SetObjectArrayElement(names, index++, env->NewStringUTF(i->second.c_str())); } return names; }