module Input where import Char (toCode) import Keyboard (KeyCode, keysDown, arrows, isDown) import Random import Time (Time, fps) import Signal (..) import Model.Vec2 (Vec2) type alias Input = { dir : Vec2 , inputKeysDown : List KeyCode , delta : Time } getInput : Signal Input getInput = let delta = fps 25 input = Input <~ map recordIntToVec2 arrows ~ keysDown ~ delta in sampleOn delta input recordIntToVec2 : {x : Int, y : Int} -> Vec2 recordIntToVec2 {x, y} = { x = toFloat x , y = toFloat y }