⚗️ feat: add button support

This commit is contained in:
Helloyunho 2025-07-01 01:20:02 +09:00
parent 43dee994b6
commit 2f3b6af4ac
3 changed files with 31 additions and 3 deletions

View File

@ -33,6 +33,7 @@
#include "roi/legoroi.h"
#include "tgl/d3drm/impl.h"
#include "viewmanager/viewmanager.h"
#include "xbox_buttons.h"
#include <miniwin/miniwindevice.h>
@ -442,6 +443,21 @@ SDL_AppResult SDL_AppEvent(void* appstate, SDL_Event* event)
}
break;
}
case SDL_EVENT_JOYSTICK_BUTTON_DOWN: {
{
if (event->gbutton.button == SDL_XBOX_BUTTON_A) {
if (InputManager()) {
InputManager()->QueueEvent(c_notificationKeyPress, SDLK_SPACE, 0, 0, SDLK_SPACE);
}
}
if (event->gbutton.button == SDL_XBOX_BUTTON_START) {
if (InputManager()) {
InputManager()->QueueEvent(c_notificationKeyPress, SDLK_ESCAPE, 0, 0, SDLK_ESCAPE);
}
}
}
break;
}
case SDL_EVENT_MOUSE_MOTION:
#ifdef __EMSCRIPTEN__
if (detectedTouchEvents) {

14
ISLE/xbox_buttons.h Normal file
View File

@ -0,0 +1,14 @@
#define SDL_XBOX_BUTTON_A 0
#define SDL_XBOX_BUTTON_B 1
#define SDL_XBOX_BUTTON_X 2
#define SDL_XBOX_BUTTON_Y 3
#define SDL_XBOX_BUTTON_LEFT_BUMPER 4
#define SDL_XBOX_BUTTON_RIGHT_BUMPER 5
#define SDL_XBOX_BUTTON_BACK 6
#define SDL_XBOX_BUTTON_START 7
#define SDL_XBOX_BUTTON_LEFT_THUMB 8
#define SDL_XBOX_BUTTON_RIGHT_THUMB 9
#define SDL_XBOX_BUTTON_DPAD_UP 10
#define SDL_XBOX_BUTTON_DPAD_DOWN 11
#define SDL_XBOX_BUTTON_DPAD_LEFT 12
#define SDL_XBOX_BUTTON_DPAD_RIGHT 13

View File

@ -153,9 +153,7 @@ MxResult LegoInputManager::GetJoystick()
}
MxS32 numJoysticks = 0;
if (m_joyids == NULL) {
m_joyids = SDL_GetJoysticks(&numJoysticks);
}
m_joyids = SDL_GetJoysticks(&numJoysticks);
if (m_useJoystick != FALSE && numJoysticks != 0) {
MxS32 joyid = m_joystickIndex;