fix input finally

This commit is contained in:
lizzie 2026-06-30 04:21:37 +00:00
parent a6061d9a93
commit 49492911f5
4 changed files with 48 additions and 16 deletions

View file

@ -10,8 +10,8 @@ set(CMAKE_SYSROOT "$OO_PS4_TOOLCHAIN")
set(CMAKE_STAGING_PREFIX "$OO_PS4_TOOLCHAIN")
set(CMAKE_SYSTEM_NAME "OpenOrbis")
set(CMAKE_C_FLAGS " -D__OPENORBIS__ -D_LIBCPP_HAS_MUSL_LIBC=1 -D_GNU_SOURCE=1 --target=x86_64-pc-freebsd12-elf -mtune=btver2 -march=btver2 -fPIC -funwind-tables")
set(CMAKE_CXX_FLAGS " -D__OPENORBIS__ -D_LIBCPP_HAS_MUSL_LIBC=1 -D_GNU_SOURCE=1 --target=x86_64-pc-freebsd12-elf -mtune=btver2 -march=btver2 -fPIC -funwind-tables")
set(CMAKE_C_FLAGS " -D__OPENORBIS__ -D_LIBCPP_HAS_MUSL_LIBC=1 -D_GNU_SOURCE=1 --target=x86_64-pc-freebsd12-elf -mtune=btver2 -march=btver2 -fPIC -funwind-tables -femulated-tls")
set(CMAKE_CXX_FLAGS " -D__OPENORBIS__ -D_LIBCPP_HAS_MUSL_LIBC=1 -D_GNU_SOURCE=1 --target=x86_64-pc-freebsd12-elf -mtune=btver2 -march=btver2 -fPIC -funwind-tables -femulated-tls")
set(CMAKE_EXE_LINKER_FLAGS "-m elf_x86_64 -pie -T $OO_PS4_TOOLCHAIN/link.x --eh-frame-hdr -L$OO_PS4_TOOLCHAIN/lib")
set(CMAKE_C_LINK_FLAGS "-m elf_x86_64 -pie -T $OO_PS4_TOOLCHAIN/link.x --eh-frame-hdr -L$OO_PS4_TOOLCHAIN/lib")

View file

@ -16,7 +16,7 @@
namespace Common {
#ifdef __OPENORBIS__
constexpr size_t DEFAULT_STACK_SIZE = 64 * 4096;
constexpr size_t DEFAULT_STACK_SIZE = 128 * 4096;
#else
constexpr size_t DEFAULT_STACK_SIZE = 512 * 4096;
#endif

View file

@ -1019,27 +1019,20 @@ ButtonBindings SDLDriver::GetDefaultButtonBinding(
};
}
ButtonMapping SDLDriver::GetSingleControllerMapping(
const std::shared_ptr<SDLJoystick>& joystick, const ButtonBindings& switch_to_sdl_button,
const ZButtonBindings& switch_to_sdl_axis) const {
ButtonMapping SDLDriver::GetSingleControllerMapping(const std::shared_ptr<SDLJoystick>& joystick, const ButtonBindings& switch_to_sdl_button, const ZButtonBindings& switch_to_sdl_axis) const {
ButtonMapping mapping;
mapping.reserve(switch_to_sdl_button.size() + switch_to_sdl_axis.size());
auto* controller = joystick->GetSDLGameController();
if (auto* controller = joystick->GetSDLGameController(); controller) {
const auto bindings = GetBindings(controller);
for (const auto& [switch_button, sdl_button] : switch_to_sdl_button) {
const auto binding = GetBindingForButton(bindings, sdl_button);
mapping.insert_or_assign(
switch_button,
BuildParamPackageForBinding(joystick->GetPort(), joystick->GetGUID(), binding));
mapping.insert_or_assign(switch_button, BuildParamPackageForBinding(joystick->GetPort(), joystick->GetGUID(), binding));
}
for (const auto& [switch_button, sdl_axis] : switch_to_sdl_axis) {
const auto binding = GetBindingForAxis(bindings, sdl_axis);
mapping.insert_or_assign(
switch_button,
BuildParamPackageForBinding(joystick->GetPort(), joystick->GetGUID(), binding));
mapping.insert_or_assign(switch_button, BuildParamPackageForBinding(joystick->GetPort(), joystick->GetGUID(), binding));
}
}
return mapping;
}

View file

@ -13,6 +13,7 @@
#include "common/detached_tasks.h"
#include "common/logging.h"
#include "common/param_package.h"
#include "common/scm_rev.h"
#include "common/settings.h"
#include "common/settings_enums.h"
@ -28,6 +29,8 @@
#include "core/hle/service/filesystem/filesystem.h"
#include "core/loader/loader.h"
#include "frontend_common/config.h"
#include "hid_core/frontend/emulated_controller.h"
#include "hid_core/hid_core.h"
#include "input_common/main.h"
#include "network/network.h"
#include "sdl_config.h"
@ -58,6 +61,7 @@
#include <orbis/libkernel.h>
#include <orbis/SystemService.h>
#include <orbis/AudioOut.h>
#include <orbis/Pad.h>
#include <orbis/UserService.h>
#elif defined(_WIN32)
extern "C" {
@ -374,7 +378,7 @@ int main(int argc, char** argv) {
// Apply the command line arguments
system.ApplySettings();
Settings::values.renderer_backend.SetValue(Settings::RendererBackend::Null);
Common::Log::SetGlobalFilter(Common::Log::Filter(Common::Log::Level::Trace));
Common::Log::SetGlobalFilter(Common::Log::Filter(Common::Log::Level::Info));
std::unique_ptr<EmuWindow_SDL3> emu_window;
switch (Settings::values.renderer_backend.GetValue()) {
@ -455,6 +459,41 @@ int main(int argc, char** argv) {
}
}
{
auto emulated_controller = system.HIDCore().GetEmulatedController(Core::HID::NpadIdType::Player1);
auto const input_devices = input_subsystem.GetInputDevices();
for (const auto& e : input_devices) {
LOG_INFO(Input, "FOUND=Device -> {} {}", e.Get("display", "Unknown"), e.Serialize());
}
auto const& device = input_devices[3];
LOG_INFO(Input, "selected? {}", device.Serialize());
auto const button_mappings = input_subsystem.GetButtonMappingForDevice(device);
auto const analog_mappings = input_subsystem.GetAnalogMappingForDevice(device);
auto const motion_mappings = input_subsystem.GetMotionMappingForDevice(device);
for (const auto& pair : button_mappings)
emulated_controller->SetButtonParam(pair.first, pair.second);
for (const auto& pair : analog_mappings)
emulated_controller->SetStickParam(pair.first, pair.second);
for (const auto& pair : motion_mappings)
emulated_controller->SetMotionParam(pair.first, pair.second);
for (const auto& pair : button_mappings)
LOG_INFO(Input, "btn:{}:{}", pair.first, pair.second.Serialize());
for (const auto& pair : analog_mappings)
LOG_INFO(Input, "ang:{}:{}", pair.first, pair.second.Serialize());
for (const auto& pair : motion_mappings)
LOG_INFO(Input, "mot:{}:{}", pair.first, pair.second.Serialize());
emulated_controller->SaveCurrentConfig();
emulated_controller->ReloadFromSettings();
auto const mapped_devices = emulated_controller->GetMappedDevices();
LOG_INFO(Input, "AND SO, WHAT MAPPED DEVICES WE GOT?");
for (const auto& e : mapped_devices) {
LOG_INFO(Input, "Mapped=Device? -> {}", e.Get("display", "Unknown"));
}
}
// Core is loaded, start the GPU (makes the GPU contexts current to this thread)
system.GPU().Start();
system.GetCpuManager().OnGpuReady();