mischief-input
Safe HaskellNone
LanguageGHC2024

Mischief.Input

Synopsis

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 InputPlugin to your App. This will add the individual plugins for all input types, such as KeysPlugin and 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.justPressed 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 justPressed and so on (same as the keys functions) to get the state of a mouse button. For instance:

Mouse.justPressed 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.pos

data InputPlugin Source #

Instances

Instances details
Eq InputPlugin Source # 
Instance details

Defined in Mischief.Input

Plugin InputPlugin Source # 
Instance details

Defined in Mischief.Input

Methods

deps :: [Dependency]

init :: System ()

data Keys Source #

Instances

Instances details
Default Keys Source # 
Instance details

Defined in Mischief.Input.Keys

Methods

def :: Keys #

Generic Keys Source # 
Instance details

Defined in Mischief.Input.Keys

Associated Types

type Rep Keys 
Instance details

Defined in Mischief.Input.Keys

type Rep Keys = D1 ('MetaData "Keys" "Mischief.Input.Keys" "mischief-input-0.1.0.0-inplace" 'False) (C1 ('MetaCons "Keys" 'PrefixI 'True) (S1 ('MetaSel ('Just "currentKeys") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [CBool]) :*: S1 ('MetaSel ('Just "previousKeys") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [CBool])))

Methods

from :: Keys -> Rep Keys x #

to :: Rep Keys x -> Keys #

Component Keys Source # 
Instance details

Defined in Mischief.Input.Keys

Associated Types

type IsExclusiveRel Keys 
Instance details

Defined in Mischief.Input.Keys

type IsExclusiveRel Keys = 'False

Methods

required :: Set DefaultComponentType

onAdd :: [Hook Keys]

onSet :: [Hook Keys]

onRemove :: [Hook Keys]

onAddRel :: [HookRel Keys]

onSetRel :: [HookRel Keys]

onRemoveRel :: [HookRel Keys]

type Rep Keys Source # 
Instance details

Defined in Mischief.Input.Keys

type Rep Keys = D1 ('MetaData "Keys" "Mischief.Input.Keys" "mischief-input-0.1.0.0-inplace" 'False) (C1 ('MetaCons "Keys" 'PrefixI 'True) (S1 ('MetaSel ('Just "currentKeys") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [CBool]) :*: S1 ('MetaSel ('Just "previousKeys") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [CBool])))
type IsExclusiveRel Keys Source # 
Instance details

Defined in Mischief.Input.Keys

type IsExclusiveRel Keys = 'False

data Mouse Source #

Instances

Instances details
Component Mouse Source # 
Instance details

Defined in Mischief.Input.Mouse

Associated Types

type IsExclusiveRel Mouse 
Instance details

Defined in Mischief.Input.Mouse

type IsExclusiveRel Mouse = 'False

Methods

required :: Set DefaultComponentType

onAdd :: [Hook Mouse]

onSet :: [Hook Mouse]

onRemove :: [Hook Mouse]

onAddRel :: [HookRel Mouse]

onSetRel :: [HookRel Mouse]

onRemoveRel :: [HookRel Mouse]

type IsExclusiveRel Mouse Source # 
Instance details

Defined in Mischief.Input.Mouse

type IsExclusiveRel Mouse = 'False