public NesVSUnisystemDIPKeyboardConnection(IntPtr handle, IInputSettingsVSUnisystemDIP settings) { DirectInput di = new DirectInput(); keyboard = new Keyboard(di); keyboard.SetCooperativeLevel(handle, CooperativeLevel.Nonexclusive | CooperativeLevel.Foreground); if (settings.CreditServiceButton != "") CreditServiceButton = (SlimDX.DirectInput.Key)Enum.Parse(typeof(SlimDX.DirectInput.Key), settings.CreditServiceButton); if (settings.DIPSwitch1 != "") DIPSwitch1 = (SlimDX.DirectInput.Key)Enum.Parse(typeof(SlimDX.DirectInput.Key), settings.DIPSwitch1); if (settings.DIPSwitch2 != "") DIPSwitch2 = (SlimDX.DirectInput.Key)Enum.Parse(typeof(SlimDX.DirectInput.Key), settings.DIPSwitch2); if (settings.DIPSwitch3 != "") DIPSwitch3 = (SlimDX.DirectInput.Key)Enum.Parse(typeof(SlimDX.DirectInput.Key), settings.DIPSwitch3); if (settings.DIPSwitch4 != "") DIPSwitch4 = (SlimDX.DirectInput.Key)Enum.Parse(typeof(SlimDX.DirectInput.Key), settings.DIPSwitch4); if (settings.DIPSwitch5 != "") DIPSwitch5 = (SlimDX.DirectInput.Key)Enum.Parse(typeof(SlimDX.DirectInput.Key), settings.DIPSwitch5); if (settings.DIPSwitch6 != "") DIPSwitch6 = (SlimDX.DirectInput.Key)Enum.Parse(typeof(SlimDX.DirectInput.Key), settings.DIPSwitch6); if (settings.DIPSwitch7 != "") DIPSwitch7 = (SlimDX.DirectInput.Key)Enum.Parse(typeof(SlimDX.DirectInput.Key), settings.DIPSwitch7); if (settings.DIPSwitch8 != "") DIPSwitch8 = (SlimDX.DirectInput.Key)Enum.Parse(typeof(SlimDX.DirectInput.Key), settings.DIPSwitch8); if (settings.CreditLeftCoinSlot != "") CreditLeftCoinSlot = (SlimDX.DirectInput.Key)Enum.Parse(typeof(SlimDX.DirectInput.Key), settings.CreditLeftCoinSlot); if (settings.CreditRightCoinSlot != "") CreditRightCoinSlot = (SlimDX.DirectInput.Key)Enum.Parse(typeof(SlimDX.DirectInput.Key), settings.CreditRightCoinSlot); NesEmu.EMUShutdown += NesEmu_EMUShutdown; }
public NesJoypadPcKeyboardConnection(IntPtr handle, IInputSettingsJoypad settings) { DirectInput di = new DirectInput(); keyboard = new Keyboard(di); keyboard.SetCooperativeLevel(handle, CooperativeLevel.Nonexclusive | CooperativeLevel.Foreground); if (settings.ButtonUp != "") KeyUp = (SlimDX.DirectInput.Key)Enum.Parse(typeof(SlimDX.DirectInput.Key), settings.ButtonUp); if (settings.ButtonDown != "") KeyDown = (SlimDX.DirectInput.Key)Enum.Parse(typeof(SlimDX.DirectInput.Key), settings.ButtonDown); if (settings.ButtonLeft != "") KeyLeft = (SlimDX.DirectInput.Key)Enum.Parse(typeof(SlimDX.DirectInput.Key), settings.ButtonLeft); if (settings.ButtonRight != "") KeyRight = (SlimDX.DirectInput.Key)Enum.Parse(typeof(SlimDX.DirectInput.Key), settings.ButtonRight); if (settings.ButtonStart != "") KeyStart = (SlimDX.DirectInput.Key)Enum.Parse(typeof(SlimDX.DirectInput.Key), settings.ButtonStart); if (settings.ButtonSelect != "") KeySelect = (SlimDX.DirectInput.Key)Enum.Parse(typeof(SlimDX.DirectInput.Key), settings.ButtonSelect); if (settings.ButtonA != "") KeyA = (SlimDX.DirectInput.Key)Enum.Parse(typeof(SlimDX.DirectInput.Key), settings.ButtonA); if (settings.ButtonB != "") KeyB = (SlimDX.DirectInput.Key)Enum.Parse(typeof(SlimDX.DirectInput.Key), settings.ButtonB); if (settings.ButtonTurboA != "") KeyTurboA = (SlimDX.DirectInput.Key)Enum.Parse(typeof(SlimDX.DirectInput.Key), settings.ButtonTurboA); if (settings.ButtonTurboB != "") KeyTurboB = (SlimDX.DirectInput.Key)Enum.Parse(typeof(SlimDX.DirectInput.Key), settings.ButtonTurboB); }
private Keyboard CreateNumericKeyboard() { Keyboard keyboard = new Keyboard(); LinearKeyboardLayout NumPadLayout = new LinearKeyboardLayout(); NumPadLayout.AddKey("1"); NumPadLayout.AddKey("2"); NumPadLayout.AddKey("3"); NumPadLayout.AddLine(); NumPadLayout.AddKey("4"); NumPadLayout.AddKey("5"); NumPadLayout.AddKey("6"); NumPadLayout.AddLine(); NumPadLayout.AddKey("7"); NumPadLayout.AddKey("8"); NumPadLayout.AddKey("9"); NumPadLayout.AddLine(); NumPadLayout.AddKey("0"); NumPadLayout.AddKey("CLR", "{BACKSPACE}", width: 21); keyboard.Layouts.Add(NumPadLayout); return keyboard; }
public GwenInput(InputManager inputManager) { this.inputManager = inputManager; canvas = null; mouseX = 0; mouseY = 0; m_AltGr = false; mouse = inputManager.Mouse; if (mouse != null) { mouse.MouseMove += ProcessMouseMove; mouse.MouseDrag += ProcessMouseDrag; mouse.MouseButtonPress += ProcessMouseButtonPressed; mouse.MouseButtonRelease += ProcessMouseButtonReleased; mouse.MouseWheelMove += ProcessMouseWheel; } keyboard = inputManager.Keyboard; if (keyboard != null) { keyboard.KeyPress += ProcessKeyDown; keyboard.KeyRelease += ProcessKeyUp; keyboard.KeyText += ProcessText; } }
public GameCore() { _renderEngine = new RenderEngine(); _input = new DirectInput(); _keyboard = new Keyboard(_input); _mouse = new Mouse(_input); Initialize(); }
public bool Initiliase(IntPtr windowHandle) { this.input = MOIS.InputManager.CreateInputSystem((uint)windowHandle.ToInt32()); //Create all devices (We only catch joystick exceptions here, as, most people have Key/Mouse) this.keyboard = (Keyboard)input.CreateInputObject(MOIS.Type.OISKeyboard, true); this.mouse = (Mouse)input.CreateInputObject(MOIS.Type.OISMouse, true); return true; }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); try { Gorgon.Initialize(true, false); VideoMode videoMode; bool fullScreen; using (Configuration configuration = new Configuration()) { configuration.FillResolutionList(); configuration.ShowDialog(this); if (configuration.DialogResult != DialogResult.OK) { Close(); return; } videoMode = configuration.VideoMode; fullScreen = configuration.FullScreen; } Gorgon.SetMode(this, videoMode.Width, videoMode.Height, BackBufferFormats.BufferRGB888, !fullScreen); Gorgon.Idle += Gorgon_Idle; //Gorgon.FrameStatsVisible = true; _input = Input.LoadInputPlugIn(Environment.CurrentDirectory + @"\GorgonInput.DLL", "Gorgon.RawInput"); _input.Bind(this); _keyboard = _input.Keyboard; _keyboard.Enabled = true; _keyboard.Exclusive = true; _keyboard.KeyDown += KeyboardOnKeyDown; _gameMain = new GameMain(); string reason; if (!_gameMain.Initialize(Gorgon.Screen.Width, Gorgon.Screen.Height, this, out reason)) { MessageBox.Show(string.Format("Error loading game resources, error message: {0}", reason)); Close(); return; } Gorgon.Go(); } catch (Exception exception) { MessageBox.Show(exception.Message); Close(); } }
static void DoStartup() { ParamList pl = new ParamList(); Form1 form = new Form1(); form.Show(); pl.Insert("WINDOW", form.Handle.ToString()); //Default mode is foreground exclusive..but, we want to show mouse - so nonexclusive pl.Insert("w32_mouse", "DISCL_FOREGROUND"); pl.Insert("w32_mouse", "DISCL_NONEXCLUSIVE"); //This never returns null.. it will raise an exception on errors g_InputManager = InputManager.CreateInputSystem(pl); uint v = InputManager.VersionNumber; Console.WriteLine("OIS Version: " + (v >> 16) + "." + ((v >> 8) & 0x000000FF) + "." + (v & 0x000000FF) + "\n\tRelease Name: " //+ InputManager.VersionName + "\n\tPlatform: " + g_InputManager.InputSystemName() + "\n\tNumber of Mice: " + g_InputManager.GetNumberOfDevices(MOIS.Type.OISMouse) + "\n\tNumber of Keyboards: " + g_InputManager.GetNumberOfDevices(MOIS.Type.OISKeyboard) + "\n\tNumber of Joys/Pads = " + g_InputManager.GetNumberOfDevices(MOIS.Type.OISJoyStick)); //List all devices DeviceList list = g_InputManager.ListFreeDevices(); foreach (KeyValuePair<MOIS.Type, string> pair in list) Console.WriteLine("\n\tDevice: " + g_DeviceType[(int)pair.Key] + " Vendor: " + pair.Value); g_kb = (Keyboard)g_InputManager.CreateInputObject(MOIS.Type.OISKeyboard, true); g_kb.KeyPressed += new KeyListener.KeyPressedHandler(KeyPressed); g_kb.KeyReleased += new KeyListener.KeyReleasedHandler(KeyReleased); g_m = (Mouse)g_InputManager.CreateInputObject(MOIS.Type.OISMouse, true); g_m.MouseMoved += new MouseListener.MouseMovedHandler(MouseMoved); g_m.MousePressed += new MouseListener.MousePressedHandler(MousePressed); g_m.MouseReleased += new MouseListener.MouseReleasedHandler(MouseReleased); MouseState_NativePtr ms = g_m.MouseState; ms.width = form.Width; ms.height = form.Height; //This demo only uses at max 4 joys int numSticks = g_InputManager.GetNumberOfDevices(MOIS.Type.OISJoyStick); if (numSticks > 4) numSticks = 4; g_joys = new JoyStick[numSticks]; for (int i = 0; i < numSticks; ++i) { g_joys[i] = (JoyStick)g_InputManager.CreateInputObject(MOIS.Type.OISJoyStick, true); g_joys[i].AxisMoved += new JoyStickListener.AxisMovedHandler(AxisMoved); g_joys[i].ButtonPressed += new JoyStickListener.ButtonPressedHandler(JoyButtonPressed); g_joys[i].ButtonReleased += new JoyStickListener.ButtonReleasedHandler(JoyButtonReleased); g_joys[i].PovMoved += new JoyStickListener.PovMovedHandler(PovMoved); g_joys[i].Vector3Moved += new JoyStickListener.Vector3MovedHandler(Vector3Moved); } }
public static void Initialize(IntPtr parent) { if (dinput == null) dinput = new DirectInput(); if (keyboard == null || keyboard.Disposed) keyboard = new Keyboard(dinput); keyboard.SetCooperativeLevel(parent, CooperativeLevel.Background | CooperativeLevel.Nonexclusive); keyboard.Properties.BufferSize = 8; }
/// <summary> /// Initialzes the Game. /// </summary> /// <param name="sceneManager">The Mogre SceneManager.</param> /// <param name="camera">The game CameraMan for the MouseControl.</param> /// <param name="mWindow">The RednerWindow for sending the width and height of the window.</param> /// <param name="mouse">The Mogre Mouse for GUI.</param> /// <param name="keyboard">The Mogre Keyboard for GUI.</param> /// <returns>Returns initializes Game singleton instance.</returns> private Game(SceneManager sceneManager, CameraMan camera, RenderWindow mWindow, Mouse mouse, Keyboard keyboard) { sceneMgr = sceneManager; gameObjectMgr = GameObjectManager.GetInstance(); gameGUI = new MyGUI((int)mWindow.Width, (int)mWindow.Height, mouse, keyboard); mouseControl = MouseControl.GetInstance(camera, (int)mWindow.Width, (int)mWindow.Height); paused = true; soundPlayer = new SoundPlayer(mWindow); mission = new Mission(); }
public Input() { _directInput = new DirectInput(); try { Result result; _keyboard = new Keyboard(_directInput); IntPtr handle = Engine.GameEngine.Window; if ((result = _keyboard.SetCooperativeLevel(handle, CooperativeLevel.Nonexclusive | CooperativeLevel.Background)) != ResultCode.Success) { Engine.GameEngine.Exception.Exceptions.Add(new ExceptionData(result.Description, result.Name, "keyboard cooperation")); } _mouse = new Mouse(_directInput); if ((result = _mouse.SetCooperativeLevel(handle, CooperativeLevel.Foreground | CooperativeLevel.Nonexclusive)) != ResultCode.Success) { Engine.GameEngine.Exception.Exceptions.Add(new ExceptionData(result.Description, result.Name, "mouse cooperation")); } if ((result = _keyboard.Acquire()) != ResultCode.Success) { Engine.GameEngine.Exception.Exceptions.Add(new ExceptionData(result.Description, result.Name, "keyboard acquire")); } if ((result = _mouse.Acquire()) != ResultCode.Success) { Engine.GameEngine.Exception.Exceptions.Add(new ExceptionData(result.Description, result.Name, "mouse acquire")); } Engine.GameEngine.Exception.Exceptions.Add(new ExceptionData("worked", "worked", "worked")); } catch (DirectInputException e) { Engine.GameEngine.Exception.Exceptions.Add(new ExceptionData(e.Message, e.Source, e.StackTrace)); } catch (Exception e) { Engine.GameEngine.Exception.Exceptions.Add(new ExceptionData(e.Message, e.Source, e.StackTrace)); } finally { Dispose(); } }
public LKeyboard(Keyboard keyboard) { kbd = keyboard; kbd.KeyDown += delegate(KeyEventArgs e) { if(keyDown != null) keyDown(new LKeyEventArgs(e)); }; kbd.KeyUp += delegate(KeyEventArgs e) { if(keyUp != null) keyUp(new LKeyEventArgs(e)); }; }
public MainWindow() { InitializeComponent(); controlDevices = new IControl[3]; controlDevices[0] = new GamePad(PadStatusChanged); controlDevices[1] = new Keyboard(); controlDevices[2] = new Kinect(); currentDevice = Device.Keyboard; connection = new Connection(controlDevices, currentDevice); this.Closing += OnWindowClosing; ((Kinect) controlDevices[2]).SkeletonTracked += KinectSkeletonTracked; DataContext = controlDevices[2]; }
public DX_Keyboard() { DirectInput dinput = new DirectInput(); keyboard = new Keyboard(dinput); keyboard.SetCooperativeLevel(Globals.l2net_home, CooperativeLevel.Nonexclusive | CooperativeLevel.Background); keyboard.Acquire(); dx_keyboard_thread = new System.Threading.Thread(new System.Threading.ThreadStart(DX_KeyboardEngine)); dx_keyboard_thread.IsBackground = true; dx_keyboard_thread.Start(); }
void CreateDevice() { // make sure that DirectInput has been initialized DirectInput dinput = new DirectInput(); // build up cooperative flags CooperativeLevel cooperativeLevel; if (exclusiveRadio.Checked) cooperativeLevel = CooperativeLevel.Exclusive; else cooperativeLevel = CooperativeLevel.Nonexclusive; if (foregroundRadio.Checked) cooperativeLevel |= CooperativeLevel.Foreground; else cooperativeLevel |= CooperativeLevel.Background; if (disableCheck.Checked) cooperativeLevel |= CooperativeLevel.NoWinKey; // create the device try { keyboard = new Keyboard(dinput); keyboard.SetCooperativeLevel(this, cooperativeLevel); } catch (DirectInputException e) { MessageBox.Show(e.Message); return; } if (!immediateRadio.Checked) { // since we want to use buffered data, we need to tell DirectInput // to set up a buffer for the data keyboard.Properties.BufferSize = 8; } // acquire the device keyboard.Acquire(); // set the timer to go off 12 times a second to read input // NOTE: Normally applications would read this much faster. // This rate is for demonstration purposes only. timer.Interval = 1000 / 12; timer.Start(); }
public Controller(OgreForm ogreForm, int windowHnd) { this.mOgreForm = ogreForm; InputManager inputMgr; this.mKeyDown = new bool[256]; this.mKeyPressed = new bool[256]; this.mKeyReleased = new bool[256]; ParamList pl = new ParamList(); pl.Insert("WINDOW", windowHnd.ToString()); inputMgr = InputManager.CreateInputSystem(pl); if (inputMgr == null) { return; } // initialize keyboard this.mKeyBoard = (Keyboard)inputMgr.CreateInputObject(MOIS.Type.OISKeyboard, true); if (this.mKeyBoard == null) return; this.mKeyBoard.KeyPressed += OnKeyPressed; this.mKeyBoard.KeyReleased += OnKeyReleased; this.mMouseDown = new Dictionary<MouseButtons, bool>(); this.mMousePressed = new Dictionary<MouseButtons, bool>(); this.mMouseReleased = new Dictionary<MouseButtons, bool>(); foreach (MouseButtons button in Enum.GetValues(typeof(MouseButtons))) { this.mMouseDown.Add(button, false); this.mMousePressed.Add(button, false); this.mMouseReleased.Add(button, false); } this.mMousePos = new Mogre.Vector3(); this.BlockMouse = false; this.mCursorVisibility = true; this.mCommands = new XmlDocument(); this.LoadCommands(); this.mUserActions = new bool[Enum.GetValues(typeof(UserAction)).Length]; this.mUserActionsOccured = new bool[this.mUserActions.Length]; this.mUserActionsEnded = new bool[this.mUserActions.Length]; this.MovementFactor = new Mogre.Vector3(); this.mOgreForm.MouseMove += OnMouseMoved; this.mOgreForm.MouseWheel += OnMouseWheel; this.mOgreForm.MouseDown += OnMousePressed; this.mOgreForm.MouseUp += OnMouseReleased; this.mOgreForm.MouseLeave += OnMouseLeave; }
public Input(Form window) { _window = window; _di = new DirectInput(); _keyboard = new Keyboard(_di); //_keyboard.SetCooperativeLevel(_window.Handle, CooperativeLevel.Background | CooperativeLevel.Nonexclusive); _keyboard.Acquire(); Log.Info("Keyboard aquired"); _mouse = new Mouse(_di); //_mouse.SetCooperativeLevel(_window.Handle, CooperativeLevel.Background | CooperativeLevel.Nonexclusive); _mouse.Acquire(); Log.Info("Mouse aquired"); _pressStamp = 0; }
private static void Initialize() { var keyboardIndex = 0; var mouseIndex = 0; var hidIndex = 0; var descriptors = NativeMethods.GetRawInputDeviceList(); for( var d = 0; d < descriptors.Length; d++ ) { var descriptor = descriptors[ d ]; if( descriptor.DeviceType == InputDeviceType.Mouse ) { if( mouseIndex == 4 ) continue; var m = new Mouse( (GameControllerIndex)( mouseIndex++ ), ref descriptor ); if( !m.IsDisconnected ) { mice.Add( m ); m.Disconnected += OnMouseDisconnected; } } else if( descriptor.DeviceType == InputDeviceType.Keyboard ) { if( keyboardIndex == 4 ) continue; var k = new Keyboard( (GameControllerIndex)( keyboardIndex++ ), ref descriptor ); if( !k.IsDisconnected ) { keyboards.Add( k ); k.Disconnected += OnKeyboardDisconnected; } } else // if( descriptor.DeviceType == InputDeviceType.HumanInterfaceDevice ) { var h = new RawHumanInterfaceDevice( hidIndex++, ref descriptor ); if( !h.IsDisconnected ) { otherDevices.Add( h ); h.Disconnected += OnHidDisconnected; } } } isInitialized = true; }
public Input(Game game, IntPtr handle) : base(game, -10000) { _directInput = new DirectInput(); _keyboard = new Keyboard(_directInput); _keyboard.Properties.BufferSize = 256; _keyboard.SetCooperativeLevel(handle, CooperativeLevel.Background | CooperativeLevel.NonExclusive); _mouse = new Mouse(_directInput); _mouse.Properties.AxisMode = DeviceAxisMode.Relative; _mouse.SetCooperativeLevel(handle, CooperativeLevel.Background | CooperativeLevel.NonExclusive); var devices = _directInput.GetDevices(DeviceType.Gamepad, DeviceEnumerationFlags.AllDevices); if (devices.Count > 0) { _joystick = new Joystick(_directInput, devices[0].InstanceGuid); _joystick.SetCooperativeLevel(handle, CooperativeLevel.Background | CooperativeLevel.NonExclusive); } }
public FormKey(SlimDX.DirectInput.DeviceType type, string deviceGuid, string keyName) { this.deviceType = type; InitializeComponent(); DirectInput di = new DirectInput(); switch (type) { case SlimDX.DirectInput.DeviceType.Keyboard: { keyboard = new Keyboard(di); keyboard.SetCooperativeLevel(this.Handle, CooperativeLevel.Nonexclusive | CooperativeLevel.Foreground); break; } case SlimDX.DirectInput.DeviceType.Joystick: { joystick = new Joystick(di, Guid.Parse(deviceGuid)); joystick.SetCooperativeLevel(this.Handle, CooperativeLevel.Nonexclusive | CooperativeLevel.Foreground); break; } case SlimDX.DirectInput.DeviceType.Other: { switch (deviceGuid) { case "x-controller-1": x_controller = new Controller(UserIndex.One); break; case "x-controller-2": x_controller = new Controller(UserIndex.Two); break; case "x-controller-3": x_controller = new Controller(UserIndex.Three); break; case "x-controller-4": x_controller = new Controller(UserIndex.Four); break; } break; } } timer_hold.Start(); label1.Text = string.Format(Program.ResourceManager.GetString("Text_PressAKeyFor") + " [{0}]", keyName); stopTimer = 10; label_cancel.Text = string.Format(Program.ResourceManager.GetString("Status_CancelIn") + " {0} " + Program.ResourceManager.GetString("Status_Seconds"), stopTimer); timer2.Start(); this.Select(); }
public void Reinitialize_Keyboard(IntPtr window_handle) { if (critical_failure == false) { try { Uninitialize_Keyboard(); dinput = new DirectInput(); keyb = new Keyboard(dinput); keyb.SetCooperativeLevel(window_handle, CooperativeLevel.Background | CooperativeLevel.Nonexclusive); keyb.Acquire(); setup_keys(); } catch (Exception e) { System.Windows.Forms.MessageBox.Show(e.ToString(), "Error!", System.Windows.Forms.MessageBoxButtons.OK); return; } } }
public InputManager(IntPtr handle) { _devices = new List<InputDevice>(); var di = new DirectInput(); foreach (var device in di.GetDevices(DeviceClass.All, DeviceEnumerationFlags.AttachedOnly)) { if ((device.Type & DeviceType.Keyboard) == DeviceType.Keyboard) { var keyboard = new Keyboard(di); keyboard.SetCooperativeLevel(handle, CooperativeLevel.Nonexclusive | CooperativeLevel.Foreground); _devices.Add(new InputDevice(keyboard)); } else if ((device.Type & DeviceType.Joystick) == DeviceType.Joystick) { var joystick = new Joystick(di, device.InstanceGuid); joystick.SetCooperativeLevel(handle, CooperativeLevel.Nonexclusive | CooperativeLevel.Foreground); _devices.Add(new InputDevice(joystick)); } } }
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 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(); }
private void InitializeDevices() { var handle = WrenCore.WindowHandle; _joysticks = new List<Joystick>(); DirectInput di = new DirectInput(); foreach (var device in di.GetDevices(DeviceClass.All, DeviceEnumerationFlags.AttachedOnly)) { if ((device.Type & DeviceType.Keyboard) == DeviceType.Keyboard) { Keyboard keyboard = new Keyboard(di); keyboard.SetCooperativeLevel(handle, CooperativeLevel.Nonexclusive | CooperativeLevel.Foreground); _keyboard = keyboard; } else if ((device.Type & DeviceType.Joystick) == DeviceType.Joystick) { Joystick joystick = new Joystick(di, device.InstanceGuid); joystick.SetCooperativeLevel(handle, CooperativeLevel.Nonexclusive | CooperativeLevel.Foreground); _joysticks.Add(joystick); } } }
public void Uninitialize_Keyboard() { if (critical_failure == false) { if (dinput != null) { dinput.Dispose(); dinput = null; } if (keyb != null) { keyb.Dispose(); keyb = null; } } }
private void Initialize_Keyboard(IntPtr window_handle) { try { dinput = new DirectInput(); keyb = new Keyboard(dinput); keyb.SetCooperativeLevel(window_handle, CooperativeLevel.Background | CooperativeLevel.Nonexclusive); keyb.Acquire(); setup_keys(); } catch { System.Windows.Forms.MessageBox.Show("A failure has been detected during DirectInput initialization, please contact the author for assistance.", "Error!", System.Windows.Forms.MessageBoxButtons.OK); critical_failure = true; } }
public override void Stop() { // Don't leave any keys pressed for (int i = 0; i < MyKeyDown.Length; i++) { if (MyKeyDown[i]) KeyUp(i); } if (KeyboardDevice != null) { KeyboardDevice.Unacquire(); KeyboardDevice.Dispose(); KeyboardDevice = null; } if (DirectInputInstance != null) { DirectInputInstance.Dispose(); DirectInputInstance = null; } }
public override Action Start() { IntPtr handle = Process.GetCurrentProcess().MainWindowHandle; KeyboardDevice = new Keyboard(DirectInputInstance); if (KeyboardDevice == null) throw new Exception("Failed to create keyboard device"); KeyboardDevice.SetCooperativeLevel(handle, CooperativeLevel.Background | CooperativeLevel.Nonexclusive); KeyboardDevice.Acquire(); KeyboardDevice.GetCurrentState(ref KeyState); setKeyPressedStrategy = new SetPressedStrategy(KeyDown, KeyUp); getKeyPressedStrategy = new GetPressedStrategy<int>(IsKeyDown); OnStarted(this, new EventArgs()); return null; }
public static bool Send(Keyboard key) { uint ret; INPUT i = new INPUT(); i.type = (int)InputType.INPUT_KEYBOARD; i.mkhi.ki = new KEYBDINPUT(); i.mkhi.ki.dwExtraInfo = IntPtr.Zero; i.mkhi.ki.dwFlags = 0; i.mkhi.ki.time = 0; i.mkhi.ki.wScan = 0; i.mkhi.ki.wVk = (ushort)key; INPUT[] ia = new INPUT[1] { i }; ret = SendInput(1, ia, Marshal.SizeOf(i)); return ret == 1; }