Cosmetics

This commit is contained in:
Unrud 2020-08-26 03:30:20 +02:00
parent bd376578d4
commit 9ad8590517
17 changed files with 70 additions and 74 deletions

View file

@ -35,6 +35,7 @@ const (
btnReleased uint32 = 0
btnPressed uint32 = 1
// linux/input-event-codes.h
btnLeft int32 = 0x110
btnRight int32 = 0x111
btnMiddle int32 = 0x112

View file

@ -34,8 +34,7 @@ modules:
dest: src/github.com/unrud/remote-touchpad
buildsystem: simple
build-commands:
- . /usr/lib/sdk/golang/enable.sh; env GOPATH="$(pwd)" go build -tags 'portal x11'
github.com/unrud/remote-touchpad
- . /usr/lib/sdk/golang/enable.sh; env GOPATH="$(pwd)" go build -tags 'portal x11' github.com/unrud/remote-touchpad
- install -Dm0755 -t /app/bin remote-touchpad
- install -Dm0755 -t /app/bin src/github.com/unrud/remote-touchpad/desktop/remote-touchpad-wait-on-error
- install -Dm0644 -t /app/share/metainfo src/github.com/unrud/remote-touchpad/desktop/com.github.unrud.RemoteTouchpad.appdata.xml

View file

@ -26,12 +26,13 @@ import "errors"
type Keysym int32
const (
xf86AudioLowerVolume Keysym = 0x1008ff11
xf86AudioMute Keysym = 0x1008ff12
xf86AudioRaiseVolume Keysym = 0x1008ff13
xf86AudioPlay Keysym = 0x1008ff14
xf86AudioPrev Keysym = 0x1008ff16
xf86AudioNext Keysym = 0x1008ff17
// X11/XF86keysym.h
xf86xkAudioLowerVolume Keysym = 0x1008ff11
xf86xkAudioMute Keysym = 0x1008ff12
xf86xkAudioRaiseVolume Keysym = 0x1008ff13
xf86xkAudioPlay Keysym = 0x1008ff14
xf86xkAudioPrev Keysym = 0x1008ff16
xf86xkAudioNext Keysym = 0x1008ff17
)
func RuneToKeysym(runeValue rune) (Keysym, error) {
@ -51,22 +52,22 @@ func RuneToKeysym(runeValue rune) (Keysym, error) {
func KeyToKeysym(key Key) (Keysym, error) {
if key == KeyVolumeMute {
return xf86AudioMute, nil
return xf86xkAudioMute, nil
}
if key == KeyVolumeDown {
return xf86AudioLowerVolume, nil
return xf86xkAudioLowerVolume, nil
}
if key == KeyVolumeUp {
return xf86AudioRaiseVolume, nil
return xf86xkAudioRaiseVolume, nil
}
if key == KeyMediaPlayPause {
return xf86AudioPlay, nil
return xf86xkAudioPlay, nil
}
if key == KeyMediaPrevTrack {
return xf86AudioPrev, nil
return xf86xkAudioPrev, nil
}
if key == KeyMediaNextTrack {
return xf86AudioNext, nil
return xf86xkAudioNext, nil
}
return 0, errors.New("key not mapped to keysym")
}

View file

@ -17,10 +17,11 @@
* along with Remote-Touchpad. If not, see <http://www.gnu.org/licenses/>.
*/
// [1 Touch, 2 Touches, 3 Touches]
// [1 Touch, 2 Touches, 3 Touches] (as pixel)
const TOUCH_MOVE_THRESHOLD = [10, 15, 15];
// Max time between consecutive touches for clicking or dragging (as milliseconds)
const TOUCH_TIMEOUT = 250;
// [[px/s, mult], ...]
// [[pixel/second, multiplicator], ...]
const POINTER_ACCELERATION = [
[0, 0],
[87, 1],
@ -311,7 +312,7 @@ window.addEventListener("load", function() {
let text = document.getElementById("text");
function showScene(scene) {
[opening, closed, pad, keys, keyboard].forEach(function (e) {
[opening, closed, pad, keys, keyboard].forEach(function(e) {
e.classList.toggle("hidden", e != scene);
});
}
@ -336,13 +337,10 @@ window.addEventListener("load", function() {
text.value = "";
showScene(opening);
let wsProtocol = "wss:";
if (location.protocol == "http:") {
wsProtocol = "ws:";
}
ws = new WebSocket(wsProtocol + "//" + location.hostname +
(location.port ? ":" + location.port : "") +
"/ws");
ws = new WebSocket(
(location.protocol == "http:" ? "ws:" : "wss:") + "//" + location.hostname +
(location.port ? ":" + location.port : "") + "/ws"
);
ws.onmessage = function(evt) {
if (authenticated) {
@ -383,13 +381,11 @@ window.addEventListener("load", function() {
{id: "volumedownbutton", key: KEY_VOLUME_DOWN},
{id: "volumemutebutton", key: KEY_VOLUME_MUTE},
{id: "volumeupbutton", key: KEY_VOLUME_UP}].forEach(function(o) {
document.getElementById(o.id).addEventListener("click",
function() {
document.getElementById(o.id).addEventListener("click", function() {
ws.send("k" + o.key);
});
});
document.getElementById("sendbutton").addEventListener("click",
function() {
document.getElementById("sendbutton").addEventListener("click", function() {
if (text.value != "") {
ws.send("t" + text.value);
text.value = "";
@ -409,8 +405,7 @@ window.addEventListener("load", function() {
}
}
};
document.getElementById("reloadbutton").addEventListener("click",
function() {
document.getElementById("reloadbutton").addEventListener("click", function() {
location.reload();
});
pad.addEventListener("touchstart", handleStart);