mirror of
https://github.com/sipeed/NanoKVM.git
synced 2026-09-11 00:22:56 -05:00
* Add ability to properly configure logrus (e.x. specify output file) * Make the code slightly more ideomatic (sort imports, etc) * Replace some of the shell calls with equivalent native code * Fix update process * Improve error handling (handle 2 previously unhandled errors) * Add locking for HID operations and make a HID-operations struct a singleton
37 lines
422 B
Go
37 lines
422 B
Go
package hid
|
|
|
|
import (
|
|
"os"
|
|
"sync"
|
|
)
|
|
|
|
var (
|
|
hid *Hid
|
|
hidOnce sync.Once
|
|
)
|
|
|
|
type Hid struct {
|
|
g0 *os.File
|
|
g1 *os.File
|
|
g2 *os.File
|
|
kbMutex sync.Mutex
|
|
mouseMutex sync.Mutex
|
|
}
|
|
|
|
func (h *Hid) Lock() {
|
|
h.kbMutex.Lock()
|
|
h.mouseMutex.Lock()
|
|
}
|
|
|
|
func (h *Hid) Unlock() {
|
|
h.kbMutex.Unlock()
|
|
h.mouseMutex.Unlock()
|
|
}
|
|
|
|
func GetHid() *Hid {
|
|
hidOnce.Do(func() {
|
|
hid = &Hid{}
|
|
})
|
|
return hid
|
|
}
|