| Safe Haskell | None |
|---|---|
| Language | GHC2024 |
Mischief.Input
Synopsis
- data InputPlugin
- data Keys
- data Mouse
- module Mischief.SDL.Window
Mischief Input
This is the official input library for the Mischief game engine. It allows you to read input, such as from a mouse or keyboard.
Dependencies
You will need to manually install the following library (click for install guide):
How to Use
To use this library, add the to your App. This will add the individual plugins for all input types, such as InputPlugin and KeysPlugin.MousePlugin
Keyboard
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 justPressed, pressed, released, justReleased functions to find out the state of a certain key. For instance:
Keys.justPressedkeys 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 justPressed and so on (same as the keys functions) to get the state of a mouse button. For instance:
Mouse.justPressedmouse 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.pos
data InputPlugin Source #
Instances
| Eq InputPlugin Source # | |
Defined in Mischief.Input | |
| Plugin InputPlugin Source # | |
Defined in Mischief.Input | |
Instances
Instances
| Component Mouse Source # | |||||
Defined in Mischief.Input.Mouse Associated Types
| |||||
| type IsExclusiveRel Mouse Source # | |||||
Defined in Mischief.Input.Mouse | |||||
module Mischief.SDL.Window