summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/Scanner.hs16
1 files changed, 6 insertions, 10 deletions
diff --git a/src/Scanner.hs b/src/Scanner.hs
index 993793c..24546be 100644
--- a/src/Scanner.hs
+++ b/src/Scanner.hs
@@ -164,16 +164,12 @@ hWaitLookAhead t h = do
decodeMouseEvent :: Int -> Int -> Int -> Bool -> Scan
decodeMouseEvent b x y pressed =
let
- button = case (b .&. 3) + (b .&. 64) of
- 0 -> 1
- 1 -> 2
- 2 -> 3
- 64 -> 4 -- wheel up
- 65 -> 5 -- wheel down
- 66 -> 6 -- wheel left
- 67 -> 7 -- wheel right
- 3 -> 0 -- X10 release
- btn -> error $ "TODO proper parseNormalButton error: " ++ show btn
+ button = case (b .&. 192, b .&. 3) of
+ (0, 3) -> 0 -- X10 release
+ (0, n) -> n + 1 -- buttons 1 to 3
+ (64, n) -> n + 4 -- wheel up, down, left, right
+ (128, n) -> n + 8 -- buttons 8 to 11
+ (_, n) -> n + 12 -- unassigned
in
ScanMouse
{ mouseButton = button