Add device locking with a flag to disable for testing.
This commit is contained in:
parent
7f104f054a
commit
9652df9366
2 changed files with 12 additions and 5 deletions
|
@ -66,7 +66,7 @@ func (parser *ConfigParser) CreateVirtualDevices() map[string]*evdev.InputDevice
|
|||
// This function assumes you have already called Parse() on the config directory.
|
||||
//
|
||||
// This function should only be called once.
|
||||
func (parser *ConfigParser) ConnectPhysicalDevices() map[string]*evdev.InputDevice {
|
||||
func (parser *ConfigParser) ConnectPhysicalDevices(lock bool) map[string]*evdev.InputDevice {
|
||||
deviceMap := make(map[string]*evdev.InputDevice)
|
||||
|
||||
for _, deviceConfig := range parser.config.Devices {
|
||||
|
@ -80,7 +80,12 @@ func (parser *ConfigParser) ConnectPhysicalDevices() map[string]*evdev.InputDevi
|
|||
continue
|
||||
}
|
||||
|
||||
// TODO: grab exclusive access to device (add config option)
|
||||
if lock {
|
||||
err := device.Grab()
|
||||
if err != nil {
|
||||
logger.LogError(err, "Failed to grab device for exclusive access")
|
||||
}
|
||||
}
|
||||
|
||||
logger.Log(fmt.Sprintf("Connected to '%s' as '%s'", deviceConfig.DeviceName, deviceConfig.Name))
|
||||
deviceMap[deviceConfig.Name] = device
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue