Beispiel #1
0
        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);
        }
Beispiel #2
0
        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);
        }
Beispiel #3
0
 public static bool IOHIDDeviceConformsTo(IntPtr inIOHIDDeviceRef, HIDInput.HIDPage inUsagePage, int inUsage);