本文整理汇总了C++中ois::InputManager::getNumberOfDevices方法的典型用法代码示例。如果您正苦于以下问题:C++ InputManager::getNumberOfDevices方法的具体用法?C++ InputManager::getNumberOfDevices怎么用?C++ InputManager::getNumberOfDevices使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ois::InputManager
的用法示例。
在下文中一共展示了InputManager::getNumberOfDevices方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
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;
}
示例2: setup
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;
}