packages feed

twentefp-eventloop-graphics-0.1.0.0: src/EventLoop/Input/Keyboard.hs

module EventLoop.Input.Keyboard(
    Keyboard(..),
    KeyboardButton
) where

import EventLoop.Json
import EventLoop.Config

-- Possible messages:
-- {"type": "keyboard", "button": "<kkey>"}
-- <kkey> = a | b | c .. | z | shift | caps ..

-- Keyboard Messages In
data Keyboard = KeyPress KeyboardButton
type KeyboardButton = [Char]

instance FromJSON Keyboard where
    fromJsonMessage (JSONObject ms) = KeyPress button
                                    where
                                        JSONString button = retrieveError buttonS ms