Compare commits

..

No commits in common. "118fd0798d41cf0941d638a4552d3222b15c3911" and "54e9be2b53e83cc161407ea5fab01e92ab3dd9cd" have entirely different histories.

4 changed files with 11 additions and 23 deletions

View File

@ -60,13 +60,7 @@ 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
}
@ -109,14 +103,13 @@ func (u *UsbGadget) AbsMouseReport(x, y int, buttons uint8) error {
return nil
}
func (u *UsbGadget) AbsMouseWheelReport(wheelY, wheelX int8) error {
func (u *UsbGadget) AbsMouseWheelReport(wheelY 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", "wheelX"}},
"wheelReport": {Func: rpcWheelReport, Params: []string{"wheelY"}},
"getVideoState": {Func: rpcGetVideoState},
"getUSBState": {Func: rpcGetUSBState},
"unmountImage": {Func: rpcUnmountImage},

View File

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