예제 #1
0
        public virtual void CreateInput()
        {
            LogManager.Singleton.LogMessage("*** Initializing OIS ***");
            MOIS.ParamList pl = new MOIS.ParamList();
            IntPtr         windowHnd;

            window.GetCustomAttribute("WINDOW", out windowHnd);
            pl.Insert("WINDOW", windowHnd.ToString());

            if (this.IsMouseNonExclusive)
            {
                pl.Insert("w32_mouse", "DISCL_FOREGROUND");
                pl.Insert("w32_mouse", "DISCL_NONEXCLUSIVE");
            }

            inputManager = MOIS.InputManager.CreateInputSystem(pl);

            //Create all devices (We only catch joystick exceptions here, as, most people have Key/Mouse)
            inputKeyboard = (MOIS.Keyboard)inputManager.CreateInputObject(MOIS.Type.OISKeyboard, UseBufferedInput);
            inputMouse    = (MOIS.Mouse)inputManager.CreateInputObject(MOIS.Type.OISMouse, UseBufferedInput);

            uint width;
            uint height;
            uint depth;
            int  left;
            int  top;

            window.GetMetrics(out width, out height, out depth, out left, out top);
            MOIS.MouseState_NativePtr cState = inputMouse.MouseState;
            cState.width  = (int)width;
            cState.height = (int)height;
        }
예제 #2
0
        /************************************************************************/
        /* handle device lost and device restored events                        */
        /************************************************************************/
        private void OnRenderSystemEventOccurred(string eventName, Const_NameValuePairList parameters)
        {
            EventHandler <OgreEventArgs> evt = null;
            OgreEventArgs args;

            // check which event occured
            switch (eventName)
            {
            // direct 3D device lost
            case "DeviceLost":
                // don't set mRenderingActive to false here, because ogre will try to restore the
                // device in the RenderOneFrame function and mRenderingActive needs to be set to true
                // for this function to be called

                // event to raise is device lost event
                evt = DeviceLost;

                // on device lost, create empty ogre event args
                args = new OgreEventArgs();
                break;

            // direct 3D device restored
            case "DeviceRestored":
                uint width;
                uint height;
                uint depth;

                // event to raise is device restored event
                evt = DeviceRestored;

                // get metrics for the render window size
                mWindow.GetMetrics(out width, out height, out depth);

                // on device restored, create ogre event args with new render window size
                args = new OgreEventArgs((int)width, (int)height);
                break;

            default:
                return;
            }

            // raise event with provided event args
            if (evt != null)
            {
                evt(this, args);
            }
        }