private static MouseState UpdateMouse(MouseState state, IntPtr val) { IntPtr element = HIDInput.NativeMethods.IOHIDValueGetElement(val); int num = HIDInput.NativeMethods.IOHIDValueGetIntegerValue(val).ToInt32(); HIDInput.HIDPage usagePage = HIDInput.NativeMethods.IOHIDElementGetUsagePage(element); int usage = HIDInput.NativeMethods.IOHIDElementGetUsage(element); switch (usagePage) { case HIDInput.HIDPage.GenericDesktop: switch ((HIDInput.HIDUsageGD)usage) { case HIDInput.HIDUsageGD.X: state.X += num; break; case HIDInput.HIDUsageGD.Y: state.Y += num; break; case HIDInput.HIDUsageGD.Wheel: state.WheelPrecise += (float)num; break; } case HIDInput.HIDPage.Button: state[(OpenTK.Input.MouseButton)(usage - 1)] = num == 1; break; } return(state); }
private static KeyboardState UpdateKeyboard(KeyboardState state, IntPtr val) { IntPtr element = HIDInput.NativeMethods.IOHIDValueGetElement(val); int num = HIDInput.NativeMethods.IOHIDValueGetIntegerValue(val).ToInt32(); HIDInput.HIDPage usagePage = HIDInput.NativeMethods.IOHIDElementGetUsagePage(element); int usage = HIDInput.NativeMethods.IOHIDElementGetUsage(element); switch (usagePage) { case HIDInput.HIDPage.GenericDesktop: case HIDInput.HIDPage.KeyboardOrKeypad: int index1 = usage; if (index1 >= HIDInput.RawKeyMap.Length || index1 < 0) { return(state); } Key index2 = HIDInput.RawKeyMap[index1]; state[index2] = num != 0; break; } return(state); }
public static bool IOHIDDeviceConformsTo(IntPtr inIOHIDDeviceRef, HIDInput.HIDPage inUsagePage, int inUsage);