Update better-xcloud.user.js

This commit is contained in:
redphx 2024-06-07 07:20:25 +07:00 committed by GitHub
parent 03d5550f05
commit 2ed1e8735f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -459,8 +459,8 @@ var MkbPresetKey;
var SUPPORTED_LANGUAGES = { var SUPPORTED_LANGUAGES = {
"en-US": "English (United States)", "en-US": "English (United States)",
"ca-CA": "Català", "ca-CA": "Català",
"en-ID": "Bahasa Indonesia",
"de-DE": "Deutsch", "de-DE": "Deutsch",
"en-ID": "Bahasa Indonesia",
"es-ES": "español (España)", "es-ES": "español (España)",
"fr-FR": "français", "fr-FR": "français",
"it-IT": "italiano", "it-IT": "italiano",
@ -3064,7 +3064,7 @@ class NativeMkbHandler extends MkbHandler {
static instance; static instance;
#pointerClient; #pointerClient;
#enabled = false; #enabled = false;
#currentButtons = 0; #mouseButtonsPressed = 0;
#inputSink; #inputSink;
#$message; #$message;
static getInstance() { static getInstance() {
@ -3215,7 +3215,7 @@ class NativeMkbHandler extends MkbHandler {
this.#sendMouseInput({ this.#sendMouseInput({
X: data.movementX, X: data.movementX,
Y: data.movementY, Y: data.movementY,
Buttons: 0, Buttons: this.#mouseButtonsPressed,
WheelX: 0, WheelX: 0,
WheelY: 0, WheelY: 0,
Type: 0 Type: 0
@ -3224,14 +3224,14 @@ class NativeMkbHandler extends MkbHandler {
handleMouseClick(data) { handleMouseClick(data) {
const { pointerButton, pressed } = data; const { pointerButton, pressed } = data;
if (pressed) { if (pressed) {
this.#currentButtons |= pointerButton; this.#mouseButtonsPressed |= pointerButton;
} else { } else {
this.#currentButtons ^= pointerButton; this.#mouseButtonsPressed ^= pointerButton;
} }
this.#sendMouseInput({ this.#sendMouseInput({
X: 0, X: 0,
Y: 0, Y: 0,
Buttons: this.#currentButtons, Buttons: this.#mouseButtonsPressed,
WheelX: 0, WheelX: 0,
WheelY: 0, WheelY: 0,
Type: 0 Type: 0
@ -3246,10 +3246,11 @@ class NativeMkbHandler extends MkbHandler {
return this.#enabled; return this.#enabled;
} }
#sendMouseInput(data) { #sendMouseInput(data) {
data.Buttons = Math.max(0, data.Buttons);
this.#inputSink?.onMouseInput(data); this.#inputSink?.onMouseInput(data);
} }
#resetMouseInput() { #resetMouseInput() {
this.#currentButtons = 0; this.#mouseButtonsPressed = 0;
this.#sendMouseInput({ this.#sendMouseInput({
X: 0, X: 0,
Y: 0, Y: 0,