| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Nes.Controller
Contents
Synopsis
- data ControllerState = MkCS {
- strobe :: !Bool
- buttonIdx :: !Byte
- buttonStatus :: !ControllerButtonStatus
- newControllerState :: ControllerState
- newtype ControllerButtonStatus = MkCBS {}
- data ControllerButton
- newtype Controller r a = MkC {
- unC :: ControllerState -> (ControllerState -> a -> r) -> r
- runController :: Controller (a, ControllerState) a -> ControllerState -> (a, ControllerState)
- setStrobe :: Byte -> Controller r ()
- setButtonAsPressed :: ControllerButton -> Bool -> Controller r ()
- readButtonStatus :: Controller r Byte
Documentation
data ControllerState Source #
Constructors
| MkCS | |
Fields
| |
newtype ControllerButtonStatus Source #
Instances
| FlagRegister ControllerButtonStatus Source # | |||||
Defined in Nes.Controller Associated Types
Methods fromByte :: Byte -> ControllerButtonStatus Source # toByte :: ControllerButtonStatus -> Byte Source # flagToBitOffset :: Flag ControllerButtonStatus -> Int Source # | |||||
| type Flag ControllerButtonStatus Source # | |||||
Defined in Nes.Controller | |||||
data ControllerButton Source #
Instances
| Enum ControllerButton Source # | |
Defined in Nes.Controller Methods succ :: ControllerButton -> ControllerButton # pred :: ControllerButton -> ControllerButton # toEnum :: Int -> ControllerButton # fromEnum :: ControllerButton -> Int # enumFrom :: ControllerButton -> [ControllerButton] # enumFromThen :: ControllerButton -> ControllerButton -> [ControllerButton] # enumFromTo :: ControllerButton -> ControllerButton -> [ControllerButton] # enumFromThenTo :: ControllerButton -> ControllerButton -> ControllerButton -> [ControllerButton] # | |
| Show ControllerButton Source # | |
Defined in Nes.Controller Methods showsPrec :: Int -> ControllerButton -> ShowS # show :: ControllerButton -> String # showList :: [ControllerButton] -> ShowS # | |
| Eq ControllerButton Source # | |
Defined in Nes.Controller Methods (==) :: ControllerButton -> ControllerButton -> Bool # (/=) :: ControllerButton -> ControllerButton -> Bool # | |
Monad
newtype Controller r a Source #
Constructors
| MkC | |
Fields
| |
runController :: Controller (a, ControllerState) a -> ControllerState -> (a, ControllerState) Source #
setStrobe :: Byte -> Controller r () Source #
Sets the strobe state if the byte's first bit is set
setButtonAsPressed :: ControllerButton -> Bool -> Controller r () Source #
readButtonStatus :: Controller r Byte Source #
Returns 1 if the button at the buttonIdx is pressed, or 0 if not.
Increments the buttonIdx Always returns 1 when the offset if larger than the button count