diff --git a/ISLE/isleapp.cpp b/ISLE/isleapp.cpp index 2c550add..438ab4e0 100644 --- a/ISLE/isleapp.cpp +++ b/ISLE/isleapp.cpp @@ -33,6 +33,7 @@ #include "roi/legoroi.h" #include "tgl/d3drm/impl.h" #include "viewmanager/viewmanager.h" +#include "xbox_buttons.h" #include @@ -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) { diff --git a/ISLE/xbox_buttons.h b/ISLE/xbox_buttons.h new file mode 100644 index 00000000..dcf84883 --- /dev/null +++ b/ISLE/xbox_buttons.h @@ -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 \ No newline at end of file diff --git a/LEGO1/lego/legoomni/src/input/legoinputmanager.cpp b/LEGO1/lego/legoomni/src/input/legoinputmanager.cpp index 3e9622c2..a70b43f5 100644 --- a/LEGO1/lego/legoomni/src/input/legoinputmanager.cpp +++ b/LEGO1/lego/legoomni/src/input/legoinputmanager.cpp @@ -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;