From 625b015aeb3e4bfd148e0a87aec0b938734ea9bd Mon Sep 17 00:00:00 2001 From: Kate Ward Date: Mon, 11 May 2015 21:53:03 +0200 Subject: [PATCH 1/6] add constants to use with VNC keyboard and mouse events --- client_events.go | 170 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 170 insertions(+) create mode 100644 client_events.go diff --git a/client_events.go b/client_events.go new file mode 100644 index 0000000..609e987 --- /dev/null +++ b/client_events.go @@ -0,0 +1,170 @@ +/* +client_events.go provides constants for making VNC keyboard and mouse events. + +Sample usage: + +// Move mouse to x=100, y=200. +x, y := 100, 200 +conn.PointerEvent(vnc.Mouse_none, x, y) +// Give mouse some time to "settle." +time.Sleep(10*time.Millisecond) +// Left click. +conn.PointerEvent(vnc.Mouse_left, x, y) +conn.PointerEvent(vnc.Mouse_none, x, y) + +// Press return key +conn.KeyEvent(vnc.Key_return, true) +// Release the key. +conn.KeyEvent(vnc.Key_return, false) +*/ + +package vnc + +// Latin 1 (byte 3 = 0) +// ISO/IEC 8859-1 = Unicode U+0020..U+00FF +const ( + Key_space = iota + 0x0020 + Key_exclam + Key_quotedbl + Key_numbersign + Key_dollar + Key_percent + Key_ampersand + Key_apostrophe + Key_parenleft + Key_parenright + Key_asterisk + Key_plus + Key_comma + Key_minus + Key_period + Key_slash + Key_0 + Key_1 + Key_2 + Key_3 + Key_4 + Key_5 + Key_6 + Key_7 + Key_8 + Key_9 + Key_colon + Key_semicolon + Key_less + Key_equal + Key_greater + Key_question + Key_at + Key_A + Key_B + Key_C + Key_D + Key_E + Key_F + Key_G + Key_H + Key_I + Key_J + Key_K + Key_L + Key_M + Key_N + Key_O + Key_P + Key_Q + Key_R + Key_S + Key_T + Key_U + Key_V + Key_W + Key_X + Key_Y + Key_Z + Key_bracketleft + Key_backslash + Key_bracketright + Key_asciicircum + Key_underscore + Key_grave + Key_a + Key_b + Key_c + Key_d + Key_e + Key_f + Key_g + Key_h + Key_i + Key_j + Key_k + Key_l + Key_m + Key_n + Key_o + Key_p + Key_q + Key_r + Key_s + Key_t + Key_u + Key_v + Key_w + Key_x + Key_y + Key_z + Key_braceleft + Key_bar + Key_braceright + Key_asciitilde +) +const ( + Key_backspace = iota + 0xff08 + Key_tab + Key_linefeed + Key_clear + _ + Key_return +) +const ( + Key_pause = 0xff13 + Key_scroll_lock = 0xff14 + Key_sys_req = 0xff15 + Key_escape = 0xff1b +) +const ( + Key_f1 = iota + 0xffbe + Key_f2 + Key_f3 + Key_f4 + Key_f5 + Key_f6 + Key_f7 + Key_f8 + Key_f9 + Key_f10 + Key_f11 + Key_f12 +) +const ( + Key_shift_l = iota + 0xffe1 + Key_shift_r + Key_control_l + Key_control_r + Key_caps_lock + _ + _ + _ + Key_alt_l + Key_alt_r + + Key_delete = 0xffff +) +const ( + // Mouse buttons + Mouse_left = 1 << iota + Mouse_middle + Mouse_right + Mouse_none = 0 +) From fcea25c0b6fe245ef64f3c028b0d17c05a39b284 Mon Sep 17 00:00:00 2001 From: Kate Ward Date: Mon, 11 May 2015 22:02:17 +0200 Subject: [PATCH 2/6] fixed constant naming according to Effective Go standards --- client_events.go | 266 +++++++++++++++++++++++------------------------ 1 file changed, 133 insertions(+), 133 deletions(-) diff --git a/client_events.go b/client_events.go index 609e987..1ec6d00 100644 --- a/client_events.go +++ b/client_events.go @@ -5,17 +5,17 @@ Sample usage: // Move mouse to x=100, y=200. x, y := 100, 200 -conn.PointerEvent(vnc.Mouse_none, x, y) +conn.PointerEvent(vnc.MouseNone, x, y) // Give mouse some time to "settle." time.Sleep(10*time.Millisecond) // Left click. -conn.PointerEvent(vnc.Mouse_left, x, y) -conn.PointerEvent(vnc.Mouse_none, x, y) +conn.PointerEvent(vnc.MouseLeft, x, y) +conn.PointerEvent(vnc.MouseNone, x, y) // Press return key -conn.KeyEvent(vnc.Key_return, true) +conn.KeyEvent(vnc.KeyReturn, true) // Release the key. -conn.KeyEvent(vnc.Key_return, false) +conn.KeyEvent(vnc.KeyReturn, false) */ package vnc @@ -23,148 +23,148 @@ package vnc // Latin 1 (byte 3 = 0) // ISO/IEC 8859-1 = Unicode U+0020..U+00FF const ( - Key_space = iota + 0x0020 - Key_exclam - Key_quotedbl - Key_numbersign - Key_dollar - Key_percent - Key_ampersand - Key_apostrophe - Key_parenleft - Key_parenright - Key_asterisk - Key_plus - Key_comma - Key_minus - Key_period - Key_slash - Key_0 - Key_1 - Key_2 - Key_3 - Key_4 - Key_5 - Key_6 - Key_7 - Key_8 - Key_9 - Key_colon - Key_semicolon - Key_less - Key_equal - Key_greater - Key_question - Key_at - Key_A - Key_B - Key_C - Key_D - Key_E - Key_F - Key_G - Key_H - Key_I - Key_J - Key_K - Key_L - Key_M - Key_N - Key_O - Key_P - Key_Q - Key_R - Key_S - Key_T - Key_U - Key_V - Key_W - Key_X - Key_Y - Key_Z - Key_bracketleft - Key_backslash - Key_bracketright - Key_asciicircum - Key_underscore - Key_grave - Key_a - Key_b - Key_c - Key_d - Key_e - Key_f - Key_g - Key_h - Key_i - Key_j - Key_k - Key_l - Key_m - Key_n - Key_o - Key_p - Key_q - Key_r - Key_s - Key_t - Key_u - Key_v - Key_w - Key_x - Key_y - Key_z - Key_braceleft - Key_bar - Key_braceright - Key_asciitilde + KeySpace = iota + 0x0020 + KeyExclam + KeyQuoteDbl + KeyNumberSign + KeyDollar + KeyPercent + KeyAmpersand + KeyApostrophe + KeyParenLeft + KeyParenRight + KeyAsterisk + KeyPlus + KeyComma + KeyMinus + KeyPeriod + KeySlash + Key0 + Key1 + Key2 + Key3 + Key4 + Key5 + Key6 + Key7 + Key8 + Key9 + KeyColon + KeySemicolon + KeyLess + KeyEqual + KeyGreater + KeyQuestion + KeyAt + KeyA + KeyB + KeyC + KeyD + KeyE + KeyF + KeyG + KeyH + KeyI + KeyJ + KeyK + KeyL + KeyM + KeyN + KeyO + KeyP + KeyQ + KeyR + KeyS + KeyT + KeyU + KeyV + KeyW + KeyX + KeyY + KeyZ + KeyBracketLeft + KeyBackslash + KeyBracketRight + KeyAsciiCircum + KeyUnderscore + KeyGrave + Keya + Keyb + Keyc + Keyd + Keye + Keyf + Keyg + Keyh + Keyi + Keyj + Keyk + Keyl + Keym + Keyn + Keyo + Keyp + Keyq + Keyr + Keys + Keyt + Keyu + Keyv + Keyw + Keyx + Keyy + Keyz + KeyBraceLeft + KeyBar + KeyBraceRight + KeyAsciiTilde ) const ( - Key_backspace = iota + 0xff08 - Key_tab - Key_linefeed - Key_clear + KeyBackspace = iota + 0xff08 + KeyTab + KeyLinefeed + KeyClear _ - Key_return + KeyReturn ) const ( - Key_pause = 0xff13 - Key_scroll_lock = 0xff14 - Key_sys_req = 0xff15 - Key_escape = 0xff1b + KeyPause = 0xff13 + KeyScrollLock = 0xff14 + KeySysReq = 0xff15 + KeyEscape = 0xff1b ) const ( - Key_f1 = iota + 0xffbe - Key_f2 - Key_f3 - Key_f4 - Key_f5 - Key_f6 - Key_f7 - Key_f8 - Key_f9 - Key_f10 - Key_f11 - Key_f12 + KeyF1 = iota + 0xffbe + KeyF2 + KeyF3 + KeyF4 + KeyF5 + KeyF6 + KeyF7 + KeyF8 + KeyF9 + KeyF10 + KeyF11 + KeyF12 ) const ( - Key_shift_l = iota + 0xffe1 - Key_shift_r - Key_control_l - Key_control_r - Key_caps_lock + KeyShiftL = iota + 0xffe1 + KeyShiftR + KeyControlL + KeyControlR + KeyCapsLock _ _ _ - Key_alt_l - Key_alt_r + KeyAltL + KeyAltR - Key_delete = 0xffff + KeyDelete = 0xffff ) const ( // Mouse buttons - Mouse_left = 1 << iota - Mouse_middle - Mouse_right - Mouse_none = 0 + MouseLeft = 1 << iota + MouseMiddle + MouseRight + MouseNone = 0 ) From 6e98bebdf506d5a3eb4e3fb3228a46b6f73b1a67 Mon Sep 17 00:00:00 2001 From: Kate Ward Date: Mon, 11 May 2015 22:05:15 +0200 Subject: [PATCH 3/6] renamed Mouse* constants (e.g. L=Left) to match Key constants --- client_events.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/client_events.go b/client_events.go index 1ec6d00..401bd4e 100644 --- a/client_events.go +++ b/client_events.go @@ -128,10 +128,10 @@ const ( KeyReturn ) const ( - KeyPause = 0xff13 + KeyPause = 0xff13 KeyScrollLock = 0xff14 KeySysReq = 0xff15 - KeyEscape = 0xff1b + KeyEscape = 0xff1b ) const ( KeyF1 = iota + 0xffbe @@ -163,8 +163,8 @@ const ( ) const ( // Mouse buttons - MouseLeft = 1 << iota - MouseMiddle - MouseRight + MouseL = 1 << iota + MouseM // middle + MouseR MouseNone = 0 ) From a0d6d8f3184312185022b093c380c35b8b7499c7 Mon Sep 17 00:00:00 2001 From: Kate Ward Date: Mon, 11 May 2015 22:07:36 +0200 Subject: [PATCH 4/6] spelled out Left and Right --- client_events.go | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/client_events.go b/client_events.go index 401bd4e..26282fc 100644 --- a/client_events.go +++ b/client_events.go @@ -148,23 +148,23 @@ const ( KeyF12 ) const ( - KeyShiftL = iota + 0xffe1 - KeyShiftR - KeyControlL - KeyControlR + KeyShiftLeft = iota + 0xffe1 + KeyShiftRight + KeyControlLeft + KeyControlRight KeyCapsLock _ _ _ - KeyAltL - KeyAltR + KeyAltLeft + KeyAltRight KeyDelete = 0xffff ) const ( // Mouse buttons - MouseL = 1 << iota - MouseM // middle - MouseR + MouseLeft = 1 << iota + MouseMiddle + MouseRight MouseNone = 0 ) From e88cfe638f1a4c4eb887ddb1031e39ba7980ff2a Mon Sep 17 00:00:00 2001 From: Kate Ward Date: Thu, 14 May 2015 15:33:22 +0200 Subject: [PATCH 5/6] Removed Mouse* constants from client_events.go as they're in pointer.go. --- client_events.go | 7 ------- pointer.go | 1 + 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/client_events.go b/client_events.go index 26282fc..49b3532 100644 --- a/client_events.go +++ b/client_events.go @@ -161,10 +161,3 @@ const ( KeyDelete = 0xffff ) -const ( - // Mouse buttons - MouseLeft = 1 << iota - MouseMiddle - MouseRight - MouseNone = 0 -) diff --git a/pointer.go b/pointer.go index 86d84e3..e33331b 100644 --- a/pointer.go +++ b/pointer.go @@ -13,4 +13,5 @@ const ( Button6 Button7 Button8 + ButtonNone = ButtonMask(0) ) From ee1d1a0e5ecaa93e74b48fef765cfad381278a31 Mon Sep 17 00:00:00 2001 From: Kate Ward Date: Thu, 14 May 2015 15:59:33 +0200 Subject: [PATCH 6/6] updated sample usage info --- client_events.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/client_events.go b/client_events.go index 49b3532..cafe9c2 100644 --- a/client_events.go +++ b/client_events.go @@ -5,12 +5,12 @@ Sample usage: // Move mouse to x=100, y=200. x, y := 100, 200 -conn.PointerEvent(vnc.MouseNone, x, y) +conn.PointerEvent(vnc.ButtonNone, x, y) // Give mouse some time to "settle." time.Sleep(10*time.Millisecond) // Left click. -conn.PointerEvent(vnc.MouseLeft, x, y) -conn.PointerEvent(vnc.MouseNone, x, y) +conn.PointerEvent(vnc.ButtonLeft, x, y) +conn.PointerEvent(vnc.ButtonNone, x, y) // Press return key conn.KeyEvent(vnc.KeyReturn, true)