{-# OPTIONS_GHC -Wno-unused-imports #-}

module Mischief.Input
  ( -- * Mischief Input
    -- $intro

    -- * Dependencies
    -- $deps

    -- * How to Use
    -- $use

    -- * Keyboard
    -- $key

    -- * Mouse
    -- $mouse
    InputPlugin,
    Keys,
    Mouse,
    module Mischief.SDL.Window,
  )
where

import Mischief.ECS
import Mischief.Input.Keys (Keys, KeysPlugin)
import Mischief.Input.Keys qualified as Keys
import Mischief.Input.Mouse (Mouse, MousePlugin)
import Mischief.Input.Mouse qualified as Mouse
import Mischief.SDL.Window

data InputPlugin = InputPlugin deriving (InputPlugin -> InputPlugin -> Bool
(InputPlugin -> InputPlugin -> Bool)
-> (InputPlugin -> InputPlugin -> Bool) -> Eq InputPlugin
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: InputPlugin -> InputPlugin -> Bool
== :: InputPlugin -> InputPlugin -> Bool
$c/= :: InputPlugin -> InputPlugin -> Bool
/= :: InputPlugin -> InputPlugin -> Bool
Eq)

instance Plugin InputPlugin where
  deps :: [Dependency]
deps = [forall p. Plugin p => Dependency
dep @KeysPlugin, forall p. Plugin p => Dependency
dep @MousePlugin]

-- $intro
-- This is the official input library for the Mischief game engine. It allows you to read input, such as from a mouse or keyboard.

-- $deps
-- * [mischief-ecs]("Mischief.ECS")
-- * [mischief-sdl]("Mischief.SDL")
--
-- You will need to manually install the following library (click for install guide):
--
-- * [SDL]("Mischief.SDL")

-- $use
-- To use this library, add the @'InputPlugin'@ to your App. This will add the individual plugins for all input types, such as @'KeysPlugin'@ and @'MousePlugin'@.

-- $key
-- To read keyboard input, import the following module:
--
-- @
-- import "Mischief.Input.Keys" qualified as Keys
-- @
--
-- Then, inside a system, query for the Keys resource:
--
-- @
-- Just keys <- 'res' \@'Keys'
-- @
--
-- You can use the 'Keys.justPressed', 'Keys.pressed', 'Keys.released', 'Keys.justReleased' functions to find out the state of a certain key. For instance:
--
-- @
-- Keys.'Keys.justPressed' keys Keys.'Keys.Space'
-- @

-- $mouse
-- To read mouse input, import the following module:
--
-- @
-- import "Mischief.Input.Mouse" qualified as Mouse
-- @
--
-- Then, query the Mouse resource:
--
-- @
-- mouse <- 'res' \@'Mouse'
-- @
--
-- You can use 'Keys.justPressed' and so on (same as the keys functions) to get the state of a mouse button. For instance:
--
-- @
-- Mouse.'Mouse.justPressed' mouse Mouse.'Mouse.Left'
-- @
--
-- You can also use the @pos@ function to get the current position of the cursor. This will be a screenspace position that is (0, 0) in the top-left corner
-- of the window:
--
-- @
-- pos <- Mouse.'Mouse.pos'
-- @