예제 #1
0
    /// <summary>
    /// Inject a Unity keyboard event into the WebView
    /// </summary>
    public void InjectKeyEvent(Event keyEvent)
    {
        UnityKeyEvent uevent = new UnityKeyEvent();

        uevent.Type      = keyEvent.type == EventType.KeyDown ? 1u : 0u;
        uevent.KeyCode   = (uint)keyEvent.keyCode;
        uevent.Character = (uint)keyEvent.character;

        // Do not forward newline
        if (uevent.Character == 10)
        {
            return;
        }

        // encode modifiers
        uevent.Modifiers = 0;

        if (keyEvent.command)
        {
            uevent.Modifiers |= (uint)UnityKeyModifiers.CommandWin;
        }

        if (keyEvent.alt)
        {
            uevent.Modifiers |= (uint)UnityKeyModifiers.Alt;
        }

        if (keyEvent.control)
        {
            uevent.Modifiers |= (uint)UnityKeyModifiers.Control;
        }

        if (keyEvent.shift)
        {
            uevent.Modifiers |= (uint)UnityKeyModifiers.Shift;
        }

        if (keyEvent.numeric)
        {
            uevent.Modifiers |= (uint)UnityKeyModifiers.Numeric;
        }

        if (keyEvent.functionKey)
        {
            uevent.Modifiers |= (uint)UnityKeyModifiers.FunctionKey;
        }

        if (keyEvent.capsLock)
        {
            uevent.Modifiers |= (uint)UnityKeyModifiers.CapsLock;
        }

        UWKPlugin.UWK_InjectKeyEvent(ID, ref uevent);
    }
예제 #2
0
    /// <summary>
    /// Process a Unity keyboard event
    /// </summary>
    public void ProcessKeyboard(Event keyEvent)
    {
        if (inputDisabled)
        {
            return;
        }

        UnityKeyEvent uevent = new UnityKeyEvent();

        uevent.Type      = keyEvent.type == EventType.KeyDown ? 1u : 0u;
        uevent.KeyCode   = (uint)keyEvent.keyCode;
        uevent.Character = (uint)keyEvent.character;

        // encode modifiers
        uevent.Modifiers = 0;

        if (keyEvent.command)
        {
            uevent.Modifiers |= (uint)UnityKeyModifiers.CommandWin;
        }

        if (keyEvent.alt)
        {
            uevent.Modifiers |= (uint)UnityKeyModifiers.Alt;
        }

        if (keyEvent.control)
        {
            uevent.Modifiers |= (uint)UnityKeyModifiers.Control;
        }

        if (keyEvent.shift)
        {
            uevent.Modifiers |= (uint)UnityKeyModifiers.Shift;
        }

        if (keyEvent.numeric)
        {
            uevent.Modifiers |= (uint)UnityKeyModifiers.Numeric;
        }

        if (keyEvent.functionKey)
        {
            uevent.Modifiers |= (uint)UnityKeyModifiers.FunctionKey;
        }

        if (keyEvent.capsLock)
        {
            uevent.Modifiers |= (uint)UnityKeyModifiers.CapsLock;
        }

        UWKPlugin.UWK_PostUnityKeyEvent(ID, ref uevent);
    }
예제 #3
0
    /// <summary>
    /// Process a Unity keyboard event
    /// </summary>
    public void ProcessKeyboard(Event keyEvent)
    {
        if (inputDisabled)
            return;

        UnityKeyEvent uevent = new UnityKeyEvent();

        uevent.Type = keyEvent.type == EventType.KeyDown ? 1u : 0u;
        uevent.KeyCode = (uint) keyEvent.keyCode;
        uevent.Character = (uint) keyEvent.character;

        if (uevent.Character == 10)
            return;

        // Fix mac deployment Unity key handling bug
        #if !UNITY_EDITOR
        #if UNITY_STANDALONE_OSX
        if (keyEvent.command && (keyEvent.keyCode == KeyCode.V || keyEvent.keyCode == KeyCode.A || keyEvent.keyCode == KeyCode.C))
        {
            if (keyEvent.type != EventType.KeyDown)
                return;

            uevent.Type = 1u;
            uevent.KeyCode = (uint) keyEvent.keyCode;
            uevent.Modifiers |= (uint) UnityKeyModifiers.CommandWin;

            if (keyEvent.keyCode == KeyCode.V)
                uevent.Character = (uint) 'v';
            if (keyEvent.keyCode == KeyCode.A)
                uevent.Character = (uint) 'a';
            if (keyEvent.keyCode == KeyCode.C)
                uevent.Character = (uint) 'c';

            UWKPlugin.UWK_PostUnityKeyEvent(ID, ref uevent);

            uevent.Type = 0u;
            UWKPlugin.UWK_PostUnityKeyEvent(ID, ref uevent);

            return;

        }
        #endif
        #endif

        // encode modifiers
        uevent.Modifiers = 0;

        if (keyEvent.command)
            uevent.Modifiers |= (uint) UnityKeyModifiers.CommandWin;

        if (keyEvent.alt)
            uevent.Modifiers |= (uint) UnityKeyModifiers.Alt;

        if (keyEvent.control)
            uevent.Modifiers |= (uint) UnityKeyModifiers.Control;

        if (keyEvent.shift)
            uevent.Modifiers |= (uint) UnityKeyModifiers.Shift;

        if (keyEvent.numeric)
            uevent.Modifiers |= (uint) UnityKeyModifiers.Numeric;

        if (keyEvent.functionKey)
            uevent.Modifiers |= (uint) UnityKeyModifiers.FunctionKey;

        if (keyEvent.capsLock)
            uevent.Modifiers |= (uint) UnityKeyModifiers.CapsLock;

        UWKPlugin.UWK_PostUnityKeyEvent(ID, ref uevent);
    }
예제 #4
0
    /// <summary>
    /// Process a Unity keyboard event
    /// </summary>
    public void ProcessKeyboard(Event keyEvent)
    {
        if (inputDisabled)
        {
            return;
        }

        UnityKeyEvent uevent = new UnityKeyEvent();

        uevent.Type      = keyEvent.type == EventType.KeyDown ? 1u : 0u;
        uevent.KeyCode   = (uint)keyEvent.keyCode;
        uevent.Character = (uint)keyEvent.character;

// Fix mac deployment Unity key handling bug
#if !UNITY_EDITOR
#if UNITY_STANDALONE_OSX
        if (keyEvent.command && (keyEvent.keyCode == KeyCode.V || keyEvent.keyCode == KeyCode.A || keyEvent.keyCode == KeyCode.C))
        {
            if (keyEvent.type != EventType.KeyDown)
            {
                return;
            }

            uevent.Type       = 1u;
            uevent.KeyCode    = (uint)keyEvent.keyCode;
            uevent.Modifiers |= (uint)UnityKeyModifiers.CommandWin;

            if (keyEvent.keyCode == KeyCode.V)
            {
                uevent.Character = (uint)'v';
            }
            if (keyEvent.keyCode == KeyCode.A)
            {
                uevent.Character = (uint)'a';
            }
            if (keyEvent.keyCode == KeyCode.C)
            {
                uevent.Character = (uint)'c';
            }


            UWKPlugin.UWK_PostUnityKeyEvent(ID, ref uevent);

            uevent.Type = 0u;
            UWKPlugin.UWK_PostUnityKeyEvent(ID, ref uevent);

            return;
        }
#endif
#endif

        // encode modifiers
        uevent.Modifiers = 0;

        if (keyEvent.command)
        {
            uevent.Modifiers |= (uint)UnityKeyModifiers.CommandWin;
        }

        if (keyEvent.alt)
        {
            uevent.Modifiers |= (uint)UnityKeyModifiers.Alt;
        }

        if (keyEvent.control)
        {
            uevent.Modifiers |= (uint)UnityKeyModifiers.Control;
        }

        if (keyEvent.shift)
        {
            uevent.Modifiers |= (uint)UnityKeyModifiers.Shift;
        }

        if (keyEvent.numeric)
        {
            uevent.Modifiers |= (uint)UnityKeyModifiers.Numeric;
        }

        if (keyEvent.functionKey)
        {
            uevent.Modifiers |= (uint)UnityKeyModifiers.FunctionKey;
        }

        if (keyEvent.capsLock)
        {
            uevent.Modifiers |= (uint)UnityKeyModifiers.CapsLock;
        }

        UWKPlugin.UWK_PostUnityKeyEvent(ID, ref uevent);
    }
예제 #5
0
    /// <summary>
    /// Process a Unity keyboard event
    /// </summary>
    public void ProcessKeyboard(Event keyEvent)
    {
        if (inputDisabled)
            return;

        UnityKeyEvent uevent = new UnityKeyEvent();

        uevent.Type = keyEvent.type == EventType.KeyDown ? 1u : 0u;
        uevent.KeyCode = (uint) keyEvent.keyCode;
        uevent.Character = (uint) keyEvent.character;

        // encode modifiers
        uevent.Modifiers = 0;

        if (keyEvent.command)
            uevent.Modifiers |= (uint) UnityKeyModifiers.CommandWin;

        if (keyEvent.alt)
            uevent.Modifiers |= (uint) UnityKeyModifiers.Alt;

        if (keyEvent.control)
            uevent.Modifiers |= (uint) UnityKeyModifiers.Control;

        if (keyEvent.shift)
            uevent.Modifiers |= (uint) UnityKeyModifiers.Shift;

        if (keyEvent.numeric)
            uevent.Modifiers |= (uint) UnityKeyModifiers.Numeric;

        if (keyEvent.functionKey)
            uevent.Modifiers |= (uint) UnityKeyModifiers.FunctionKey;

        if (keyEvent.capsLock)
            uevent.Modifiers |= (uint) UnityKeyModifiers.CapsLock;

        UWKPlugin.UWK_PostUnityKeyEvent(ID, ref uevent);
    }
예제 #6
0
 public static extern uint UWK_PostUnityKeyEvent(uint browserID, ref UnityKeyEvent keyEvent);
예제 #7
0
 public static extern uint UWK_PostUnityKeyEvent(uint browserID, ref UnityKeyEvent keyEvent);