We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
uinput-echo
1 parent a014ea8 commit 5d3d3a2Copy full SHA for 5d3d3a2
evdev-examples/uinput/Main.hs
@@ -1,7 +1,10 @@
1
module Main (main) where
2
3
+import Control.Exception
4
import Control.Monad
5
import Data.Maybe (mapMaybe)
6
+import System.Exit
7
+import System.IO.Error
8
9
import qualified Evdev.Codes as Codes
10
import Evdev.Uinput
@@ -13,7 +16,11 @@ main = do
13
16
"haskell-uinput-echo-example"
14
17
defaultDeviceOpts{keys = mapMaybe charToEvent (['a' .. 'z'] ++ ['0' .. '9'])}
15
18
forever do
- cs <- getLine
19
+ cs <-
20
+ catchJust
21
+ (guard . isEOFError)
22
+ getLine
23
+ \() -> exitSuccess
24
writeBatch dev [KeyEvent k a | Just k <- map charToEvent cs, a <- [Pressed, Released]]
25
26
charToEvent :: Char -> Maybe Codes.Key
0 commit comments