START_FLAG = 0x1
SELECT_FLAG = 0x2
OPTION_FLAG = 0x4
SHIFT_FLAG = 0x10
CTRL_FLAG = 0x20
MOUSE_DELTA_FLAG = 0x80  # if not set, direct mouse mode is used where values are sent directly to POKEY potentiometer input; otherwise mouse movements are sent as deltas

# Atari key codes from akey.h

# All key codes are identical to the values in akey.h except for the
# special keys. In akey.h they are negative, but here they are positive
# because we're using unsigned bytes for all the code

AKEY_NONE = -1

# Special key codes.
AKEY_WARMSTART = 2
AKEY_COLDSTART = 3
AKEY_EXIT = 4
AKEY_BREAK = 5
AKEY_UI = 7
AKEY_SCREENSHOT = 8
AKEY_SCREENSHOT_INTERLACE = 9
AKEY_START = 10
AKEY_SELECT = 11
AKEY_OPTION = 12
AKEY_PBI_BB_MENU = 13
AKEY_CX85_1 = 14
AKEY_CX85_2 = 15
AKEY_CX85_3 = 16
AKEY_CX85_4 = 17
AKEY_CX85_5 = 18
AKEY_CX85_6 = 19
AKEY_CX85_7 = 20
AKEY_CX85_8 = 21
AKEY_CX85_9 = 22
AKEY_CX85_0 = 23
AKEY_CX85_PERIOD = 24
AKEY_CX85_MINUS = 25
AKEY_CX85_PLUS_ENTER = 26
AKEY_CX85_ESCAPE = 27
AKEY_CX85_NO = 28
AKEY_CX85_DELETE = 29
AKEY_CX85_YES = 30
AKEY_TURBO = 31

AKEY_SHFT = 0x40
AKEY_CTRL = 0x80
AKEY_SHFTCTRL = 0xc0

AKEY_0 = 0x32
AKEY_1 = 0x1f
AKEY_2 = 0x1e
AKEY_3 = 0x1a
AKEY_4 = 0x18
AKEY_5 = 0x1d
AKEY_6 = 0x1b
AKEY_7 = 0x33
AKEY_8 = 0x35
AKEY_9 = 0x30

AKEY_CTRL_0 = (AKEY_CTRL | AKEY_0)
AKEY_CTRL_1 = (AKEY_CTRL | AKEY_1)
AKEY_CTRL_2 = (AKEY_CTRL | AKEY_2)
AKEY_CTRL_3 = (AKEY_CTRL | AKEY_3)
AKEY_CTRL_4 = (AKEY_CTRL | AKEY_4)
AKEY_CTRL_5 = (AKEY_CTRL | AKEY_5)
AKEY_CTRL_6 = (AKEY_CTRL | AKEY_6)
AKEY_CTRL_7 = (AKEY_CTRL | AKEY_7)
AKEY_CTRL_8 = (AKEY_CTRL | AKEY_8)
AKEY_CTRL_9 = (AKEY_CTRL | AKEY_9)

AKEY_a = 0x3f
AKEY_b = 0x15
AKEY_c = 0x12
AKEY_d = 0x3a
AKEY_e = 0x2a
AKEY_f = 0x38
AKEY_g = 0x3d
AKEY_h = 0x39
AKEY_i = 0x0d
AKEY_j = 0x01
AKEY_k = 0x05
AKEY_l = 0x00
AKEY_m = 0x25
AKEY_n = 0x23
AKEY_o = 0x08
AKEY_p = 0x0a
AKEY_q = 0x2f
AKEY_r = 0x28
AKEY_s = 0x3e
AKEY_t = 0x2d
AKEY_u = 0x0b
AKEY_v = 0x10
AKEY_w = 0x2e
AKEY_x = 0x16
AKEY_y = 0x2b
AKEY_z = 0x17

AKEY_A = (AKEY_SHFT | AKEY_a)
AKEY_B = (AKEY_SHFT | AKEY_b)
AKEY_C = (AKEY_SHFT | AKEY_c)
AKEY_D = (AKEY_SHFT | AKEY_d)
AKEY_E = (AKEY_SHFT | AKEY_e)
AKEY_F = (AKEY_SHFT | AKEY_f)
AKEY_G = (AKEY_SHFT | AKEY_g)
AKEY_H = (AKEY_SHFT | AKEY_h)
AKEY_I = (AKEY_SHFT | AKEY_i)
AKEY_J = (AKEY_SHFT | AKEY_j)
AKEY_K = (AKEY_SHFT | AKEY_k)
AKEY_L = (AKEY_SHFT | AKEY_l)
AKEY_M = (AKEY_SHFT | AKEY_m)
AKEY_N = (AKEY_SHFT | AKEY_n)
AKEY_O = (AKEY_SHFT | AKEY_o)
AKEY_P = (AKEY_SHFT | AKEY_p)
AKEY_Q = (AKEY_SHFT | AKEY_q)
AKEY_R = (AKEY_SHFT | AKEY_r)
AKEY_S = (AKEY_SHFT | AKEY_s)
AKEY_T = (AKEY_SHFT | AKEY_t)
AKEY_U = (AKEY_SHFT | AKEY_u)
AKEY_V = (AKEY_SHFT | AKEY_v)
AKEY_W = (AKEY_SHFT | AKEY_w)
AKEY_X = (AKEY_SHFT | AKEY_x)
AKEY_Y = (AKEY_SHFT | AKEY_y)
AKEY_Z = (AKEY_SHFT | AKEY_z)

AKEY_CTRL_a = (AKEY_CTRL | AKEY_a)
AKEY_CTRL_b = (AKEY_CTRL | AKEY_b)
AKEY_CTRL_c = (AKEY_CTRL | AKEY_c)
AKEY_CTRL_d = (AKEY_CTRL | AKEY_d)
AKEY_CTRL_e = (AKEY_CTRL | AKEY_e)
AKEY_CTRL_f = (AKEY_CTRL | AKEY_f)
AKEY_CTRL_g = (AKEY_CTRL | AKEY_g)
AKEY_CTRL_h = (AKEY_CTRL | AKEY_h)
AKEY_CTRL_i = (AKEY_CTRL | AKEY_i)
AKEY_CTRL_j = (AKEY_CTRL | AKEY_j)
AKEY_CTRL_k = (AKEY_CTRL | AKEY_k)
AKEY_CTRL_l = (AKEY_CTRL | AKEY_l)
AKEY_CTRL_m = (AKEY_CTRL | AKEY_m)
AKEY_CTRL_n = (AKEY_CTRL | AKEY_n)
AKEY_CTRL_o = (AKEY_CTRL | AKEY_o)
AKEY_CTRL_p = (AKEY_CTRL | AKEY_p)
AKEY_CTRL_q = (AKEY_CTRL | AKEY_q)
AKEY_CTRL_r = (AKEY_CTRL | AKEY_r)
AKEY_CTRL_s = (AKEY_CTRL | AKEY_s)
AKEY_CTRL_t = (AKEY_CTRL | AKEY_t)
AKEY_CTRL_u = (AKEY_CTRL | AKEY_u)
AKEY_CTRL_v = (AKEY_CTRL | AKEY_v)
AKEY_CTRL_w = (AKEY_CTRL | AKEY_w)
AKEY_CTRL_x = (AKEY_CTRL | AKEY_x)
AKEY_CTRL_y = (AKEY_CTRL | AKEY_y)
AKEY_CTRL_z = (AKEY_CTRL | AKEY_z)

AKEY_CTRL_A = (AKEY_CTRL | AKEY_A)
AKEY_CTRL_B = (AKEY_CTRL | AKEY_B)
AKEY_CTRL_C = (AKEY_CTRL | AKEY_C)
AKEY_CTRL_D = (AKEY_CTRL | AKEY_D)
AKEY_CTRL_E = (AKEY_CTRL | AKEY_E)
AKEY_CTRL_F = (AKEY_CTRL | AKEY_F)
AKEY_CTRL_G = (AKEY_CTRL | AKEY_G)
AKEY_CTRL_H = (AKEY_CTRL | AKEY_H)
AKEY_CTRL_I = (AKEY_CTRL | AKEY_I)
AKEY_CTRL_J = (AKEY_CTRL | AKEY_J)
AKEY_CTRL_K = (AKEY_CTRL | AKEY_K)
AKEY_CTRL_L = (AKEY_CTRL | AKEY_L)
AKEY_CTRL_M = (AKEY_CTRL | AKEY_M)
AKEY_CTRL_N = (AKEY_CTRL | AKEY_N)
AKEY_CTRL_O = (AKEY_CTRL | AKEY_O)
AKEY_CTRL_P = (AKEY_CTRL | AKEY_P)
AKEY_CTRL_Q = (AKEY_CTRL | AKEY_Q)
AKEY_CTRL_R = (AKEY_CTRL | AKEY_R)
AKEY_CTRL_S = (AKEY_CTRL | AKEY_S)
AKEY_CTRL_T = (AKEY_CTRL | AKEY_T)
AKEY_CTRL_U = (AKEY_CTRL | AKEY_U)
AKEY_CTRL_V = (AKEY_CTRL | AKEY_V)
AKEY_CTRL_W = (AKEY_CTRL | AKEY_W)
AKEY_CTRL_X = (AKEY_CTRL | AKEY_X)
AKEY_CTRL_Y = (AKEY_CTRL | AKEY_Y)
AKEY_CTRL_Z = (AKEY_CTRL | AKEY_Z)

AKEY_HELP = 0x11
AKEY_DOWN = 0x8f
AKEY_LEFT = 0x86
AKEY_RIGHT = 0x87
AKEY_UP = 0x8e
AKEY_BACKSPACE = 0x34
AKEY_DELETE_CHAR = 0xb4
AKEY_DELETE_LINE = 0x74
AKEY_INSERT_CHAR = 0xb7
AKEY_INSERT_LINE = 0x77
AKEY_ESCAPE = 0x1c
AKEY_ATARI = 0x27
AKEY_CAPSLOCK = 0x7c
AKEY_CAPSTOGGLE = 0x3c
AKEY_TAB = 0x2c
AKEY_SETTAB = 0x6c
AKEY_CLRTAB = 0xac
AKEY_RETURN = 0x0c
AKEY_SPACE = 0x21
AKEY_EXCLAMATION = 0x5f
AKEY_DBLQUOTE = 0x5e
AKEY_HASH = 0x5a
AKEY_DOLLAR = 0x58
AKEY_PERCENT = 0x5d
AKEY_AMPERSAND = 0x5b
AKEY_QUOTE = 0x73
AKEY_AT = 0x75
AKEY_PARENLEFT = 0x70
AKEY_PARENRIGHT = 0x72
AKEY_LESS = 0x36
AKEY_GREATER = 0x37
AKEY_EQUAL = 0x0f
AKEY_QUESTION = 0x66
AKEY_MINUS = 0x0e
AKEY_PLUS = 0x06
AKEY_ASTERISK = 0x07
AKEY_SLASH = 0x26
AKEY_COLON = 0x42
AKEY_SEMICOLON = 0x02
AKEY_COMMA = 0x20
AKEY_FULLSTOP = 0x22
AKEY_UNDERSCORE = 0x4e
AKEY_BRACKETLEFT = 0x60
AKEY_BRACKETRIGHT = 0x62
AKEY_CIRCUMFLEX = 0x47
AKEY_BACKSLASH = 0x46
AKEY_BAR = 0x4f
AKEY_CLEAR = (AKEY_SHFT | AKEY_LESS)
AKEY_CARET = (AKEY_SHFT | AKEY_ASTERISK)
AKEY_F1 = 0x03
AKEY_F2 = 0x04
AKEY_F3 = 0x13
AKEY_F4 = 0x14

# Following keys cannot be read with both shift and control pressed:
#   J K L ; + * Z X C V B F1 F2 F3 F4 HELP

# 5200 key codes
AKEY_5200_START = 0x39
AKEY_5200_PAUSE = 0x31
AKEY_5200_RESET = 0x29
AKEY_5200_0 = 0x25
AKEY_5200_1 = 0x3f
AKEY_5200_2 = 0x3d
AKEY_5200_3 = 0x3b
AKEY_5200_4 = 0x37
AKEY_5200_5 = 0x35
AKEY_5200_6 = 0x33
AKEY_5200_7 = 0x2f
AKEY_5200_8 = 0x2d
AKEY_5200_9 = 0x2b
AKEY_5200_HASH = 0x23
AKEY_5200_ASTERISK = 0x27
