Compare commits

..

1 Commits

Author SHA1 Message Date
Scai 364bd8632f
Merge 57fbee1490 into 17baf1647f 2025-05-17 12:43:00 +02:00
4 changed files with 33 additions and 19 deletions

View File

@ -7,8 +7,6 @@
[![Twitter](https://img.shields.io/twitter/url/https/twitter.com/jetkvm.svg?style=social&label=Follow%20%40JetKVM)](https://twitter.com/jetkvm) [![Twitter](https://img.shields.io/twitter/url/https/twitter.com/jetkvm.svg?style=social&label=Follow%20%40JetKVM)](https://twitter.com/jetkvm)
[![Go Report Card](https://goreportcard.com/badge/github.com/jetkvm/kvm)](https://goreportcard.com/report/github.com/jetkvm/kvm)
</div> </div>
JetKVM is a high-performance, open-source KVM over IP (Keyboard, Video, Mouse) solution designed for efficient remote management of computers, servers, and workstations. Whether you're dealing with boot failures, installing a new operating system, adjusting BIOS settings, or simply taking control of a machine from afar, JetKVM provides the tools to get it done effectively. JetKVM is a high-performance, open-source KVM over IP (Keyboard, Video, Mouse) solution designed for efficient remote management of computers, servers, and workstations. Whether you're dealing with boot failures, installing a new operating system, adjusting BIOS settings, or simply taking control of a machine from afar, JetKVM provides the tools to get it done effectively.

View File

@ -107,16 +107,24 @@ func (u *UsbGadget) AbsMouseWheelReport(wheelY int8) error {
u.absMouseLock.Lock() u.absMouseLock.Lock()
defer u.absMouseLock.Unlock() defer u.absMouseLock.Unlock()
// Only send a report if the value is non-zero // Accumulate the wheelY value
if wheelY == 0 { u.absMouseAccumulatedWheelY += float64(wheelY) / 8.0
// Only send a report if the accumulated value is significant
if abs(u.absMouseAccumulatedWheelY) < 1.0 {
return nil return nil
} }
scaledWheelY := int8(u.absMouseAccumulatedWheelY)
err := u.absMouseWriteHidFile([]byte{ err := u.absMouseWriteHidFile([]byte{
2, // Report ID 2 2, // Report ID 2
byte(wheelY), // Wheel Y (signed) byte(scaledWheelY), // Scaled Wheel Y (signed)
}) })
// Reset the accumulator, keeping any remainder
u.absMouseAccumulatedWheelY -= float64(scaledWheelY)
u.resetUserInputTime() u.resetUserInputTime()
return err return err
} }

View File

@ -7,6 +7,14 @@ import (
"path/filepath" "path/filepath"
) )
// Helper function to get absolute value of float64
func abs(x float64) float64 {
if x < 0 {
return -x
}
return x
}
func joinPath(basePath string, paths []string) string { func joinPath(basePath string, paths []string) string {
pathArr := append([]string{basePath}, paths...) pathArr := append([]string{basePath}, paths...)
return filepath.Join(pathArr...) return filepath.Join(pathArr...)

View File

@ -259,25 +259,25 @@ export default function WebRTCVideo() {
(e: WheelEvent) => { (e: WheelEvent) => {
if (blockWheelEvent) return; if (blockWheelEvent) return;
// Determine if the wheel event is an accel scroll value // Determine if the wheel event is from a trackpad or a mouse wheel
const isAccel = Math.abs(e.deltaY) >= 100; const isTrackpad = Math.abs(e.deltaY) < trackpadThreshold;
// Calculate the accel scroll value // Apply appropriate sensitivity based on input device
const accelScrollValue = e.deltaY / 100; const scrollSensitivity = isTrackpad ? trackpadSensitivity : mouseSensitivity;
// Calculate the no accel scroll value // Calculate the scroll value
const noAccelScrollValue = e.deltaY > 0 ? 1 : (e.deltaY < 0 ? -1 : 0); const scroll = e.deltaY * scrollSensitivity;
// Get scroll value // Apply clamping
const scrollValue = isAccel ? accelScrollValue : noAccelScrollValue; const clampedScroll = Math.max(clampMin, Math.min(clampMax, scroll));
// Apply clamping (i.e. min and max mouse wheel hardware value) // Round to the nearest integer
const clampedScrollValue = Math.max(-127, Math.min(127, scrollValue)); const roundedScroll = Math.round(clampedScroll);
// Invert the clamped scroll value to match expected behavior // Invert the scroll value to match expected behavior
const invertedScrollValue = -clampedScrollValue; const invertedScroll = -roundedScroll;
send("wheelReport", { wheelY : invertedScrollValue }); send("wheelReport", { wheelY: invertedScroll });
// Apply blocking delay // Apply blocking delay
setBlockWheelEvent(true); setBlockWheelEvent(true);