mirror of
https://github.com/dingusdev/dingusppc.git
synced 2026-04-25 19:18:34 +00:00
Start i18n
This commit is contained in:
+13
-2
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
DingusPPC - The Experimental PowerPC Macintosh emulator
|
||||
Copyright (C) 2018-23 divingkatae and maximum
|
||||
Copyright (C) 2018-25 divingkatae and maximum
|
||||
(theweirdo) spatium
|
||||
|
||||
(Contact divingkatae#1017 or powermax#2286 on Discord for more info)
|
||||
@@ -73,6 +73,17 @@ public:
|
||||
uint16_t keys_state;
|
||||
};
|
||||
|
||||
|
||||
enum KeyboardLocale : uint32_t {
|
||||
Eng_USA = 0,
|
||||
Eng_GBR = 1,
|
||||
Fra_FRA = 10,
|
||||
Deu_DEU = 20,
|
||||
Ita_ITA = 30,
|
||||
Spa_ESP = 40,
|
||||
Jpn_JPN = 80,
|
||||
};
|
||||
|
||||
/* AppleJack bits 3-7 are supported but unused */
|
||||
enum GamepadButton : uint8_t {
|
||||
Red = 14,
|
||||
@@ -112,7 +123,7 @@ public:
|
||||
return event_manager;
|
||||
};
|
||||
|
||||
void poll_events();
|
||||
void poll_events(uint32_t kbd_locale);
|
||||
|
||||
template <typename T>
|
||||
void add_window_handler(T *inst, void (T::*func)(const WindowEvent&)) {
|
||||
|
||||
+14
-14
@@ -28,11 +28,10 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
EventManager* EventManager::event_manager;
|
||||
|
||||
static int get_sdl_event_key_code(const SDL_KeyboardEvent &event);
|
||||
static int get_sdl_event_key_code(const SDL_KeyboardEvent& event, uint32_t kbd_locale);
|
||||
static void toggle_mouse_grab(const SDL_KeyboardEvent &event);
|
||||
|
||||
void EventManager::poll_events()
|
||||
{
|
||||
void EventManager::poll_events(uint32_t kbd_locale) {
|
||||
SDL_Event event;
|
||||
|
||||
while (SDL_PollEvent(&event)) {
|
||||
@@ -45,7 +44,7 @@ void EventManager::poll_events()
|
||||
break;
|
||||
|
||||
case SDL_WINDOWEVENT: {
|
||||
WindowEvent we;
|
||||
WindowEvent we{};
|
||||
we.sub_type = event.window.event;
|
||||
we.window_id = event.window.windowID;
|
||||
this->_window_signal.emit(we);
|
||||
@@ -65,16 +64,16 @@ void EventManager::poll_events()
|
||||
// Control-S: scale quality
|
||||
if (event.key.keysym.sym == SDLK_s && SDL_GetModState() & KMOD_LCTRL) {
|
||||
if (event.type == SDL_KEYUP) {
|
||||
WindowEvent we;
|
||||
WindowEvent we{};
|
||||
we.sub_type = WINDOW_SCALE_QUALITY_TOGGLE;
|
||||
we.window_id = event.window.windowID;
|
||||
this->_window_signal.emit(we);
|
||||
}
|
||||
return;
|
||||
}
|
||||
int key_code = get_sdl_event_key_code(event.key);
|
||||
int key_code = get_sdl_event_key_code(event.key, kbd_locale);
|
||||
if (key_code != -1) {
|
||||
KeyboardEvent ke;
|
||||
KeyboardEvent ke{};
|
||||
ke.key = key_code;
|
||||
if (event.type == SDL_KEYDOWN) {
|
||||
ke.flags = KEYBOARD_EVENT_DOWN;
|
||||
@@ -96,7 +95,7 @@ void EventManager::poll_events()
|
||||
break;
|
||||
|
||||
case SDL_MOUSEMOTION: {
|
||||
MouseEvent me;
|
||||
MouseEvent me{};
|
||||
me.xrel = event.motion.xrel;
|
||||
me.yrel = event.motion.yrel;
|
||||
me.xabs = event.motion.x;
|
||||
@@ -107,7 +106,7 @@ void EventManager::poll_events()
|
||||
break;
|
||||
|
||||
case SDL_MOUSEBUTTONDOWN: {
|
||||
MouseEvent me;
|
||||
MouseEvent me{};
|
||||
Uint8 adb_button;
|
||||
switch (event.button.button) {
|
||||
case SDL_BUTTON_LEFT : adb_button = 0; break;
|
||||
@@ -124,7 +123,7 @@ void EventManager::poll_events()
|
||||
break;
|
||||
|
||||
case SDL_MOUSEBUTTONUP: {
|
||||
MouseEvent me;
|
||||
MouseEvent me{};
|
||||
Uint8 adb_button;
|
||||
switch (event.button.button) {
|
||||
case SDL_BUTTON_LEFT : adb_button = 0; break;
|
||||
@@ -141,7 +140,7 @@ void EventManager::poll_events()
|
||||
break;
|
||||
|
||||
case SDL_CONTROLLERBUTTONDOWN: {
|
||||
GamepadEvent ge;
|
||||
GamepadEvent ge{};
|
||||
switch (event.cbutton.button) {
|
||||
case SDL_CONTROLLER_BUTTON_BACK: ge.button = GamepadButton::FrontLeft; break;
|
||||
case SDL_CONTROLLER_BUTTON_GUIDE: ge.button = GamepadButton::FrontMiddle; break;
|
||||
@@ -164,7 +163,7 @@ void EventManager::poll_events()
|
||||
break;
|
||||
|
||||
case SDL_CONTROLLERBUTTONUP: {
|
||||
GamepadEvent ge;
|
||||
GamepadEvent ge{};
|
||||
switch (event.cbutton.button) {
|
||||
case SDL_CONTROLLER_BUTTON_BACK: ge.button = GamepadButton::FrontLeft; break;
|
||||
case SDL_CONTROLLER_BUTTON_GUIDE: ge.button = GamepadButton::FrontMiddle; break;
|
||||
@@ -196,7 +195,7 @@ void EventManager::poll_events()
|
||||
}
|
||||
|
||||
|
||||
static int get_sdl_event_key_code(const SDL_KeyboardEvent &event)
|
||||
static int get_sdl_event_key_code(const SDL_KeyboardEvent &event, uint32_t kbd_locale)
|
||||
{
|
||||
switch (event.keysym.sym) {
|
||||
case SDLK_a: return AdbKey_A;
|
||||
@@ -331,7 +330,8 @@ static int get_sdl_event_key_code(const SDL_KeyboardEvent &event)
|
||||
|
||||
//Japanese keyboard
|
||||
case SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_INTERNATIONAL3):
|
||||
return AdbKey_JIS_Yen;
|
||||
if (kbd_locale == Jpn_JPN)
|
||||
return AdbKey_JIS_Yen;
|
||||
case SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_INTERNATIONAL1):
|
||||
return AdbKey_JIS_Underscore;
|
||||
case 0XBC:
|
||||
|
||||
@@ -37,6 +37,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
#include <csignal>
|
||||
#include <cstring>
|
||||
#include <iostream>
|
||||
#include <optional>
|
||||
#include <CLI11.hpp>
|
||||
#include <loguru.hpp>
|
||||
|
||||
@@ -60,7 +61,7 @@ static void sigabrt_handler(int signum) {
|
||||
}
|
||||
|
||||
static string appDescription = string(
|
||||
"\nDingusPPC - Alpha 1.01 (10/31/2024) "
|
||||
"\nDingusPPC - Alpha 1.02 (5/10/2025) "
|
||||
"\nWritten by divingkatae, maximumspatium, "
|
||||
"\njoevt, mihaip, kkaisershot, et. al. "
|
||||
"\n(c) 2018-2024 The DingusPPC Dev Team. "
|
||||
@@ -99,8 +100,10 @@ int main(int argc, char** argv) {
|
||||
app.allow_windows_style_options(); /* we want Windows-style options */
|
||||
app.allow_extras();
|
||||
|
||||
bool realtime_enabled = false;
|
||||
bool debugger_enabled = false;
|
||||
bool realtime_enabled = false;
|
||||
bool debugger_enabled = false;
|
||||
uint32_t keyboard_id = 0;
|
||||
|
||||
string bootrom_path("bootrom.bin");
|
||||
string working_directory_path(".");
|
||||
|
||||
@@ -110,6 +113,7 @@ int main(int argc, char** argv) {
|
||||
"Run the emulator in real-time");
|
||||
execution_mode_group->add_flag("-d,--debugger", debugger_enabled,
|
||||
"Enter the built-in debugger");
|
||||
app.add_option("-k,--keyboard", keyboard_id, "Specify keyboard ID");
|
||||
app.add_option("-w,--workingdir", working_directory_path, "Specifies working directory")
|
||||
->check(WorkingDirectory);
|
||||
app.add_option("-b,--bootrom", bootrom_path, "Specifies BootROM path")
|
||||
@@ -179,7 +183,7 @@ int main(int argc, char** argv) {
|
||||
}
|
||||
|
||||
auto rom_data = std::unique_ptr<char[]>(new char[4 * 1024 * 1024]);
|
||||
memset(&rom_data[0], 0, 4 * 1024 * 1024);
|
||||
memset(&rom_data[0], 0, static_cast<size_t>(4 * 1024 * 1024));
|
||||
size_t rom_size = MachineFactory::read_boot_rom(bootrom_path, &rom_data[0]);
|
||||
if (!rom_size) {
|
||||
return 1;
|
||||
@@ -309,8 +313,8 @@ void run_machine(std::string machine_str, char *rom_data, size_t rom_size, uint3
|
||||
|
||||
// set up system wide event polling using
|
||||
// default Macintosh polling rate of 11 ms
|
||||
uint32_t event_timer = TimerManager::get_instance()->add_cyclic_timer(MSECS_TO_NSECS(11), [] {
|
||||
EventManager::get_instance()->poll_events();
|
||||
uint32_t event_timer = TimerManager::get_instance()->add_cyclic_timer(MSECS_TO_NSECS(11), [] {
|
||||
EventManager::get_instance()->poll_events(Eng_USA);
|
||||
});
|
||||
|
||||
#ifdef CPU_PROFILING
|
||||
|
||||
Reference in New Issue
Block a user