emoemu 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude/settings.local.json +77 -0
- package/.node-version +1 -0
- package/CLAUDE.md +435 -0
- package/README.md +404 -0
- package/TODO.md +655 -0
- package/dist/index.cjs +25108 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +25085 -0
- package/docs/building-libretro-cores-arm-mac.md +237 -0
- package/docs/config-file-format.md +488 -0
- package/docs/cores-trd.md +425 -0
- package/docs/headless-hardware-rendering-trd.md +676 -0
- package/docs/libretro-cores-trd.md +997 -0
- package/docs/mupen64-software-rendering-trd.md +751 -0
- package/docs/n64-support-trd.md +306 -0
- package/docs/native-rendering-trd.md +540 -0
- package/docs/native-ui-rendering-trd.md +1195 -0
- package/docs/netplay-trd.md +665 -0
- package/docs/retroarch-netplay-docs.md +277 -0
- package/docs/save-state-format.md +666 -0
- package/eslint.config.js +111 -0
- package/icon/icon.png +0 -0
- package/icon/icon.pxd +0 -0
- package/package.json +63 -0
- package/pnpm-workspace.yaml +10 -0
- package/src/Emulator/consts.ts +14 -0
- package/src/Emulator/index.ts +2496 -0
- package/src/Emulator/saveState/index.ts +155 -0
- package/src/Emulator/screenshot/index.ts +160 -0
- package/src/Emulator/terminalDimensions/index.ts +79 -0
- package/src/Emulator/types.ts +83 -0
- package/src/cli/commands/consts.ts +10 -0
- package/src/cli/commands/index.ts +462 -0
- package/src/cli/parseArgs/consts.ts +17 -0
- package/src/cli/parseArgs/index.ts +457 -0
- package/src/cli/parseArgs/types.ts +61 -0
- package/src/cli/runEmulator/index.ts +406 -0
- package/src/cli/runEmulator/types.ts +7 -0
- package/src/consts.ts +19 -0
- package/src/core/button/consts.ts +35 -0
- package/src/core/button/index.ts +123 -0
- package/src/core/core.ts +300 -0
- package/src/core/index.ts +19 -0
- package/src/cores/libretro/api/index.ts +334 -0
- package/src/cores/libretro/api/types.ts +148 -0
- package/src/cores/libretro/callbacks/consts.ts +41 -0
- package/src/cores/libretro/callbacks/index.ts +456 -0
- package/src/cores/libretro/consts.ts +45 -0
- package/src/cores/libretro/coreOptions/consts.ts +36 -0
- package/src/cores/libretro/coreOptions/index.ts +222 -0
- package/src/cores/libretro/environment/consts.ts +118 -0
- package/src/cores/libretro/environment/index.ts +1095 -0
- package/src/cores/libretro/index.ts +937 -0
- package/src/cores/libretro/loader/index.ts +496 -0
- package/src/cores/libretro/pixelFormat/consts.ts +43 -0
- package/src/cores/libretro/pixelFormat/index.ts +397 -0
- package/src/cores/libretro/types.ts +339 -0
- package/src/frontend/AudioManager/index.ts +420 -0
- package/src/frontend/SettingsManager/index.ts +250 -0
- package/src/frontend/config/index.ts +608 -0
- package/src/frontend/config/tests.ts +354 -0
- package/src/frontend/config/types.ts +36 -0
- package/src/frontend/consts.ts +114 -0
- package/src/frontend/coreBuilder/index.ts +644 -0
- package/src/frontend/coreBuilder/types.ts +15 -0
- package/src/frontend/coreDownloader/index.ts +620 -0
- package/src/frontend/coreDownloader/types.ts +17 -0
- package/src/frontend/corePreferences/index.ts +69 -0
- package/src/frontend/coreRegistry/index.ts +276 -0
- package/src/frontend/directoryCache/index.ts +75 -0
- package/src/frontend/index.ts +79 -0
- package/src/frontend/notifications/consts.ts +14 -0
- package/src/frontend/notifications/index.ts +250 -0
- package/src/frontend/playlist/consts.ts +168 -0
- package/src/frontend/playlist/index.ts +899 -0
- package/src/frontend/playlist/labelFormatter/consts.ts +15 -0
- package/src/frontend/playlist/labelFormatter/index.ts +155 -0
- package/src/frontend/playlist/labelFormatter/tests.ts +153 -0
- package/src/frontend/playlist/reader/index.ts +559 -0
- package/src/frontend/playlist/sync/index.ts +511 -0
- package/src/frontend/playlist/systemLookup/index.ts +233 -0
- package/src/frontend/playlist/utils/index.ts +50 -0
- package/src/frontend/romScanner/consts.ts +348 -0
- package/src/frontend/romScanner/index.ts +1957 -0
- package/src/frontend/saveServices/consts.ts +2 -0
- package/src/frontend/saveServices/index.ts +313 -0
- package/src/frontend/serviceProvider/index.ts +108 -0
- package/src/frontend/serviceProvider/types.ts +13 -0
- package/src/index.ts +428 -0
- package/src/input/Controller/consts.ts +50 -0
- package/src/input/Controller/index.ts +81 -0
- package/src/input/GamepadManager/consts.ts +22 -0
- package/src/input/GamepadManager/index.ts +418 -0
- package/src/input/InputManager/consts.ts +86 -0
- package/src/input/InputManager/index.ts +593 -0
- package/src/input/InputMapper/consts.ts +33 -0
- package/src/input/InputMapper/index.ts +436 -0
- package/src/input/consts.ts +410 -0
- package/src/input/gamepadProfiles/index.ts +1100 -0
- package/src/input/index.ts +38 -0
- package/src/input/inputUtils/index.ts +31 -0
- package/src/netplay/FrameBuffer/consts.ts +2 -0
- package/src/netplay/FrameBuffer/index.ts +364 -0
- package/src/netplay/FrameBuffer/tests.ts +286 -0
- package/src/netplay/InputBuffer/consts.ts +7 -0
- package/src/netplay/InputBuffer/index.ts +347 -0
- package/src/netplay/InputBuffer/tests.ts +166 -0
- package/src/netplay/NetplayClient/index.ts +976 -0
- package/src/netplay/NetplayConnection/index.ts +536 -0
- package/src/netplay/NetplayDiscovery/consts.ts +41 -0
- package/src/netplay/NetplayDiscovery/index.ts +525 -0
- package/src/netplay/NetplayServer/index.ts +1407 -0
- package/src/netplay/SyncManager/index.ts +984 -0
- package/src/netplay/SyncManager/tests.ts +419 -0
- package/src/netplay/consts.ts +371 -0
- package/src/netplay/crc32/consts.ts +14 -0
- package/src/netplay/crc32/index.ts +97 -0
- package/src/netplay/crc32/tests.ts +40 -0
- package/src/netplay/index.ts +41 -0
- package/src/netplay/netplayLogger/consts.ts +30 -0
- package/src/netplay/netplayLogger/index.ts +345 -0
- package/src/netplay/protocol/consts.ts +86 -0
- package/src/netplay/protocol/index.ts +1280 -0
- package/src/netplay/protocol/tests.ts +606 -0
- package/src/netplay/protocol/types.ts +20 -0
- package/src/netplay/types.ts +395 -0
- package/src/rendering/KittyRenderer/index.ts +616 -0
- package/src/rendering/NativeRenderer/index.ts +279 -0
- package/src/rendering/NativeRenderer/tests.ts +133 -0
- package/src/rendering/TerminalRenderer/index.ts +770 -0
- package/src/rendering/consts.ts +401 -0
- package/src/rendering/fonts/CozetteVector.ttf +0 -0
- package/src/rendering/index.ts +26 -0
- package/src/rendering/nativeUi/NativeWindowManager/index.ts +158 -0
- package/src/rendering/nativeUi/NativeWindowManager/tests.ts +81 -0
- package/src/rendering/nativeUi/consts.ts +6 -0
- package/src/rendering/nativeUi/index.ts +20 -0
- package/src/rendering/postProcessing/consts.ts +38 -0
- package/src/rendering/postProcessing/index.ts +923 -0
- package/src/rendering/shared/ansi/consts.ts +12 -0
- package/src/rendering/shared/ansi/index.ts +104 -0
- package/src/rendering/shared/consts.ts +2 -0
- package/src/rendering/shared/fitToTerminal/index.ts +67 -0
- package/src/ui/AddRomsPrompt/consts.ts +13 -0
- package/src/ui/AddRomsPrompt/index.tsx +781 -0
- package/src/ui/App/consts.ts +2 -0
- package/src/ui/App/index.tsx +456 -0
- package/src/ui/AppCapabilities/index.tsx +67 -0
- package/src/ui/ConfigContext/index.tsx +56 -0
- package/src/ui/CoreManager/consts.ts +11 -0
- package/src/ui/CoreManager/index.tsx +779 -0
- package/src/ui/CoreSelector/consts.ts +2 -0
- package/src/ui/CoreSelector/index.tsx +251 -0
- package/src/ui/DialogContainer/index.tsx +42 -0
- package/src/ui/DialogOptionsList/index.tsx +61 -0
- package/src/ui/DuplicateCrcPrompt/consts.ts +5 -0
- package/src/ui/DuplicateCrcPrompt/index.tsx +146 -0
- package/src/ui/GamepadContext/consts.ts +15 -0
- package/src/ui/GamepadContext/index.tsx +295 -0
- package/src/ui/NativeDialog/index.tsx +120 -0
- package/src/ui/NetplayDisconnectedDialog/index.tsx +93 -0
- package/src/ui/NetplayPauseMenu/consts.ts +2 -0
- package/src/ui/NetplayPauseMenu/index.tsx +97 -0
- package/src/ui/RomBrowser/NetplayPanel/consts.ts +24 -0
- package/src/ui/RomBrowser/NetplayPanel/index.tsx +520 -0
- package/src/ui/RomBrowser/SettingsPanel/index.tsx +478 -0
- package/src/ui/RomBrowser/consts.ts +61 -0
- package/src/ui/RomBrowser/index.tsx +1164 -0
- package/src/ui/RomBrowser/settingsConfig/index.ts +320 -0
- package/src/ui/RomBrowser/types.ts +67 -0
- package/src/ui/SaveStateDialog/consts.ts +2 -0
- package/src/ui/SaveStateDialog/index.tsx +225 -0
- package/src/ui/WarningDialog/index.tsx +113 -0
- package/src/ui/consts.ts +27 -0
- package/src/ui/hooks/useClearTerminal/consts.ts +2 -0
- package/src/ui/hooks/useClearTerminal/index.ts +37 -0
- package/src/ui/hooks/useDialogNavigation/index.ts +99 -0
- package/src/ui/hooks/useGamepad/consts.ts +21 -0
- package/src/ui/hooks/useGamepad/index.ts +194 -0
- package/src/ui/index.ts +27 -0
- package/src/utils/buffer/consts.ts +17 -0
- package/src/utils/buffer/index.ts +129 -0
- package/src/utils/color/consts.ts +58 -0
- package/src/utils/color/index.ts +183 -0
- package/src/utils/compression/consts.ts +50 -0
- package/src/utils/compression/index.ts +101 -0
- package/src/utils/consts.ts +2 -0
- package/src/utils/crc32/consts.ts +22 -0
- package/src/utils/crc32/index.ts +83 -0
- package/src/utils/ensureDirectory/index.ts +10 -0
- package/src/utils/format/consts.ts +8 -0
- package/src/utils/format/index.ts +53 -0
- package/src/utils/getErrorMessage/index.ts +10 -0
- package/src/utils/index.ts +113 -0
- package/src/utils/ini/index.ts +200 -0
- package/src/utils/kitty/consts.ts +13 -0
- package/src/utils/kitty/index.ts +181 -0
- package/src/utils/logger/consts.ts +35 -0
- package/src/utils/logger/index.ts +217 -0
- package/src/utils/paths/consts.ts +18 -0
- package/src/utils/paths/index.ts +151 -0
- package/src/utils/png/consts.ts +34 -0
- package/src/utils/png/index.ts +131 -0
- package/src/utils/readJsonFile/index.ts +16 -0
- package/src/utils/rotateLogFile/index.ts +44 -0
- package/src/utils/safeClose/index.ts +10 -0
- package/src/utils/terminal/consts.ts +8 -0
- package/src/utils/terminal/index.ts +102 -0
- package/src/utils/thumbnailRenderer/consts.ts +2 -0
- package/src/utils/thumbnailRenderer/index.ts +147 -0
- package/src/utils/typedError/index.ts +26 -0
- package/tsconfig.json +31 -0
- package/vitest.config.ts +13 -0
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
import { describe, it, expect, beforeEach } from 'vitest';
|
|
2
|
+
import { InputBuffer, createInputBuffer } from '.';
|
|
3
|
+
import { MAX_INPUT_DEVICES } from '..';
|
|
4
|
+
|
|
5
|
+
describe('InputBuffer', () => {
|
|
6
|
+
let inputBuffer: InputBuffer;
|
|
7
|
+
|
|
8
|
+
beforeEach(() => {
|
|
9
|
+
inputBuffer = createInputBuffer();
|
|
10
|
+
inputBuffer.initialize(0, 2); // Client 0, 2 frame delay
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
describe('initialization', () => {
|
|
14
|
+
it('should set local client ID and delay', () => {
|
|
15
|
+
expect(inputBuffer.localClientId).toBe(0);
|
|
16
|
+
expect(inputBuffer.inputDelayFrames).toBe(2);
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
it('should auto-register local client', () => {
|
|
20
|
+
expect(inputBuffer.getClientIds()).toContain(0);
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
it('should clamp delay to max', () => {
|
|
24
|
+
inputBuffer.initialize(0, 100);
|
|
25
|
+
expect(inputBuffer.inputDelayFrames).toBeLessThanOrEqual(16);
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
describe('client registration', () => {
|
|
30
|
+
it('should register new clients', () => {
|
|
31
|
+
inputBuffer.registerClient(1);
|
|
32
|
+
inputBuffer.registerClient(2);
|
|
33
|
+
expect(inputBuffer.getClientIds()).toContain(1);
|
|
34
|
+
expect(inputBuffer.getClientIds()).toContain(2);
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
it('should not duplicate clients', () => {
|
|
38
|
+
inputBuffer.registerClient(1);
|
|
39
|
+
inputBuffer.registerClient(1);
|
|
40
|
+
const ids = inputBuffer.getClientIds().filter((id) => id === 1);
|
|
41
|
+
expect(ids.length).toBe(1);
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
it('should unregister clients', () => {
|
|
45
|
+
inputBuffer.registerClient(1);
|
|
46
|
+
inputBuffer.unregisterClient(1);
|
|
47
|
+
expect(inputBuffer.getClientIds()).not.toContain(1);
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
it('should return only remote client IDs', () => {
|
|
51
|
+
inputBuffer.registerClient(1);
|
|
52
|
+
inputBuffer.registerClient(2);
|
|
53
|
+
const remoteIds = inputBuffer.getRemoteClientIds();
|
|
54
|
+
expect(remoteIds).toContain(1);
|
|
55
|
+
expect(remoteIds).toContain(2);
|
|
56
|
+
expect(remoteIds).not.toContain(0); // Local client
|
|
57
|
+
});
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
describe('local input delay queue', () => {
|
|
61
|
+
it('should queue input with delay', () => {
|
|
62
|
+
const targetFrame = inputBuffer.queueLocalInput(10, [0xff]);
|
|
63
|
+
expect(targetFrame).toBe(12); // 10 + 2 frame delay
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
it('should retrieve delayed input', () => {
|
|
67
|
+
inputBuffer.queueLocalInput(10, [0xaa, 0xbb]);
|
|
68
|
+
const input = inputBuffer.getDelayedLocalInput(12);
|
|
69
|
+
expect(input).toEqual([0xaa, 0xbb]);
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
it('should return null for unavailable input', () => {
|
|
73
|
+
expect(inputBuffer.getDelayedLocalInput(100)).toBeNull();
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
it('should prune old entries', () => {
|
|
77
|
+
inputBuffer.queueLocalInput(10, [1]);
|
|
78
|
+
inputBuffer.queueLocalInput(11, [2]);
|
|
79
|
+
inputBuffer.queueLocalInput(12, [3]);
|
|
80
|
+
|
|
81
|
+
inputBuffer.pruneDelayQueue(13);
|
|
82
|
+
|
|
83
|
+
expect(inputBuffer.getDelayedLocalInput(12)).toBeNull();
|
|
84
|
+
expect(inputBuffer.getDelayedLocalInput(14)).toEqual([3]);
|
|
85
|
+
});
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
describe('remote input', () => {
|
|
89
|
+
it('should record remote input', () => {
|
|
90
|
+
inputBuffer.registerClient(1);
|
|
91
|
+
inputBuffer.recordRemoteInput(1, 10, [0xab, 0xcd]);
|
|
92
|
+
|
|
93
|
+
expect(inputBuffer.getLastRealInputFrame(1)).toBe(10);
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
it('should auto-register unknown clients', () => {
|
|
97
|
+
inputBuffer.recordRemoteInput(99, 5, [1, 2, 3]);
|
|
98
|
+
expect(inputBuffer.getClientIds()).toContain(99);
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
it('should update last input on record', () => {
|
|
102
|
+
inputBuffer.registerClient(1);
|
|
103
|
+
inputBuffer.recordRemoteInput(1, 10, [0x11]);
|
|
104
|
+
inputBuffer.recordRemoteInput(1, 11, [0x22]);
|
|
105
|
+
|
|
106
|
+
const { input } = inputBuffer.getInputForClient(1, 11, true);
|
|
107
|
+
expect(input[0]).toBe(0x22);
|
|
108
|
+
});
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
describe('input prediction', () => {
|
|
112
|
+
it('should return real input when available', () => {
|
|
113
|
+
inputBuffer.registerClient(1);
|
|
114
|
+
inputBuffer.recordRemoteInput(1, 10, [0xaa]);
|
|
115
|
+
|
|
116
|
+
const result = inputBuffer.getInputForClient(1, 10, true);
|
|
117
|
+
expect(result.isReal).toBe(true);
|
|
118
|
+
expect(result.input[0]).toBe(0xaa);
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
it('should predict when real input not available', () => {
|
|
122
|
+
inputBuffer.registerClient(1);
|
|
123
|
+
inputBuffer.recordRemoteInput(1, 10, [0xbb]);
|
|
124
|
+
|
|
125
|
+
const result = inputBuffer.getInputForClient(1, 15, false);
|
|
126
|
+
expect(result.isReal).toBe(false);
|
|
127
|
+
// Should repeat last known input
|
|
128
|
+
expect(result.input[0]).toBe(0xbb);
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
it('should return zeros for unknown client', () => {
|
|
132
|
+
const result = inputBuffer.getInputForClient(999, 10, false);
|
|
133
|
+
expect(result.isReal).toBe(false);
|
|
134
|
+
expect(result.input[0]).toBe(0);
|
|
135
|
+
});
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
describe('device input', () => {
|
|
139
|
+
it('should set and get device input', () => {
|
|
140
|
+
inputBuffer.setDeviceInput(0, 1, 0xff, 0x1234, 0x5678);
|
|
141
|
+
|
|
142
|
+
const device = inputBuffer.getDeviceInput(0, 1);
|
|
143
|
+
expect(device).not.toBeNull();
|
|
144
|
+
expect(device!.joypad).toBe(0xff);
|
|
145
|
+
expect(device!.analogLeft).toBe(0x1234);
|
|
146
|
+
expect(device!.analogRight).toBe(0x5678);
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
it('should return null for out of range device', () => {
|
|
150
|
+
expect(inputBuffer.getDeviceInput(0, MAX_INPUT_DEVICES)).toBeNull();
|
|
151
|
+
});
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
describe('clear', () => {
|
|
155
|
+
it('should clear all state', () => {
|
|
156
|
+
inputBuffer.registerClient(1);
|
|
157
|
+
inputBuffer.registerClient(2);
|
|
158
|
+
inputBuffer.queueLocalInput(10, [1]);
|
|
159
|
+
|
|
160
|
+
inputBuffer.clear();
|
|
161
|
+
|
|
162
|
+
expect(inputBuffer.getClientIds()).toHaveLength(0);
|
|
163
|
+
expect(inputBuffer.getDelayedLocalInput(12)).toBeNull();
|
|
164
|
+
});
|
|
165
|
+
});
|
|
166
|
+
});
|