Home | History | Annotate | Download | only in jni
      1 #include <com.badlogic.gdx.controllers.desktop.ois.Ois.h>
      2 
      3 //@line:58
      4 
      5 	#include <OISJoyStick.h>
      6 	#include <OISInputManager.h>
      7 	#include <sstream>
      8 	JNIEXPORT jlong JNICALL Java_com_badlogic_gdx_controllers_desktop_ois_Ois_createInputManager(JNIEnv* env, jobject object, jlong hwnd) {
      9 
     10 
     11 //@line:64
     12 
     13 		OIS::ParamList params;
     14 		#ifndef __APPLE__
     15 			std::ostringstream hwndStr;
     16 			hwndStr << hwnd;
     17 			params.insert(std::make_pair("WINDOW", hwndStr.str()));
     18 		#endif
     19 
     20 		OIS::InputManager *inputManager = OIS::InputManager::createInputSystem(params);
     21 		return (jlong)inputManager;
     22 
     23 
     24 }
     25 
     26 JNIEXPORT jobjectArray JNICALL Java_com_badlogic_gdx_controllers_desktop_ois_Ois_getJoystickNames(JNIEnv* env, jobject object, jlong inputManagerPtr) {
     27 
     28 
     29 //@line:76
     30 
     31 		OIS::InputManager* inputManager = (OIS::InputManager*)inputManagerPtr;
     32 		OIS::DeviceList map = inputManager->listFreeDevices();
     33 		int joystickCount = inputManager->getNumberOfDevices(OIS::OISJoyStick);
     34 		jobjectArray names = (jobjectArray)env->NewObjectArray(joystickCount, env->FindClass("java/lang/String"), env->NewStringUTF(""));
     35 		int index = 0;
     36 		for (OIS::DeviceList::iterator i = map.begin(); i != map.end(); ++i) {
     37 			if (i->first != OIS::OISJoyStick) continue;
     38 			env->SetObjectArrayElement(names, index++, env->NewStringUTF(i->second.c_str()));
     39 		}
     40 		return names;
     41 
     42 
     43 }
     44 
     45 JNIEXPORT jint JNICALL Java_com_badlogic_gdx_controllers_desktop_ois_Ois_getVersionNumber(JNIEnv* env, jobject object, jlong inputManagerPtr) {
     46 
     47 
     48 //@line:89
     49 
     50 		OIS::InputManager* inputManager = (OIS::InputManager*)inputManagerPtr;
     51 	 	return inputManager->getVersionNumber();
     52 
     53 
     54 }
     55 
     56 JNIEXPORT jstring JNICALL Java_com_badlogic_gdx_controllers_desktop_ois_Ois_getVersionName(JNIEnv* env, jobject object, jlong inputManagerPtr) {
     57 
     58 
     59 //@line:94
     60 
     61 		OIS::InputManager* inputManager = (OIS::InputManager*)inputManagerPtr;
     62 	 	return env->NewStringUTF(inputManager->getVersionName().c_str());
     63 
     64 
     65 }
     66 
     67 JNIEXPORT jstring JNICALL Java_com_badlogic_gdx_controllers_desktop_ois_Ois_getInputSystemName(JNIEnv* env, jobject object, jlong inputManagerPtr) {
     68 
     69 
     70 //@line:99
     71 
     72 		OIS::InputManager* inputManager = (OIS::InputManager*)inputManagerPtr;
     73 	 	return env->NewStringUTF(inputManager->inputSystemName().c_str());
     74 
     75 
     76 }
     77 
     78 JNIEXPORT jlong JNICALL Java_com_badlogic_gdx_controllers_desktop_ois_Ois_createJoystick(JNIEnv* env, jobject object, jlong inputManagerPtr) {
     79 
     80 
     81 //@line:104
     82 
     83 		OIS::InputManager* inputManager = (OIS::InputManager*)inputManagerPtr;
     84 		try {
     85 			return (jlong)static_cast<OIS::JoyStick*>(inputManager->createInputObject(OIS::OISJoyStick, true));
     86 		} catch (std::exception &ex) {
     87 			printf("Error creating joystick: %s\n", ex.what());
     88 			fflush(stdout);
     89 			return 0;
     90 		}
     91 
     92 
     93 }
     94 
     95