internal override void HandleButtons(I2CUIDevice sender, ButtonMask buttons)
        {
            bool confirm = false;
            bool tickAllowed = Buttons == ConfirmationPromptButtons.Tick || Buttons == ConfirmationPromptButtons.TickAndCross;
            bool crossAllowed = Buttons == ConfirmationPromptButtons.Cross || Buttons == ConfirmationPromptButtons.TickAndCross;

            if ((buttons & ButtonMask.Button2) == ButtonMask.Button2 && crossAllowed)
            {
                confirm = false;
            }
            else if ((buttons & ButtonMask.Button5) == ButtonMask.Button5 && tickAllowed)
            {
                confirm = true;
            }
            else
            {
                return;
            }

            if (RespondToPrompt != null)
            {
                RespondToPrompt(this, confirm);
            }
            NotifyExit();
        }
예제 #2
0
 internal override void HandleButtons(I2CUIDevice sender, ButtonMask buttons)
 {
     if ((buttons & ButtonMask.Button1) == ButtonMask.Button1)
         HandleBackButton();
     else if ((buttons & ButtonMask.Button3) == ButtonMask.Button3)
         HandleUpButton();
     else if ((buttons & ButtonMask.Button4) == ButtonMask.Button4)
         HandleDownButton();
 }
예제 #3
0
        public static void InitializeMasks()
        {
            //these use to be listed out, but I changed the order
            //of the enumeration so that the enumeration matches the
            //way the buttons are actually mapped in the USB packet.
            for (int i = 0; i < 39; i++)
            {
                int offset = 2 + (int)((i) / 8);
                MaskList[i] = new ButtonMask(offset, 1 << (i % 8));
            }

            MaskList[(int)ButtonEnum.TunerDialStateChange] = new ButtonMask(24, 0x0F);
            MaskList[(int)ButtonEnum.GearLeverStateChange] = new ButtonMask(25, 0xFF);
        }
예제 #4
0
    static bool GetKey(Controller controller, ButtonMask key, string methodName)
    {
        CacheCheck();
        string keyName = methodName + key.ToString();

        switch (controller)
        {
        case Controller.Right:
            return(GetSafeTable(ref rightKeyTable, keyName));

        case Controller.Left:
            return(GetSafeTable(ref leftkeyTable, keyName));

        default:
            return(false);
        }
    }
예제 #5
0
    static bool GetKey(GameObject controller, ButtonMask key, string methodName)
    {
        CacheCheck();
        string keyName = methodName + key.ToString();

        switch (controller.name)
        {
        case rightControllerName:
            return(GetSafeTable(ref rightKeyTable, keyName));

        case leftControllerName:
            return(GetSafeTable(ref leftkeyTable, keyName));

        default:
            Debug.Log("ViveInput.GetKey(GameObject,ButtonMask,string) UnknownControllerName.不正な値です.");
            return(false);
        }
    }
예제 #6
0
 public static bool GetTouchUp(Controller controller, ButtonMask key)
 {
     return(GetKey(controller, key, MethodBase.GetCurrentMethod().Name));
 }
 internal override void HandleButtons(I2CUIDevice sender, ButtonMask buttons)
 {
     if ((buttons & ButtonMask.Button1) == ButtonMask.Button1)
         HandleBackButton();
 }
예제 #8
0
 internal virtual void HandleButtons(I2CUIDevice sender, ButtonMask buttons)
 {
 }
예제 #9
0
 public ButtonEventArgs(DeviceInfo dInfo, ButtonMask buttonMask)
 {
     m_deviceInfo = dInfo;
     m_buttonMask = buttonMask;
 }
예제 #10
0
 private void EnableBit(ButtonMask mask)
 {
     Report.Buttons = (byte)(Report.Buttons | (int)mask);
 }
예제 #11
0
        private void HandleButtons(I2CUIDevice sender, ButtonMask buttons)
        {
            if (CurrentInfoScreen != null) {
                CurrentInfoScreen.HandleButtons(sender, buttons);
                return;
            }

            if ((buttons & ButtonMask.Button1) == ButtonMask.Button1)
                HandleBackButton();
            else if ((buttons & ButtonMask.Button3) == ButtonMask.Button3)
                HandleUpButton();
            else if ((buttons & ButtonMask.Button4) == ButtonMask.Button4)
                HandleDownButton();
            else if ((buttons & ButtonMask.Button6) == ButtonMask.Button6)
                HandleSelectButton();
        }
예제 #12
0
 public ButtonEventArgs(DeviceInfo dInfo, ButtonMask buttonMask)
 {
     m_deviceInfo = dInfo;
     m_buttonMask = buttonMask;
 }
예제 #13
0
        /// <summary>
        /// Processes WM_INPUT messages to retrieve information about any
        /// keyboard events that occur.
        /// </summary>
        /// <param name="message">The WM_INPUT message to process.</param>
        public void ProcessInputCommand(Message message)
        {
            uint dwSize = 0;

            // First call to GetRawInputData sets the value of dwSize
            // dwSize can then be used to allocate the appropriate amount of memory,
            // storing the pointer in "buffer".
            GetRawInputData(message.LParam,
                             RID_HEADER, IntPtr.Zero,
                             ref dwSize,
                             (uint)Marshal.SizeOf(typeof(RAWINPUTHEADER)));

            var headerBuffer = Marshal.AllocHGlobal((int)dwSize);
            try
            {
                // Check that buffer points to something, and if so,
                // call GetRawInputData again to fill the allocated memory
                // with information about the input
                if (headerBuffer != IntPtr.Zero &&
                    GetRawInputData(message.LParam,
                                     RID_HEADER,
                                     headerBuffer,
                                     ref dwSize,
                                     (uint)Marshal.SizeOf(typeof(RAWINPUTHEADER))) == dwSize)
                {

                    var header = (RAWINPUTHEADER)Marshal.PtrToStructure(headerBuffer, typeof(RAWINPUTHEADER));
                    if (header.dwType == RIM_TYPEHID)
                    {
                        DeviceInfo dInfo = null;

                        if (deviceList.Contains(header.hDevice))
                        {
                            dInfo = (DeviceInfo)deviceList[header.hDevice];
                        }
                        else
                        {
                            // Device not in list.  Reenumerate all of them again.  Could warn the code with some sort of Connect/Disconnect event.
                            EnumerateDevices();
                            dInfo = (DeviceInfo)deviceList[header.hDevice];
                        }

                        // The header tells us the size of the actual event
                        var eventBuffer = Marshal.AllocHGlobal(header.dwSize);

                        var eventSize = (uint)header.dwSize;
                        if (eventBuffer != IntPtr.Zero &&
                            GetRawInputData(message.LParam,
                                            RID_INPUT,
                                            eventBuffer,
                                            ref eventSize,
                                            (uint)Marshal.SizeOf(typeof(RAWINPUTHEADER))) == header.dwSize)
                        {
                            var eventType = (RAW3DMOUSE_EVENTTYPE)Marshal.PtrToStructure(new IntPtr(eventBuffer.ToInt32() + Marshal.SizeOf(typeof(RAWINPUTHEADER))), typeof(RAW3DMOUSE_EVENTTYPE));
                            switch (eventType.eventType)
                            {
                                case (byte)RAW3DxMouseEventType.TranslationVector:
                                    if (header.dwSize == Marshal.SizeOf(typeof(RAWINPUTHEADER)) + SIZEOF_STANDARD_REPORT)  // standard length T report
                                    {
                                        var t = (RAW3DMOUSEMOTION_T)Marshal.PtrToStructure(new IntPtr(eventBuffer.ToInt32() + Marshal.SizeOf(typeof(RAWINPUTHEADER))), typeof(RAW3DMOUSEMOTION_T));
                                        var tv = new TranslationVector(t.X_lb, t.X_hb, t.Y_lb, t.Y_hb, t.Z_lb, t.Z_hb);
                                        // Console.Write("Motion Event = {0} {1} {2}", tv.X, tv.Y, tv.Z);
                                        MotionEvent(this, new MotionEventArgs(dInfo, tv));
                                    }
                                    else // "High Speed" firmware version includes both T and R vector in the same report
                                    {
                                        var tr = (RAW3DMOUSEMOTION_TR_COMBINED)Marshal.PtrToStructure(new IntPtr(eventBuffer.ToInt32() + Marshal.SizeOf(typeof(RAWINPUTHEADER))), typeof(RAW3DMOUSEMOTION_TR_COMBINED));
                                        var tv = new TranslationVector(tr.X_lb, tr.X_hb, tr.Y_lb, tr.Y_hb, tr.Z_lb, tr.Z_hb);
                                        var rv = new RotationVector(tr.RX_lb, tr.RX_hb, tr.RY_lb, tr.RY_hb, tr.RZ_lb, tr.RZ_hb);
                                        // Console.WriteLine("6DOF Motion Event = {0} {1} {2} {3} {4} {5}", tv.X, tv.Y, tv.Z, rv.X, rv.Y, rv.Z);
                                        MotionEvent(this, new MotionEventArgs(dInfo, tv, rv));
                                    }
                                    break;

                                case (byte)RAW3DxMouseEventType.RotationVector:
                                    {
                                        var r = (RAW3DMOUSEMOTION_R)Marshal.PtrToStructure(new IntPtr(eventBuffer.ToInt32() + Marshal.SizeOf(typeof(RAWINPUTHEADER))), typeof(RAW3DMOUSEMOTION_R));
                                        var rv = new RotationVector(r.X_lb, r.X_hb, r.Y_lb, r.Y_hb, r.Z_lb, r.Z_hb);
                                        // Console.WriteLine(" {0} {1} {2}", rv.X, rv.Y, rv.Z);
                                        MotionEvent(this, new MotionEventArgs(dInfo, rv));
                                    }
                                    break;

                                case (byte)RAW3DxMouseEventType.ButtonReport:
                                    var b = (RAW3DMOUSEBUTTONS)Marshal.PtrToStructure(new IntPtr(eventBuffer.ToInt32() + Marshal.SizeOf(typeof(RAWINPUTHEADER))), typeof(RAW3DMOUSEBUTTONS));
                                    var bm = new ButtonMask(b.b1, b.b2, b.b3, b.b4);
                                    Console.WriteLine("raw.buttons = {0:X}", bm.Pressed);
                                    ButtonEvent(this, new ButtonEventArgs(dInfo, bm));
                                    break;
                            }
                        }
                    }
                }
            }
            finally
            {
                Marshal.FreeHGlobal(headerBuffer);
            }
        }
예제 #14
0
 public bool GetNoloButtonUp(NoloButtonID button)
 {
     return(GetNoloButtonUp(ButtonMask.GetButtonMask(button)));
 }
예제 #15
0
 public bool GetNoloButtonPressed(NoloButtonID button)
 {
     return(GetNoloButtonPressed(ButtonMask.GetButtonMask(button)));
 }
예제 #16
0
 public static bool GetPressUp(GameObject controller, ButtonMask key)
 {
     return(GetKey(controller, key, MethodBase.GetCurrentMethod().Name));
 }
예제 #17
0
 static ulong ConvertKey(ButtonMask key)
 {
     return((ulong)buttonMaskTable[key]);
 }
예제 #18
0
 private void DisableBit(ButtonMask mask)
 {
     Report.Buttons = (byte)(Report.Buttons & ~(int)mask);
 }
예제 #19
0
        /// <summary>
        /// Processes WM_INPUT messages to retrieve information about any
        /// keyboard events that occur.
        /// </summary>
        /// <param name="message">The WM_INPUT message to process.</param>
        public void ProcessInputCommand(Message message)
        {
            uint dwSize = 0;

            // First call to GetRawInputData sets the value of dwSize
            // dwSize can then be used to allocate the appropriate amount of memory,
            // storing the pointer in "buffer".
            GetRawInputData(message.LParam,
                            RID_HEADER, IntPtr.Zero,
                            ref dwSize,
                            (uint)Marshal.SizeOf(typeof(RAWINPUTHEADER)));

            IntPtr headerBuffer = Marshal.AllocHGlobal((int)dwSize);

            try
            {
                // Check that buffer points to something, and if so,
                // call GetRawInputData again to fill the allocated memory
                // with information about the input
                if (headerBuffer != IntPtr.Zero &&
                    GetRawInputData(message.LParam,
                                    RID_HEADER,
                                    headerBuffer,
                                    ref dwSize,
                                    (uint)Marshal.SizeOf(typeof(RAWINPUTHEADER))) == dwSize)
                {
                    RAWINPUTHEADER header = (RAWINPUTHEADER)Marshal.PtrToStructure(headerBuffer, typeof(RAWINPUTHEADER));
                    if (header.dwType == RIM_TYPEHID)
                    {
                        DeviceInfo dInfo = null;

                        if (deviceList.Contains(header.hDevice))
                        {
                            dInfo = (DeviceInfo)deviceList[header.hDevice];
                        }
                        else
                        {
                            // Device not in list.  Reenumerate all of them again.  Could warn the code with some sort of Connect/Disconnect event.
                            EnumerateDevices();
                            dInfo = (DeviceInfo)deviceList[header.hDevice];
                        }

                        // The header tells us the size of the actual event
                        IntPtr eventBuffer = Marshal.AllocHGlobal(header.dwSize);

                        uint eventSize = (uint)header.dwSize;
                        if (eventBuffer != IntPtr.Zero &&
                            GetRawInputData(message.LParam,
                                            RID_INPUT,
                                            eventBuffer,
                                            ref eventSize,
                                            (uint)Marshal.SizeOf(typeof(RAWINPUTHEADER))) == header.dwSize)
                        {
                            RAW3DMOUSE_EVENTTYPE eventType = (RAW3DMOUSE_EVENTTYPE)Marshal.PtrToStructure(new IntPtr(eventBuffer.ToInt32() + Marshal.SizeOf(typeof(RAWINPUTHEADER))), typeof(RAW3DMOUSE_EVENTTYPE));
                            switch (eventType.eventType)
                            {
                            case (byte)RAW3DxMouseEventType.TranslationVector:
                                if (header.dwSize == Marshal.SizeOf(typeof(RAWINPUTHEADER)) + SIZEOF_STANDARD_REPORT)      // standard length T report
                                {
                                    RAW3DMOUSEMOTION_T t  = (RAW3DMOUSEMOTION_T)Marshal.PtrToStructure(new IntPtr(eventBuffer.ToInt32() + Marshal.SizeOf(typeof(RAWINPUTHEADER))), typeof(RAW3DMOUSEMOTION_T));
                                    TranslationVector  tv = new TranslationVector(t.X_lb, t.X_hb, t.Y_lb, t.Y_hb, t.Z_lb, t.Z_hb);
                                    // Console.Write("Motion Event = {0} {1} {2}", tv.X, tv.Y, tv.Z);
                                    MotionEvent(this, new MotionEventArgs(dInfo, tv));
                                }
                                else     // "High Speed" firmware version includes both T and R vector in the same report
                                {
                                    RAW3DMOUSEMOTION_TR_COMBINED tr = (RAW3DMOUSEMOTION_TR_COMBINED)Marshal.PtrToStructure(new IntPtr(eventBuffer.ToInt32() + Marshal.SizeOf(typeof(RAWINPUTHEADER))), typeof(RAW3DMOUSEMOTION_TR_COMBINED));
                                    TranslationVector            tv = new TranslationVector(tr.X_lb, tr.X_hb, tr.Y_lb, tr.Y_hb, tr.Z_lb, tr.Z_hb);
                                    RotationVector rv = new RotationVector(tr.RX_lb, tr.RX_hb, tr.RY_lb, tr.RY_hb, tr.RZ_lb, tr.RZ_hb);
                                    // Console.WriteLine("6DOF Motion Event = {0} {1} {2} {3} {4} {5}", tv.X, tv.Y, tv.Z, rv.X, rv.Y, rv.Z);
                                    MotionEvent(this, new MotionEventArgs(dInfo, tv, rv));
                                }
                                break;

                            case (byte)RAW3DxMouseEventType.RotationVector:
                            {
                                RAW3DMOUSEMOTION_R r  = (RAW3DMOUSEMOTION_R)Marshal.PtrToStructure(new IntPtr(eventBuffer.ToInt32() + Marshal.SizeOf(typeof(RAWINPUTHEADER))), typeof(RAW3DMOUSEMOTION_R));
                                RotationVector     rv = new RotationVector(r.X_lb, r.X_hb, r.Y_lb, r.Y_hb, r.Z_lb, r.Z_hb);
                                // Console.WriteLine(" {0} {1} {2}", rv.X, rv.Y, rv.Z);
                                MotionEvent(this, new MotionEventArgs(dInfo, rv));
                            }
                            break;

                            case (byte)RAW3DxMouseEventType.ButtonReport:
                                RAW3DMOUSEBUTTONS b  = (RAW3DMOUSEBUTTONS)Marshal.PtrToStructure(new IntPtr(eventBuffer.ToInt32() + Marshal.SizeOf(typeof(RAWINPUTHEADER))), typeof(RAW3DMOUSEBUTTONS));
                                ButtonMask        bm = new ButtonMask(b.b1, b.b2, b.b3, b.b4);
                                //Console.WriteLine("raw.buttons = {0:X}", bm.Pressed);
                                ButtonEvent(this, new ButtonEventArgs(dInfo, bm));
                                break;
                            }
                        }
                    }
                }
            }
            finally
            {
                Marshal.FreeHGlobal(headerBuffer);
            }
        }
예제 #20
0
 internal static void EnableBit(ButtonMask mask)
 {
     InkReport.Buttons = (byte)(InkReport.Buttons | (int)mask);
 }