From 2c313f3acc21ba1f263255982f7ecfe9c35794ed Mon Sep 17 00:00:00 2001 From: Helloyunho Date: Sat, 5 Jul 2025 11:03:40 +0900 Subject: [PATCH] =?UTF-8?q?=F0=9F=A7=91=E2=80=8D=F0=9F=92=BB=20chore:=20im?= =?UTF-8?q?prove=20reusability?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CMakeLists.txt | 5 +++++ ISLE/dummy_controller_map.h | 8 ++++++++ ISLE/isleapp.cpp | 18 ++++++++++++------ .../xbox_controller_map.h} | 9 +++++++++ 4 files changed, 34 insertions(+), 6 deletions(-) create mode 100644 ISLE/dummy_controller_map.h rename ISLE/{xbox_buttons.h => xbox_one_series/xbox_controller_map.h} (71%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4116e3f5..eb4ac915 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -545,6 +545,11 @@ if (ISLE_BUILD_APP) ISLE/3ds/config.cpp ) endif() + if(WINDOWS_STORE) + target_sources(isle PRIVATE + ISLE/xbox_one_series/config.cpp + ) + endif() if(Python3_FOUND) if(NOT DEFINED PYTHON_PIL_AVAILABLE) execute_process( diff --git a/ISLE/dummy_controller_map.h b/ISLE/dummy_controller_map.h new file mode 100644 index 00000000..f5a1f576 --- /dev/null +++ b/ISLE/dummy_controller_map.h @@ -0,0 +1,8 @@ +#pragma once + +#define ISLE_BUTTON_SPACE 0 +#define ISLE_BUTTON_ESCAPE 0 + +#define ISLE_MOUSE_JOYSTICK_X 0 +#define ISLE_MOUSE_JOYSTICK_Y 0 +#define ISLE_MOUSE_CLICK_AXIS 0 \ No newline at end of file diff --git a/ISLE/isleapp.cpp b/ISLE/isleapp.cpp index d578b68b..c94ef494 100644 --- a/ISLE/isleapp.cpp +++ b/ISLE/isleapp.cpp @@ -36,7 +36,6 @@ #include "roi/legoroi.h" #include "tgl/d3drm/impl.h" #include "viewmanager/viewmanager.h" -#include "xbox_buttons.h" #include @@ -54,6 +53,8 @@ #include "emscripten/messagebox.h" #endif +#include "dummy_controller_map.h" + #ifdef __3DS__ #include "3ds/apthooks.h" #include "3ds/config.h" @@ -61,6 +62,7 @@ #ifdef WINDOWS_STORE #include "xbox_one_series/config.h" +#include "xbox_one_series/xbox_controller_map.h" #endif DECOMP_SIZE_ASSERT(IsleApp, 0x8c) @@ -491,12 +493,12 @@ SDL_AppResult SDL_AppEvent(void* appstate, SDL_Event* event) } case SDL_EVENT_JOYSTICK_BUTTON_DOWN: { { - if (event->gbutton.button == SDL_XBOX_BUTTON_A) { + if (event->gbutton.button == ISLE_BUTTON_SPACE) { if (InputManager()) { InputManager()->QueueEvent(c_notificationKeyPress, SDLK_SPACE, 0, 0, SDLK_SPACE); } } - if (event->gbutton.button == SDL_XBOX_BUTTON_START) { + if (event->gbutton.button == ISLE_BUTTON_ESCAPE) { if (InputManager()) { InputManager()->QueueEvent(c_notificationKeyPress, SDLK_ESCAPE, 0, 0, SDLK_ESCAPE); } @@ -505,14 +507,18 @@ SDL_AppResult SDL_AppEvent(void* appstate, SDL_Event* event) break; } case SDL_EVENT_JOYSTICK_AXIS_MOTION: { - if (event->gaxis.axis == SDL_XBOX_AXIS_RIGHT_X) { + if (event->gaxis.axis == ISLE_MOUSE_JOYSTICK_X) { g_lastJoystickMouseX = ((float) event->gaxis.value) / SDL_JOYSTICK_AXIS_MAX * g_isle->GetMouseSensitivity(); } - else if (event->gaxis.axis == SDL_XBOX_AXIS_RIGHT_Y) { + else if (event->gaxis.axis == ISLE_MOUSE_JOYSTICK_Y) { +#ifdef WINDOWS_STORE g_lastJoystickMouseY = -((float) event->gaxis.value) / SDL_JOYSTICK_AXIS_MAX * g_isle->GetMouseSensitivity(); +#else + g_lastJoystickMouseY = ((float) event->gaxis.value) / SDL_JOYSTICK_AXIS_MAX * g_isle->GetMouseSensitivity(); +#endif } - else if (event->gaxis.axis == SDL_XBOX_AXIS_RIGHT_TRIGGER) { + else if (event->gaxis.axis == ISLE_MOUSE_CLICK_AXIS) { if (event->gaxis.value != SDL_JOYSTICK_AXIS_MIN) { g_mousedown = TRUE; diff --git a/ISLE/xbox_buttons.h b/ISLE/xbox_one_series/xbox_controller_map.h similarity index 71% rename from ISLE/xbox_buttons.h rename to ISLE/xbox_one_series/xbox_controller_map.h index 56fdad77..19dc325d 100644 --- a/ISLE/xbox_buttons.h +++ b/ISLE/xbox_one_series/xbox_controller_map.h @@ -1,3 +1,5 @@ +#pragma once + #define SDL_XBOX_BUTTON_A 0 #define SDL_XBOX_BUTTON_B 1 #define SDL_XBOX_BUTTON_X 2 @@ -19,3 +21,10 @@ #define SDL_XBOX_AXIS_RIGHT_X 3 #define SDL_XBOX_AXIS_LEFT_TRIGGER 4 #define SDL_XBOX_AXIS_RIGHT_TRIGGER 5 + +#define ISLE_BUTTON_SPACE SDL_XBOX_BUTTON_A +#define ISLE_BUTTON_ESCAPE SDL_XBOX_BUTTON_START + +#define ISLE_MOUSE_JOYSTICK_X SDL_XBOX_AXIS_RIGHT_X +#define ISLE_MOUSE_JOYSTICK_Y SDL_XBOX_AXIS_RIGHT_Y +#define ISLE_MOUSE_CLICK_AXIS SDL_XBOX_AXIS_RIGHT_TRIGGER