mirror of
https://git.eden-emu.dev/eden-emu/eden
synced 2026-07-02 13:25:42 +02:00
sysconf stub cuz crash(?) + some stderrp stuff
This commit is contained in:
parent
bb76331a6e
commit
8c77a3f84f
10 changed files with 469 additions and 53 deletions
|
|
@ -23,12 +23,14 @@ Joycons::Joycons(const std::string& input_engine_) : InputEngine(input_engine_)
|
|||
return;
|
||||
}
|
||||
LOG_INFO(Input, "Joycon driver Initialization started");
|
||||
const int init_res = SDL_hid_init();
|
||||
if (init_res == 0) {
|
||||
#if SDL_VERSION_ATLEAST(2, 26, 4)
|
||||
int const res = SDL_hid_init();
|
||||
if (res == 0) {
|
||||
Setup();
|
||||
} else {
|
||||
LOG_ERROR(Input, "Hidapi could not be initialized. failed with error = {}", init_res);
|
||||
LOG_ERROR(Input, "Hidapi could not be initialized. failed with error = {}", res);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
Joycons::~Joycons() {
|
||||
|
|
@ -55,7 +57,9 @@ void Joycons::Reset() {
|
|||
}
|
||||
device->Stop();
|
||||
}
|
||||
#if SDL_VERSION_ATLEAST(2, 26, 4)
|
||||
SDL_hid_exit();
|
||||
#endif
|
||||
}
|
||||
|
||||
void Joycons::Setup() {
|
||||
|
|
@ -80,9 +84,9 @@ void Joycons::Setup() {
|
|||
}
|
||||
|
||||
void Joycons::ScanThread(std::stop_token stop_token) {
|
||||
#if SDL_VERSION_ATLEAST(2, 26, 4)
|
||||
constexpr u16 nintendo_vendor_id = 0x057e;
|
||||
Common::SetCurrentThreadName("JoyconScanThread");
|
||||
|
||||
do {
|
||||
SDL_hid_device_info* devs = SDL_hid_enumerate(nintendo_vendor_id, 0x0);
|
||||
SDL_hid_device_info* cur_dev = devs;
|
||||
|
|
@ -98,6 +102,7 @@ void Joycons::ScanThread(std::stop_token stop_token) {
|
|||
|
||||
SDL_hid_free_enumeration(devs);
|
||||
} while (Common::StoppableTimedWait(stop_token, std::chrono::seconds{5}));
|
||||
#endif
|
||||
}
|
||||
|
||||
bool Joycons::IsDeviceNew(SDL_hid_device_info* device_info) const {
|
||||
|
|
|
|||
|
|
@ -92,6 +92,7 @@ public:
|
|||
}
|
||||
|
||||
void EnableMotion() {
|
||||
#if SDL_VERSION_ATLEAST(2, 26, 4)
|
||||
if (!sdl_controller) {
|
||||
return;
|
||||
}
|
||||
|
|
@ -174,6 +175,7 @@ public:
|
|||
motion.delta_timestamp = time_difference;
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
const BasicMotion& GetMotion() const {
|
||||
return motion;
|
||||
|
|
@ -352,6 +354,7 @@ public:
|
|||
}
|
||||
|
||||
std::string GetControllerName() const {
|
||||
#if SDL_VERSION_ATLEAST(2, 26, 4)
|
||||
if (sdl_controller) {
|
||||
switch (SDL_GetGamepadType(sdl_controller.get())) {
|
||||
case SDL_GAMEPAD_TYPE_XBOX360:
|
||||
|
|
@ -365,6 +368,8 @@ public:
|
|||
case SDL_GAMEPAD_TYPE_PS5:
|
||||
return "DualSense Controller";
|
||||
default:
|
||||
if (auto const name = SDL_GameControllerName(sdl_controller.get()); name)
|
||||
return name;
|
||||
break;
|
||||
}
|
||||
const auto name = SDL_GetGamepadName(sdl_controller.get());
|
||||
|
|
@ -372,6 +377,7 @@ public:
|
|||
return name;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if (sdl_joystick) {
|
||||
const auto name = SDL_GetJoystickName(sdl_joystick.get());
|
||||
|
|
@ -639,6 +645,7 @@ void SDLDriver::CloseJoysticks() {
|
|||
}
|
||||
|
||||
SDLDriver::SDLDriver(std::string input_engine_) : InputEngine(std::move(input_engine_)) {
|
||||
#if SDL_VERSION_ATLEAST(2, 26, 4)
|
||||
// Set our application name. Currently passed to DBus by SDL and visible to the user through
|
||||
// their desktop environment.
|
||||
SDL_SetHint(SDL_HINT_APP_NAME, "Eden");
|
||||
|
|
@ -677,6 +684,7 @@ SDLDriver::SDLDriver(std::string input_engine_) : InputEngine(std::move(input_en
|
|||
// Disable hidapi driver for xbox. Already default on Windows, this causes conflict with native
|
||||
// driver on Linux.
|
||||
SDL_SetHint(SDL_HINT_JOYSTICK_HIDAPI_XBOX, "0");
|
||||
#endif
|
||||
|
||||
// If the frontend is going to manage the event loop, then we don't start one here
|
||||
start_thread = SDL_WasInit(SDL_INIT_JOYSTICK | SDL_INIT_GAMEPAD) == 0;
|
||||
|
|
@ -986,6 +994,7 @@ ButtonBindings SDLDriver::GetDefaultButtonBinding(
|
|||
auto slr_button = SDL_GAMEPAD_BUTTON_LEFT_SHOULDER;
|
||||
auto srr_button = SDL_GAMEPAD_BUTTON_RIGHT_SHOULDER;
|
||||
|
||||
#if SDL_VERSION_ATLEAST(2, 26, 4)
|
||||
if (joystick->IsJoyconLeft()) {
|
||||
sll_button = SDL_GAMEPAD_BUTTON_LEFT_PADDLE1;
|
||||
srl_button = SDL_GAMEPAD_BUTTON_LEFT_PADDLE2;
|
||||
|
|
@ -994,6 +1003,7 @@ ButtonBindings SDLDriver::GetDefaultButtonBinding(
|
|||
slr_button = SDL_GAMEPAD_BUTTON_RIGHT_PADDLE2;
|
||||
srr_button = SDL_GAMEPAD_BUTTON_RIGHT_PADDLE1;
|
||||
}
|
||||
#endif
|
||||
|
||||
return {
|
||||
std::pair{Settings::NativeButton::A, SDL_GAMEPAD_BUTTON_EAST},
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue