x
Yes
No
Do you want to visit DriveHQ English website?
首页
产品服务
价格
免费试用
下载客户端
关于我们
云文件服务
|
云备份服务
|
FTP服务
|
企业邮箱服务
|
网站托管
|
客户端软件
云文件服务
云备份服务
FTP服务
企业级邮箱服务
网站托管
客户端软件
InputManager.cpp - Hosted on DriveHQ Cloud IT Platform
返回上层目录
上传
下载
共享
发布
新建文件夹
新建文件
复制
剪切
删除
粘贴
评论
升级服务
路径: \\game3dprogramming\materials\GameFactory\GameFactoryDemo\GameFactory\InputManager.cpp
旋转
特效
属性
历史版本
#include "InputManager.h" #include "GameScene.h" InputManager* InputManager::theSingleton = NULL; extern HWND hWndMainWin; InputManager::InputManager(){ myassert(theSingleton==NULL); theSingleton = this; OIS::ParamList pl; size_t windowHnd = 0; std::ostringstream windowHndStr; GameScene::GetSingleton()->GetRenderWindow()->getCustomAttribute("WINDOW", &windowHnd); //windowHndStr << windowHnd; windowHndStr << (size_t)hWndMainWin; pl.insert(std::make_pair(std::string("WINDOW"), windowHndStr.str())); 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"))); mInputManager = OIS::InputManager::createInputSystem( pl ); //Create all devices (We only catch joystick exceptions here, as, most people have Key/Mouse) mKeyboard = new RKeyboard(static_cast
(mInputManager->createInputObject( OIS::OISKeyboard, false/*bufferedKeys*/ ))); mMouse = static_cast
(mInputManager->createInputObject( OIS::OISMouse, false/*bufferedMouse*/ )); unsigned int width, height, depth; int left, top; GameScene::GetSingleton()->GetRenderWindow()->getMetrics(width, height, depth, left, top); const OIS::MouseState &ms = mMouse->getMouseState(); ms.width = width; ms.height = height; } InputManager::~InputManager(){ while (mInputControllerPool.GetPool().size()>0){//cannot use for loop here because element's destructor remove itself from the container InputController* firstElement = (InputController*)*(mInputControllerPool.GetPool().begin()); SAFE_DELETE(firstElement); } theSingleton = NULL; mInputManager->destroyInputObject( mMouse ); mInputManager->destroyInputObject( mKeyboard->mKeyboard ); //mInputManager->destroyInputObject( mJoy ); OIS::InputManager::destroyInputSystem(mInputManager); mInputManager = NULL; } void InputManager::FrameMove(Ogre::Real elapsedTime){ mMouse->capture(); //const OIS::MouseState &ms = mMouse->getMouseState(); //if (ms.X.abs<=ms.width && ms.Y.abs <= ms.height){//got focus // mKeyboard->_Capture(); //} mKeyboard->_Capture(); RMouse* myMouse = &((RMouse)mMouse->getMouseState()); for (list
::iterator iter = mInputControllerPool.GetPool().begin(); iter!=mInputControllerPool.GetPool().end();iter++){ InputController* controller = static_cast
(*iter); controller->FrameMove(elapsedTime, myMouse, mKeyboard); } }
InputManager.cpp
网页地址
文件地址
上一页
25/55
下一页
下载
( 2 KB )
Comments
Total ratings:
0
Average rating:
无评论
of 10
Would you like to comment?
Join now
, or
Logon
if you are already a member.