Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified bun.lockb
Binary file not shown.
6 changes: 6 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"@types/bun": "latest",
"@types/node-forge": "^1.3.11",
"@types/uglify-js": "^3.17.5",
"@webgpu/types": "^0.1.59",
"axios": "^1.7.9",
"javascript-obfuscator": "^4.1.1",
"node-forge": "^1.3.1",
Expand All @@ -22,5 +23,10 @@
},
"peerDependencies": {
"typescript": "^5.0.0"
},
"dependencies": {
"@types/stats.js": "^0.17.3",
"gl-matrix": "^3.4.3",
"stats.js": "^0.17.0"
}
}
26 changes: 13 additions & 13 deletions src/3rdparty/MobileKeyboard.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { canvas, canvas2d } from "#/graphics/Canvas";
import { canvasOverlay, canvas2d } from "#/graphics/Canvas";

// ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!"£$%^&*()-_=+[{]};:\'@#~,<.>/?\\|
// ^ Allowed characters in client
Expand Down Expand Up @@ -435,8 +435,8 @@ class CanvasMobileKeyboard implements Keyboard {
key: char,
code: char,
})
canvas.dispatchEvent(downEvent);
canvas.dispatchEvent(upEvent);
canvasOverlay.dispatchEvent(downEvent);
canvasOverlay.dispatchEvent(upEvent);
if (!this.animateBoxTimeout) {
if (index >= 30 && index <= 35) {
this.animateBoxIndex = 30;
Expand Down Expand Up @@ -492,7 +492,7 @@ class CanvasMobileKeyboard implements Keyboard {
this.startX = newStartX;
this.startY = newStartY;
// Focus event forces a re-draw of canvas
canvas.dispatchEvent(new FocusEvent('focus'));
canvasOverlay.dispatchEvent(new FocusEvent('focus'));
}
}
}
Expand All @@ -510,7 +510,7 @@ class NativeMobileKeyboard implements Keyboard {
this.virtualInputElement.setAttribute('autofocus', 'autofocus');
this.virtualInputElement.setAttribute('spellcheck', 'false');
this.virtualInputElement.setAttribute('autocomplete', 'off');
this.virtualInputElement.setAttribute('style', 'position: fixed; top: 0px; left: 0px; width: 1px; height: 1px; opacity: 0;');
this.virtualInputElement.setAttribute('style', `position: fixed; top: 0px; left: 0px; width: 1px; height: 1px; opacity: 0; z-index: 20;`);
if (this.isAndroid) {
// Android uses `input` event for text entry rathern than `keydown` / `keyup`

Expand All @@ -528,27 +528,27 @@ class NativeMobileKeyboard implements Keyboard {
return;
}

canvas.dispatchEvent(new KeyboardEvent('keydown', { key: data, code: data }));
canvas.dispatchEvent(new KeyboardEvent('keyup', { key: data, code: data }));
canvasOverlay.dispatchEvent(new KeyboardEvent('keydown', { key: data, code: data }));
canvasOverlay.dispatchEvent(new KeyboardEvent('keyup', { key: data, code: data }));
});

this.virtualInputElement.addEventListener('keydown', (ev: KeyboardEvent) => {
if (ev.key === 'Enter' || ev.key === 'Backspace') {
canvas.dispatchEvent(new KeyboardEvent('keydown', { key: ev.key, code: ev.key }));
canvasOverlay.dispatchEvent(new KeyboardEvent('keydown', { key: ev.key, code: ev.key }));
}
});
this.virtualInputElement.addEventListener('keyup', (ev: KeyboardEvent) => {
if (ev.key === 'Enter' || ev.key === 'Backspace') {
canvas.dispatchEvent(new KeyboardEvent('keyup', { key: ev.key, code: ev.key }));
canvasOverlay.dispatchEvent(new KeyboardEvent('keyup', { key: ev.key, code: ev.key }));
}
});
} else {
// Non-android can use `keydown` / `keyup` directly
this.virtualInputElement.addEventListener('keydown', (ev: KeyboardEvent) => {
canvas.dispatchEvent(new KeyboardEvent('keydown', { key: ev.key, code: ev.key }));
canvasOverlay.dispatchEvent(new KeyboardEvent('keydown', { key: ev.key, code: ev.key }));
});
this.virtualInputElement.addEventListener('keyup', (ev: KeyboardEvent) => {
canvas.dispatchEvent(new KeyboardEvent('keyup', { key: ev.key, code: ev.key }));
canvasOverlay.dispatchEvent(new KeyboardEvent('keyup', { key: ev.key, code: ev.key }));
});
}
document.body.appendChild(this.virtualInputElement);
Expand All @@ -562,15 +562,15 @@ class NativeMobileKeyboard implements Keyboard {
this.virtualInputElement.style.left = `${originX}px`;
this.virtualInputElement.style.top = `${originY}px`;
}
canvas.blur();
canvasOverlay.blur();
this.virtualInputElement.focus();
this.virtualInputElement.click();
this.displayed = true;
}
hide(): void {
// Blur the virtual input field
this.virtualInputElement.blur();
canvas.focus();
canvasOverlay.focus();
this.displayed = false;
}
isDisplayed(): boolean {
Expand Down
Loading