Include missing rune, key or button in error
This commit is contained in:
parent
6f03281fc7
commit
124152f7ec
4 changed files with 10 additions and 9 deletions
|
|
@ -245,7 +245,7 @@ func (p *portalController) PointerButton(button PointerButton, press bool) error
|
||||||
case PointerButtonRight:
|
case PointerButtonRight:
|
||||||
btn = btnRight
|
btn = btnRight
|
||||||
default:
|
default:
|
||||||
return errors.New("unsupported pointer button")
|
return fmt.Errorf("unsupported pointer button: %#v", button)
|
||||||
}
|
}
|
||||||
state := btnReleased
|
state := btnReleased
|
||||||
if press {
|
if press {
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@
|
||||||
package inputcontrol
|
package inputcontrol
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"fmt"
|
||||||
"syscall"
|
"syscall"
|
||||||
"unsafe"
|
"unsafe"
|
||||||
)
|
)
|
||||||
|
|
@ -173,7 +173,7 @@ func (p *windowsController) KeyboardKey(key Key) error {
|
||||||
case KeyMediaPlayPause:
|
case KeyMediaPlayPause:
|
||||||
input.wVk = vkMediaPlayPause
|
input.wVk = vkMediaPlayPause
|
||||||
default:
|
default:
|
||||||
return errors.New("key not mapped to virtual-key code")
|
return fmt.Errorf("key not mapped to virtual-key code: %#v", key)
|
||||||
}
|
}
|
||||||
inputs := [...]keybdInput{input, input}
|
inputs := [...]keybdInput{input, input}
|
||||||
inputs[1].dwFlags |= keyeventfKeyup
|
inputs[1].dwFlags |= keyeventfKeyup
|
||||||
|
|
@ -195,7 +195,7 @@ func (p *windowsController) PointerButton(button PointerButton, press bool) erro
|
||||||
} else if button == PointerButtonRight {
|
} else if button == PointerButtonRight {
|
||||||
input.dwFlags = mouseeventfRightup
|
input.dwFlags = mouseeventfRightup
|
||||||
} else {
|
} else {
|
||||||
return errors.New("unsupported pointer button")
|
return fmt.Errorf("unsupported pointer button: %#v", button)
|
||||||
}
|
}
|
||||||
if r, _, err := sendInputProc.Call(1, uintptr(unsafe.Pointer(&input)),
|
if r, _, err := sendInputProc.Call(1, uintptr(unsafe.Pointer(&input)),
|
||||||
unsafe.Sizeof(input)); int(r) != 1 {
|
unsafe.Sizeof(input)); int(r) != 1 {
|
||||||
|
|
|
||||||
|
|
@ -33,6 +33,7 @@ package inputcontrol
|
||||||
import "C"
|
import "C"
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
@ -309,7 +310,7 @@ func (p *x11Controller) PointerButton(button PointerButton, press bool) error {
|
||||||
case PointerButtonMiddle:
|
case PointerButtonMiddle:
|
||||||
return p.sendButton(2, press)
|
return p.sendButton(2, press)
|
||||||
default:
|
default:
|
||||||
return errors.New("unsupported pointer button")
|
return fmt.Errorf("unsupported pointer button: %#v", button)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ package inputcontrol
|
||||||
|
|
||||||
//go:generate go run keysyms.generator.go
|
//go:generate go run keysyms.generator.go
|
||||||
|
|
||||||
import "errors"
|
import "fmt"
|
||||||
|
|
||||||
type Keysym int32
|
type Keysym int32
|
||||||
|
|
||||||
|
|
@ -57,8 +57,8 @@ func RuneToKeysym(runeValue rune) (Keysym, error) {
|
||||||
keysym, found := keysymsMap[runeValue]
|
keysym, found := keysymsMap[runeValue]
|
||||||
if !found {
|
if !found {
|
||||||
if runeValue < 0x100 || runeValue > 0x10ffff {
|
if runeValue < 0x100 || runeValue > 0x10ffff {
|
||||||
return 0, errors.New("rune not mappend to keysym and " +
|
return 0, fmt.Errorf("rune not mappend to keysym and "+
|
||||||
"out of range for direct unicode mapping")
|
"out of range for direct unicode mapping: %q", runeValue)
|
||||||
}
|
}
|
||||||
keysym = Keysym(0x01000000 + runeValue)
|
keysym = Keysym(0x01000000 + runeValue)
|
||||||
}
|
}
|
||||||
|
|
@ -104,6 +104,6 @@ func KeyToKeysym(key Key) (Keysym, error) {
|
||||||
case KeyBrowserForward:
|
case KeyBrowserForward:
|
||||||
return xf86xkForward, nil
|
return xf86xkForward, nil
|
||||||
default:
|
default:
|
||||||
return 0, errors.New("key not mapped to keysym")
|
return 0, fmt.Errorf("key not mapped to keysym: %#v", key)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue