void ToggleKey(ref XKeyEvent keyEvent, bool pressed)
        {
            IntPtr keysym  = API.XLookupKeysym(ref keyEvent, 0);
            IntPtr keysym2 = API.XLookupKeysym(ref keyEvent, 1);

            if (keymap.ContainsKey((XKey)keysym))
            {
                keyboard[keymap[(XKey)keysym]] = pressed;
            }
            else if (keymap.ContainsKey((XKey)keysym2))
            {
                keyboard[keymap[(XKey)keysym2]] = pressed;
            }
            else
            {
                Debug.Print("KeyCode {0} (Keysym: {1}, {2}) not mapped.", e.KeyEvent.keycode, (XKey)keysym, (XKey)keysym2);
            }
        }
Beispiel #2
0
        internal bool TranslateKey(ref XKeyEvent e, out Key key)
        {
            XKey keysym  = (XKey)API.LookupKeysym(ref e, 0);
            XKey keysym2 = (XKey)API.LookupKeysym(ref e, 1);

            key = Key.Unknown;

            if (keymap.ContainsKey(keysym))
            {
                key = keymap[keysym];
            }
            else if (keymap.ContainsKey(keysym2))
            {
                key = keymap[keysym2];
            }
            else
            {
                Debug.Print("KeyCode {0} (Keysym: {1}, {2}) not mapped.", e.keycode, (XKey)keysym, (XKey)keysym2);
            }

            return(key != Key.Unknown);
        }
Beispiel #3
0
        internal void ProcessEvent(ref XEvent e)
        {
            switch (e.type)
            {
            case XEventName.KeyPress:
            case XEventName.KeyRelease:
                bool pressed = e.type == XEventName.KeyPress;

                IntPtr keysym  = API.LookupKeysym(ref e.KeyEvent, 0);
                IntPtr keysym2 = API.LookupKeysym(ref e.KeyEvent, 1);

                if (keymap.ContainsKey((XKey)keysym))
                {
                    keyboard[keymap[(XKey)keysym]] = pressed;
                }
                else if (keymap.ContainsKey((XKey)keysym2))
                {
                    keyboard[keymap[(XKey)keysym2]] = pressed;
                }
                else
                {
                    Debug.Print("KeyCode {0} (Keysym: {1}, {2}) not mapped.", e.KeyEvent.keycode, (XKey)keysym, (XKey)keysym2);
                }
                break;

            case XEventName.ButtonPress:
                if (e.ButtonEvent.button == 1)
                {
                    mouse[OpenTK.Input.MouseButton.Left] = true;
                }
                else if (e.ButtonEvent.button == 2)
                {
                    mouse[OpenTK.Input.MouseButton.Middle] = true;
                }
                else if (e.ButtonEvent.button == 3)
                {
                    mouse[OpenTK.Input.MouseButton.Right] = true;
                }
                else if (e.ButtonEvent.button == 4)
                {
                    mouse.Wheel++;
                }
                else if (e.ButtonEvent.button == 5)
                {
                    mouse.Wheel--;
                }
                else if (e.ButtonEvent.button == 6)
                {
                    mouse[OpenTK.Input.MouseButton.Button1] = true;
                }
                else if (e.ButtonEvent.button == 7)
                {
                    mouse[OpenTK.Input.MouseButton.Button2] = true;
                }
                else if (e.ButtonEvent.button == 8)
                {
                    mouse[OpenTK.Input.MouseButton.Button3] = true;
                }
                else if (e.ButtonEvent.button == 9)
                {
                    mouse[OpenTK.Input.MouseButton.Button4] = true;
                }
                else if (e.ButtonEvent.button == 10)
                {
                    mouse[OpenTK.Input.MouseButton.Button5] = true;
                }
                else if (e.ButtonEvent.button == 11)
                {
                    mouse[OpenTK.Input.MouseButton.Button6] = true;
                }
                else if (e.ButtonEvent.button == 12)
                {
                    mouse[OpenTK.Input.MouseButton.Button7] = true;
                }
                else if (e.ButtonEvent.button == 13)
                {
                    mouse[OpenTK.Input.MouseButton.Button8] = true;
                }
                else if (e.ButtonEvent.button == 14)
                {
                    mouse[OpenTK.Input.MouseButton.Button9] = true;
                }
                //if ((e.state & (int)X11.MouseMask.Button4Mask) != 0) m.Wheel++;
                //if ((e.state & (int)X11.MouseMask.Button5Mask) != 0) m.Wheel--;
                //Debug.Print("Button pressed: {0}", e.ButtonEvent.button);
                break;

            case XEventName.ButtonRelease:
                if (e.ButtonEvent.button == 1)
                {
                    mouse[OpenTK.Input.MouseButton.Left] = false;
                }
                else if (e.ButtonEvent.button == 2)
                {
                    mouse[OpenTK.Input.MouseButton.Middle] = false;
                }
                else if (e.ButtonEvent.button == 3)
                {
                    mouse[OpenTK.Input.MouseButton.Right] = false;
                }
                else if (e.ButtonEvent.button == 6)
                {
                    mouse[OpenTK.Input.MouseButton.Button1] = false;
                }
                else if (e.ButtonEvent.button == 7)
                {
                    mouse[OpenTK.Input.MouseButton.Button2] = false;
                }
                else if (e.ButtonEvent.button == 8)
                {
                    mouse[OpenTK.Input.MouseButton.Button3] = false;
                }
                else if (e.ButtonEvent.button == 9)
                {
                    mouse[OpenTK.Input.MouseButton.Button4] = false;
                }
                else if (e.ButtonEvent.button == 10)
                {
                    mouse[OpenTK.Input.MouseButton.Button5] = false;
                }
                else if (e.ButtonEvent.button == 11)
                {
                    mouse[OpenTK.Input.MouseButton.Button6] = false;
                }
                else if (e.ButtonEvent.button == 12)
                {
                    mouse[OpenTK.Input.MouseButton.Button7] = false;
                }
                else if (e.ButtonEvent.button == 13)
                {
                    mouse[OpenTK.Input.MouseButton.Button8] = false;
                }
                else if (e.ButtonEvent.button == 14)
                {
                    mouse[OpenTK.Input.MouseButton.Button9] = false;
                }
                break;

            case XEventName.MotionNotify:
                mouse.Position = new Point(e.MotionEvent.x, e.MotionEvent.y);
                break;
            }
        }