Ejemplo n.º 1
0
        public static bool ProcessShiftKey(CoherentUIGTKeyEventData eventData, bool shiftPressed)
        {
            if (shiftPressed != s_WasShiftPressed ||
                (shiftPressed && Time.unscaledTime > s_LastShiftEventTime + KEY_REPEAT_RATE))
            {
                if (shiftPressed)
                {
                    eventData.Type = KeyEventData.EventType.KeyDown;
                }
                else
                {
                    eventData.Type = KeyEventData.EventType.KeyUp;
                }

                s_LastShiftEventTime = Time.unscaledTime;

                if (shiftPressed != s_WasShiftPressed)
                {
                    s_LastShiftEventTime += KEY_REPEAT_DELAY;
                }

                eventData.KeyCode = 16;
                eventData.Modifiers.IsShiftDown = shiftPressed;
                s_WasShiftPressed = shiftPressed;

                return(true);
            }

            return(false);
        }
Ejemplo n.º 2
0
        public static void ProcessKeyEvent(CoherentUIGTKeyEventData eventData, Event evt)
        {
            if (evt.type == EventType.KeyDown)
            {
                eventData.Type = KeyEventData.EventType.KeyDown;
            }
            else if (evt.type == EventType.KeyUp)
            {
                eventData.Type = KeyEventData.EventType.KeyUp;
            }
            else
            {
                eventData.Type = KeyEventData.EventType.Unknown;
                return;
            }

            s_LastShiftEventTime = float.PositiveInfinity;

            GetEventModifiersState(eventData.Modifiers, evt);
            eventData.IsNumPad     = evt.numeric;
            eventData.IsAutoRepeat = false;             // Indeterminate
            eventData.IsSystemKey  = evt.alt && !Input.GetKey(KeyCode.AltGr);

            //TODO: Send Enter as Down->Char->Up

            if (evt.keyCode != KeyCode.Escape &&
                evt.keyCode != KeyCode.Tab &&
                evt.character != 0)
            {
                eventData.Type    = KeyEventData.EventType.Char;
                eventData.KeyCode = (int)evt.character;

                //Unity3D reports Return character as NewLine and we want CarrageReturn
                if (evt.character == 10)
                {
                    eventData.KeyCode = 13;
                }
            }
            else
            {
                eventData.KeyCode = s_KeyCodeMapping[(int)evt.keyCode];
            }

            if (eventData.KeyCode == 0)
            {
                eventData.Type = KeyEventData.EventType.Unknown;
            }
        }