mirror of https://github.com/jetkvm/kvm.git
Compare commits
5 Commits
54e9be2b53
...
118fd0798d
Author | SHA1 | Date |
---|---|---|
|
118fd0798d | |
|
6f8004e9ba | |
|
2ff72aec6a | |
|
4494d87acb | |
|
7670e87ab5 |
|
@ -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()
|
||||
|
|
|
@ -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},
|
||||
|
|
|
@ -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
4
usb.go
|
@ -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"
|
||||
|
|
Loading…
Reference in New Issue