Compare commits

...

5 Commits

Author SHA1 Message Date
rmschooley 118fd0798d
Update jsonrpc.go
Added support for mouse wheel horizontal scrolling.
2025-05-15 23:09:35 -05:00
rmschooley 6f8004e9ba
Update WebRTCVideo.tsx
Added support for mouse wheel vertical scrolling.
2025-05-15 23:07:05 -05:00
rmschooley 2ff72aec6a
Update hid_mouse_absolute.go
Minor syntax change.
2025-05-15 22:57:29 -05:00
rmschooley 4494d87acb
Update usb.go
Added support for mouse wheel vertical scroll.
2025-05-15 22:53:58 -05:00
rmschooley 7670e87ab5
Update hid_mouse_absolute.go
Added support for mouse vertical wheel scrolling.
2025-05-15 22:51:47 -05:00
4 changed files with 23 additions and 11 deletions

View File

@ -60,7 +60,13 @@ var absoluteMouseCombinedReportDesc = []byte{
0x75, 0x08, // Report Size (8)
0x95, 0x01, // Report Count (1)
0x81, 0x06, // Input (Data, Var, Rel)
0x05, 0x0C, // Usage Page (Consumer Ctrls)
0x0A, 0x38, 0x02, // Usage (AC Pan)
0x15, 0x81, // Logical Minimum (-127)
0x25, 0x7F, // Logical Maximum (127)
0x75, 0x08, // Report Size (8)
0x95, 0x01, // Report Count (1)
0x81, 0x06, // Input (Data, Var, Rel)
0xC0, // End Collection
}
@ -103,13 +109,14 @@ func (u *UsbGadget) AbsMouseReport(x, y int, buttons uint8) error {
return nil
}
func (u *UsbGadget) AbsMouseWheelReport(wheelY int8) error {
func (u *UsbGadget) AbsMouseWheelReport(wheelY, wheelX int8) error {
u.absMouseLock.Lock()
defer u.absMouseLock.Unlock()
err := u.absMouseWriteHidFile([]byte{
2, // Report ID 2
byte(wheelY), // Wheel Y (signed)
byte(wheelX), // Wheel X (signed)
})
u.resetUserInputTime()

View File

@ -994,7 +994,7 @@ var rpcHandlers = map[string]RPCHandler{
"keyboardReport": {Func: rpcKeyboardReport, Params: []string{"modifier", "keys"}},
"absMouseReport": {Func: rpcAbsMouseReport, Params: []string{"x", "y", "buttons"}},
"relMouseReport": {Func: rpcRelMouseReport, Params: []string{"dx", "dy", "buttons"}},
"wheelReport": {Func: rpcWheelReport, Params: []string{"wheelY"}},
"wheelReport": {Func: rpcWheelReport, Params: []string{"wheelY", "wheelX"}},
"getVideoState": {Func: rpcGetVideoState},
"getUSBState": {Func: rpcGetUSBState},
"unmountImage": {Func: rpcUnmountImage},

View File

@ -260,21 +260,26 @@ export default function WebRTCVideo() {
if (blockWheelEvent) return;
// Determine if the wheel event is an accelerable scroll value
const isAccel = Math.abs(e.deltaY) >= 100;
const isAccelY = Math.abs(e.deltaY) >= 100;
const isAccelX = Math.abs(e.deltaX) >= 100;
// Calculate the accelerable scroll value
const accelScrollValue = e.deltaY / 100;
const accelScrollValueY = e.deltaY / 100;
const accelScrollValueX = e.deltaX / 100;
// Calculate the non-accelerable scroll value
const nonAccelScrollValue = e.deltaY > 0 ? 1: -1;
const nonAccelScrollValueY = e.deltaY > 0 ? 1 : e.deltaY < 0 ? -1 : 0;
const nonAccelScrollValueX = e.deltaX > 0 ? 1 : e.deltaX < 0 ? -1 : 0;
// Get actual scroll value
const scrollValue = isAccel ? accelScrollValue : nonAccelScrollValue;
const scrollValueY = isAccelY ? accelScrollValueY : nonAccelScrollValueY;
const scrollValueX = isAccelX ? accelScrollValueX : nonAccelScrollValueX;
// Apply clamping (i.e. min and max mouse wheel hardware value)
const clampedScrollValue = Math.max(-128, Math.min(127, scrollValue));
const clampedScrollValueY = Math.max(-127, Math.min(127, scrollValueY));
const clampedScrollValueX = Math.max(-127, Math.min(127, scrollValueX));
send("wheelReport", { wheelY: clampedScrollValue });
send("wheelReport", { wheelY: clampedScrollValueY, wheelX : clampedScrollValueX });
// Apply blocking delay
setBlockWheelEvent(true);

4
usb.go
View File

@ -38,8 +38,8 @@ func rpcRelMouseReport(dx, dy int8, buttons uint8) error {
return gadget.RelMouseReport(dx, dy, buttons)
}
func rpcWheelReport(wheelY int8) error {
return gadget.AbsMouseWheelReport(wheelY)
func rpcWheelReport(wheelY, wheelX int8) error {
return gadget.AbsMouseWheelReport(wheelY, wheelX)
}
var usbState = "unknown"