diff --git a/inputdevices/exported_methods_auto.go b/inputdevices/exported_methods_auto.go index bae7cc8c2..607dc0a6b 100644 --- a/inputdevices/exported_methods_auto.go +++ b/inputdevices/exported_methods_auto.go @@ -58,6 +58,11 @@ func (v *Manager) GetExportedMethods() dbusutil.ExportedMethods { } func (v *Mouse) GetExportedMethods() dbusutil.ExportedMethods { return dbusutil.ExportedMethods{ + { + Name: "Enable", + Fn: v.Enable, + InArgs: []string{"enabled"}, + }, { Name: "Reset", Fn: v.Reset, @@ -66,6 +71,11 @@ func (v *Mouse) GetExportedMethods() dbusutil.ExportedMethods { } func (v *Touchpad) GetExportedMethods() dbusutil.ExportedMethods { return dbusutil.ExportedMethods{ + { + Name: "Enable", + Fn: v.Enable, + InArgs: []string{"enabled"}, + }, { Name: "Reset", Fn: v.Reset, diff --git a/inputdevices/ifc.go b/inputdevices/ifc.go index 0c5ed389c..80c0ed7a6 100644 --- a/inputdevices/ifc.go +++ b/inputdevices/ifc.go @@ -6,8 +6,8 @@ package inputdevices import ( "github.com/godbus/dbus/v5" + langselector "github.com/linuxdeepin/dde-daemon/langselector1" "github.com/linuxdeepin/go-lib/dbusutil" - "github.com/linuxdeepin/dde-daemon/langselector1" ) func (m *Mouse) Reset() *dbus.Error { @@ -17,6 +17,14 @@ func (m *Mouse) Reset() *dbus.Error { return nil } +func (m *Mouse) Enable(enabled bool) *dbus.Error { + if err := m.enable(enabled); err != nil { + return dbusutil.ToError(err) + } + + return nil +} + func (tp *TrackPoint) Reset() *dbus.Error { for _, key := range tp.setting.ListKeys() { tp.setting.Reset(key) @@ -31,6 +39,11 @@ func (tpad *Touchpad) Reset() *dbus.Error { return nil } +func (tpad *Touchpad) Enable(enabled bool) *dbus.Error { + tpad.enable(enabled) + return nil +} + func (w *Wacom) Reset() *dbus.Error { for _, key := range w.setting.ListKeys() { w.setting.Reset(key) diff --git a/inputdevices/mouse.go b/inputdevices/mouse.go index ebdbd1b41..5662ca11c 100644 --- a/inputdevices/mouse.go +++ b/inputdevices/mouse.go @@ -154,6 +154,19 @@ func (m *Mouse) disableTouchPad() { touchPad.enable(false) } +func (m *Mouse) enable(enabled bool) error { + for _, v := range m.devInfos { + err := v.Enable(enabled) + if err != nil { + logger.Debugf("Enable left handed for '%d - %v' failed: %v", + v.Id, v.Name, err) + return err + } + } + + return nil +} + func (m *Mouse) enableLeftHanded() { enabled := m.LeftHanded.Get() for _, v := range m.devInfos {