Started implementing modifier keys

This commit is contained in:
Kevin F 2023-01-27 17:22:02 -06:00
parent 138c54d75c
commit 50a46e4c42
4 changed files with 47 additions and 12 deletions

View File

@ -75,11 +75,11 @@ if string(authResponse) == "authenticated" {
--- load connection URL from second CLI argument --- noWeave
if len(os.Args) < 3 {
if len(os.Args) < 2 {
log.Fatal("missing connection URL")
}
connectionURL := os.Args[2]
connectionURL := os.Args[1]
if !strings.HasPrefix(connectionURL, "ws://") && !strings.HasPrefix(connectionURL, "wss://") {
log.Fatal("connection URL must start with ws:// or wss://")
@ -122,7 +122,10 @@ for {
## Sending keys from stdin
We read keys from stdin and send them to the server until we get EOF
We read keys from stdin and send them to the server until we get EOF.
We specify xdotool if the key is not a QWERTY key or if KEYBOARD_ALWAYS_XDOTOOL is set to true.
``` go
@ -159,6 +162,7 @@ for {
--- add xdotool if non qwerty function --- noWeave
addXDoToolIfNonQWERTY := func(message string)(string) {
if strings.HasPrefix(message, "{kb_cmd:xdotool}:") {
return message
}

View File

@ -1,6 +1,17 @@
# GoSmartKeyboard Environment Variables
## Always use xdotool
Some users may always want xdotool, see the [Streaming.md](Streaming.md) file for more information.
--- always use xdotool environment variable
alwaysUseXdotool, alwaysUseXdotoolExists := os.LookupEnv("KEYBOARD_ALWAYS_USE_XDOTOOL")
---
## Authentication token file
The authentication token configuration file is set by the environment variable `KEYBOARD_AUTH_TOKEN_FILE`, but defaults to
@ -19,7 +30,7 @@ authTokenFile, authTokenFileIsSet := os.LookupEnv("KEYBOARD_AUTH_TOKEN_FILE")
--- get authTokenInput from environment
authTokenInput, authTokenInputExists := os.LookupEnv("KEYBOARD_AUTH")
authTokenInput, authTokenInputExists := os.LookupEnv("KEYBOARD_AUTH")
---
@ -28,7 +39,7 @@ authTokenFile, authTokenFileIsSet := os.LookupEnv("KEYBOARD_AUTH_TOKEN_FILE")
--- get client fifo input file from environment
clientFifoInputFile, clientFifoInputFileExists := os.LookupEnv("KEYBOARD_FIFO")
clientFifoInputFile, clientFifoInputFileExists := os.LookupEnv("KEYBOARD_FIFO")
---

View File

@ -81,14 +81,7 @@ Then we can start the web server and listen for websocket connections.
package main
import(
"os"
"fmt"
"io"
"strings"
"bufio"
"io/ioutil"
"log"
@{gorilla/websocket import string}
"keyboard.voidnet.tech/server"
"keyboard.voidnet.tech/auth"
)

View File

@ -110,6 +110,33 @@ if strings.HasPrefix(message_string, "{kb_cmd:xdotool}:") {
doXDoTool("type", message_string)
}
continue
} else if strings.HasPrefix(message_string, "{kb_cmd:xdotoolk}:") {
message_string = strings.TrimPrefix(message_string, "{kb_cmd:xdotoolk}:")
if message_string == "" {
message_string = "\n"
}
if characterRegex.MatchString(message_string) {
for _, character := range message_string {
charString := string(character)
if charString == "\n" {
charString = "Enter"
} else if charString == "\t" {
charString = "Tab"
} else if charString == "\b" {
charString = "BackSpace"
} else{
doXDoTool("key", charString)
continue
}
// key is required for special characters
err = doXDoTool("key", charString)
continue
}
continue
} else {
doXDoTool("key", message_string)
}
continue
}
if characterRegex.MatchString(message_string) {