mirror of
https://github.com/RoganDawes/P4wnP1_aloa.git
synced 2025-11-15 08:32:06 +01:00
Fix: TriggerAction couldn't fire HIDScript during GadgetDeployment by other TriggerAction
This commit is contained in:
@@ -464,7 +464,10 @@ func (tam *TriggerActionManager) executeActionStartHidScript(evt *pb.Event, ta *
|
|||||||
}
|
}
|
||||||
|
|
||||||
err := tam.rootSvc.SubSysUSB.HidScriptUsable()
|
err := tam.rootSvc.SubSysUSB.HidScriptUsable()
|
||||||
if err != nil { return }
|
if err != nil {
|
||||||
|
fmt.Printf("Couldn't start HIDScript: %v\n", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
scriptFile, err := ioutil.ReadFile(scriptPath)
|
scriptFile, err := ioutil.ReadFile(scriptPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -104,6 +104,12 @@ func (gm *UsbGadgetManager) HandleEvent(event hid.Event) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (gm *UsbGadgetManager) HidScriptUsable() error {
|
func (gm *UsbGadgetManager) HidScriptUsable() error {
|
||||||
|
// Fix: If a TriggerAction fires a HIDScript during Deployment of GadgetSettings, this method is called
|
||||||
|
// upfront, to check if mouse or keyboard are up
|
||||||
|
// We avoid returning false, if Deployment is still going on (undefined state), so we block
|
||||||
|
gm.gadgetSettingsLock.Lock()
|
||||||
|
defer gm.gadgetSettingsLock.Unlock()
|
||||||
|
|
||||||
if gm.hidCtl == nil {
|
if gm.hidCtl == nil {
|
||||||
return ErrHidNotUsable
|
return ErrHidNotUsable
|
||||||
}
|
}
|
||||||
@@ -537,11 +543,7 @@ func (gm *UsbGadgetManager) DeployGadgetSettings(settings *pb.GadgetSettings) (e
|
|||||||
|
|
||||||
//Lock, only one change at a time
|
//Lock, only one change at a time
|
||||||
gm.gadgetSettingsLock.Lock()
|
gm.gadgetSettingsLock.Lock()
|
||||||
//defer gm.gadgetSettingsLock.Unlock()
|
defer gm.gadgetSettingsLock.Unlock()
|
||||||
defer func() {
|
|
||||||
//fmt.Println("UNLOCKING DeployGadgetSettings")
|
|
||||||
gm.gadgetSettingsLock.Unlock()
|
|
||||||
}()
|
|
||||||
//fmt.Println("DeployGadgetSettings beyond lock ...")
|
//fmt.Println("DeployGadgetSettings beyond lock ...")
|
||||||
|
|
||||||
err = ValidateGadgetSetting(settings)
|
err = ValidateGadgetSetting(settings)
|
||||||
|
|||||||
Reference in New Issue
Block a user