{-# OPTIONS_GHC -Wno-missing-pattern-synonym-signatures #-}

module Mischief.Input.Keys
  ( -- * Resource
    Keys,

    -- * Functions
    pressed,
    released,
    justPressed,
    justReleased,

    -- * Plugin
    KeysPlugin,

    -- * Keys
    -- $keys
    pattern Mischief.Input.Keys.A,
    pattern Mischief.Input.Keys.B,
    pattern Mischief.Input.Keys.C,
    pattern Mischief.Input.Keys.D,
    pattern Mischief.Input.Keys.E,
    pattern Mischief.Input.Keys.F,
    pattern Mischief.Input.Keys.G,
    pattern Mischief.Input.Keys.H,
    pattern Mischief.Input.Keys.I,
    pattern Mischief.Input.Keys.J,
    pattern Mischief.Input.Keys.K,
    pattern Mischief.Input.Keys.L,
    pattern Mischief.Input.Keys.M,
    pattern Mischief.Input.Keys.N,
    pattern Mischief.Input.Keys.O,
    pattern Mischief.Input.Keys.P,
    pattern Mischief.Input.Keys.Q,
    pattern Mischief.Input.Keys.R,
    pattern Mischief.Input.Keys.S,
    pattern Mischief.Input.Keys.T,
    pattern Mischief.Input.Keys.U,
    pattern Mischief.Input.Keys.V,
    pattern Mischief.Input.Keys.W,
    pattern Mischief.Input.Keys.X,
    pattern Mischief.Input.Keys.Y,
    pattern Mischief.Input.Keys.Z,
    pattern Mischief.Input.Keys.Key0,
    pattern Mischief.Input.Keys.Key1,
    pattern Mischief.Input.Keys.Key2,
    pattern Mischief.Input.Keys.Key3,
    pattern Mischief.Input.Keys.Key4,
    pattern Mischief.Input.Keys.Key5,
    pattern Mischief.Input.Keys.Key6,
    pattern Mischief.Input.Keys.Key7,
    pattern Mischief.Input.Keys.Key8,
    pattern Mischief.Input.Keys.Key9,
    pattern Mischief.Input.Keys.Enter,
    pattern Mischief.Input.Keys.Escape,
    pattern Mischief.Input.Keys.Backspace,
    pattern Mischief.Input.Keys.Tab,
    pattern Mischief.Input.Keys.Space,
    pattern Mischief.Input.Keys.Minus,
    pattern Mischief.Input.Keys.Equals,
    pattern Mischief.Input.Keys.LeftBracket,
    pattern Mischief.Input.Keys.RightBracket,
    pattern Mischief.Input.Keys.BackSlash,
    pattern Mischief.Input.Keys.Semicolon,
    pattern Mischief.Input.Keys.Apostrophe,
    pattern Mischief.Input.Keys.Grave,
    pattern Mischief.Input.Keys.Comma,
    pattern Mischief.Input.Keys.Period,
    pattern Mischief.Input.Keys.Slash,
    pattern Mischief.Input.Keys.Capslock,
    pattern Mischief.Input.Keys.F1,
    pattern Mischief.Input.Keys.F2,
    pattern Mischief.Input.Keys.F3,
    pattern Mischief.Input.Keys.F4,
    pattern Mischief.Input.Keys.F5,
    pattern Mischief.Input.Keys.F6,
    pattern Mischief.Input.Keys.F7,
    pattern Mischief.Input.Keys.F8,
    pattern Mischief.Input.Keys.F9,
    pattern Mischief.Input.Keys.F10,
    pattern Mischief.Input.Keys.F11,
    pattern Mischief.Input.Keys.F12,
    pattern Mischief.Input.Keys.Printscreen,
    pattern Mischief.Input.Keys.Scrolllock,
    pattern Mischief.Input.Keys.Pause,
    pattern Mischief.Input.Keys.Insert,
    pattern Mischief.Input.Keys.Home,
    pattern Mischief.Input.Keys.PageUp,
    pattern Mischief.Input.Keys.PageDown,
    pattern Mischief.Input.Keys.Delete,
    pattern Mischief.Input.Keys.End,
    pattern Mischief.Input.Keys.Right,
    pattern Mischief.Input.Keys.Left,
    pattern Mischief.Input.Keys.Down,
    pattern Mischief.Input.Keys.Up,
    pattern Mischief.Input.Keys.Numlockclear,
    pattern Mischief.Input.Keys.KeypadDivide,
    pattern Mischief.Input.Keys.KeypadMultiply,
    pattern Mischief.Input.Keys.Keypad0,
    pattern Mischief.Input.Keys.Keypad1,
    pattern Mischief.Input.Keys.Keypad2,
    pattern Mischief.Input.Keys.Keypad3,
    pattern Mischief.Input.Keys.Keypad4,
    pattern Mischief.Input.Keys.Keypad5,
    pattern Mischief.Input.Keys.Keypad6,
    pattern Mischief.Input.Keys.Keypad7,
    pattern Mischief.Input.Keys.Keypad8,
    pattern Mischief.Input.Keys.Keypad9,
    pattern Mischief.Input.Keys.KeypadPeriod,
    pattern Mischief.Input.Keys.KeypadComma,
    pattern Mischief.Input.Keys.KeypadEnter,
    pattern Mischief.Input.Keys.KeypadEquals,
    pattern Mischief.Input.Keys.KeypadMinus,
    pattern Mischief.Input.Keys.KeypadPlus,
    pattern Mischief.Input.Keys.LCtrl,
    pattern Mischief.Input.Keys.LShift,
    pattern Mischief.Input.Keys.LAlt,
    pattern Mischief.Input.Keys.RCtrl,
    pattern Mischief.Input.Keys.RShift,
    pattern Mischief.Input.Keys.RAlt,
    pattern Mischief.Input.Keys.Application,
  )
where

import Control.Monad.IO.Class
import Data.List ((!?))
import Foreign (nullPtr, peekArray, toBool)
import Foreign.C (CBool)
import Foreign.C.ConstPtr
import GHC.Generics
import Mischief.ECS
import Mischief.ECS.App.Schedules (First)
import Mischief.SDL (SDLPlugin)
import SDL3.Sys qualified as SDL3

data Keys = Keys
  { Keys -> [CBool]
currentKeys :: [CBool],
    Keys -> [CBool]
previousKeys :: [CBool]
  }
  deriving ((forall x. Keys -> Rep Keys x)
-> (forall x. Rep Keys x -> Keys) -> Generic Keys
forall x. Rep Keys x -> Keys
forall x. Keys -> Rep Keys x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. Keys -> Rep Keys x
from :: forall x. Keys -> Rep Keys x
$cto :: forall x. Rep Keys x -> Keys
to :: forall x. Rep Keys x -> Keys
Generic, Keys
Keys -> Default Keys
forall a. a -> Default a
$cdef :: Keys
def :: Keys
Default, Typeable Keys
[Hook Keys]
[HookRel Keys]
Set DefaultComponentType
IsExclusive (IsExclusiveRel Keys)
(Typeable Keys, IsExclusive (IsExclusiveRel Keys)) =>
Set DefaultComponentType
-> [Hook Keys]
-> [Hook Keys]
-> [Hook Keys]
-> [HookRel Keys]
-> [HookRel Keys]
-> [HookRel Keys]
-> Component Keys
forall c.
(Typeable c, IsExclusive (IsExclusiveRel c)) =>
Set DefaultComponentType
-> [Hook c]
-> [Hook c]
-> [Hook c]
-> [HookRel c]
-> [HookRel c]
-> [HookRel c]
-> Component c
$crequired :: Set DefaultComponentType
required :: Set DefaultComponentType
$conAdd :: [Hook Keys]
onAdd :: [Hook Keys]
$conSet :: [Hook Keys]
onSet :: [Hook Keys]
$conRemove :: [Hook Keys]
onRemove :: [Hook Keys]
$conAddRel :: [HookRel Keys]
onAddRel :: [HookRel Keys]
$conSetRel :: [HookRel Keys]
onSetRel :: [HookRel Keys]
$conRemoveRel :: [HookRel Keys]
onRemoveRel :: [HookRel Keys]
Component)

-- newtype HotKeys = HotKeys [((SDL3.SDL_Scancode, SDL3.SDL_Keycode), KeyState)] deriving (Generic, Default, Component)

-- setStatePhysical :: KeyState -> SDL3.SDL_Scancode -> IORef Keys -> IO ()
-- setStatePhysical state scancode keys =
--   modifyIORef' keys (\Keys {physical, virtual} -> Keys {physical = Map.insert scancode state physical, virtual})

-- setStateVirtual :: KeyState -> SDL3.SDL_Keycode -> IORef Keys -> IO ()
-- setStateVirtual state keycode keys =
--   modifyIORef' keys (\Keys {physical, virtual} -> Keys {physical, virtual = Map.insert keycode state virtual})

pressed :: Keys -> SDL3.SDL_Scancode -> Bool
pressed :: Keys -> SDL_Scancode -> Bool
pressed Keys {[CBool]
currentKeys :: Keys -> [CBool]
currentKeys :: [CBool]
currentKeys} SDL_Scancode
code = Bool -> (CBool -> Bool) -> Maybe CBool -> Bool
forall b a. b -> (a -> b) -> Maybe a -> b
maybe Bool
False CBool -> Bool
forall a. (Eq a, Num a) => a -> Bool
toBool (Maybe CBool -> Bool) -> Maybe CBool -> Bool
forall a b. (a -> b) -> a -> b
$ [CBool]
currentKeys [CBool] -> Int -> Maybe CBool
forall a. [a] -> Int -> Maybe a
!? SDL_Scancode -> Int
unwrapScancode SDL_Scancode
code

justPressed :: Keys -> SDL3.SDL_Scancode -> Bool
justPressed :: Keys -> SDL_Scancode -> Bool
justPressed Keys {[CBool]
currentKeys :: Keys -> [CBool]
currentKeys :: [CBool]
currentKeys, [CBool]
previousKeys :: Keys -> [CBool]
previousKeys :: [CBool]
previousKeys} SDL_Scancode
code = do
  let c :: Int
c = SDL_Scancode -> Int
unwrapScancode SDL_Scancode
code
  Bool -> (CBool -> Bool) -> Maybe CBool -> Bool
forall b a. b -> (a -> b) -> Maybe a -> b
maybe Bool
False CBool -> Bool
forall a. (Eq a, Num a) => a -> Bool
toBool ([CBool]
currentKeys [CBool] -> Int -> Maybe CBool
forall a. [a] -> Int -> Maybe a
!? Int
c) Bool -> Bool -> Bool
&& Bool -> Bool
not (Bool -> (CBool -> Bool) -> Maybe CBool -> Bool
forall b a. b -> (a -> b) -> Maybe a -> b
maybe Bool
False CBool -> Bool
forall a. (Eq a, Num a) => a -> Bool
toBool (Maybe CBool -> Bool) -> Maybe CBool -> Bool
forall a b. (a -> b) -> a -> b
$ [CBool]
previousKeys [CBool] -> Int -> Maybe CBool
forall a. [a] -> Int -> Maybe a
!? Int
c)

released :: Keys -> SDL3.SDL_Scancode -> Bool
released :: Keys -> SDL_Scancode -> Bool
released Keys {[CBool]
currentKeys :: Keys -> [CBool]
currentKeys :: [CBool]
currentKeys} SDL_Scancode
code = Bool -> Bool
not (Bool -> Bool) -> Bool -> Bool
forall a b. (a -> b) -> a -> b
$ Bool -> (CBool -> Bool) -> Maybe CBool -> Bool
forall b a. b -> (a -> b) -> Maybe a -> b
maybe Bool
False CBool -> Bool
forall a. (Eq a, Num a) => a -> Bool
toBool (Maybe CBool -> Bool) -> Maybe CBool -> Bool
forall a b. (a -> b) -> a -> b
$ [CBool]
currentKeys [CBool] -> Int -> Maybe CBool
forall a. [a] -> Int -> Maybe a
!? SDL_Scancode -> Int
unwrapScancode SDL_Scancode
code

justReleased :: Keys -> SDL3.SDL_Scancode -> Bool
justReleased :: Keys -> SDL_Scancode -> Bool
justReleased Keys {[CBool]
currentKeys :: Keys -> [CBool]
currentKeys :: [CBool]
currentKeys, [CBool]
previousKeys :: Keys -> [CBool]
previousKeys :: [CBool]
previousKeys} SDL_Scancode
code = do
  let c :: Int
c = SDL_Scancode -> Int
unwrapScancode SDL_Scancode
code
  Bool -> Bool
not (Bool -> (CBool -> Bool) -> Maybe CBool -> Bool
forall b a. b -> (a -> b) -> Maybe a -> b
maybe Bool
False CBool -> Bool
forall a. (Eq a, Num a) => a -> Bool
toBool ([CBool]
currentKeys [CBool] -> Int -> Maybe CBool
forall a. [a] -> Int -> Maybe a
!? Int
c)) Bool -> Bool -> Bool
&& Bool -> (CBool -> Bool) -> Maybe CBool -> Bool
forall b a. b -> (a -> b) -> Maybe a -> b
maybe Bool
False CBool -> Bool
forall a. (Eq a, Num a) => a -> Bool
toBool ([CBool]
previousKeys [CBool] -> Int -> Maybe CBool
forall a. [a] -> Int -> Maybe a
!? Int
c)

-- | Plugin which keeps track of key inputs and updates the 'Keys' resource.
data KeysPlugin

instance Plugin KeysPlugin where
  init :: System ()
init = do
    System () -> SystemConfig
forall a. ToSystems a => a -> SystemConfig
systems System ()
updateKeys
      SystemConfig -> (SystemConfig -> System ()) -> System ()
forall a b. a -> (a -> b) -> b
& forall sc. Schedule sc => SystemConfig -> System ()
forall {k} (sc :: k). Schedule sc => SystemConfig -> System ()
schedule @First

    Keys -> System ()
forall r. (Component r, Bundle r) => r -> System ()
insertRes (Keys -> System ()) -> Keys -> System ()
forall a b. (a -> b) -> a -> b
$ [CBool] -> [CBool] -> Keys
Keys [] []

  deps :: [Dependency]
deps = [forall p. Plugin p => Dependency
dep @SDLPlugin]

unwrapScancode :: SDL3.SDL_Scancode -> Int
unwrapScancode :: SDL_Scancode -> Int
unwrapScancode (SDL3.SDL_Scancode CUInt
i) = CUInt -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral CUInt
i

updateKeys :: System ()
updateKeys :: System ()
updateKeys = do
  Just keys <- forall c (m :: * -> *) w.
(MonadSystem w m, Component c) =>
m (Maybe c)
res @Keys
  ConstPtr a <- liftIO $ SDL3.getKeyboardState nullPtr
  b <- liftIO $ peekArray (unwrapScancode SDL3.SDL_SCANCODE_COUNT) a
  insertRes Keys {currentKeys = b, previousKeys = keys.currentKeys}

pattern $mA :: forall {r}. SDL_Scancode -> ((# #) -> r) -> ((# #) -> r) -> r
$bA :: SDL_Scancode
A = SDL3.SDL_SCANCODE_A

pattern $mB :: forall {r}. SDL_Scancode -> ((# #) -> r) -> ((# #) -> r) -> r
$bB :: SDL_Scancode
B = SDL3.SDL_SCANCODE_B

pattern $mC :: forall {r}. SDL_Scancode -> ((# #) -> r) -> ((# #) -> r) -> r
$bC :: SDL_Scancode
C = SDL3.SDL_SCANCODE_C

pattern $mD :: forall {r}. SDL_Scancode -> ((# #) -> r) -> ((# #) -> r) -> r
$bD :: SDL_Scancode
D = SDL3.SDL_SCANCODE_D

pattern $mE :: forall {r}. SDL_Scancode -> ((# #) -> r) -> ((# #) -> r) -> r
$bE :: SDL_Scancode
E = SDL3.SDL_SCANCODE_E

pattern $mF :: forall {r}. SDL_Scancode -> ((# #) -> r) -> ((# #) -> r) -> r
$bF :: SDL_Scancode
F = SDL3.SDL_SCANCODE_F

pattern $mG :: forall {r}. SDL_Scancode -> ((# #) -> r) -> ((# #) -> r) -> r
$bG :: SDL_Scancode
G = SDL3.SDL_SCANCODE_G

pattern $mH :: forall {r}. SDL_Scancode -> ((# #) -> r) -> ((# #) -> r) -> r
$bH :: SDL_Scancode
H = SDL3.SDL_SCANCODE_H

pattern $mI :: forall {r}. SDL_Scancode -> ((# #) -> r) -> ((# #) -> r) -> r
$bI :: SDL_Scancode
I = SDL3.SDL_SCANCODE_I

pattern $mJ :: forall {r}. SDL_Scancode -> ((# #) -> r) -> ((# #) -> r) -> r
$bJ :: SDL_Scancode
J = SDL3.SDL_SCANCODE_J

pattern $mK :: forall {r}. SDL_Scancode -> ((# #) -> r) -> ((# #) -> r) -> r
$bK :: SDL_Scancode
K = SDL3.SDL_SCANCODE_K

pattern $mL :: forall {r}. SDL_Scancode -> ((# #) -> r) -> ((# #) -> r) -> r
$bL :: SDL_Scancode
L = SDL3.SDL_SCANCODE_L

pattern $mM :: forall {r}. SDL_Scancode -> ((# #) -> r) -> ((# #) -> r) -> r
$bM :: SDL_Scancode
M = SDL3.SDL_SCANCODE_M

pattern $mN :: forall {r}. SDL_Scancode -> ((# #) -> r) -> ((# #) -> r) -> r
$bN :: SDL_Scancode
N = SDL3.SDL_SCANCODE_N

pattern $mO :: forall {r}. SDL_Scancode -> ((# #) -> r) -> ((# #) -> r) -> r
$bO :: SDL_Scancode
O = SDL3.SDL_SCANCODE_O

pattern $mP :: forall {r}. SDL_Scancode -> ((# #) -> r) -> ((# #) -> r) -> r
$bP :: SDL_Scancode
P = SDL3.SDL_SCANCODE_P

pattern $mQ :: forall {r}. SDL_Scancode -> ((# #) -> r) -> ((# #) -> r) -> r
$bQ :: SDL_Scancode
Q = SDL3.SDL_SCANCODE_Q

pattern $mR :: forall {r}. SDL_Scancode -> ((# #) -> r) -> ((# #) -> r) -> r
$bR :: SDL_Scancode
R = SDL3.SDL_SCANCODE_R

pattern $mS :: forall {r}. SDL_Scancode -> ((# #) -> r) -> ((# #) -> r) -> r
$bS :: SDL_Scancode
S = SDL3.SDL_SCANCODE_S

pattern $mT :: forall {r}. SDL_Scancode -> ((# #) -> r) -> ((# #) -> r) -> r
$bT :: SDL_Scancode
T = SDL3.SDL_SCANCODE_T

pattern $mU :: forall {r}. SDL_Scancode -> ((# #) -> r) -> ((# #) -> r) -> r
$bU :: SDL_Scancode
U = SDL3.SDL_SCANCODE_U

pattern $mV :: forall {r}. SDL_Scancode -> ((# #) -> r) -> ((# #) -> r) -> r
$bV :: SDL_Scancode
V = SDL3.SDL_SCANCODE_V

pattern $mW :: forall {r}. SDL_Scancode -> ((# #) -> r) -> ((# #) -> r) -> r
$bW :: SDL_Scancode
W = SDL3.SDL_SCANCODE_W

pattern $mX :: forall {r}. SDL_Scancode -> ((# #) -> r) -> ((# #) -> r) -> r
$bX :: SDL_Scancode
X = SDL3.SDL_SCANCODE_X

pattern $mY :: forall {r}. SDL_Scancode -> ((# #) -> r) -> ((# #) -> r) -> r
$bY :: SDL_Scancode
Y = SDL3.SDL_SCANCODE_Y

pattern $mZ :: forall {r}. SDL_Scancode -> ((# #) -> r) -> ((# #) -> r) -> r
$bZ :: SDL_Scancode
Z = SDL3.SDL_SCANCODE_Z

pattern $mKey1 :: forall {r}. SDL_Scancode -> ((# #) -> r) -> ((# #) -> r) -> r
$bKey1 :: SDL_Scancode
Key1 = SDL3.SDL_SCANCODE_1

pattern $mKey2 :: forall {r}. SDL_Scancode -> ((# #) -> r) -> ((# #) -> r) -> r
$bKey2 :: SDL_Scancode
Key2 = SDL3.SDL_SCANCODE_2

pattern $mKey3 :: forall {r}. SDL_Scancode -> ((# #) -> r) -> ((# #) -> r) -> r
$bKey3 :: SDL_Scancode
Key3 = SDL3.SDL_SCANCODE_3

pattern $mKey4 :: forall {r}. SDL_Scancode -> ((# #) -> r) -> ((# #) -> r) -> r
$bKey4 :: SDL_Scancode
Key4 = SDL3.SDL_SCANCODE_4

pattern $mKey5 :: forall {r}. SDL_Scancode -> ((# #) -> r) -> ((# #) -> r) -> r
$bKey5 :: SDL_Scancode
Key5 = SDL3.SDL_SCANCODE_5

pattern $mKey6 :: forall {r}. SDL_Scancode -> ((# #) -> r) -> ((# #) -> r) -> r
$bKey6 :: SDL_Scancode
Key6 = SDL3.SDL_SCANCODE_6

pattern $mKey7 :: forall {r}. SDL_Scancode -> ((# #) -> r) -> ((# #) -> r) -> r
$bKey7 :: SDL_Scancode
Key7 = SDL3.SDL_SCANCODE_7

pattern $mKey8 :: forall {r}. SDL_Scancode -> ((# #) -> r) -> ((# #) -> r) -> r
$bKey8 :: SDL_Scancode
Key8 = SDL3.SDL_SCANCODE_8

pattern $mKey9 :: forall {r}. SDL_Scancode -> ((# #) -> r) -> ((# #) -> r) -> r
$bKey9 :: SDL_Scancode
Key9 = SDL3.SDL_SCANCODE_9

pattern $mKey0 :: forall {r}. SDL_Scancode -> ((# #) -> r) -> ((# #) -> r) -> r
$bKey0 :: SDL_Scancode
Key0 = SDL3.SDL_SCANCODE_0

pattern $mEnter :: forall {r}. SDL_Scancode -> ((# #) -> r) -> ((# #) -> r) -> r
$bEnter :: SDL_Scancode
Enter = SDL3.SDL_SCANCODE_RETURN

pattern $mEscape :: forall {r}. SDL_Scancode -> ((# #) -> r) -> ((# #) -> r) -> r
$bEscape :: SDL_Scancode
Escape = SDL3.SDL_SCANCODE_ESCAPE

pattern $mBackspace :: forall {r}. SDL_Scancode -> ((# #) -> r) -> ((# #) -> r) -> r
$bBackspace :: SDL_Scancode
Backspace = SDL3.SDL_SCANCODE_BACKSPACE

pattern $mTab :: forall {r}. SDL_Scancode -> ((# #) -> r) -> ((# #) -> r) -> r
$bTab :: SDL_Scancode
Tab = SDL3.SDL_SCANCODE_TAB

pattern $mSpace :: forall {r}. SDL_Scancode -> ((# #) -> r) -> ((# #) -> r) -> r
$bSpace :: SDL_Scancode
Space = SDL3.SDL_SCANCODE_SPACE

pattern $mMinus :: forall {r}. SDL_Scancode -> ((# #) -> r) -> ((# #) -> r) -> r
$bMinus :: SDL_Scancode
Minus = SDL3.SDL_SCANCODE_MINUS

pattern $mEquals :: forall {r}. SDL_Scancode -> ((# #) -> r) -> ((# #) -> r) -> r
$bEquals :: SDL_Scancode
Equals = SDL3.SDL_SCANCODE_EQUALS

pattern $mLeftBracket :: forall {r}. SDL_Scancode -> ((# #) -> r) -> ((# #) -> r) -> r
$bLeftBracket :: SDL_Scancode
LeftBracket = SDL3.SDL_SCANCODE_LEFTBRACKET

pattern $mRightBracket :: forall {r}. SDL_Scancode -> ((# #) -> r) -> ((# #) -> r) -> r
$bRightBracket :: SDL_Scancode
RightBracket = SDL3.SDL_SCANCODE_RIGHTBRACKET

pattern $mBackSlash :: forall {r}. SDL_Scancode -> ((# #) -> r) -> ((# #) -> r) -> r
$bBackSlash :: SDL_Scancode
BackSlash = SDL3.SDL_SCANCODE_BACKSLASH

pattern $mSemicolon :: forall {r}. SDL_Scancode -> ((# #) -> r) -> ((# #) -> r) -> r
$bSemicolon :: SDL_Scancode
Semicolon = SDL3.SDL_SCANCODE_SEMICOLON

pattern $mApostrophe :: forall {r}. SDL_Scancode -> ((# #) -> r) -> ((# #) -> r) -> r
$bApostrophe :: SDL_Scancode
Apostrophe = SDL3.SDL_SCANCODE_APOSTROPHE

pattern $mGrave :: forall {r}. SDL_Scancode -> ((# #) -> r) -> ((# #) -> r) -> r
$bGrave :: SDL_Scancode
Grave = SDL3.SDL_SCANCODE_GRAVE

pattern $mComma :: forall {r}. SDL_Scancode -> ((# #) -> r) -> ((# #) -> r) -> r
$bComma :: SDL_Scancode
Comma = SDL3.SDL_SCANCODE_COMMA

pattern $mPeriod :: forall {r}. SDL_Scancode -> ((# #) -> r) -> ((# #) -> r) -> r
$bPeriod :: SDL_Scancode
Period = SDL3.SDL_SCANCODE_PERIOD

pattern $mSlash :: forall {r}. SDL_Scancode -> ((# #) -> r) -> ((# #) -> r) -> r
$bSlash :: SDL_Scancode
Slash = SDL3.SDL_SCANCODE_SLASH

pattern $mCapslock :: forall {r}. SDL_Scancode -> ((# #) -> r) -> ((# #) -> r) -> r
$bCapslock :: SDL_Scancode
Capslock = SDL3.SDL_SCANCODE_CAPSLOCK

pattern $mF1 :: forall {r}. SDL_Scancode -> ((# #) -> r) -> ((# #) -> r) -> r
$bF1 :: SDL_Scancode
F1 = SDL3.SDL_SCANCODE_F1

pattern $mF2 :: forall {r}. SDL_Scancode -> ((# #) -> r) -> ((# #) -> r) -> r
$bF2 :: SDL_Scancode
F2 = SDL3.SDL_SCANCODE_F2

pattern $mF3 :: forall {r}. SDL_Scancode -> ((# #) -> r) -> ((# #) -> r) -> r
$bF3 :: SDL_Scancode
F3 = SDL3.SDL_SCANCODE_F3

pattern $mF4 :: forall {r}. SDL_Scancode -> ((# #) -> r) -> ((# #) -> r) -> r
$bF4 :: SDL_Scancode
F4 = SDL3.SDL_SCANCODE_F4

pattern $mF5 :: forall {r}. SDL_Scancode -> ((# #) -> r) -> ((# #) -> r) -> r
$bF5 :: SDL_Scancode
F5 = SDL3.SDL_SCANCODE_F5

pattern $mF6 :: forall {r}. SDL_Scancode -> ((# #) -> r) -> ((# #) -> r) -> r
$bF6 :: SDL_Scancode
F6 = SDL3.SDL_SCANCODE_F6

pattern $mF7 :: forall {r}. SDL_Scancode -> ((# #) -> r) -> ((# #) -> r) -> r
$bF7 :: SDL_Scancode
F7 = SDL3.SDL_SCANCODE_F7

pattern $mF8 :: forall {r}. SDL_Scancode -> ((# #) -> r) -> ((# #) -> r) -> r
$bF8 :: SDL_Scancode
F8 = SDL3.SDL_SCANCODE_F8

pattern $mF9 :: forall {r}. SDL_Scancode -> ((# #) -> r) -> ((# #) -> r) -> r
$bF9 :: SDL_Scancode
F9 = SDL3.SDL_SCANCODE_F9

pattern $mF10 :: forall {r}. SDL_Scancode -> ((# #) -> r) -> ((# #) -> r) -> r
$bF10 :: SDL_Scancode
F10 = SDL3.SDL_SCANCODE_F10

pattern $mF11 :: forall {r}. SDL_Scancode -> ((# #) -> r) -> ((# #) -> r) -> r
$bF11 :: SDL_Scancode
F11 = SDL3.SDL_SCANCODE_F11

pattern $mF12 :: forall {r}. SDL_Scancode -> ((# #) -> r) -> ((# #) -> r) -> r
$bF12 :: SDL_Scancode
F12 = SDL3.SDL_SCANCODE_F12

pattern $mPrintscreen :: forall {r}. SDL_Scancode -> ((# #) -> r) -> ((# #) -> r) -> r
$bPrintscreen :: SDL_Scancode
Printscreen = SDL3.SDL_SCANCODE_PRINTSCREEN

pattern $mScrolllock :: forall {r}. SDL_Scancode -> ((# #) -> r) -> ((# #) -> r) -> r
$bScrolllock :: SDL_Scancode
Scrolllock = SDL3.SDL_SCANCODE_SCROLLLOCK

pattern $mPause :: forall {r}. SDL_Scancode -> ((# #) -> r) -> ((# #) -> r) -> r
$bPause :: SDL_Scancode
Pause = SDL3.SDL_SCANCODE_PAUSE

pattern $mInsert :: forall {r}. SDL_Scancode -> ((# #) -> r) -> ((# #) -> r) -> r
$bInsert :: SDL_Scancode
Insert = SDL3.SDL_SCANCODE_INSERT

pattern $mHome :: forall {r}. SDL_Scancode -> ((# #) -> r) -> ((# #) -> r) -> r
$bHome :: SDL_Scancode
Home = SDL3.SDL_SCANCODE_HOME

pattern $mPageUp :: forall {r}. SDL_Scancode -> ((# #) -> r) -> ((# #) -> r) -> r
$bPageUp :: SDL_Scancode
PageUp = SDL3.SDL_SCANCODE_PAGEUP

pattern $mDelete :: forall {r}. SDL_Scancode -> ((# #) -> r) -> ((# #) -> r) -> r
$bDelete :: SDL_Scancode
Delete = SDL3.SDL_SCANCODE_DELETE

pattern $mEnd :: forall {r}. SDL_Scancode -> ((# #) -> r) -> ((# #) -> r) -> r
$bEnd :: SDL_Scancode
End = SDL3.SDL_SCANCODE_END

pattern $mPageDown :: forall {r}. SDL_Scancode -> ((# #) -> r) -> ((# #) -> r) -> r
$bPageDown :: SDL_Scancode
PageDown = SDL3.SDL_SCANCODE_PAGEDOWN

pattern $mRight :: forall {r}. SDL_Scancode -> ((# #) -> r) -> ((# #) -> r) -> r
$bRight :: SDL_Scancode
Right = SDL3.SDL_SCANCODE_RIGHT

pattern $mLeft :: forall {r}. SDL_Scancode -> ((# #) -> r) -> ((# #) -> r) -> r
$bLeft :: SDL_Scancode
Left = SDL3.SDL_SCANCODE_LEFT

pattern $mDown :: forall {r}. SDL_Scancode -> ((# #) -> r) -> ((# #) -> r) -> r
$bDown :: SDL_Scancode
Down = SDL3.SDL_SCANCODE_DOWN

pattern $mUp :: forall {r}. SDL_Scancode -> ((# #) -> r) -> ((# #) -> r) -> r
$bUp :: SDL_Scancode
Up = SDL3.SDL_SCANCODE_UP

pattern $mNumlockclear :: forall {r}. SDL_Scancode -> ((# #) -> r) -> ((# #) -> r) -> r
$bNumlockclear :: SDL_Scancode
Numlockclear = SDL3.SDL_SCANCODE_NUMLOCKCLEAR

pattern $mKeypadDivide :: forall {r}. SDL_Scancode -> ((# #) -> r) -> ((# #) -> r) -> r
$bKeypadDivide :: SDL_Scancode
KeypadDivide = SDL3.SDL_SCANCODE_KP_DIVIDE

pattern $mKeypadMultiply :: forall {r}. SDL_Scancode -> ((# #) -> r) -> ((# #) -> r) -> r
$bKeypadMultiply :: SDL_Scancode
KeypadMultiply = SDL3.SDL_SCANCODE_KP_MULTIPLY

pattern $mKeypadMinus :: forall {r}. SDL_Scancode -> ((# #) -> r) -> ((# #) -> r) -> r
$bKeypadMinus :: SDL_Scancode
KeypadMinus = SDL3.SDL_SCANCODE_KP_MINUS

pattern $mKeypadPlus :: forall {r}. SDL_Scancode -> ((# #) -> r) -> ((# #) -> r) -> r
$bKeypadPlus :: SDL_Scancode
KeypadPlus = SDL3.SDL_SCANCODE_KP_PLUS

pattern $mKeypadEnter :: forall {r}. SDL_Scancode -> ((# #) -> r) -> ((# #) -> r) -> r
$bKeypadEnter :: SDL_Scancode
KeypadEnter = SDL3.SDL_SCANCODE_KP_ENTER

pattern $mKeypad1 :: forall {r}. SDL_Scancode -> ((# #) -> r) -> ((# #) -> r) -> r
$bKeypad1 :: SDL_Scancode
Keypad1 = SDL3.SDL_SCANCODE_KP_1

pattern $mKeypad2 :: forall {r}. SDL_Scancode -> ((# #) -> r) -> ((# #) -> r) -> r
$bKeypad2 :: SDL_Scancode
Keypad2 = SDL3.SDL_SCANCODE_KP_2

pattern $mKeypad3 :: forall {r}. SDL_Scancode -> ((# #) -> r) -> ((# #) -> r) -> r
$bKeypad3 :: SDL_Scancode
Keypad3 = SDL3.SDL_SCANCODE_KP_3

pattern $mKeypad4 :: forall {r}. SDL_Scancode -> ((# #) -> r) -> ((# #) -> r) -> r
$bKeypad4 :: SDL_Scancode
Keypad4 = SDL3.SDL_SCANCODE_KP_4

pattern $mKeypad5 :: forall {r}. SDL_Scancode -> ((# #) -> r) -> ((# #) -> r) -> r
$bKeypad5 :: SDL_Scancode
Keypad5 = SDL3.SDL_SCANCODE_KP_5

pattern $mKeypad6 :: forall {r}. SDL_Scancode -> ((# #) -> r) -> ((# #) -> r) -> r
$bKeypad6 :: SDL_Scancode
Keypad6 = SDL3.SDL_SCANCODE_KP_6

pattern $mKeypad7 :: forall {r}. SDL_Scancode -> ((# #) -> r) -> ((# #) -> r) -> r
$bKeypad7 :: SDL_Scancode
Keypad7 = SDL3.SDL_SCANCODE_KP_7

pattern $mKeypad8 :: forall {r}. SDL_Scancode -> ((# #) -> r) -> ((# #) -> r) -> r
$bKeypad8 :: SDL_Scancode
Keypad8 = SDL3.SDL_SCANCODE_KP_8

pattern $mKeypad9 :: forall {r}. SDL_Scancode -> ((# #) -> r) -> ((# #) -> r) -> r
$bKeypad9 :: SDL_Scancode
Keypad9 = SDL3.SDL_SCANCODE_KP_9

pattern $mKeypad0 :: forall {r}. SDL_Scancode -> ((# #) -> r) -> ((# #) -> r) -> r
$bKeypad0 :: SDL_Scancode
Keypad0 = SDL3.SDL_SCANCODE_KP_0

pattern $mKeypadPeriod :: forall {r}. SDL_Scancode -> ((# #) -> r) -> ((# #) -> r) -> r
$bKeypadPeriod :: SDL_Scancode
KeypadPeriod = SDL3.SDL_SCANCODE_KP_PERIOD

pattern $mKeypadEquals :: forall {r}. SDL_Scancode -> ((# #) -> r) -> ((# #) -> r) -> r
$bKeypadEquals :: SDL_Scancode
KeypadEquals = SDL3.SDL_SCANCODE_KP_EQUALS

pattern $mKeypadComma :: forall {r}. SDL_Scancode -> ((# #) -> r) -> ((# #) -> r) -> r
$bKeypadComma :: SDL_Scancode
KeypadComma = SDL3.SDL_SCANCODE_KP_COMMA

pattern $mLCtrl :: forall {r}. SDL_Scancode -> ((# #) -> r) -> ((# #) -> r) -> r
$bLCtrl :: SDL_Scancode
LCtrl = SDL3.SDL_SCANCODE_LCTRL

pattern $mLShift :: forall {r}. SDL_Scancode -> ((# #) -> r) -> ((# #) -> r) -> r
$bLShift :: SDL_Scancode
LShift = SDL3.SDL_SCANCODE_LSHIFT

pattern $mLAlt :: forall {r}. SDL_Scancode -> ((# #) -> r) -> ((# #) -> r) -> r
$bLAlt :: SDL_Scancode
LAlt = SDL3.SDL_SCANCODE_LALT

pattern $mRCtrl :: forall {r}. SDL_Scancode -> ((# #) -> r) -> ((# #) -> r) -> r
$bRCtrl :: SDL_Scancode
RCtrl = SDL3.SDL_SCANCODE_RCTRL

pattern $mRShift :: forall {r}. SDL_Scancode -> ((# #) -> r) -> ((# #) -> r) -> r
$bRShift :: SDL_Scancode
RShift = SDL3.SDL_SCANCODE_RSHIFT

pattern $mRAlt :: forall {r}. SDL_Scancode -> ((# #) -> r) -> ((# #) -> r) -> r
$bRAlt :: SDL_Scancode
RAlt = SDL3.SDL_SCANCODE_RALT

pattern $mApplication :: forall {r}. SDL_Scancode -> ((# #) -> r) -> ((# #) -> r) -> r
$bApplication :: SDL_Scancode
Application = SDL3.SDL_SCANCODE_APPLICATION

-- $keys
-- Below is an opinionated collection of keys selected from SDL3's scancodes. These can be used with 'pressed', 'justPressed', and so on.
--
-- Most key names are the same as SDL's, the only significant exception is @Return@ which has been renamed to @Enter@.
--
-- If you wish to access a key that's not defined here, you can grab it directly from "SDL3.Sys.Bindgen.Scancode".