From 955ce5c82cfa63cc0a1708a08570068db6ee8844 Mon Sep 17 00:00:00 2001 From: Christian Rocha Date: Mon, 31 May 2021 10:27:20 -0400 Subject: [PATCH] Extract magic number in X10 mouse parser --- mouse.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/mouse.go b/mouse.go index 90d147c..928fec8 100644 --- a/mouse.go +++ b/mouse.go @@ -64,7 +64,9 @@ func parseX10MouseEvent(buf []byte) (m MouseEvent, err error) { return m, errors.New("not an X10 mouse event") } - e := buf[3] - 32 + const byteOffset = 32 + + e := buf[3] - byteOffset const ( bitShift = 0b0000_0100 @@ -119,8 +121,8 @@ func parseX10MouseEvent(buf []byte) (m MouseEvent, err error) { } // (1,1) is the upper left. We subtract 1 to normalize it to (0,0). - m.X = int(buf[4]) - 32 - 1 - m.Y = int(buf[5]) - 32 - 1 + m.X = int(buf[4]) - byteOffset - 1 + m.Y = int(buf[5]) - byteOffset - 1 return m, nil }