本文整理汇总了C++中ois::InputManager类的典型用法代码示例。如果您正苦于以下问题:C++ InputManager类的具体用法?C++ InputManager怎么用?C++ InputManager使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了InputManager类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
JNIEXPORT jint JNICALL Java_com_badlogic_gdx_controllers_desktop_ois_Ois_getVersionNumber(JNIEnv* env, jobject object, jlong inputManagerPtr) {
//@line:88
OIS::InputManager* inputManager = (OIS::InputManager*)inputManagerPtr;
return inputManager->getVersionNumber();
}
示例2: windowClosed
void application::windowClosed (Ogre::RenderWindow* wnd)
{
if (wnd == this->wnd)
if (input)
{
input->destroyInputObject(mouse);
input->destroyInputObject(kbd);
OIS::InputManager::destroyInputSystem(input);
input = 0;
}
}
示例3: windowClosed
void windowClosed(Ogre::RenderWindow* rw)
{
mExit = true;
if (mInputManager) {
Ogre::LogManager::getSingletonPtr()->logMessage("*-*-* OIS Shutdown");
mInputManager->destroyInputObject(mMouse);
mInputManager->destroyInputObject(mKeyboard);
OIS::InputManager::destroyInputSystem(mInputManager);
mInputManager = 0;
}
}
示例4: initOIS
void App::initOIS()
{
size_t windowHnd = 0;
mWindow->getCustomAttribute("WINDOW", &windowHnd);
std::ostringstream windowHndStr;
windowHndStr << windowHnd;
OIS::ParamList pl;
pl.insert(std::make_pair(std::string("WINDOW"), windowHndStr.str()));
OIS::InputManager* inputManager = OIS::InputManager::createInputSystem(pl);
mKeyboard = static_cast<OIS::Keyboard*>(inputManager->createInputObject(OIS::OISKeyboard, true));
mKeyboard->setEventCallback(this);
}
示例5: Init
void cKeyboard::Init()
{
// Clear the input buffer
memset(mabInputBuffer, 0, kuiInputChanelSize);
assert(cInputManager::Get().mpOISInputManager);
// Creates keyboard object
OIS::InputManager * lpOISInputManager =cInputManager::Get().mpOISInputManager;
mpOISKeyboard = (OIS::Keyboard*)lpOISInputManager->createInputObject( OIS::OISKeyboard, true );
// Set callbacks
mpOISKeyboard->setEventCallback( this );
mbIsValid = true;
}
示例6:
MyFrameListener(RenderWindow* win, Ogre::Camera* Cam ){
size_t windowHnd = 0;
std::stringstream windowsHndStr;
win->getCustomAttribute("WINDOW", &windowHnd);
windowsHndStr << windowHnd;
OIS::ParamList pl;
pl.insert(std::make_pair(std::string("WINDOW"), windowsHndStr.str()));
_man = OIS::InputManager::createInputSystem(pl);
_key = static_cast<OIS::Keyboard*>(_man->createInputObject(OIS::OISKeyboard,false));
_mouse = static_cast<OIS::Mouse*>(_man->createInputObject(OIS::OISMouse,false));
_cam = Cam;
}
示例7: catch
JNIEXPORT jlong JNICALL Java_com_badlogic_gdx_controllers_desktop_ois_Ois_createJoystick(JNIEnv* env, jobject object, jlong inputManagerPtr) {
//@line:103
OIS::InputManager* inputManager = (OIS::InputManager*)inputManagerPtr;
try {
return (jlong)static_cast<OIS::JoyStick*>(inputManager->createInputObject(OIS::OISJoyStick, true));
} catch (std::exception &ex) {
printf("Error creating joystick: %s\n", ex.what());
fflush(stdout);
return 0;
}
}
示例8:
AppFrameListener(Ogre::RenderWindow* win, Ogre::Camera* cam, Ogre::SceneManager* _sceneManager){
OIS::ParamList parameters;
unsigned int windowHandle = 0;
std::ostringstream windowHandleString;
win->getCustomAttribute("WINDOW", &windowHandle);
windowHandleString << windowHandle;
parameters.insert(std::make_pair("WINDOW", windowHandleString.str()));
_InputManager = OIS::InputManager::createInputSystem(parameters);
_Keyboard = static_cast<OIS::Keyboard*>(_InputManager->createInputObject( OIS::OISKeyboard, false ));
_Mouse = static_cast<OIS::Mouse*>(_InputManager->createInputObject( OIS::OISMouse, false ));
_sManager = _sceneManager;
_Cam = cam;
_movementspeed = 25;
}
示例9: 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;
}
示例10: setupInputSystem
void setupInputSystem()
{
size_t windowHnd = 0;
std::ostringstream windowHndStr;
OIS::ParamList pl;
RenderWindow *win = mWindow;
win->getCustomAttribute("WINDOW", &windowHnd);
windowHndStr << windowHnd;
pl.insert(std::make_pair(std::string("WINDOW"), windowHndStr.str()));
mInputManager = OIS::InputManager::createInputSystem(pl);
try
{
mKeyboard = static_cast<OIS::Keyboard*>(mInputManager->createInputObject(OIS::OISKeyboard, true));
mMouse = static_cast<OIS::Mouse*>(mInputManager->createInputObject(OIS::OISMouse, true));
//mJoy = static_cast<OIS::JoyStick*>(mInputManager->createInputObject(OIS::OISJoyStick, false));
}
catch (const OIS::Exception &e)
{
throw Exception(42, e.eText, "Application::setupInputSystem");
}
}
示例11: init
void OglOIS::init()
{
OIS::ParamList pl;
OIS::InputManager *mInputSystem;
/*SDL_SysWMinfo info;
SDL_VERSION( &info.version );
SDL_GetWindowWMInfo( window, &info );*/
size_t m_windowHandle;
#if defined OIS_WIN32_PLATFORM
m_windowHandle = (int) GetActiveWindow();//*(reinterpret_cast<std::size_t*>(&(/*info.info.x11.window*/info.info.win.window)));
#elif defined OIS_LINUX_PLATFORM
Display *display;
Window focus;
int revert;
display = XOpenDisplay( NULL );
XGetInputFocus( display, &focus, &revert );
m_windowHandle = (int) focus;
#endif
ostringstream windowHndStr;
windowHndStr << m_windowHandle;
pl.insert( std::make_pair( std::string( "WINDOW" ), windowHndStr.str( ) ) );
#if defined OIS_WIN32_PLATFORM
pl.insert( std::make_pair( std::string( "w32_mouse" ), std::string( "DISCL_FOREGROUND" ) ) );
pl.insert( std::make_pair( std::string( "w32_mouse" ), std::string( "DISCL_NONEXCLUSIVE" ) ) );
#elif defined OIS_LINUX_PLATFORM
pl.insert( std::make_pair( std::string( "x11_mouse_grab" ), std::string( "false" ) ) );
pl.insert( std::make_pair( std::string( "x11_mouse_hide" ), std::string( "false" ) ) );;
#endif
mInputSystem = OIS::InputManager::createInputSystem( pl );
mouse = static_cast<OIS::Mouse*>(mInputSystem->createInputObject( OIS::OISMouse, false ));
keyb = static_cast<OIS::Keyboard*>(mInputSystem->createInputObject( OIS::OISKeyboard, false ));
}
示例12: create_frame_listener
void application::create_frame_listener()
{
Ogre::LogManager::getSingletonPtr() -> logMessage("Initializing OIS");
OIS::ParamList pl;
size_t wndhnd = 0;
std::ostringstream wndhndstr;
wnd->getCustomAttribute ("WINDOW", &wndhnd);
wndhndstr << wndhnd;
pl.insert (std::make_pair (std::string {"WINDOW"}, wndhndstr.str()));
input = OIS::InputManager::createInputSystem(pl);
kbd = static_cast<OIS::Keyboard*> (input->createInputObject (OIS::OISKeyboard, true));
mouse = static_cast<OIS::Mouse*> (input->createInputObject (OIS::OISMouse, true));
mouse -> setEventCallback(this);
kbd -> setEventCallback(this);
windowResized(wnd);
Ogre::WindowEventUtilities::addWindowEventListener (wnd, this);
OgreBites::InputContext inctx;
inctx.mMouse = mouse;
inctx.mKeyboard = kbd;
tray_mgr = new OgreBites::SdkTrayManager ("InterfaceName", wnd, inctx, this);
tray_mgr->showFrameStats(OgreBites::TL_BOTTOMLEFT);
tray_mgr->showLogo(OgreBites::TL_BOTTOMRIGHT);
tray_mgr->hideCursor();
Ogre::StringVector items;
items.push_back("cam.pX");
items.push_back("cam.pY");
items.push_back("cam.pZ");
items.push_back("");
items.push_back("cam.oW");
items.push_back("cam.oX");
items.push_back("cam.oY");
items.push_back("cam.oZ");
items.push_back("");
items.push_back("Filtering");
items.push_back("Poly Mode");
root->addFrameListener(this);
}
示例13: WinMain
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdLine, int iCmdShow) {
#else
int main(int argc, char** argv) {
#endif
Window window("Sample_InteractiveWater", 1024, 768, true);
RenderParameters_t renderParameters;
renderParameters.width = 1024;
renderParameters.height = 768;
renderParameters.displayFormat = DISPLAY_FORMAT_X8R8G8B8;
renderParameters.refreshRate = 0;
renderParameters.depthStencilBits = DEPTH_STENCIL_BITS_D24X8;
Renderer::GetInstance()->Initialize(RENDER_SYSTEM_OPENGL, window, renderParameters);
Renderer::GetInstance()->SetClearColor(0.2f, 0.2f, 0.2f);
// Water surface creation
const int NUM_VERTICES = 64;
SurfaceTriangles_t surface;
surface.numVertices = NUM_VERTICES * NUM_VERTICES;
surface.numNormals = NUM_VERTICES * NUM_VERTICES;
surface.numTexCoords = NUM_VERTICES * NUM_VERTICES;
surface.vertices = new Vector3[surface.numVertices];
surface.normals = new Vector3[surface.numNormals];
surface.texCoords = new Vector2[surface.numTexCoords];
Vector3* buffer = new Vector3[surface.numVertices];
Vector3* buffer2 = surface.vertices;
size_t idx = 0;
const int NUM_CELLS = NUM_VERTICES - 1;
float step = 2.0f / NUM_CELLS;
float uvStep = 1.0f / NUM_VERTICES;
for (size_t i = 0; i < NUM_VERTICES; i++) {
for (size_t j = 0; j < NUM_VERTICES; j++) {
idx = i * NUM_VERTICES + j;
buffer[idx] = surface.vertices[idx] = Vector3(j * step - 1.0f, i * step - 1.0f, 0.0f);
surface.normals[idx] = -Vector3::LOOK;
surface.texCoords[idx] = Vector2(uvStep * j, uvStep * i);
}
}
surface.numIndices = NUM_CELLS * NUM_CELLS * 6;
surface.indices = new unsigned short[surface.numIndices];
idx = 0;
for (size_t i = 0; i < NUM_CELLS; i++) {
for (size_t j = 0; j < NUM_CELLS; j++) {
surface.indices[idx++] = i * NUM_VERTICES + j;
surface.indices[idx++] = (i + 1) * NUM_VERTICES + j;
surface.indices[idx++] = (i + 1) * NUM_VERTICES + j + 1;
surface.indices[idx++] = i * NUM_VERTICES + j;
surface.indices[idx++] = (i + 1) * NUM_VERTICES + j + 1;
surface.indices[idx++] = i * NUM_VERTICES + j + 1;
}
}
Mesh waterMesh(MESH_TYPE_DYNAMIC);
waterMesh.AddSurface(&surface);
VertexAttributesMap_t vertexAttributes;
vertexAttributes[VERTEX_ATTRIBUTES_POSITION] = 0;
vertexAttributes[VERTEX_ATTRIBUTES_NORMAL] = 1;
vertexAttributes[VERTEX_ATTRIBUTES_TEX_COORDS] = 2;
waterMesh.Initialize(vertexAttributes);
// Material surface
Shader* waterShader = Renderer::GetInstance()->CreateShader();
waterShader->SetSourceFile("Shaders/vert", "Shaders/frag");
Material waterMaterial(waterShader);
Texture2D* waterTexture = Renderer::GetInstance()->CreateTexture2DFromFile("Media/water.jpg");
waterMaterial.SetUniformTexture("waterTexture", waterTexture);
// Water node
Node waterNode;
waterNode.SetMaterial(&waterMaterial);
waterNode.SetMesh(&waterMesh);
Renderer::GetInstance()->GetSceneTree().AddNode(&waterNode);
Renderer::GetInstance()->CameraLookAt(Vector3(0.0f, 0.0f, -3.5f), Vector3::ZERO);
// Create the OIS system if present
#ifdef OIS_AVAILABLE
size_t windowHandle = (size_t)window.GetHandle();
OIS::ParamList paramList;
paramList.insert(pair<string, string>("WINDOW", to_string(windowHandle)));
#if defined OIS_WIN32_PLATFORM
paramList.insert(pair<string, string>("w32_mouse", "DISCL_FOREGROUND"));
paramList.insert(pair<string, string>("w32_mouse", "DISCL_NONEXCLUSIVE"));
#elif defined OIS_LINUX_PLATFORM
paramList.insert(pair<string, string>("x11_mouse_grab", "false"));
paramList.insert(pair<string, string>("x11_mouse_hide", "false"));
#endif
OIS::InputManager* inputManager = OIS::InputManager::createInputSystem(paramList);
//.........这里部分代码省略.........
示例14: main
int main(int argc, char **argv)
#endif
{
//-----------------------------------------------------
// 1 enter ogre
//-----------------------------------------------------
Root* root = new Root;
//-----------------------------------------------------
// 2 configure resource paths
//-----------------------------------------------------
// Load resource paths from config file
// File format is:
// [ResourceGroupName]
// ArchiveType=Path
// .. repeat
// For example:
// [General]
// FileSystem=media/
// Zip=packages/level1.zip
ConfigFile cf;
cf.load("./resources.cfg");
// Go through all sections & settings in the file
ConfigFile::SectionIterator seci = cf.getSectionIterator();
String secName, typeName, archName;
while (seci.hasMoreElements())
{
secName = seci.peekNextKey();
ConfigFile::SettingsMultiMap *settings = seci.getNext();
ConfigFile::SettingsMultiMap::iterator i;
for (i = settings->begin(); i != settings->end(); ++i)
{
typeName = i->first;
archName = i->second;
ResourceGroupManager::getSingleton().addResourceLocation(
archName, typeName, secName);
}
}
//-----------------------------------------------------
// 3 Configures the application and creates the window
//-----------------------------------------------------
if(!root->showConfigDialog())
{
//Ogre
delete root;
return false; // Exit the application on cancel
}
RenderWindow* window = root->initialise(true, "Simple Ogre App");
ResourceGroupManager::getSingleton().initialiseAllResourceGroups();
//-----------------------------------------------------
// 4 Create the SceneManager
//
// ST_GENERIC = octree
// ST_EXTERIOR_CLOSE = simple terrain
// ST_EXTERIOR_FAR = nature terrain (depreciated)
// ST_EXTERIOR_REAL_FAR = paging landscape
// ST_INTERIOR = Quake3 BSP
//-----------------------------------------------------
SceneManager* sceneMgr = root->createSceneManager(ST_GENERIC);
//-----------------------------------------------------
// 5 Create the camera
//-----------------------------------------------------
Camera* camera = sceneMgr->createCamera("SimpleCamera");
//-----------------------------------------------------
// 6 Create one viewport, entire window
//-----------------------------------------------------
Viewport* viewPort = window->addViewport(camera);
//----------------------------------------------------
// 7 add OIS input handling
//----------------------------------------------------
OIS::ParamList pl;
size_t windowHnd = 0;
std::ostringstream windowHndStr;
//tell OIS about the Ogre window
window->getCustomAttribute("WINDOW", &windowHnd);
windowHndStr << windowHnd;
pl.insert(std::make_pair(std::string("WINDOW"), windowHndStr.str()));
//setup the manager, keyboard and mouse to handle input
OIS::InputManager* inputManager = OIS::InputManager::createInputSystem(pl);
OIS::Keyboard* keyboard = static_cast<OIS::Keyboard*>(inputManager->createInputObject(OIS::OISKeyboard, true));
OIS::Mouse* mouse = static_cast<OIS::Mouse*>(inputManager->createInputObject(OIS::OISMouse, true));
//tell OIS about the window's dimensions
unsigned int width, height, depth;
int top, left;
window->getMetrics(width, height, depth, left, top);
const OIS::MouseState &ms = mouse->getMouseState();
ms.width = width;
//.........这里部分代码省略.........
示例15:
~FrameListenerProyectos(){
_man->destroyInputObject(_key);
_man->destroyInputObject(_mouse);
OIS::InputManager::destroyInputSystem(_man);
}