#ifndef TWN_CONTROL_H
#define TWN_CONTROL_H

/*
  Simple DirectMedia Layer
  Copyright (C) 1997-2024 Sam Lantinga <slouken@libsdl.org>

  This software is provided 'as-is', without any express or implied
  warranty.  In no event will the authors be held liable for any damages
  arising from the use of this software.

  Permission is granted to anyone to use this software for any purpose,
  including commercial applications, and to alter it and redistribute it
  freely, subject to the following restrictions:

  1. The origin of this software must not be misrepresented; you must not
     claim that you wrote the original software. If you use this software
     in a product, an acknowledgment in the product documentation would be
     appreciated but is not required.
  2. Altered source versions must be plainly marked as such, and must not be
     misrepresented as being the original software.
  3. This notice may not be removed or altered from any source distribution.
*/

/* based on SDL2 */
/* main difference is that we combine mouse and scancode sources into one enum space */

typedef enum
{
CONTROL_SCANCODE_START = 0,
    CONTROL_UNKNOWN = 0,

    /**
     *  \name Usage page 0x07
     *
     *  These values are from usage page 0x07 (USB keyboard page).
     */
    /* @{ */

    CONTROL_A = 4,
    CONTROL_B = 5,
    CONTROL_C = 6,
    CONTROL_D = 7,
    CONTROL_E = 8,
    CONTROL_F = 9,
    CONTROL_G = 10,
    CONTROL_H = 11,
    CONTROL_I = 12,
    CONTROL_J = 13,
    CONTROL_K = 14,
    CONTROL_L = 15,
    CONTROL_M = 16,
    CONTROL_N = 17,
    CONTROL_O = 18,
    CONTROL_P = 19,
    CONTROL_Q = 20,
    CONTROL_R = 21,
    CONTROL_S = 22,
    CONTROL_T = 23,
    CONTROL_U = 24,
    CONTROL_V = 25,
    CONTROL_W = 26,
    CONTROL_X = 27,
    CONTROL_Y = 28,
    CONTROL_Z = 29,

    CONTROL_1 = 30,
    CONTROL_2 = 31,
    CONTROL_3 = 32,
    CONTROL_4 = 33,
    CONTROL_5 = 34,
    CONTROL_6 = 35,
    CONTROL_7 = 36,
    CONTROL_8 = 37,
    CONTROL_9 = 38,
    CONTROL_0 = 39,

    CONTROL_RETURN = 40,
    CONTROL_ESCAPE = 41,
    CONTROL_BACKSPACE = 42,
    CONTROL_TAB = 43,
    CONTROL_SPACE = 44,

    CONTROL_MINUS = 45,
    CONTROL_EQUALS = 46,
    CONTROL_LEFTBRACKET = 47,
    CONTROL_RIGHTBRACKET = 48,
    CONTROL_BACKSLASH = 49, /**< Located at the lower left of the return
                                  *   key on ISO keyboards and at the right end
                                  *   of the QWERTY row on ANSI keyboards.
                                  *   Produces REVERSE SOLIDUS (backslash) and
                                  *   VERTICAL LINE in a US layout, REVERSE
                                  *   SOLIDUS and VERTICAL LINE in a UK Mac
                                  *   layout, NUMBER SIGN and TILDE in a UK
                                  *   Windows layout, DOLLAR SIGN and POUND SIGN
                                  *   in a Swiss German layout, NUMBER SIGN and
                                  *   APOSTROPHE in a German layout, GRAVE
                                  *   ACCENT and POUND SIGN in a French Mac
                                  *   layout, and ASTERISK and MICRO SIGN in a
                                  *   French Windows layout.
                                  */
    CONTROL_NONUSHASH = 50, /**< ISO USB keyboards actually use this code
                                  *   instead of 49 for the same key, but all
                                  *   OSes I've seen treat the two codes
                                  *   identically. So, as an implementor, unless
                                  *   your keyboard generates both of those
                                  *   codes and your OS treats them differently,
                                  *   you should generate CONTROL_BACKSLASH
                                  *   instead of this code. As a user, you
                                  *   should not rely on this code because SDL
                                  *   will never generate it with most (all?)
                                  *   keyboards.
                                  */
    CONTROL_SEMICOLON = 51,
    CONTROL_APOSTROPHE = 52,
    CONTROL_GRAVE = 53, /**< Located in the top left corner (on both ANSI
                              *   and ISO keyboards). Produces GRAVE ACCENT and
                              *   TILDE in a US Windows layout and in US and UK
                              *   Mac layouts on ANSI keyboards, GRAVE ACCENT
                              *   and NOT SIGN in a UK Windows layout, SECTION
                              *   SIGN and PLUS-MINUS SIGN in US and UK Mac
                              *   layouts on ISO keyboards, SECTION SIGN and
                              *   DEGREE SIGN in a Swiss German layout (Mac:
                              *   only on ISO keyboards), CIRCUMFLEX ACCENT and
                              *   DEGREE SIGN in a German layout (Mac: only on
                              *   ISO keyboards), SUPERSCRIPT TWO and TILDE in a
                              *   French Windows layout, COMMERCIAL AT and
                              *   NUMBER SIGN in a French Mac layout on ISO
                              *   keyboards, and LESS-THAN SIGN and GREATER-THAN
                              *   SIGN in a Swiss German, German, or French Mac
                              *   layout on ANSI keyboards.
                              */
    CONTROL_COMMA = 54,
    CONTROL_PERIOD = 55,
    CONTROL_SLASH = 56,

    CONTROL_CAPSLOCK = 57,

    CONTROL_F1 = 58,
    CONTROL_F2 = 59,
    CONTROL_F3 = 60,
    CONTROL_F4 = 61,
    CONTROL_F5 = 62,
    CONTROL_F6 = 63,
    CONTROL_F7 = 64,
    CONTROL_F8 = 65,
    CONTROL_F9 = 66,
    CONTROL_F10 = 67,
    CONTROL_F11 = 68,
    CONTROL_F12 = 69,

    CONTROL_PRINTSCREEN = 70,
    CONTROL_SCROLLLOCK = 71,
    CONTROL_PAUSE = 72,
    CONTROL_INSERT = 73, /**< insert on PC, help on some Mac keyboards (but
                                   does send code 73, not 117) */
    CONTROL_HOME = 74,
    CONTROL_PAGEUP = 75,
    CONTROL_DELETE = 76,
    CONTROL_END = 77,
    CONTROL_PAGEDOWN = 78,
    CONTROL_RIGHT = 79,
    CONTROL_LEFT = 80,
    CONTROL_DOWN = 81,
    CONTROL_UP = 82,

    CONTROL_NUMLOCKCLEAR = 83, /**< num lock on PC, clear on Mac keyboards
                                     */
    CONTROL_KP_DIVIDE = 84,
    CONTROL_KP_MULTIPLY = 85,
    CONTROL_KP_MINUS = 86,
    CONTROL_KP_PLUS = 87,
    CONTROL_KP_ENTER = 88,
    CONTROL_KP_1 = 89,
    CONTROL_KP_2 = 90,
    CONTROL_KP_3 = 91,
    CONTROL_KP_4 = 92,
    CONTROL_KP_5 = 93,
    CONTROL_KP_6 = 94,
    CONTROL_KP_7 = 95,
    CONTROL_KP_8 = 96,
    CONTROL_KP_9 = 97,
    CONTROL_KP_0 = 98,
    CONTROL_KP_PERIOD = 99,

    CONTROL_NONUSBACKSLASH = 100, /**< This is the additional key that ISO
                                        *   keyboards have over ANSI ones,
                                        *   located between left shift and Y.
                                        *   Produces GRAVE ACCENT and TILDE in a
                                        *   US or UK Mac layout, REVERSE SOLIDUS
                                        *   (backslash) and VERTICAL LINE in a
                                        *   US or UK Windows layout, and
                                        *   LESS-THAN SIGN and GREATER-THAN SIGN
                                        *   in a Swiss German, German, or French
                                        *   layout. */
    CONTROL_APPLICATION = 101, /**< windows contextual menu, compose */
    CONTROL_POWER = 102, /**< The USB document says this is a status flag,
                               *   not a physical key - but some Mac keyboards
                               *   do have a power key. */
    CONTROL_KP_EQUALS = 103,
    CONTROL_F13 = 104,
    CONTROL_F14 = 105,
    CONTROL_F15 = 106,
    CONTROL_F16 = 107,
    CONTROL_F17 = 108,
    CONTROL_F18 = 109,
    CONTROL_F19 = 110,
    CONTROL_F20 = 111,
    CONTROL_F21 = 112,
    CONTROL_F22 = 113,
    CONTROL_F23 = 114,
    CONTROL_F24 = 115,
    CONTROL_EXECUTE = 116,
    CONTROL_HELP = 117,    /**< AL Integrated Help Center */
    CONTROL_MENU = 118,    /**< Menu (show menu) */
    CONTROL_SELECT = 119,
    CONTROL_STOP = 120,    /**< AC Stop */
    CONTROL_AGAIN = 121,   /**< AC Redo/Repeat */
    CONTROL_UNDO = 122,    /**< AC Undo */
    CONTROL_CUT = 123,     /**< AC Cut */
    CONTROL_COPY = 124,    /**< AC Copy */
    CONTROL_PASTE = 125,   /**< AC Paste */
    CONTROL_FIND = 126,    /**< AC Find */
    CONTROL_MUTE = 127,
    CONTROL_VOLUMEUP = 128,
    CONTROL_VOLUMEDOWN = 129,
/* not sure whether there's a reason to enable these */
/*     CONTROL_LOCKINGCAPSLOCK = 130,  */
/*     CONTROL_LOCKINGNUMLOCK = 131, */
/*     CONTROL_LOCKINGSCROLLLOCK = 132, */
    CONTROL_KP_COMMA = 133,
    CONTROL_KP_EQUALSAS400 = 134,

    CONTROL_INTERNATIONAL1 = 135, /**< used on Asian keyboards, see
                                            footnotes in USB doc */
    CONTROL_INTERNATIONAL2 = 136,
    CONTROL_INTERNATIONAL3 = 137, /**< Yen */
    CONTROL_INTERNATIONAL4 = 138,
    CONTROL_INTERNATIONAL5 = 139,
    CONTROL_INTERNATIONAL6 = 140,
    CONTROL_INTERNATIONAL7 = 141,
    CONTROL_INTERNATIONAL8 = 142,
    CONTROL_INTERNATIONAL9 = 143,
    CONTROL_LANG1 = 144, /**< Hangul/English toggle */
    CONTROL_LANG2 = 145, /**< Hanja conversion */
    CONTROL_LANG3 = 146, /**< Katakana */
    CONTROL_LANG4 = 147, /**< Hiragana */
    CONTROL_LANG5 = 148, /**< Zenkaku/Hankaku */
    CONTROL_LANG6 = 149, /**< reserved */
    CONTROL_LANG7 = 150, /**< reserved */
    CONTROL_LANG8 = 151, /**< reserved */
    CONTROL_LANG9 = 152, /**< reserved */

    CONTROL_ALTERASE = 153,    /**< Erase-Eaze */
    CONTROL_SYSREQ = 154,
    CONTROL_CANCEL = 155,      /**< AC Cancel */
    CONTROL_CLEAR = 156,
    CONTROL_PRIOR = 157,
    CONTROL_RETURN2 = 158,
    CONTROL_SEPARATOR = 159,
    CONTROL_OUT = 160,
    CONTROL_OPER = 161,
    CONTROL_CLEARAGAIN = 162,
    CONTROL_CRSEL = 163,
    CONTROL_EXSEL = 164,

    CONTROL_KP_00 = 176,
    CONTROL_KP_000 = 177,
    CONTROL_THOUSANDSSEPARATOR = 178,
    CONTROL_DECIMALSEPARATOR = 179,
    CONTROL_CURRENCYUNIT = 180,
    CONTROL_CURRENCYSUBUNIT = 181,
    CONTROL_KP_LEFTPAREN = 182,
    CONTROL_KP_RIGHTPAREN = 183,
    CONTROL_KP_LEFTBRACE = 184,
    CONTROL_KP_RIGHTBRACE = 185,
    CONTROL_KP_TAB = 186,
    CONTROL_KP_BACKSPACE = 187,
    CONTROL_KP_A = 188,
    CONTROL_KP_B = 189,
    CONTROL_KP_C = 190,
    CONTROL_KP_D = 191,
    CONTROL_KP_E = 192,
    CONTROL_KP_F = 193,
    CONTROL_KP_XOR = 194,
    CONTROL_KP_POWER = 195,
    CONTROL_KP_PERCENT = 196,
    CONTROL_KP_LESS = 197,
    CONTROL_KP_GREATER = 198,
    CONTROL_KP_AMPERSAND = 199,
    CONTROL_KP_DBLAMPERSAND = 200,
    CONTROL_KP_VERTICALBAR = 201,
    CONTROL_KP_DBLVERTICALBAR = 202,
    CONTROL_KP_COLON = 203,
    CONTROL_KP_HASH = 204,
    CONTROL_KP_SPACE = 205,
    CONTROL_KP_AT = 206,
    CONTROL_KP_EXCLAM = 207,
    CONTROL_KP_MEMSTORE = 208,
    CONTROL_KP_MEMRECALL = 209,
    CONTROL_KP_MEMCLEAR = 210,
    CONTROL_KP_MEMADD = 211,
    CONTROL_KP_MEMSUBTRACT = 212,
    CONTROL_KP_MEMMULTIPLY = 213,
    CONTROL_KP_MEMDIVIDE = 214,
    CONTROL_KP_PLUSMINUS = 215,
    CONTROL_KP_CLEAR = 216,
    CONTROL_KP_CLEARENTRY = 217,
    CONTROL_KP_BINARY = 218,
    CONTROL_KP_OCTAL = 219,
    CONTROL_KP_DECIMAL = 220,
    CONTROL_KP_HEXADECIMAL = 221,

    CONTROL_LCTRL = 224,
    CONTROL_LSHIFT = 225,
    CONTROL_LALT = 226, /**< alt, option */
    CONTROL_LGUI = 227, /**< windows, command (apple), meta */
    CONTROL_RCTRL = 228,
    CONTROL_RSHIFT = 229,
    CONTROL_RALT = 230, /**< alt gr, option */
    CONTROL_RGUI = 231, /**< windows, command (apple), meta */

    CONTROL_MODE = 257,    /**< I'm not sure if this is really not covered
                                 *   by any of the above, but since there's a
                                 *   special KMOD_MODE for it I'm adding it here
                                 */

    /* @} *//* Usage page 0x07 */

    /**
     *  \name Usage page 0x0C
     *
     *  These values are mapped from usage page 0x0C (USB consumer page).
     *  See https://usb.org/sites/default/files/hut1_2.pdf
     *
     *  There are way more keys in the spec than we can represent in the
     *  current scancode range, so pick the ones that commonly come up in
     *  real world usage.
     */
    /* @{ */

    CONTROL_AUDIONEXT = 258,
    CONTROL_AUDIOPREV = 259,
    CONTROL_AUDIOSTOP = 260,
    CONTROL_AUDIOPLAY = 261,
    CONTROL_AUDIOMUTE = 262,
    CONTROL_MEDIASELECT = 263,
    CONTROL_WWW = 264,             /**< AL Internet Browser */
    CONTROL_MAIL = 265,
    CONTROL_CALCULATOR = 266,      /**< AL Calculator */
    CONTROL_COMPUTER = 267,
    CONTROL_AC_SEARCH = 268,       /**< AC Search */
    CONTROL_AC_HOME = 269,         /**< AC Home */
    CONTROL_AC_BACK = 270,         /**< AC Back */
    CONTROL_AC_FORWARD = 271,      /**< AC Forward */
    CONTROL_AC_STOP = 272,         /**< AC Stop */
    CONTROL_AC_REFRESH = 273,      /**< AC Refresh */
    CONTROL_AC_BOOKMARKS = 274,    /**< AC Bookmarks */

    /* @} *//* Usage page 0x0C */

    /**
     *  \name Walther keys
     *
     *  These are values that Christian Walther added (for mac keyboard?).
     */
    /* @{ */

    CONTROL_BRIGHTNESSDOWN = 275,
    CONTROL_BRIGHTNESSUP = 276,
    CONTROL_DISPLAYSWITCH = 277, /**< display mirroring/dual display
                                           switch, video mode switch */
    CONTROL_KBDILLUMTOGGLE = 278,
    CONTROL_KBDILLUMDOWN = 279,
    CONTROL_KBDILLUMUP = 280,
    CONTROL_EJECT = 281,
    CONTROL_SLEEP = 282,           /**< SC System Sleep */

    CONTROL_APP1 = 283,
    CONTROL_APP2 = 284,

    /* @} *//* Walther keys */

    /**
     *  \name Usage page 0x0C (additional media keys)
     *
     *  These values are mapped from usage page 0x0C (USB consumer page).
     */
    /* @{ */

    CONTROL_AUDIOREWIND = 285,
    CONTROL_AUDIOFASTFORWARD = 286,

    /* @} *//* Usage page 0x0C (additional media keys) */

    /**
     *  \name Mobile keys
     *
     *  These are values that are often used on mobile phones.
     */
    /* @{ */

    CONTROL_SOFTLEFT = 287, /**< Usually situated below the display on phones and
                                      used as a multi-function feature key for selecting
                                      a software defined function shown on the bottom left
                                      of the display. */
    CONTROL_SOFTRIGHT = 288, /**< Usually situated below the display on phones and
                                       used as a multi-function feature key for selecting
                                       a software defined function shown on the bottom right
                                       of the display. */
    CONTROL_CALL = 289, /**< Used for accepting phone calls. */
    CONTROL_ENDCALL = 290, /**< Used for rejecting phone calls. */

    /* @} *//* Mobile keys */

    /* Add any other keys here. */

CONTROL_SCANCODE_LIMIT = 512, /**< not a key, just marks the number of scancodes
                                    for array bounds */

CONTROL_MOUSECODE_START = 512,

    CONTROL_LEFT_MOUSE = 513,
    CONTROL_RIGHT_MOUSE = 515,
    CONTROL_MIDDLE_MOUSE = 514,
    CONTROL_X1 = 516,
    CONTROL_X2 = 517,

CONTROL_MOUSECODE_LIMIT = 532,

} Control;

#endif
