ansi-terminal-game-0.1.0.0: platform-dep/windows/Terminal/Game/Input.hs
--------------------------------------------------------------------------------
-- Nonbuffering getChar
-- 2017 Francesco Ariis GPLv3 80cols
--------------------------------------------------------------------------------
{-# LANGUAGE ForeignFunctionInterface #-}
-- see .cabal conditionals for more info
module Terminal.Game.Input where
import qualified Foreign.C.Types as FT
import qualified Data.Char as C
inputCharTerminal :: IO Char
inputCharTerminal = getCharWindows
-- no idea but unsafe breaks it
getCharWindows :: IO Char
getCharWindows = fmap (C.chr . fromEnum) c_getch
foreign import ccall safe "conio.h getch"
c_getch :: IO FT.CInt