Browse Source

remote control improvements

main
Martin Dørum 9 months ago
parent
commit
d31027ad31
3 changed files with 12 additions and 4 deletions
  1. 1
    0
      config.toml
  2. 2
    1
      main.go
  3. 9
    3
      web/remote.html

+ 1
- 0
config.toml View File

@@ -1 +1,2 @@
base_path = "./media"
scroll_step = 1

+ 2
- 1
main.go View File

@@ -14,6 +14,7 @@ import "coffee.mort.mediator/screencap"

type Config struct {
BasePath string `toml:"base_path"`
ScrollStep int `toml:"scroll_step"`
}

type EmptyData struct {}
@@ -156,7 +157,7 @@ func main() {
return err
}

robotgo.Scroll(scroll.X * 20, scroll.Y * 20)
robotgo.Scroll(scroll.X * conf.ScrollStep, scroll.Y * conf.ScrollStep)
return json.NewEncoder(w).Encode(&EmptyData{})
} else {
return errors.New("Invalid method: "+ req.Method)

+ 9
- 3
web/remote.html View File

@@ -60,6 +60,7 @@ body {
<button onclick='sendKey("escape")'>Esc</button>
<button onclick='sendKey("enter")'>Enter</button>
<button onclick='sendKey("space")'>Space</button>
<button onclick='sendKey("backspace")'>Backspace</button>
</div>
</div>

@@ -114,11 +115,14 @@ screencastEl.addEventListener("error", evt => {
});

window.addEventListener("keydown", evt => {
if (document.activeElement.tagName == "INPUT") {
return;
}

let handled = true;
console.log("key:", evt.key);
if (evt.key == " ") {
sendKey("space");
} else if (evt.key == "Enter" && document.activeElement.tagName != "INPUT") {
} else if (evt.key == "Enter") {
sendKey("enter");
} else if (evt.key == "ArrowUp") {
sendKey("up");
@@ -130,9 +134,11 @@ window.addEventListener("keydown", evt => {
sendKey("right");
} else if (evt.key == "Escape") {
sendKey("escape");
} else if (evt.key == "Backspace") {
sendKey("backspace");
} else {
handled = false;
if (evt.key.length == 1 && document.activeElement.tagName != "INPUT") {
if (evt.key.length == 1) {
textEl.focus();
}
}

Loading…
Cancel
Save