/// <summary> /// Get key state. /// </summary> /// <param name="msg">Message.</param> /// <param name="k">Keyboard.</param> /// <returns>Key state.</returns> private static DeviceState GetDeviceState(uint msg, Keyboard k) { DeviceState state = new DeviceState(); Keys key = (Keys)k.VirtualKey; switch (msg) { case Event.KeyboardKeyDown: state.SetKeyTarget(DeviceEvent.KeyDown, key); break; case Event.KeyboardKeyUp: state.SetKeyTarget(DeviceEvent.KeyUp, key); break; case Event.KeyboardSystemKeyDown: state.SetKeyTarget(DeviceEvent.KeyDown, key); break; case Event.KeyboardSystemKeyUp: state.SetKeyTarget(DeviceEvent.KeyUp, key); break; } return(state); }
/// <summary> /// Get mouse state. /// </summary> /// <param name="msg">Message.</param> /// <param name="m">Mouse.</param> /// <returns>Mouse state.</returns> private static DeviceState GetDeviceState(uint msg, Mouse m) { DeviceState state = new DeviceState(); Keys key; switch (msg) { case Event.MouseMove: state.SetMouseTarget(DeviceEvent.MouseMove, Cursor.Position); break; case Event.MouseWheel: state.SetMouseTarget(DeviceEvent.MouseWheel, new Point(0, GetMousePoint(m.Data))); break; case Event.MouseTilt: state.SetMouseTarget(DeviceEvent.MouseTilt, new Point(GetMousePoint(m.Data), 0)); break; case Event.MouseLButtonDown: state.SetKeyTarget(DeviceEvent.KeyDown, Keys.LButton); break; case Event.MouseLButtonUp: state.SetKeyTarget(DeviceEvent.KeyUp, Keys.LButton); break; case Event.MouseRButtonDown: state.SetKeyTarget(DeviceEvent.KeyDown, Keys.RButton); break; case Event.MouseRButtonUp: state.SetKeyTarget(DeviceEvent.KeyUp, Keys.RButton); break; case Event.MouseMButtonDown: state.SetKeyTarget(DeviceEvent.KeyDown, Keys.MButton); break; case Event.MouseMButtonUp: state.SetKeyTarget(DeviceEvent.KeyUp, Keys.MButton); break; case Event.MouseXButtonDown: key = GetMouseXButton(m.Data); if (key != Keys.None) { state.SetKeyTarget(DeviceEvent.KeyDown, key); } break; case Event.MouseXButtonUp: key = GetMouseXButton(m.Data); if (key != Keys.None) { state.SetKeyTarget(DeviceEvent.KeyUp, key); } break; } return(state); }
public DeviceEventArgs(DeviceState state) { State = state; }
/// <summary> /// Invoke device event. /// </summary> /// <param name="state">Device state.</param> private void InvokeEvent(DeviceState state) { eventHandler(new DeviceEventArgs(state)); }
/// <summary> /// Dispatch device events. /// </summary> /// <param name="state">Device state.</param> /// <param name="oldState">Old device state.</param> public async void Dispatch(DeviceState state, DeviceState oldState) { await Task.Run(() => Listen(state, oldState)); }