summaryrefslogtreecommitdiff
path: root/m4p
diff options
context:
space:
mode:
Diffstat (limited to 'm4p')
-rw-r--r--m4p/client.go9
-rw-r--r--m4p/message.go20
2 files changed, 26 insertions, 3 deletions
diff --git a/m4p/client.go b/m4p/client.go
index 45f8b77..3467b3f 100644
--- a/m4p/client.go
+++ b/m4p/client.go
@@ -2,7 +2,6 @@ package m4p
import (
"context"
- "encoding/hex"
"encoding/json"
"errors"
"fmt"
@@ -132,8 +131,14 @@ recvLoop:
case InputMessage:
log.Printf("m4p: Client: recv: got %s: %v", m.Type, m.Input)
+ case MouseMessage:
+ log.Printf("m4p: Client: recv: got %s: %v", m.Type, m.Mouse)
+
+ case WheelMessage:
+ log.Printf("m4p: Client: recv: got %s: %v", m.Type, m.Wheel)
+
case RemoteUpdateMessage:
- log.Printf("m4p: Client: recv: got %s: %s", m.Type, hex.EncodeToString(m.RemoteUpdate.Payload))
+ // log.Printf("m4p: Client: recv: got %s: %s", m.Type, hex.EncodeToString(m.RemoteUpdate.Payload))
default:
log.Printf("m4p: Client: recv: unknown message: %s", m.Type)
diff --git a/m4p/message.go b/m4p/message.go
index 34a9383..0a9ebeb 100644
--- a/m4p/message.go
+++ b/m4p/message.go
@@ -13,6 +13,8 @@ const (
SubSensorMessage MessageType = "sub_sensor"
RemoteUpdateMessage MessageType = "remote_update"
InputMessage MessageType = "input"
+ MouseMessage MessageType = "mouse"
+ WheelMessage MessageType = "wheel"
KeepAliveMessage MessageType = "keepalive"
)
@@ -24,6 +26,8 @@ type Message struct {
*Register
*RemoteUpdate
*Input
+ Mouse Mouse `json:"mouse"`
+ Wheel Wheel `json:"wheel"`
}
// NewMessage initializes a message with the type and protocol version.
@@ -62,10 +66,24 @@ type RemoteUpdate struct {
Payload []byte `json:"payload"`
}
+type Coordinates struct {
+ X int32 `json:"x"`
+ Y int32 `json:"y"`
+}
+
+type Mouse struct {
+ Type string `json:"type"` // mousedown, mouseup
+ Coordinates
+}
+
+type Wheel struct {
+ Delta int32 `json:"delta"`
+ Coordinates
+}
+
// type (
// ReturnValue uint8
// DeviceID uint8
-// Coordinates struct{ X, Y int32 }
// Gyroscope struct{ X, Y, Z float32 }
// Acceleration struct{ X, Y, Z float32 }
// Quaternion struct{ Q0, Q1, Q2, Q3 float32 }