Exemplo n.º 1
0
        static void KeyCallback(Glfw.Window window, Glfw.KeyCode key, int scancode, Glfw.InputState state, Glfw.KeyMods mods)
        {
            var    slot = m_Slots[window];
            string name = Glfw.GetKeyName(key, scancode);

            if (!string.IsNullOrEmpty(name))
            {
                Log("{0} to {1} at {2}: Key 0x{3} Scancode 0x{4} ({5}) ({6}) ({7}) was {8}",
                    m_Counter++, slot.Number, Glfw.GetTime(), (int)key, scancode,
                    GetKeyName(key),
                    name,
                    GetModsName(mods),
                    GetActioName(state));
            }
            else
            {
                Log("{0} to {1} at {2}: Key 0x{3} Scancode 0x{4} ({5}) ({6}) was {7}",
                    m_Counter++, slot.Number, Glfw.GetTime(), (int)key, scancode,
                    GetKeyName(key),
                    GetModsName(mods),
                    GetActioName(state));
            }

            if (state != Glfw.InputState.Press)
            {
                return;
            }

            switch (key)
            {
            case Glfw.KeyCode.C:
            {
                slot.Closeable = !slot.Closeable;

                Log("(( closing {0} ))", slot.Closeable ? "enabled" : "disabled");
                break;
            }

            default:
                break;
            }
        }
Exemplo n.º 2
0
 public static string Name(this Key key) => Glfw.GetKeyName((int) key, 0);