uinput: Detect unsupported platform
This commit is contained in:
parent
891fde7051
commit
37dff3cb6b
2 changed files with 8 additions and 1 deletions
|
|
@ -23,6 +23,7 @@
|
||||||
package inputcontrol
|
package inputcontrol
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/bendahl/uinput"
|
"github.com/bendahl/uinput"
|
||||||
"log"
|
"log"
|
||||||
|
|
@ -52,10 +53,16 @@ func InitUinputController() (Controller, error) {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
keyboard, err := uinput.CreateKeyboard("/dev/uinput", []byte("remote-touchpad-keyboard"))
|
keyboard, err := uinput.CreateKeyboard("/dev/uinput", []byte("remote-touchpad-keyboard"))
|
||||||
|
if errors.Is(err, os.ErrNotExist) || errors.Is(err, os.ErrPermission) {
|
||||||
|
err = &UnsupportedPlatformError{err}
|
||||||
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
mouse, err := uinput.CreateMouse("/dev/uinput", []byte("remote-touchpad-mouse"))
|
mouse, err := uinput.CreateMouse("/dev/uinput", []byte("remote-touchpad-mouse"))
|
||||||
|
if errors.Is(err, os.ErrNotExist) || errors.Is(err, os.ErrPermission) {
|
||||||
|
err = &UnsupportedPlatformError{err}
|
||||||
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
keyboard.Close()
|
keyboard.Close()
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|
|
||||||
|
|
@ -61,7 +61,7 @@ func LoadKeymap(name string) (*Keymap, error) {
|
||||||
}
|
}
|
||||||
bkeymap, err := exec.Command("loadkeys", "--bkeymap", name).Output()
|
bkeymap, err := exec.Command("loadkeys", "--bkeymap", name).Output()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, &UnsupportedPlatformError{err}
|
||||||
}
|
}
|
||||||
if !strings.HasPrefix(string(bkeymap), bkeymapFileSignature) {
|
if !strings.HasPrefix(string(bkeymap), bkeymapFileSignature) {
|
||||||
return nil, fmt.Errorf("invalid bkeymap: signature not found")
|
return nil, fmt.Errorf("invalid bkeymap: signature not found")
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue