project structure refactoring

This commit is contained in:
Artem
2024-11-05 23:47:00 +01:00
parent 1f5a56cc5d
commit c228921237
16 changed files with 51 additions and 47 deletions

64
hid/hid.go Normal file
View File

@@ -0,0 +1,64 @@
package hid
import (
"os"
"sync"
)
const (
MouseUp = iota
MouseDown
MouseMoveAbsolute
MouseMoveRelative
MouseScroll
)
const (
MouseLeft = 1
MouseRight = 2
MouseWheel = 3
)
const (
HidMouseLeft byte = 0x01
HidMouseRight byte = 0x02
HidMouseWheel byte = 0x04
)
const (
ModifierLCtrl byte = 0x01
ModifierLShift byte = 0x02
ModifierLAlt byte = 0x04
ModifierLGUI byte = 0x08
ModifierRAlt byte = 0x40
)
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
}