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()
|
u.kbdAutoReleaseTimers[key].Stop()
|
||||||
}
|
}
|
||||||
|
|
||||||
duration := u.kbdAutoReleaseTimerExtension
|
// TODO: make this configurable
|
||||||
if duration == 0 {
|
// We currently hardcode the duration to 100ms
|
||||||
duration = DefaultAutoReleaseDuration
|
// 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.log.Debug().Dur("duration", duration).Msg("autoRelease scheduled with duration")
|
|
||||||
|
|
||||||
u.kbdAutoReleaseTimers[key] = time.AfterFunc(duration, func() {
|
|
||||||
u.performAutoRelease(key)
|
u.performAutoRelease(key)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -204,8 +200,6 @@ func (u *UsbGadget) DelayAutoReleaseWithDuration(resetDuration time.Duration) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
u.kbdAutoReleaseTimerExtension = resetDuration
|
|
||||||
|
|
||||||
u.log.Debug().Dur("reset_duration", resetDuration).Msg("delaying auto-release with dynamic duration")
|
u.log.Debug().Dur("reset_duration", resetDuration).Msg("delaying auto-release with dynamic duration")
|
||||||
|
|
||||||
for _, timer := range u.kbdAutoReleaseTimers {
|
for _, timer := range u.kbdAutoReleaseTimers {
|
||||||
|
|
|
@ -68,9 +68,8 @@ type UsbGadget struct {
|
||||||
keyboardState byte // keyboard latched state (NumLock, CapsLock, ScrollLock, Compose, Kana)
|
keyboardState byte // keyboard latched state (NumLock, CapsLock, ScrollLock, Compose, Kana)
|
||||||
keysDownState KeysDownState // keyboard dynamic state (modifier keys and pressed keys)
|
keysDownState KeysDownState // keyboard dynamic state (modifier keys and pressed keys)
|
||||||
|
|
||||||
kbdAutoReleaseLock sync.Mutex
|
kbdAutoReleaseLock sync.Mutex
|
||||||
kbdAutoReleaseTimers map[byte]*time.Timer
|
kbdAutoReleaseTimers map[byte]*time.Timer
|
||||||
kbdAutoReleaseTimerExtension time.Duration
|
|
||||||
|
|
||||||
keyboardStateLock sync.Mutex
|
keyboardStateLock sync.Mutex
|
||||||
keyboardStateCtx context.Context
|
keyboardStateCtx context.Context
|
||||||
|
@ -123,25 +122,24 @@ func newUsbGadget(name string, configMap map[string]gadgetConfigItem, enabledDev
|
||||||
keyboardCtx, keyboardCancel := context.WithCancel(context.Background())
|
keyboardCtx, keyboardCancel := context.WithCancel(context.Background())
|
||||||
|
|
||||||
g := &UsbGadget{
|
g := &UsbGadget{
|
||||||
name: name,
|
name: name,
|
||||||
kvmGadgetPath: path.Join(gadgetPath, name),
|
kvmGadgetPath: path.Join(gadgetPath, name),
|
||||||
configC1Path: path.Join(gadgetPath, name, "configs/c.1"),
|
configC1Path: path.Join(gadgetPath, name, "configs/c.1"),
|
||||||
configMap: configMap,
|
configMap: configMap,
|
||||||
customConfig: *config,
|
customConfig: *config,
|
||||||
configLock: sync.Mutex{},
|
configLock: sync.Mutex{},
|
||||||
keyboardLock: sync.Mutex{},
|
keyboardLock: sync.Mutex{},
|
||||||
absMouseLock: sync.Mutex{},
|
absMouseLock: sync.Mutex{},
|
||||||
relMouseLock: sync.Mutex{},
|
relMouseLock: sync.Mutex{},
|
||||||
txLock: sync.Mutex{},
|
txLock: sync.Mutex{},
|
||||||
keyboardStateCtx: keyboardCtx,
|
keyboardStateCtx: keyboardCtx,
|
||||||
keyboardStateCancel: keyboardCancel,
|
keyboardStateCancel: keyboardCancel,
|
||||||
keyboardState: 0,
|
keyboardState: 0,
|
||||||
keysDownState: KeysDownState{Modifier: 0, Keys: []byte{0, 0, 0, 0, 0, 0}}, // must be initialized to hidKeyBufferSize (6) zero bytes
|
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),
|
kbdAutoReleaseTimers: make(map[byte]*time.Timer),
|
||||||
kbdAutoReleaseTimerExtension: 0,
|
enabledDevices: *enabledDevices,
|
||||||
enabledDevices: *enabledDevices,
|
lastUserInput: time.Now(),
|
||||||
lastUserInput: time.Now(),
|
log: logger,
|
||||||
log: logger,
|
|
||||||
|
|
||||||
strictMode: config.strictMode,
|
strictMode: config.strictMode,
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue