2021-09-03 07:06:58 +12:00
|
|
|
package payload
|
|
|
|
|
2023-01-21 11:08:27 +13:00
|
|
|
import "math"
|
|
|
|
|
2021-09-03 07:06:58 +12:00
|
|
|
const (
|
|
|
|
OP_MOVE = 0x01
|
|
|
|
OP_SCROLL = 0x02
|
|
|
|
OP_KEY_DOWN = 0x03
|
|
|
|
OP_KEY_UP = 0x04
|
|
|
|
OP_BTN_DOWN = 0x05
|
|
|
|
OP_BTN_UP = 0x06
|
2023-01-21 11:08:27 +13:00
|
|
|
OP_PING = 0x07
|
2023-08-18 02:14:59 +12:00
|
|
|
// touch events
|
|
|
|
OP_TOUCH_BEGIN = 0x08
|
|
|
|
OP_TOUCH_UPDATE = 0x09
|
|
|
|
OP_TOUCH_END = 0x0a
|
2021-09-03 07:06:58 +12:00
|
|
|
)
|
|
|
|
|
|
|
|
type Move struct {
|
|
|
|
X uint16
|
|
|
|
Y uint16
|
|
|
|
}
|
|
|
|
|
2023-09-12 02:34:57 +12:00
|
|
|
// TODO: remove this once the client is fixed
|
|
|
|
type Scroll_Old struct {
|
2021-09-03 07:06:58 +12:00
|
|
|
X int16
|
|
|
|
Y int16
|
|
|
|
}
|
|
|
|
|
2023-09-12 02:34:57 +12:00
|
|
|
type Scroll struct {
|
|
|
|
DeltaX int16
|
|
|
|
DeltaY int16
|
|
|
|
ControlKey bool
|
|
|
|
}
|
|
|
|
|
2021-09-03 07:06:58 +12:00
|
|
|
type Key struct {
|
|
|
|
Key uint32
|
|
|
|
}
|
2023-01-21 11:08:27 +13:00
|
|
|
|
|
|
|
type Ping struct {
|
|
|
|
// client's timestamp split into two uint32
|
|
|
|
ClientTs1 uint32
|
|
|
|
ClientTs2 uint32
|
|
|
|
}
|
|
|
|
|
|
|
|
func (p Ping) ClientTs() uint64 {
|
|
|
|
return (uint64(p.ClientTs1) * uint64(math.MaxUint32)) + uint64(p.ClientTs2)
|
|
|
|
}
|
2023-08-18 02:14:59 +12:00
|
|
|
|
|
|
|
type Touch struct {
|
|
|
|
TouchId uint32
|
|
|
|
X int32
|
|
|
|
Y int32
|
|
|
|
Pressure uint8
|
|
|
|
}
|