public void CreateInput() { MOIS.ParamList pl = new ParamList(); IntPtr windHnd; this.mRenderWindow.GetCustomAttribute("WINDOW", out windHnd); pl.Insert("WINDOW", windHnd.ToString()); //Non-exclusive input, show OS cursor //If you want to see the mouse cursor and be able to move it outside your OGRE window and use the keyboard outside the running application pl.Insert("w32_mouse", "DISCL_FOREGROUND"); pl.Insert("w32_mouse", "DISCL_NONEXCLUSIVE"); pl.Insert("w32_keyboard", "DISCL_FOREGROUND"); pl.Insert("w32_keyboard", "DISCL_NONEXCLUSIVE"); inputManager = MOIS.InputManager.CreateInputSystem(pl); //Create all devices (except joystick, as most people have Keyboard/Mouse) using buffered input. inputKeyboard = (Keyboard)inputManager.CreateInputObject(MOIS.Type.OISKeyboard, true); inputMouse = (Mouse)inputManager.CreateInputObject(MOIS.Type.OISMouse, true); MOIS.MouseState_NativePtr mouseState = inputMouse.MouseState; mouseState.width = this.mViewport.ActualWidth;//update after resize window mouseState.height = this.mViewport.ActualHeight; CreateEventHandler(); }
public void InputSystem_SizeChanged(int cWidth, int cHeight) { MOIS.MouseState_NativePtr mptr = this.Mouse.MouseState; if (cWidth != 0 && cHeight != 0) { mptr.width = cWidth; mptr.height = cHeight; } }
protected virtual void InitializeInput() { LogManager.Singleton.LogMessage("*** Initializing OIS ***"); mRenderWindow = mWindow; int windowHnd; mWindow.GetCustomAttribute("WINDOW", out windowHnd); inputMgr = MOIS.InputManager.CreateInputSystem((uint)windowHnd); mKeyboard = (MOIS.Keyboard)inputMgr.CreateInputObject(MOIS.Type.OISKeyboard, true); mMouse = (MOIS.Mouse)inputMgr.CreateInputObject(MOIS.Type.OISMouse, true); MOIS.MouseState_NativePtr state = mMouse.MouseState; state.width = mWindow.GetViewport(0).ActualWidth; state.height = mWindow.GetViewport(0).ActualHeight; mKeyboard.KeyPressed += new KeyListener.KeyPressedHandler(OnKeyPressed); mKeyboard.KeyReleased += new KeyListener.KeyReleasedHandler(OnKeyReleased); mMouse.MouseMoved += new MouseListener.MouseMovedHandler(OnMouseMoved); mMouse.MousePressed += new MouseListener.MousePressedHandler(OnMousePressed); mMouse.MouseReleased += new MouseListener.MouseReleasedHandler(OnMouseReleased); }
public bool initOgre(String wndTitle) { LogManager logMgr = new LogManager(); m_pLog = LogManager.Singleton.CreateLog("OgreLogfile.log", true, true, false); m_pLog.SetDebugOutputEnabled(true); m_pRoot = new Root(); if (!m_pRoot.ShowConfigDialog()) { return(false); } m_pRenderWnd = m_pRoot.Initialise(true, wndTitle); m_pViewport = m_pRenderWnd.AddViewport(null); ColourValue cv = new ColourValue(0.5f, 0.5f, 0.5f); m_pViewport.BackgroundColour = cv; m_pViewport.Camera = null; int hWnd = 0; //ParamList paramList; m_pRenderWnd.GetCustomAttribute("WINDOW", out hWnd); m_pInputMgr = InputManager.CreateInputSystem((uint)hWnd); m_pKeyboard = (MOIS.Keyboard)m_pInputMgr.CreateInputObject(MOIS.Type.OISKeyboard, true); m_pMouse = (MOIS.Mouse)m_pInputMgr.CreateInputObject(MOIS.Type.OISMouse, true); m_pMouse.MouseMoved += new MouseListener.MouseMovedHandler(mouseMoved); m_pMouse.MousePressed += new MouseListener.MousePressedHandler(mousePressed); m_pMouse.MouseReleased += new MouseListener.MouseReleasedHandler(mouseReleased); m_pKeyboard.KeyPressed += new KeyListener.KeyPressedHandler(keyPressed); m_pKeyboard.KeyReleased += new KeyListener.KeyReleasedHandler(keyReleased); MOIS.MouseState_NativePtr mouseState = m_pMouse.MouseState; mouseState.width = m_pViewport.ActualWidth; mouseState.height = m_pViewport.ActualHeight; //m_pMouse.MouseState = tempMouseState; String secName, typeName, archName; ConfigFile cf = new ConfigFile(); cf.Load("resources.cfg", "\t:=", true); ConfigFile.SectionIterator seci = cf.GetSectionIterator(); while (seci.MoveNext()) { secName = seci.CurrentKey; ConfigFile.SettingsMultiMap settings = seci.Current; foreach (KeyValuePair <string, string> pair in settings) { typeName = pair.Key; archName = pair.Value; ResourceGroupManager.Singleton.AddResourceLocation(archName, typeName, secName); } } TextureManager.Singleton.DefaultNumMipmaps = 5; ResourceGroupManager.Singleton.InitialiseAllResourceGroups(); m_pTrayMgr = new SdkTrayManager("AOFTrayMgr", m_pRenderWnd, m_pMouse, null); m_pTimer = new Timer(); m_pTimer.Reset(); m_pRenderWnd.IsActive = true; return(true); }