Allow button targets to handle keyboard events.
This commit is contained in:
parent
61fe5208e6
commit
32fa7d27e0
4 changed files with 123 additions and 88 deletions
|
@ -8,13 +8,23 @@ import (
|
|||
"github.com/holoplot/go-evdev"
|
||||
)
|
||||
|
||||
func parseCodeButton(code string) (evdev.EvCode, error) {
|
||||
prefix := CodePrefixButton
|
||||
|
||||
if strings.HasPrefix(code, CodePrefixKey+"_") {
|
||||
prefix = CodePrefixKey
|
||||
}
|
||||
|
||||
return parseCode(code, prefix)
|
||||
}
|
||||
|
||||
func parseCode(code, prefix string) (evdev.EvCode, error) {
|
||||
code = strings.ToUpper(code)
|
||||
|
||||
var codeLookup map[string]evdev.EvCode
|
||||
|
||||
switch prefix {
|
||||
case CodePrefixButton:
|
||||
case CodePrefixButton, CodePrefixKey:
|
||||
codeLookup = evdev.KEYFromString
|
||||
case CodePrefixAxis:
|
||||
codeLookup = evdev.ABSFromString
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue