Merge pull request #5681 from mcandre/super-key
add super key (vmware builder)
This commit is contained in:
commit
8ae8f31a52
|
@ -6,6 +6,7 @@ import (
|
||||||
"log"
|
"log"
|
||||||
"net"
|
"net"
|
||||||
"os"
|
"os"
|
||||||
|
"regexp"
|
||||||
"runtime"
|
"runtime"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
@ -184,6 +185,8 @@ func vncSendString(c *vnc.ClientConn, original string) {
|
||||||
special["<rightAlt>"] = 0xFFEA
|
special["<rightAlt>"] = 0xFFEA
|
||||||
special["<rightCtrl>"] = 0xFFE4
|
special["<rightCtrl>"] = 0xFFE4
|
||||||
special["<rightShift>"] = 0xFFE2
|
special["<rightShift>"] = 0xFFE2
|
||||||
|
special["<leftSuper>"] = 0xFFEB
|
||||||
|
special["<rightSuper>"] = 0xFFEC
|
||||||
|
|
||||||
shiftedChars := "~!@#$%^&*()_+{}|:\"<>?"
|
shiftedChars := "~!@#$%^&*()_+{}|:\"<>?"
|
||||||
|
|
||||||
|
@ -194,6 +197,9 @@ func vncSendString(c *vnc.ClientConn, original string) {
|
||||||
keyInterval = delay
|
keyInterval = delay
|
||||||
}
|
}
|
||||||
|
|
||||||
|
azOnRegex := regexp.MustCompile("^<(?P<ordinary>[a-zA-Z])On>")
|
||||||
|
azOffRegex := regexp.MustCompile("^<(?P<ordinary>[a-zA-Z])Off>")
|
||||||
|
|
||||||
// TODO(mitchellh): Ripe for optimizations of some point, perhaps.
|
// TODO(mitchellh): Ripe for optimizations of some point, perhaps.
|
||||||
for len(original) > 0 {
|
for len(original) > 0 {
|
||||||
var keyCode uint32
|
var keyCode uint32
|
||||||
|
@ -232,6 +238,36 @@ func vncSendString(c *vnc.ClientConn, original string) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if strings.HasPrefix(original, "<leftSuperOn>") {
|
||||||
|
keyCode = special["<leftSuper>"]
|
||||||
|
original = original[len("<leftSuperOn>"):]
|
||||||
|
log.Printf("Special code '<leftSuperOn>' found, replacing with: %d", keyCode)
|
||||||
|
|
||||||
|
c.KeyEvent(keyCode, true)
|
||||||
|
time.Sleep(keyInterval)
|
||||||
|
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
if azOnRegex.MatchString(original) {
|
||||||
|
m := azOnRegex.FindStringSubmatch(original)
|
||||||
|
r, _ := utf8.DecodeRuneInString(m[1])
|
||||||
|
original = original[len("<aOn>"):]
|
||||||
|
keyCode = uint32(r)
|
||||||
|
keyShift = unicode.IsUpper(r) || strings.ContainsRune(shiftedChars, r)
|
||||||
|
|
||||||
|
log.Printf("Special code '%s' found, replacing with %d, shift %v", m[0], keyCode, keyShift)
|
||||||
|
|
||||||
|
if keyShift {
|
||||||
|
c.KeyEvent(KeyLeftShift, true)
|
||||||
|
}
|
||||||
|
|
||||||
|
c.KeyEvent(keyCode, true)
|
||||||
|
time.Sleep(keyInterval)
|
||||||
|
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
if strings.HasPrefix(original, "<leftAltOff>") {
|
if strings.HasPrefix(original, "<leftAltOff>") {
|
||||||
keyCode = special["<leftAlt>"]
|
keyCode = special["<leftAlt>"]
|
||||||
original = original[len("<leftAltOff>"):]
|
original = original[len("<leftAltOff>"):]
|
||||||
|
@ -265,6 +301,36 @@ func vncSendString(c *vnc.ClientConn, original string) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if strings.HasPrefix(original, "<leftSuperOff>") {
|
||||||
|
keyCode = special["<leftSuper>"]
|
||||||
|
original = original[len("<leftSuperOff>"):]
|
||||||
|
log.Printf("Special code '<leftSuperOff>' found, replacing with: %d", keyCode)
|
||||||
|
|
||||||
|
c.KeyEvent(keyCode, false)
|
||||||
|
time.Sleep(keyInterval)
|
||||||
|
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
if azOffRegex.MatchString(original) {
|
||||||
|
m := azOffRegex.FindStringSubmatch(original)
|
||||||
|
r, _ := utf8.DecodeRuneInString(m[1])
|
||||||
|
original = original[len("<aOff>"):]
|
||||||
|
keyCode = uint32(r)
|
||||||
|
keyShift = unicode.IsUpper(r) || strings.ContainsRune(shiftedChars, r)
|
||||||
|
|
||||||
|
log.Printf("Special code '%s' found, replacing with %d, shift %v", m[0], keyCode, keyShift)
|
||||||
|
|
||||||
|
if keyShift {
|
||||||
|
c.KeyEvent(KeyLeftShift, false)
|
||||||
|
}
|
||||||
|
|
||||||
|
c.KeyEvent(keyCode, false)
|
||||||
|
time.Sleep(keyInterval)
|
||||||
|
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
if strings.HasPrefix(original, "<rightAltOn>") {
|
if strings.HasPrefix(original, "<rightAltOn>") {
|
||||||
keyCode = special["<rightAlt>"]
|
keyCode = special["<rightAlt>"]
|
||||||
original = original[len("<rightAltOn>"):]
|
original = original[len("<rightAltOn>"):]
|
||||||
|
@ -298,6 +364,17 @@ func vncSendString(c *vnc.ClientConn, original string) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if strings.HasPrefix(original, "<rightSuperOn>") {
|
||||||
|
keyCode = special["<rightSuper>"]
|
||||||
|
original = original[len("<rightSuperOn>"):]
|
||||||
|
log.Printf("Special code '<rightSuperOn>' found, replacing with: %d", keyCode)
|
||||||
|
|
||||||
|
c.KeyEvent(keyCode, true)
|
||||||
|
time.Sleep(keyInterval)
|
||||||
|
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
if strings.HasPrefix(original, "<rightAltOff>") {
|
if strings.HasPrefix(original, "<rightAltOff>") {
|
||||||
keyCode = special["<rightAlt>"]
|
keyCode = special["<rightAlt>"]
|
||||||
original = original[len("<rightAltOff>"):]
|
original = original[len("<rightAltOff>"):]
|
||||||
|
@ -331,6 +408,17 @@ func vncSendString(c *vnc.ClientConn, original string) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if strings.HasPrefix(original, "<rightSuperOff>") {
|
||||||
|
keyCode = special["<rightSuper>"]
|
||||||
|
original = original[len("<rightSuperOff>"):]
|
||||||
|
log.Printf("Special code '<rightSuperOff>' found, replacing with: %d", keyCode)
|
||||||
|
|
||||||
|
c.KeyEvent(keyCode, false)
|
||||||
|
time.Sleep(keyInterval)
|
||||||
|
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
if strings.HasPrefix(original, "<wait>") {
|
if strings.HasPrefix(original, "<wait>") {
|
||||||
log.Printf("Special code '<wait>' found, sleeping one second")
|
log.Printf("Special code '<wait>' found, sleeping one second")
|
||||||
time.Sleep(1 * time.Second)
|
time.Sleep(1 * time.Second)
|
||||||
|
|
Loading…
Reference in New Issue