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 }