mirror of https://github.com/jetkvm/kvm.git
Use harcoded timer reset value for now
This commit is contained in:
parent
6892eeba42
commit
b1f345db70
|
@ -168,14 +168,10 @@ func (u *UsbGadget) scheduleAutoRelease(key byte) {
|
|||
u.kbdAutoReleaseTimers[key].Stop()
|
||||
}
|
||||
|
||||
duration := u.kbdAutoReleaseTimerExtension
|
||||
if duration == 0 {
|
||||
duration = DefaultAutoReleaseDuration
|
||||
}
|
||||
|
||||
u.log.Debug().Dur("duration", duration).Msg("autoRelease scheduled with duration")
|
||||
|
||||
u.kbdAutoReleaseTimers[key] = time.AfterFunc(duration, func() {
|
||||
// TODO: make this configurable
|
||||
// We currently hardcode the duration to 100ms
|
||||
// However, it should be the same as the duration of the keep-alive reset called baseExtension.
|
||||
u.kbdAutoReleaseTimers[key] = time.AfterFunc(100*time.Millisecond, func() {
|
||||
u.performAutoRelease(key)
|
||||
})
|
||||
}
|
||||
|
@ -204,8 +200,6 @@ func (u *UsbGadget) DelayAutoReleaseWithDuration(resetDuration time.Duration) {
|
|||
return
|
||||
}
|
||||
|
||||
u.kbdAutoReleaseTimerExtension = resetDuration
|
||||
|
||||
u.log.Debug().Dur("reset_duration", resetDuration).Msg("delaying auto-release with dynamic duration")
|
||||
|
||||
for _, timer := range u.kbdAutoReleaseTimers {
|
||||
|
|
|
@ -68,9 +68,8 @@ type UsbGadget struct {
|
|||
keyboardState byte // keyboard latched state (NumLock, CapsLock, ScrollLock, Compose, Kana)
|
||||
keysDownState KeysDownState // keyboard dynamic state (modifier keys and pressed keys)
|
||||
|
||||
kbdAutoReleaseLock sync.Mutex
|
||||
kbdAutoReleaseTimers map[byte]*time.Timer
|
||||
kbdAutoReleaseTimerExtension time.Duration
|
||||
kbdAutoReleaseLock sync.Mutex
|
||||
kbdAutoReleaseTimers map[byte]*time.Timer
|
||||
|
||||
keyboardStateLock sync.Mutex
|
||||
keyboardStateCtx context.Context
|
||||
|
@ -123,25 +122,24 @@ func newUsbGadget(name string, configMap map[string]gadgetConfigItem, enabledDev
|
|||
keyboardCtx, keyboardCancel := context.WithCancel(context.Background())
|
||||
|
||||
g := &UsbGadget{
|
||||
name: name,
|
||||
kvmGadgetPath: path.Join(gadgetPath, name),
|
||||
configC1Path: path.Join(gadgetPath, name, "configs/c.1"),
|
||||
configMap: configMap,
|
||||
customConfig: *config,
|
||||
configLock: sync.Mutex{},
|
||||
keyboardLock: sync.Mutex{},
|
||||
absMouseLock: sync.Mutex{},
|
||||
relMouseLock: sync.Mutex{},
|
||||
txLock: sync.Mutex{},
|
||||
keyboardStateCtx: keyboardCtx,
|
||||
keyboardStateCancel: keyboardCancel,
|
||||
keyboardState: 0,
|
||||
keysDownState: KeysDownState{Modifier: 0, Keys: []byte{0, 0, 0, 0, 0, 0}}, // must be initialized to hidKeyBufferSize (6) zero bytes
|
||||
kbdAutoReleaseTimers: make(map[byte]*time.Timer),
|
||||
kbdAutoReleaseTimerExtension: 0,
|
||||
enabledDevices: *enabledDevices,
|
||||
lastUserInput: time.Now(),
|
||||
log: logger,
|
||||
name: name,
|
||||
kvmGadgetPath: path.Join(gadgetPath, name),
|
||||
configC1Path: path.Join(gadgetPath, name, "configs/c.1"),
|
||||
configMap: configMap,
|
||||
customConfig: *config,
|
||||
configLock: sync.Mutex{},
|
||||
keyboardLock: sync.Mutex{},
|
||||
absMouseLock: sync.Mutex{},
|
||||
relMouseLock: sync.Mutex{},
|
||||
txLock: sync.Mutex{},
|
||||
keyboardStateCtx: keyboardCtx,
|
||||
keyboardStateCancel: keyboardCancel,
|
||||
keyboardState: 0,
|
||||
keysDownState: KeysDownState{Modifier: 0, Keys: []byte{0, 0, 0, 0, 0, 0}}, // must be initialized to hidKeyBufferSize (6) zero bytes
|
||||
kbdAutoReleaseTimers: make(map[byte]*time.Timer),
|
||||
enabledDevices: *enabledDevices,
|
||||
lastUserInput: time.Now(),
|
||||
log: logger,
|
||||
|
||||
strictMode: config.strictMode,
|
||||
|
||||
|
|
Loading…
Reference in New Issue