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
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"github.com/bendahl/uinput"
|
||||
"log"
|
||||
|
|
@ -52,10 +53,16 @@ func InitUinputController() (Controller, error) {
|
|||
return nil, err
|
||||
}
|
||||
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 {
|
||||
return nil, err
|
||||
}
|
||||
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 {
|
||||
keyboard.Close()
|
||||
return nil, err
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ func LoadKeymap(name string) (*Keymap, error) {
|
|||
}
|
||||
bkeymap, err := exec.Command("loadkeys", "--bkeymap", name).Output()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return nil, &UnsupportedPlatformError{err}
|
||||
}
|
||||
if !strings.HasPrefix(string(bkeymap), bkeymapFileSignature) {
|
||||
return nil, fmt.Errorf("invalid bkeymap: signature not found")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue