break long lines
This commit is contained in:
parent
a296bd1188
commit
26337f3a0e
3 changed files with 22 additions and 10 deletions
3
host.go
3
host.go
|
|
@ -61,7 +61,8 @@ func FindDefaultHost() string {
|
|||
if fallbackAddr == "" {
|
||||
fallbackAddr = ip.String()
|
||||
}
|
||||
for _, linkLocalPrefix := range []string{"169.254.", "fe8", "fe9", "fea", "feb"} {
|
||||
for _, linkLocalPrefix := range []string{
|
||||
"169.254.", "fe8", "fe9", "fea", "feb"} {
|
||||
if strings.HasPrefix(ip.String(), linkLocalPrefix) {
|
||||
continue addrs
|
||||
}
|
||||
|
|
|
|||
|
|
@ -98,7 +98,9 @@ func (p *windowsPlugin) KeyboardText(text string) error {
|
|||
inputs[i].dwFlags |= keyeventfKeyup
|
||||
}
|
||||
}
|
||||
if r, _, err := p.sendInputProc.Call(uintptr(len(inputs)), uintptr(unsafe.Pointer(&inputs[0])), unsafe.Sizeof(inputs[0])); int(r) != len(inputs) {
|
||||
if r, _, err := p.sendInputProc.Call(uintptr(len(inputs)),
|
||||
uintptr(unsafe.Pointer(&inputs[0])),
|
||||
unsafe.Sizeof(inputs[0])); int(r) != len(inputs) {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
|
|
@ -124,7 +126,8 @@ func (p *windowsPlugin) PointerButton(button uint, press bool) error {
|
|||
} else if button == 3 {
|
||||
input.dwFlags = mouseeventfRightup
|
||||
}
|
||||
if r, _, err := p.sendInputProc.Call(1, uintptr(unsafe.Pointer(&input)), unsafe.Sizeof(input)); int(r) != 1 {
|
||||
if r, _, err := p.sendInputProc.Call(1, uintptr(unsafe.Pointer(&input)),
|
||||
unsafe.Sizeof(input)); int(r) != 1 {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
|
|
@ -137,7 +140,8 @@ func (p *windowsPlugin) PointerMove(deltaX, deltaY int) error {
|
|||
dy: int32(deltaY),
|
||||
dwFlags: mouseeventfMove,
|
||||
}
|
||||
if r, _, err := p.sendInputProc.Call(1, uintptr(unsafe.Pointer(&input)), unsafe.Sizeof(input)); int(r) != 1 {
|
||||
if r, _, err := p.sendInputProc.Call(1, uintptr(unsafe.Pointer(&input)),
|
||||
unsafe.Sizeof(input)); int(r) != 1 {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
|
|
@ -162,7 +166,9 @@ func (p *windowsPlugin) PointerScroll(stepsHorizontal, stepsVertical int) error
|
|||
if len(inputs) == 0 {
|
||||
return nil
|
||||
}
|
||||
if r, _, err := p.sendInputProc.Call(uintptr(len(inputs)), uintptr(unsafe.Pointer(&inputs[0])), unsafe.Sizeof(inputs[0])); int(r) != len(inputs) {
|
||||
if r, _, err := p.sendInputProc.Call(uintptr(len(inputs)),
|
||||
uintptr(unsafe.Pointer(&inputs[0])),
|
||||
unsafe.Sizeof(inputs[0])); int(r) != len(inputs) {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
|
|
|
|||
|
|
@ -71,7 +71,8 @@ func (p *x11Plugin) KeyboardText(text string) error {
|
|||
var minKeycodes, maxKeycodes C.int
|
||||
C.XDisplayKeycodes(p.display, &minKeycodes, &maxKeycodes)
|
||||
var keysymsPerKeycode C.int
|
||||
keysyms := C.XGetKeyboardMapping(p.display, C.KeyCode(minKeycodes), maxKeycodes-minKeycodes+1, &keysymsPerKeycode)
|
||||
keysyms := C.XGetKeyboardMapping(p.display, C.KeyCode(minKeycodes),
|
||||
maxKeycodes-minKeycodes+1, &keysymsPerKeycode)
|
||||
if keysyms == nil {
|
||||
return errors.New("failed to get keyboard mapping")
|
||||
}
|
||||
|
|
@ -79,8 +80,10 @@ func (p *x11Plugin) KeyboardText(text string) error {
|
|||
keycodes:
|
||||
for keycode := C.KeyCode(minKeycodes); keycode <= C.KeyCode(maxKeycodes); keycode++ {
|
||||
for i := 0; i < int(keysymsPerKeycode); i++ {
|
||||
keysymsIndex := int(keycode-C.KeyCode(minKeycodes))*int(keysymsPerKeycode) + i
|
||||
keysym := *(*C.KeySym)(unsafe.Pointer(uintptr(unsafe.Pointer(keysyms)) + uintptr(keysymsIndex)*unsafe.Sizeof(*keysyms)))
|
||||
keysymsIndex := int(keycode-
|
||||
C.KeyCode(minKeycodes))*int(keysymsPerKeycode) + i
|
||||
keysym := *(*C.KeySym)(unsafe.Pointer(uintptr(unsafe.Pointer(keysyms)) +
|
||||
uintptr(keysymsIndex)*unsafe.Sizeof(*keysyms)))
|
||||
if keysym != 0 {
|
||||
continue keycodes
|
||||
}
|
||||
|
|
@ -98,7 +101,8 @@ keycodes:
|
|||
for i := range keycodeMapping {
|
||||
keycodeMapping[i] = keysym
|
||||
}
|
||||
C.XChangeKeyboardMapping(p.display, C.int(emptyKeycode), keysymsPerKeycode, (*C.KeySym)(unsafe.Pointer(&keycodeMapping[0])), 1)
|
||||
C.XChangeKeyboardMapping(p.display, C.int(emptyKeycode), keysymsPerKeycode,
|
||||
(*C.KeySym)(unsafe.Pointer(&keycodeMapping[0])), 1)
|
||||
C.XTestFakeKeyEvent(p.display, C.uint(emptyKeycode), C.True, 0)
|
||||
C.XTestFakeKeyEvent(p.display, C.uint(emptyKeycode), C.False, 0)
|
||||
// race condition!
|
||||
|
|
@ -108,7 +112,8 @@ keycodes:
|
|||
for i := range keycodeMapping {
|
||||
keycodeMapping[i] = 0
|
||||
}
|
||||
C.XChangeKeyboardMapping(p.display, C.int(emptyKeycode), keysymsPerKeycode, (*C.KeySym)(unsafe.Pointer(&keycodeMapping[0])), 1)
|
||||
C.XChangeKeyboardMapping(p.display, C.int(emptyKeycode), keysymsPerKeycode,
|
||||
(*C.KeySym)(unsafe.Pointer(&keycodeMapping[0])), 1)
|
||||
C.XFlush(p.display)
|
||||
return nil
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue