Example #1
0
        void KeyShiftingPress(Local local, KeyInfo key)
        {
            switch (key.scan_code)
            {
            case SCAN_BACKSPACE:
            case SCAN_TAB:
            case SCAN_ENTER:
            case SCAN_ESC:
            case SCAN_ALTGR:
                return;

            default:
                if (keys_displayed < 2)
                {
                    key.current_text    = key.texts[1];
                    shifting_single_key = key;
                }

                if (key.current_text == "")        /* typical if keys_displayed == 2 */
                {
                    return;
                }

                KeyCombine(local, key.current_text, replacement: true);
                break;
            }
            key.SetBlink(0.15f);
            local.ctrl.HapticPulse(900);
        }
Example #2
0
        void KeyTouch(Local local, KeyInfo key, bool shift)
        {
            if (keys_displayed < 2)
            {
                key.current_text = key.texts[shift ? 1 : 0];
            }

            if (key.current_text == "")    /* occurs if keys_displayed == 2 */
            {
                return;
            }

            key.SetBlink(0.2f);

            switch (key.scan_code)
            {
            case SCAN_BACKSPACE: SpecialKey(EKeyState.Special_Backspace, ""); break;

            case SCAN_TAB: SpecialKey(EKeyState.Special_Tab, key.scan_code_extra.ToString()); break;

            case SCAN_ENTER: SpecialKey(EKeyState.Special_Enter, key.scan_code_extra.ToString()); break;

            case SCAN_ESC: SpecialKey(EKeyState.Special_Esc, ""); break;

            case SCAN_ALTGR:
                return;         /* no haptic pulse */

            default:
                KeyCombine(local, key.current_text, replacement: false);
                break;
            }
            local.ctrl.HapticPulse(500);
        }
Example #3
0
        protected virtual void OnControllersUpdate(Controller[] controllers)
        {
            foreach (var local in locals)
            {
                KeyInfo key = FindKey(local.ctrl.position);
                if (key != null)
                {
                    key.SetBlink(0.91f);
                }

                if (!TouchpadTouched(local.ctrl))
                {
                    /* Touchpad is not touched.  Confirm the key and cancel all other state */
                    ConfirmKeyLocal(local);
                    local.touchpad_down = 0;
                    local.shift_outside = false;
                    if (local.dead_key_touchpad_not_released)
                    {
                        local.dead_key_touchpad_not_released = false;
                    }
                    if (local.altgr_touched != null)
                    {
                        local.altgr_touched = null;
                        local.ctrl.GrabHover(false);
                    }
                    continue;
                }

                /* Touchpad is touched. */
                switch (local.touchpad_down)
                {
                case 0:        /* touchpad was not touched previously */
                    local.just_touched = null;
                    if (key != null)
                    {
                        if (key.scan_code == SCAN_ALTGR)
                        {
                            local.altgr_touched = key;
                            local.ctrl.GrabHover(true);
                        }
                        else
                        {
                            local.just_touched = key;
                        }

                        KeyTouch(local, key, shift: keys_displayed == 1);
                    }
                    else
                    {
                        /* only if pressing far enough from any key */
                        const float d = 9f;
                        if (FindKey(local.ctrl.position, +d, +d) == null &&
                            FindKey(local.ctrl.position, +d, -d) == null &&
                            FindKey(local.ctrl.position, -d, +d) == null &&
                            FindKey(local.ctrl.position, -d, -d) == null)
                        {
                            local.shift_outside = true;
                        }
                    }
                    local.touchpad_down = 1;
                    break;

                case 1:        /* touchpad was already touched (but not pressed) previously */
                    if (local.just_touched != key)
                    {
                        /* moving the controller away from the 'just_touched' key: confirm the key, if
                         * it was touched by this controller */
                        local.just_touched = null;
                        ConfirmKeyLocal(local);
                    }
                    if (TouchpadPressed(local.ctrl))
                    {
                        if (key != null)
                        {
                            if (local.just_touched == key)
                            {
                                KeyShiftingPress(local, key);
                            }
                            else
                            {
                                KeyTouch(local, key, shift: !(dead_key_status == 1 && local.dead_key_touchpad_not_released));
                            }
                            ConfirmKeyLocal(local);
                        }
                        local.touchpad_down = 2;
                    }
                    break;

                case 2:         /* touchpad was pressed previously */
                    if (!TouchpadPressed(local.ctrl))
                    {
                        local.just_touched  = null;
                        local.touchpad_down = 1;
                    }
                    break;
                }
            }

            UpdateAltGr();
        }