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,339 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Libretro type definitions and constants
|
|
3
|
+
* Based on libretro.h from the libretro API
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import {
|
|
7
|
+
MEMDESC_SAVE_RAM_BIT,
|
|
8
|
+
MEMDESC_VIDEO_RAM_BIT,
|
|
9
|
+
MEMDESC_ALIGN_BIT,
|
|
10
|
+
MEMDESC_MINSIZE_BIT,
|
|
11
|
+
MEMDESC_SIZE_8,
|
|
12
|
+
} from "./environment";
|
|
13
|
+
import { createTypedError } from "../../utils/typedError";
|
|
14
|
+
|
|
15
|
+
// Memory region IDs for retro_get_memory_data/size
|
|
16
|
+
export const RETRO_MEMORY = {
|
|
17
|
+
SAVE_RAM: 0,
|
|
18
|
+
RTC: 1,
|
|
19
|
+
SYSTEM_RAM: 2,
|
|
20
|
+
VIDEO_RAM: 3,
|
|
21
|
+
} as const;
|
|
22
|
+
|
|
23
|
+
// Memory descriptor flags for SET_MEMORY_MAPS
|
|
24
|
+
export const RETRO_MEMDESC = {
|
|
25
|
+
CONST: 1 << 0, // Memory is read-only
|
|
26
|
+
BIGENDIAN: 1 << 1, // Memory is big-endian
|
|
27
|
+
SYSTEM_RAM: 1 << 2, // System RAM
|
|
28
|
+
SAVE_RAM: 1 << MEMDESC_SAVE_RAM_BIT, // Save RAM (battery-backed)
|
|
29
|
+
VIDEO_RAM: 1 << MEMDESC_VIDEO_RAM_BIT, // Video RAM
|
|
30
|
+
ALIGN_2: 1 << MEMDESC_ALIGN_BIT, // Alignment hints
|
|
31
|
+
ALIGN_4: 2 << MEMDESC_ALIGN_BIT,
|
|
32
|
+
ALIGN_8: MEMDESC_SIZE_8 << MEMDESC_ALIGN_BIT,
|
|
33
|
+
MINSIZE_2: 1 << MEMDESC_MINSIZE_BIT,
|
|
34
|
+
MINSIZE_4: 2 << MEMDESC_MINSIZE_BIT,
|
|
35
|
+
MINSIZE_8: MEMDESC_SIZE_8 << MEMDESC_MINSIZE_BIT,
|
|
36
|
+
} as const;
|
|
37
|
+
|
|
38
|
+
// Device types for retro_set_controller_port_device
|
|
39
|
+
export const RETRO_DEVICE = {
|
|
40
|
+
NONE: 0,
|
|
41
|
+
JOYPAD: 1,
|
|
42
|
+
MOUSE: 2,
|
|
43
|
+
KEYBOARD: 3,
|
|
44
|
+
LIGHTGUN: 4,
|
|
45
|
+
ANALOG: 5,
|
|
46
|
+
POINTER: 6,
|
|
47
|
+
} as const;
|
|
48
|
+
|
|
49
|
+
// Joypad button IDs for retro_input_state
|
|
50
|
+
export const RETRO_DEVICE_ID_JOYPAD = {
|
|
51
|
+
B: 0,
|
|
52
|
+
Y: 1,
|
|
53
|
+
SELECT: 2,
|
|
54
|
+
START: 3,
|
|
55
|
+
UP: 4,
|
|
56
|
+
DOWN: 5,
|
|
57
|
+
LEFT: 6,
|
|
58
|
+
RIGHT: 7,
|
|
59
|
+
A: 8,
|
|
60
|
+
X: 9,
|
|
61
|
+
L: 10,
|
|
62
|
+
R: 11,
|
|
63
|
+
L2: 12,
|
|
64
|
+
R2: 13,
|
|
65
|
+
L3: 14,
|
|
66
|
+
R3: 15,
|
|
67
|
+
} as const;
|
|
68
|
+
|
|
69
|
+
// Analog stick index for retro_input_state
|
|
70
|
+
export const RETRO_DEVICE_INDEX_ANALOG = {
|
|
71
|
+
LEFT: 0, // Left analog stick
|
|
72
|
+
RIGHT: 1, // Right analog stick
|
|
73
|
+
BUTTON: 2, // Analog buttons (L2/R2 as analog)
|
|
74
|
+
} as const;
|
|
75
|
+
|
|
76
|
+
// Analog stick axis IDs for retro_input_state
|
|
77
|
+
export const RETRO_DEVICE_ID_ANALOG = {
|
|
78
|
+
X: 0, // Horizontal axis (negative = left, positive = right)
|
|
79
|
+
Y: 1, // Vertical axis (negative = up, positive = down)
|
|
80
|
+
} as const;
|
|
81
|
+
|
|
82
|
+
// Pixel format constants
|
|
83
|
+
export const RETRO_PIXEL_FORMAT = {
|
|
84
|
+
XRGB1555: 0, // 15-bit color, X ignored (0RRRRRGGGGGBBBBB)
|
|
85
|
+
XRGB8888: 1, // 32-bit XRGB (XXXXXXXX RRRRRRRR GGGGGGGG BBBBBBBB)
|
|
86
|
+
RGB565: 2, // 16-bit RGB (RRRRRGGG GGGBBBBB)
|
|
87
|
+
} as const;
|
|
88
|
+
|
|
89
|
+
// Environment callback commands
|
|
90
|
+
export const RETRO_ENVIRONMENT = {
|
|
91
|
+
// Experimental commands have bit 16 set
|
|
92
|
+
EXPERIMENTAL: 0x10000,
|
|
93
|
+
|
|
94
|
+
// Core info
|
|
95
|
+
SET_ROTATION: 1,
|
|
96
|
+
GET_OVERSCAN: 2,
|
|
97
|
+
GET_CAN_DUPE: 3,
|
|
98
|
+
SET_MESSAGE: 6,
|
|
99
|
+
SHUTDOWN: 7,
|
|
100
|
+
SET_PERFORMANCE_LEVEL: 8,
|
|
101
|
+
GET_SYSTEM_DIRECTORY: 9,
|
|
102
|
+
SET_PIXEL_FORMAT: 10,
|
|
103
|
+
SET_INPUT_DESCRIPTORS: 11,
|
|
104
|
+
SET_KEYBOARD_CALLBACK: 12,
|
|
105
|
+
SET_DISK_CONTROL_INTERFACE: 13,
|
|
106
|
+
SET_HW_RENDER: 14,
|
|
107
|
+
GET_VARIABLE: 15,
|
|
108
|
+
SET_VARIABLES: 16,
|
|
109
|
+
GET_VARIABLE_UPDATE: 17,
|
|
110
|
+
SET_SUPPORT_NO_GAME: 18,
|
|
111
|
+
GET_LIBRETRO_PATH: 19,
|
|
112
|
+
SET_FRAME_TIME_CALLBACK: 21,
|
|
113
|
+
SET_AUDIO_CALLBACK: 22,
|
|
114
|
+
GET_RUMBLE_INTERFACE: 23,
|
|
115
|
+
GET_INPUT_DEVICE_CAPABILITIES: 24,
|
|
116
|
+
GET_SENSOR_INTERFACE: 25,
|
|
117
|
+
GET_CAMERA_INTERFACE: 26,
|
|
118
|
+
GET_LOG_INTERFACE: 27,
|
|
119
|
+
GET_PERF_INTERFACE: 28,
|
|
120
|
+
GET_LOCATION_INTERFACE: 29,
|
|
121
|
+
GET_CORE_ASSETS_DIRECTORY: 30,
|
|
122
|
+
GET_SAVE_DIRECTORY: 31,
|
|
123
|
+
SET_SYSTEM_AV_INFO: 32,
|
|
124
|
+
SET_PROC_ADDRESS_CALLBACK: 33,
|
|
125
|
+
SET_SUBSYSTEM_INFO: 34,
|
|
126
|
+
SET_CONTROLLER_INFO: 35,
|
|
127
|
+
SET_MEMORY_MAPS: 36,
|
|
128
|
+
SET_GEOMETRY: 37,
|
|
129
|
+
GET_USERNAME: 38,
|
|
130
|
+
GET_LANGUAGE: 39,
|
|
131
|
+
GET_CURRENT_SOFTWARE_FRAMEBUFFER: 40,
|
|
132
|
+
GET_HW_RENDER_INTERFACE: 41,
|
|
133
|
+
SET_SUPPORT_ACHIEVEMENTS: 42,
|
|
134
|
+
SET_HW_RENDER_CONTEXT_NEGOTIATION_INTERFACE: 43,
|
|
135
|
+
SET_SERIALIZATION_QUIRKS: 44,
|
|
136
|
+
SET_HW_SHARED_CONTEXT: 44,
|
|
137
|
+
GET_VFS_INTERFACE: 45,
|
|
138
|
+
GET_LED_INTERFACE: 46,
|
|
139
|
+
GET_AUDIO_VIDEO_ENABLE: 47,
|
|
140
|
+
GET_MIDI_INTERFACE: 48,
|
|
141
|
+
GET_FASTFORWARDING: 49,
|
|
142
|
+
GET_TARGET_REFRESH_RATE: 50,
|
|
143
|
+
GET_INPUT_BITMASKS: 51,
|
|
144
|
+
GET_CORE_OPTIONS_VERSION: 52,
|
|
145
|
+
SET_CORE_OPTIONS: 53,
|
|
146
|
+
SET_CORE_OPTIONS_INTL: 54,
|
|
147
|
+
SET_CORE_OPTIONS_DISPLAY: 55,
|
|
148
|
+
GET_PREFERRED_HW_RENDER: 56,
|
|
149
|
+
GET_DISK_CONTROL_INTERFACE_VERSION: 57,
|
|
150
|
+
SET_DISK_CONTROL_EXT_INTERFACE: 58,
|
|
151
|
+
GET_MESSAGE_INTERFACE_VERSION: 59,
|
|
152
|
+
SET_MESSAGE_EXT: 60,
|
|
153
|
+
GET_INPUT_MAX_USERS: 61,
|
|
154
|
+
SET_AUDIO_BUFFER_STATUS_CALLBACK: 62,
|
|
155
|
+
SET_MINIMUM_AUDIO_LATENCY: 63,
|
|
156
|
+
SET_FASTFORWARDING_OVERRIDE: 64,
|
|
157
|
+
SET_CONTENT_INFO_OVERRIDE: 65,
|
|
158
|
+
GET_GAME_INFO_EXT: 66,
|
|
159
|
+
SET_CORE_OPTIONS_V2: 67,
|
|
160
|
+
SET_CORE_OPTIONS_V2_INTL: 68,
|
|
161
|
+
SET_CORE_OPTIONS_UPDATE_DISPLAY_CALLBACK: 69,
|
|
162
|
+
SET_VARIABLE: 70,
|
|
163
|
+
GET_THROTTLE_STATE: 71,
|
|
164
|
+
GET_SAVESTATE_CONTEXT: 72,
|
|
165
|
+
GET_HW_RENDER_CONTEXT_NEGOTIATION_INTERFACE_SUPPORT: 73,
|
|
166
|
+
GET_JIT_CAPABLE: 74,
|
|
167
|
+
GET_MICROPHONE_INTERFACE: 75,
|
|
168
|
+
GET_DEVICE_POWER: 77,
|
|
169
|
+
SET_NETPACKET_INTERFACE: 78,
|
|
170
|
+
GET_PLAYLIST_DIRECTORY: 79,
|
|
171
|
+
} as const;
|
|
172
|
+
|
|
173
|
+
// Log levels for GET_LOG_INTERFACE
|
|
174
|
+
export const RETRO_LOG = {
|
|
175
|
+
DEBUG: 0,
|
|
176
|
+
INFO: 1,
|
|
177
|
+
WARN: 2,
|
|
178
|
+
ERROR: 3,
|
|
179
|
+
} as const;
|
|
180
|
+
|
|
181
|
+
// Message target for SET_MESSAGE_EXT
|
|
182
|
+
export const RETRO_MESSAGE_TARGET = {
|
|
183
|
+
ALL: 0, // Display on OSD and log
|
|
184
|
+
OSD: 1, // Display on OSD only
|
|
185
|
+
LOG: 2, // Log only (don't display on screen)
|
|
186
|
+
} as const;
|
|
187
|
+
|
|
188
|
+
// Message type for SET_MESSAGE_EXT
|
|
189
|
+
export const RETRO_MESSAGE_TYPE = {
|
|
190
|
+
NOTIFICATION: 0, // Standard notification
|
|
191
|
+
NOTIFICATION_ALT: 1, // Alternate notification slot
|
|
192
|
+
STATUS: 2, // Persistent status message
|
|
193
|
+
PROGRESS: 3, // Progress indicator
|
|
194
|
+
} as const;
|
|
195
|
+
|
|
196
|
+
// Region constants
|
|
197
|
+
export const RETRO_REGION = {
|
|
198
|
+
NTSC: 0,
|
|
199
|
+
PAL: 1,
|
|
200
|
+
} as const;
|
|
201
|
+
|
|
202
|
+
// Language constants
|
|
203
|
+
export const RETRO_LANGUAGE = {
|
|
204
|
+
ENGLISH: 0,
|
|
205
|
+
JAPANESE: 1,
|
|
206
|
+
FRENCH: 2,
|
|
207
|
+
SPANISH: 3,
|
|
208
|
+
GERMAN: 4,
|
|
209
|
+
ITALIAN: 5,
|
|
210
|
+
DUTCH: 6,
|
|
211
|
+
PORTUGUESE_BRAZIL: 7,
|
|
212
|
+
PORTUGUESE_PORTUGAL: 8,
|
|
213
|
+
RUSSIAN: 9,
|
|
214
|
+
KOREAN: 10,
|
|
215
|
+
CHINESE_TRADITIONAL: 11,
|
|
216
|
+
CHINESE_SIMPLIFIED: 12,
|
|
217
|
+
ESPERANTO: 13,
|
|
218
|
+
POLISH: 14,
|
|
219
|
+
VIETNAMESE: 15,
|
|
220
|
+
ARABIC: 16,
|
|
221
|
+
GREEK: 17,
|
|
222
|
+
TURKISH: 18,
|
|
223
|
+
SLOVAK: 19,
|
|
224
|
+
PERSIAN: 20,
|
|
225
|
+
HEBREW: 21,
|
|
226
|
+
ASTURIAN: 22,
|
|
227
|
+
FINNISH: 23,
|
|
228
|
+
INDONESIAN: 24,
|
|
229
|
+
SWEDISH: 25,
|
|
230
|
+
UKRAINIAN: 26,
|
|
231
|
+
CZECH: 27,
|
|
232
|
+
CATALAN_VALENCIA: 28,
|
|
233
|
+
CATALAN: 29,
|
|
234
|
+
BRITISH_ENGLISH: 30,
|
|
235
|
+
HUNGARIAN: 31,
|
|
236
|
+
BELARUSIAN: 32,
|
|
237
|
+
GALICIAN: 33,
|
|
238
|
+
NORWEGIAN: 34,
|
|
239
|
+
LAST: 35,
|
|
240
|
+
} as const;
|
|
241
|
+
|
|
242
|
+
// TypeScript interfaces for libretro structs
|
|
243
|
+
export interface RetroSystemInfo {
|
|
244
|
+
library_name: string;
|
|
245
|
+
library_version: string;
|
|
246
|
+
valid_extensions: string;
|
|
247
|
+
need_fullpath: boolean;
|
|
248
|
+
block_extract: boolean;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
export interface RetroGameGeometry {
|
|
252
|
+
base_width: number;
|
|
253
|
+
base_height: number;
|
|
254
|
+
max_width: number;
|
|
255
|
+
max_height: number;
|
|
256
|
+
aspect_ratio: number;
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
export interface RetroSystemTiming {
|
|
260
|
+
fps: number;
|
|
261
|
+
sample_rate: number;
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
export interface RetroSystemAVInfo {
|
|
265
|
+
geometry: RetroGameGeometry;
|
|
266
|
+
timing: RetroSystemTiming;
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
export interface RetroGameInfo {
|
|
270
|
+
path: string | null;
|
|
271
|
+
data: Buffer | null;
|
|
272
|
+
size: number;
|
|
273
|
+
meta: string | null;
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
export interface RetroVariable {
|
|
277
|
+
key: string;
|
|
278
|
+
value: string;
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
export interface RetroInputDescriptor {
|
|
282
|
+
port: number;
|
|
283
|
+
device: number;
|
|
284
|
+
index: number;
|
|
285
|
+
id: number;
|
|
286
|
+
description: string;
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
export interface RetroLogCallback {
|
|
290
|
+
log: (level: number, fmt: string, ...args: unknown[]) => void;
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
/**
|
|
294
|
+
* Basic message structure (SET_MESSAGE)
|
|
295
|
+
*/
|
|
296
|
+
export interface RetroMessage {
|
|
297
|
+
msg: string;
|
|
298
|
+
frames: number; // Duration in frames (60fps assumed)
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
/**
|
|
302
|
+
* Extended message structure (SET_MESSAGE_EXT)
|
|
303
|
+
*/
|
|
304
|
+
export interface RetroMessageExt {
|
|
305
|
+
msg: string;
|
|
306
|
+
duration: number; // Duration in milliseconds
|
|
307
|
+
priority: number; // Higher = more important
|
|
308
|
+
level: number; // RETRO_LOG level
|
|
309
|
+
target: number; // RETRO_MESSAGE_TARGET
|
|
310
|
+
type: number; // RETRO_MESSAGE_TYPE
|
|
311
|
+
progress: number; // -1 = indeterminate, 0-100 = progress percentage
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
/** Libretro core error codes */
|
|
315
|
+
export type LibretroErrorCode =
|
|
316
|
+
| 'ROM_READ_FAILED'
|
|
317
|
+
| 'ROM_REJECTED'
|
|
318
|
+
| 'NO_GAME_LOADED'
|
|
319
|
+
| 'STATE_LOAD_FAILED';
|
|
320
|
+
|
|
321
|
+
const { TypedError: LibretroErrorClass, isTypedError: isLibretroErrorGuard } = createTypedError<LibretroErrorCode>('LibretroError');
|
|
322
|
+
export const LibretroError = LibretroErrorClass;
|
|
323
|
+
export type LibretroError = InstanceType<typeof LibretroErrorClass>;
|
|
324
|
+
export const isLibretroError = isLibretroErrorGuard;
|
|
325
|
+
|
|
326
|
+
// Type guards
|
|
327
|
+
export type RetroMemoryType =
|
|
328
|
+
(typeof RETRO_MEMORY)[keyof typeof RETRO_MEMORY];
|
|
329
|
+
export type RetroDeviceType = (typeof RETRO_DEVICE)[keyof typeof RETRO_DEVICE];
|
|
330
|
+
export type RetroJoypadButton =
|
|
331
|
+
(typeof RETRO_DEVICE_ID_JOYPAD)[keyof typeof RETRO_DEVICE_ID_JOYPAD];
|
|
332
|
+
export type RetroAnalogIndex =
|
|
333
|
+
(typeof RETRO_DEVICE_INDEX_ANALOG)[keyof typeof RETRO_DEVICE_INDEX_ANALOG];
|
|
334
|
+
export type RetroAnalogAxis =
|
|
335
|
+
(typeof RETRO_DEVICE_ID_ANALOG)[keyof typeof RETRO_DEVICE_ID_ANALOG];
|
|
336
|
+
export type RetroPixelFormat =
|
|
337
|
+
(typeof RETRO_PIXEL_FORMAT)[keyof typeof RETRO_PIXEL_FORMAT];
|
|
338
|
+
export type RetroEnvironmentCmd =
|
|
339
|
+
(typeof RETRO_ENVIRONMENT)[keyof typeof RETRO_ENVIRONMENT];
|