mirror of
https://github.com/hedge-dev/UnleashedRecomp.git
synced 2025-10-30 07:11:05 +00:00
SDL/HID fixes and clean-up (#224)
This commit is contained in:
parent
ff29b3e786
commit
7b9b4245de
15 changed files with 47 additions and 32 deletions
|
|
@ -156,7 +156,6 @@ set(UNLEASHED_RECOMP_UI_CXX_SOURCES
|
||||||
"ui/message_window.cpp"
|
"ui/message_window.cpp"
|
||||||
"ui/options_menu_thumbnails.cpp"
|
"ui/options_menu_thumbnails.cpp"
|
||||||
"ui/options_menu.cpp"
|
"ui/options_menu.cpp"
|
||||||
"ui/sdl_listener.cpp"
|
|
||||||
"ui/game_window.cpp"
|
"ui/game_window.cpp"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -231,6 +230,7 @@ set(UNLEASHED_RECOMP_CXX_SOURCES
|
||||||
"exports.cpp"
|
"exports.cpp"
|
||||||
"main.cpp"
|
"main.cpp"
|
||||||
"misc_impl.cpp"
|
"misc_impl.cpp"
|
||||||
|
"sdl_listener.cpp"
|
||||||
"stdafx.cpp"
|
"stdafx.cpp"
|
||||||
"version.cpp"
|
"version.cpp"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -24,10 +24,10 @@
|
||||||
#include <ui/installer_wizard.h>
|
#include <ui/installer_wizard.h>
|
||||||
#include <ui/message_window.h>
|
#include <ui/message_window.h>
|
||||||
#include <ui/options_menu.h>
|
#include <ui/options_menu.h>
|
||||||
#include <ui/sdl_listener.h>
|
|
||||||
#include <ui/game_window.h>
|
#include <ui/game_window.h>
|
||||||
#include <patches/aspect_ratio_patches.h>
|
#include <patches/aspect_ratio_patches.h>
|
||||||
#include <user/config.h>
|
#include <user/config.h>
|
||||||
|
#include <sdl_listener.h>
|
||||||
#include <xxHashMap.h>
|
#include <xxHashMap.h>
|
||||||
|
|
||||||
#if defined(ASYNC_PSO_DEBUG) || defined(PSO_CACHING)
|
#if defined(ASYNC_PSO_DEBUG) || defined(PSO_CACHING)
|
||||||
|
|
|
||||||
|
|
@ -127,6 +127,11 @@ public:
|
||||||
|
|
||||||
SDL_GameControllerRumble(controller, vibration.wLeftMotorSpeed * 256, vibration.wRightMotorSpeed * 256, VIBRATION_TIMEOUT_MS);
|
SDL_GameControllerRumble(controller, vibration.wLeftMotorSpeed * 256, vibration.wRightMotorSpeed * 256, VIBRATION_TIMEOUT_MS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SetLED(const uint8_t r, const uint8_t g, const uint8_t b) const
|
||||||
|
{
|
||||||
|
SDL_GameControllerSetLED(controller, r, g, b);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
std::array<Controller, 4> g_controllers;
|
std::array<Controller, 4> g_controllers;
|
||||||
|
|
@ -182,6 +187,15 @@ static void SetControllerInputDevice(Controller* controller)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void SetControllerTimeOfDayLED(Controller& controller, bool isNight)
|
||||||
|
{
|
||||||
|
auto r = isNight ? 22 : 0;
|
||||||
|
auto g = isNight ? 0 : 37;
|
||||||
|
auto b = isNight ? 101 : 184;
|
||||||
|
|
||||||
|
controller.SetLED(r, g, b);
|
||||||
|
}
|
||||||
|
|
||||||
int HID_OnSDLEvent(void*, SDL_Event* event)
|
int HID_OnSDLEvent(void*, SDL_Event* event)
|
||||||
{
|
{
|
||||||
switch (event->type)
|
switch (event->type)
|
||||||
|
|
@ -191,7 +205,13 @@ int HID_OnSDLEvent(void*, SDL_Event* event)
|
||||||
const auto freeIndex = FindFreeController();
|
const auto freeIndex = FindFreeController();
|
||||||
|
|
||||||
if (freeIndex != -1)
|
if (freeIndex != -1)
|
||||||
g_controllers[freeIndex] = Controller(event->cdevice.which);
|
{
|
||||||
|
auto controller = Controller(event->cdevice.which);
|
||||||
|
|
||||||
|
g_controllers[freeIndex] = controller;
|
||||||
|
|
||||||
|
SetControllerTimeOfDayLED(controller, App::s_isWerehog);
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
@ -258,17 +278,8 @@ int HID_OnSDLEvent(void*, SDL_Event* event)
|
||||||
|
|
||||||
case SDL_USER_EVILSONIC:
|
case SDL_USER_EVILSONIC:
|
||||||
{
|
{
|
||||||
auto* controller = FindController(event->cdevice.which);
|
for (auto& controller : g_controllers)
|
||||||
|
SetControllerTimeOfDayLED(controller, event->user.code);
|
||||||
if (!controller)
|
|
||||||
break;
|
|
||||||
|
|
||||||
auto isNight = event->user.code;
|
|
||||||
auto r = isNight ? 22 : 0;
|
|
||||||
auto g = isNight ? 0 : 37;
|
|
||||||
auto b = isNight ? 101 : 184;
|
|
||||||
|
|
||||||
SDL_GameControllerSetLED(controller->controller, r, g, b);
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
@ -279,12 +290,15 @@ int HID_OnSDLEvent(void*, SDL_Event* event)
|
||||||
|
|
||||||
void hid::Init()
|
void hid::Init()
|
||||||
{
|
{
|
||||||
|
SDL_SetHint(SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS, "1");
|
||||||
|
SDL_SetHint(SDL_HINT_JOYSTICK_HIDAPI_GAMECUBE, "1");
|
||||||
SDL_SetHint(SDL_HINT_JOYSTICK_HIDAPI_PS3, "1");
|
SDL_SetHint(SDL_HINT_JOYSTICK_HIDAPI_PS3, "1");
|
||||||
SDL_SetHint(SDL_HINT_JOYSTICK_HIDAPI_PS4, "1");
|
SDL_SetHint(SDL_HINT_JOYSTICK_HIDAPI_PS4, "1");
|
||||||
|
SDL_SetHint(SDL_HINT_JOYSTICK_HIDAPI_PS4_RUMBLE, "1");
|
||||||
SDL_SetHint(SDL_HINT_JOYSTICK_HIDAPI_PS5, "1");
|
SDL_SetHint(SDL_HINT_JOYSTICK_HIDAPI_PS5, "1");
|
||||||
SDL_SetHint(SDL_HINT_JOYSTICK_HIDAPI_GAMECUBE, "1");
|
SDL_SetHint(SDL_HINT_JOYSTICK_HIDAPI_PS5_PLAYER_LED, "1");
|
||||||
|
SDL_SetHint(SDL_HINT_JOYSTICK_HIDAPI_PS5_RUMBLE, "1");
|
||||||
SDL_SetHint(SDL_HINT_JOYSTICK_HIDAPI_WII, "1");
|
SDL_SetHint(SDL_HINT_JOYSTICK_HIDAPI_WII, "1");
|
||||||
SDL_SetHint(SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS, "1");
|
|
||||||
SDL_SetHint(SDL_HINT_XINPUT_ENABLED, "1");
|
SDL_SetHint(SDL_HINT_XINPUT_ENABLED, "1");
|
||||||
|
|
||||||
SDL_InitSubSystem(SDL_INIT_EVENTS);
|
SDL_InitSubSystem(SDL_INIT_EVENTS);
|
||||||
|
|
|
||||||
|
|
@ -35,12 +35,12 @@ namespace hid
|
||||||
extern uint16_t g_prohibitedButtons;
|
extern uint16_t g_prohibitedButtons;
|
||||||
|
|
||||||
void Init();
|
void Init();
|
||||||
void SetProhibitedButtons(uint16_t wButtons);
|
|
||||||
|
|
||||||
uint32_t GetState(uint32_t dwUserIndex, XAMINPUT_STATE* pState);
|
uint32_t GetState(uint32_t dwUserIndex, XAMINPUT_STATE* pState);
|
||||||
uint32_t SetState(uint32_t dwUserIndex, XAMINPUT_VIBRATION* pVibration);
|
uint32_t SetState(uint32_t dwUserIndex, XAMINPUT_VIBRATION* pVibration);
|
||||||
uint32_t GetCapabilities(uint32_t dwUserIndex, XAMINPUT_CAPABILITIES* pCaps);
|
uint32_t GetCapabilities(uint32_t dwUserIndex, XAMINPUT_CAPABILITIES* pCaps);
|
||||||
|
|
||||||
|
void SetProhibitedButtons(uint16_t wButtons);
|
||||||
bool IsInputAllowed();
|
bool IsInputAllowed();
|
||||||
bool IsInputDeviceController();
|
bool IsInputDeviceController();
|
||||||
std::string GetInputDeviceName();
|
std::string GetInputDeviceName();
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,9 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <kernel/memory.h>
|
#include <kernel/memory.h>
|
||||||
#include <ui/sdl_listener.h>
|
|
||||||
#include <ui/options_menu.h>
|
#include <ui/options_menu.h>
|
||||||
#include <os/logger.h>
|
#include <os/logger.h>
|
||||||
|
#include <sdl_listener.h>
|
||||||
|
|
||||||
class FrontendListener : public SDLEventListener
|
class FrontendListener : public SDLEventListener
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
#include <api/SWA.h>
|
#include <api/SWA.h>
|
||||||
#include <hid/hid.h>
|
#include <hid/hid.h>
|
||||||
#include <ui/sdl_listener.h>
|
|
||||||
#include <app.h>
|
#include <app.h>
|
||||||
#include <exports.h>
|
#include <exports.h>
|
||||||
|
#include <sdl_listener.h>
|
||||||
|
|
||||||
constexpr double WORLD_MAP_ROTATE_DEADZONE = 0.69999999;
|
constexpr double WORLD_MAP_ROTATE_DEADZONE = 0.69999999;
|
||||||
constexpr double WORLD_MAP_CURSOR_DEADZONE = 0.30000001;
|
constexpr double WORLD_MAP_CURSOR_DEADZONE = 0.30000001;
|
||||||
|
|
@ -42,7 +42,7 @@ public:
|
||||||
}
|
}
|
||||||
g_worldMapCursorParamsOrbis;
|
g_worldMapCursorParamsOrbis;
|
||||||
|
|
||||||
#ifdef UI_KBM_SUPPORT
|
#ifdef UNLEASHED_RECOMP_UI_KBM_SUPPORT
|
||||||
class WorldMapCursorParamsMouse : public WorldMapCursorParams
|
class WorldMapCursorParamsMouse : public WorldMapCursorParams
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
@ -128,7 +128,7 @@ public:
|
||||||
|
|
||||||
switch (event->type)
|
switch (event->type)
|
||||||
{
|
{
|
||||||
#ifdef UI_KBM_SUPPORT
|
#ifdef UNLEASHED_RECOMP_UI_KBM_SUPPORT
|
||||||
case SDL_MOUSEMOTION:
|
case SDL_MOUSEMOTION:
|
||||||
{
|
{
|
||||||
if (!ms_isMouseDown)
|
if (!ms_isMouseDown)
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,9 @@
|
||||||
#include "inspire_patches.h"
|
#include "inspire_patches.h"
|
||||||
#include <api/SWA.h>
|
#include <api/SWA.h>
|
||||||
#include <ui/game_window.h>
|
#include <ui/game_window.h>
|
||||||
#include <ui/window_events.h>
|
|
||||||
#include <os/logger.h>
|
#include <os/logger.h>
|
||||||
#include <app.h>
|
#include <app.h>
|
||||||
|
#include <sdl_events.h>
|
||||||
|
|
||||||
static SWA::Inspire::CScene* g_pScene;
|
static SWA::Inspire::CScene* g_pScene;
|
||||||
static std::string g_sceneName;
|
static std::string g_sceneName;
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,9 @@
|
||||||
#include <api/SWA.h>
|
#include <api/SWA.h>
|
||||||
#include <ui/game_window.h>
|
#include <ui/game_window.h>
|
||||||
#include <ui/window_events.h>
|
|
||||||
#include <user/config.h>
|
#include <user/config.h>
|
||||||
#include <os/logger.h>
|
#include <os/logger.h>
|
||||||
#include <app.h>
|
#include <app.h>
|
||||||
|
#include <sdl_events.h>
|
||||||
|
|
||||||
static uint32_t g_lastEnemyScore;
|
static uint32_t g_lastEnemyScore;
|
||||||
static uint32_t g_lastTrickScore;
|
static uint32_t g_lastTrickScore;
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <SDL.h>
|
#include <SDL.h>
|
||||||
#include "ui/game_window.h"
|
#include <ui/game_window.h>
|
||||||
|
|
||||||
#define SDL_USER_EVILSONIC (SDL_USEREVENT + 1)
|
#define SDL_USER_EVILSONIC (SDL_USEREVENT + 1)
|
||||||
|
|
||||||
|
|
@ -3,8 +3,8 @@
|
||||||
#include <os/logger.h>
|
#include <os/logger.h>
|
||||||
#include <os/user.h>
|
#include <os/user.h>
|
||||||
#include <os/version.h>
|
#include <os/version.h>
|
||||||
#include <ui/sdl_listener.h>
|
|
||||||
#include <app.h>
|
#include <app.h>
|
||||||
|
#include <sdl_listener.h>
|
||||||
#include <SDL_syswm.h>
|
#include <SDL_syswm.h>
|
||||||
|
|
||||||
#if _WIN32
|
#if _WIN32
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <gpu/rhi/plume_render_interface_types.h>
|
#include <gpu/rhi/plume_render_interface_types.h>
|
||||||
#include <ui/window_events.h>
|
|
||||||
#include <user/config.h>
|
#include <user/config.h>
|
||||||
|
#include <sdl_events.h>
|
||||||
|
|
||||||
#define DEFAULT_WIDTH 1280
|
#define DEFAULT_WIDTH 1280
|
||||||
#define DEFAULT_HEIGHT 720
|
#define DEFAULT_HEIGHT 720
|
||||||
|
|
|
||||||
|
|
@ -12,10 +12,10 @@
|
||||||
#include <ui/imgui_utils.h>
|
#include <ui/imgui_utils.h>
|
||||||
#include <ui/button_guide.h>
|
#include <ui/button_guide.h>
|
||||||
#include <ui/message_window.h>
|
#include <ui/message_window.h>
|
||||||
#include <ui/sdl_listener.h>
|
|
||||||
#include <ui/game_window.h>
|
#include <ui/game_window.h>
|
||||||
#include <decompressor.h>
|
#include <decompressor.h>
|
||||||
#include <exports.h>
|
#include <exports.h>
|
||||||
|
#include <sdl_listener.h>
|
||||||
|
|
||||||
#include <res/images/common/hedge-dev.dds.h>
|
#include <res/images/common/hedge-dev.dds.h>
|
||||||
#include <res/images/installer/install_001.dds.h>
|
#include <res/images/installer/install_001.dds.h>
|
||||||
|
|
|
||||||
|
|
@ -1,17 +1,18 @@
|
||||||
#include "message_window.h"
|
#include "message_window.h"
|
||||||
#include "imgui_utils.h"
|
|
||||||
#include <api/SWA.h>
|
#include <api/SWA.h>
|
||||||
|
#include <gpu/imgui/imgui_snapshot.h>
|
||||||
#include <gpu/video.h>
|
#include <gpu/video.h>
|
||||||
#include <hid/hid.h>
|
#include <hid/hid.h>
|
||||||
#include <locale/locale.h>
|
#include <locale/locale.h>
|
||||||
#include <ui/button_guide.h>
|
#include <ui/button_guide.h>
|
||||||
#include <ui/sdl_listener.h>
|
#include <ui/imgui_utils.h>
|
||||||
#include <app.h>
|
#include <app.h>
|
||||||
#include <exports.h>
|
|
||||||
#include <res/images/common/general_window.dds.h>
|
|
||||||
#include <decompressor.h>
|
#include <decompressor.h>
|
||||||
|
#include <exports.h>
|
||||||
|
#include <sdl_listener.h>
|
||||||
|
|
||||||
|
#include <res/images/common/general_window.dds.h>
|
||||||
#include <res/images/common/select_fade.dds.h>
|
#include <res/images/common/select_fade.dds.h>
|
||||||
#include <gpu/imgui/imgui_snapshot.h>
|
|
||||||
|
|
||||||
constexpr double OVERLAY_CONTAINER_COMMON_MOTION_START = 0;
|
constexpr double OVERLAY_CONTAINER_COMMON_MOTION_START = 0;
|
||||||
constexpr double OVERLAY_CONTAINER_COMMON_MOTION_END = 11;
|
constexpr double OVERLAY_CONTAINER_COMMON_MOTION_END = 11;
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue