internal void EnqueueContact(MouseContact contact) { lock (contactsQueue) { contactsQueue.Enqueue((MouseContact)contact.Clone()); } }
internal void EnqueueContact(MouseContact contact) { lock (contactsQueue) { //Trace.WriteLine(contact.Position.ToString()); contactsQueue.Enqueue((MouseContact)contact.Clone()); } }
void RawDevice_RawInput(object sender, RawInputEventArgs e) { if (devices.Contains(e.Handle)) { DeviceStatus state = devices[e.Handle]; MouseData mouseData = e.GetRawData() as MouseData; if (mouseData != null) { UpdateMouse(mouseData, state); } else { DeviceData deviceData = e.GetRawData() as DeviceData; if (deviceData != null) { UpdatePen(deviceData, state); } } if (state.ButtonState == DeviceState.None) { return; } MouseContact contact = null; if (state.ButtonState == DeviceState.Down) { contact = new MouseContact(state); //Debug.WriteLine("Down: " + contact); contacts.Add(contact); } else if ((state.ButtonState == DeviceState.Move || state.ButtonState == DeviceState.Up) && contacts.Contains(e.Handle)) { contact = contacts[e.Handle]; //Debug.WriteLine("Move: " + contact); contact.Update(state); } if (contact != null) { inputProvider.EnqueueContact(contact); } if (state.ButtonState == DeviceState.Up) { contact = contacts[e.Handle]; contact.Update(state); //Debug.WriteLine("Up: " + contact); contacts.Remove(e.Handle); } } }
public MouseContact(MouseContact clone) : base(clone.Id, clone.State, clone.Position, clone.MajorAxis, clone.MinorAxis) { Handle = clone.Handle; Orientation = clone.Orientation; }
void RawDevice_RawInput(object sender, RawInputEventArgs e) { if (devices.Contains(e.Handle)) { DeviceStatus state = devices[e.Handle]; MouseData mouseData = e.GetRawData() as MouseData; if (mouseData != null) UpdateMouse(mouseData, state); else { DeviceData deviceData = e.GetRawData() as DeviceData; if (deviceData != null) UpdatePen(deviceData, state); } if(state.ButtonState == DeviceState.None) return; MouseContact contact = null; if (state.ButtonState == DeviceState.Down) { contact = new MouseContact(state); //Debug.WriteLine("Down: " + contact); contacts.Add(contact); } else if ((state.ButtonState == DeviceState.Move || state.ButtonState == DeviceState.Up) && contacts.Contains(e.Handle)) { contact = contacts[e.Handle]; //Debug.WriteLine("Move: " + contact); contact.Update(state); } if (contact != null) inputProvider.EnqueueContact(contact); if (state.ButtonState == DeviceState.Up) { contact = contacts[e.Handle]; contact.Update(state); //Debug.WriteLine("Up: " + contact); contacts.Remove(e.Handle); } } }