Work with SDL as subtree

This commit is contained in:
SimoneN64
2024-09-04 23:11:10 +02:00
parent 7435b8d527
commit 2f466dae11
8 changed files with 78 additions and 87 deletions

View File

@@ -14,7 +14,7 @@ jobs:
run: | run: |
sudo add-apt-repository universe sudo add-apt-repository universe
sudo apt-get update -qq sudo apt-get update -qq
sudo apt-get install -y clang build-essential libgtk-3-dev libsdl2-dev git ninja-build qt6-base-dev sudo apt-get install -y clang build-essential libgtk-3-dev git ninja-build qt6-base-dev
sudo apt-get install -y vulkan-tools libvulkan1 libvulkan-dev vulkan-utility-libraries-dev spirv-tools sudo apt-get install -y vulkan-tools libvulkan1 libvulkan-dev vulkan-utility-libraries-dev spirv-tools
- name: Build Kaizen - name: Build Kaizen
run: | run: |
@@ -36,9 +36,6 @@ jobs:
- uses: actions/checkout@master - uses: actions/checkout@master
with: with:
submodules: recursive submodules: recursive
- name: Setup dependencies
run: |
vcpkg install sdl2[vulkan]:x64-windows
- name: Setup Qt - name: Setup Qt
uses: jurplel/install-qt-action@v3 uses: jurplel/install-qt-action@v3
with: with:
@@ -54,7 +51,6 @@ jobs:
cp build/src/frontend/Release/kaizen-qt.exe upload cp build/src/frontend/Release/kaizen-qt.exe upload
mkdir upload/resources mkdir upload/resources
cp resources/* upload/resources cp resources/* upload/resources
cp build/src/frontend/Release/SDL2.dll upload
windeployqt --dir upload upload/kaizen-qt.exe windeployqt --dir upload upload/kaizen-qt.exe
- name: Upload artifacts - name: Upload artifacts
uses: actions/upload-artifact@master uses: actions/upload-artifact@master

View File

@@ -1,22 +1,23 @@
#include <Audio.hpp> #include <Audio.hpp>
#include <SDL2/SDL.h> #include <SDL3/SDL_audio.h>
#include <SDL3/SDL_init.h>
#include <log.hpp> #include <log.hpp>
namespace n64 { namespace n64 {
#define AUDIO_SAMPLE_RATE 44100 #define AUDIO_SAMPLE_RATE 44100
#define SYSTEM_SAMPLE_FORMAT AUDIO_F32SYS #define SYSTEM_SAMPLE_FORMAT SDL_AUDIO_F32
#define SYSTEM_SAMPLE_SIZE 4 #define SYSTEM_SAMPLE_SIZE 4
#define BYTES_PER_HALF_SECOND (((float)AUDIO_SAMPLE_RATE / 2) * SYSTEM_SAMPLE_SIZE) #define BYTES_PER_HALF_SECOND (((float)AUDIO_SAMPLE_RATE / 2) * SYSTEM_SAMPLE_SIZE)
void audioCallback(void *user, Uint8 *stream, int length) { void audioCallback(void *userdata, SDL_AudioStream *stream, int additional_amount, int total_amount) {
auto audioDevice = (AudioDevice *)user; auto audioDevice = (AudioDevice *)userdata;
int gotten = 0, available = 0; int gotten = 0, available = 0;
if (audioDevice) { if (audioDevice) {
audioDevice->LockMutex(); audioDevice->LockMutex();
available = SDL_AudioStreamAvailable(audioDevice->GetStream()); available = SDL_GetAudioStreamAvailable(audioDevice->GetStream());
if (available > 0) { if (available > 0) {
gotten = SDL_AudioStreamGet(audioDevice->GetStream(), stream, length); gotten = SDL_GetAudioStreamData(audioDevice->GetStream(), stream, total_amount);
} }
audioDevice->UnlockMutex(); audioDevice->UnlockMutex();
} }
@@ -25,7 +26,7 @@ void audioCallback(void *user, Uint8 *stream, int length) {
auto *out = (float *)stream; auto *out = (float *)stream;
out += gottenSamples; out += gottenSamples;
for (int i = gottenSamples; i < length / sizeof(float); i++) { for (int i = gottenSamples; i < total_amount / sizeof(float); i++) {
float sample = 0; float sample = 0;
*out++ = sample; *out++ = sample;
} }
@@ -33,35 +34,33 @@ void audioCallback(void *user, Uint8 *stream, int length) {
AudioDevice::~AudioDevice() { AudioDevice::~AudioDevice() {
LockMutex(); LockMutex();
SDL_FreeAudioStream(GetStream()); SDL_DestroyAudioStream(GetStream());
UnlockMutex(); UnlockMutex();
SDL_DestroyMutex(audioStreamMutex); SDL_DestroyMutex(audioStreamMutex);
} }
AudioDevice::AudioDevice() : AudioDevice::AudioDevice() : audioStreamMutex(SDL_CreateMutex()) {
audioStream( request.freq = AUDIO_SAMPLE_RATE;
SDL_NewAudioStream(SYSTEM_SAMPLE_FORMAT, 2, AUDIO_SAMPLE_RATE, SYSTEM_SAMPLE_FORMAT, 2, AUDIO_SAMPLE_RATE)), request.format = SYSTEM_SAMPLE_FORMAT;
audioStreamMutex(SDL_CreateMutex()) { request.channels = 2;
audioStream = SDL_CreateAudioStream(&request, &request);
SDL_InitSubSystem(SDL_INIT_AUDIO); SDL_InitSubSystem(SDL_INIT_AUDIO);
if (!audioStreamMutex) { if (!audioStreamMutex) {
Util::panic("Unable to initialize audio mutex: {}", SDL_GetError()); Util::panic("Unable to initialize audio mutex: {}", SDL_GetError());
} }
request.freq = AUDIO_SAMPLE_RATE; handle = SDL_OpenAudioDevice(SDL_AUDIO_DEVICE_DEFAULT_PLAYBACK, &request);
request.format = SYSTEM_SAMPLE_FORMAT; SDL_BindAudioStream(handle, audioStream);
request.channels = 2; SDL_SetAudioStreamGetCallback(audioStream, audioCallback, this);
request.samples = 1024;
request.callback = audioCallback;
request.userdata = (void *)this;
handle = SDL_OpenAudioDevice(nullptr, 0, &request, &audioSpec, 0);
if (!handle) { if (!handle) {
Util::panic("Failed to initialize SDL Audio: {}", SDL_GetError()); Util::panic("Failed to initialize SDL Audio: {}", SDL_GetError());
} }
SDL_PauseAudioDevice(handle, false); SDL_PauseAudioDevice(handle);
} }
void AudioDevice::PushSample(float left, float volumeL, float right, float volumeR) { void AudioDevice::PushSample(float left, float volumeL, float right, float volumeR) {
@@ -69,16 +68,23 @@ void AudioDevice::PushSample(float left, float volumeL, float right, float volum
float adjustedR = right * volumeR; float adjustedR = right * volumeR;
float samples[2]{adjustedL, adjustedR}; float samples[2]{adjustedL, adjustedR};
auto availableBytes = (float)SDL_AudioStreamAvailable(audioStream); auto availableBytes = (float)SDL_GetAudioStreamAvailable(audioStream);
if (availableBytes <= BYTES_PER_HALF_SECOND) { if (availableBytes <= BYTES_PER_HALF_SECOND) {
SDL_AudioStreamPut(audioStream, samples, 2 * sizeof(float)); SDL_PutAudioStreamData(audioStream, samples, 2 * sizeof(float));
} }
} }
void AudioDevice::AdjustSampleRate(int sampleRate) { void AudioDevice::AdjustSampleRate(int sampleRate) {
LockMutex(); LockMutex();
SDL_FreeAudioStream(audioStream); SDL_DestroyAudioStream(audioStream);
audioStream = SDL_NewAudioStream(SYSTEM_SAMPLE_FORMAT, 2, sampleRate, SYSTEM_SAMPLE_FORMAT, 2, AUDIO_SAMPLE_RATE);
auto oldReq = request;
request.freq = sampleRate;
request.format = SYSTEM_SAMPLE_FORMAT;
request.channels = 2;
audioStream = SDL_CreateAudioStream(&request, &oldReq);
UnlockMutex(); UnlockMutex();
} }
} // namespace n64 } // namespace n64

View File

@@ -1,6 +1,6 @@
#pragma once #pragma once
#include <MemoryHelpers.hpp> #include <MemoryHelpers.hpp>
#include <SDL2/SDL_audio.h> #include <SDL3/SDL_audio.h>
namespace n64 { namespace n64 {
struct AudioDevice { struct AudioDevice {
@@ -22,7 +22,7 @@ struct AudioDevice {
private: private:
SDL_AudioStream *audioStream; SDL_AudioStream *audioStream;
SDL_mutex *audioStreamMutex; SDL_Mutex *audioStreamMutex;
SDL_AudioSpec audioSpec{}; SDL_AudioSpec audioSpec{};
SDL_AudioSpec request{}; SDL_AudioSpec request{};
SDL_AudioDeviceID handle{}; SDL_AudioDeviceID handle{};

View File

@@ -1,7 +1,4 @@
file(GLOB_RECURSE SOURCES *.cpp) file(GLOB_RECURSE SOURCES *.cpp)
file(GLOB_RECURSE HEADERS *.hpp) file(GLOB_RECURSE HEADERS *.hpp)
find_package(SDL2 CONFIG REQUIRED) add_library(mmio ${SOURCES} ${HEADERS} ../../../../external/cic_nus_6105/n64_cic_nus_6105.cpp)
add_library(mmio ${SOURCES} ${HEADERS} ../../../../external/cic_nus_6105/n64_cic_nus_6105.cpp)
target_link_libraries(mmio PRIVATE SDL2::SDL2)

View File

@@ -144,7 +144,7 @@ bool Cop1::isqnan<double>(double f) {
template <> template <>
bool Cop1::CheckCVTArg<s32>(float &f) { bool Cop1::CheckCVTArg<s32>(float &f) {
switch (fpclassify(f)) { switch (std::fpclassify(f)) {
case FP_SUBNORMAL: case FP_SUBNORMAL:
case FP_INFINITE: case FP_INFINITE:
case FP_NAN: case FP_NAN:
@@ -164,7 +164,7 @@ bool Cop1::CheckCVTArg<s32>(float &f) {
template <> template <>
bool Cop1::CheckCVTArg<s32>(double &f) { bool Cop1::CheckCVTArg<s32>(double &f) {
switch (fpclassify(f)) { switch (std::fpclassify(f)) {
case FP_SUBNORMAL: case FP_SUBNORMAL:
case FP_INFINITE: case FP_INFINITE:
case FP_NAN: case FP_NAN:
@@ -184,7 +184,7 @@ bool Cop1::CheckCVTArg<s32>(double &f) {
template <> template <>
bool Cop1::CheckCVTArg<s64>(float &f) { bool Cop1::CheckCVTArg<s64>(float &f) {
switch (fpclassify(f)) { switch (std::fpclassify(f)) {
case FP_SUBNORMAL: case FP_SUBNORMAL:
case FP_INFINITE: case FP_INFINITE:
case FP_NAN: case FP_NAN:
@@ -204,7 +204,7 @@ bool Cop1::CheckCVTArg<s64>(float &f) {
template <> template <>
bool Cop1::CheckCVTArg<s64>(double &f) { bool Cop1::CheckCVTArg<s64>(double &f) {
switch (fpclassify(f)) { switch (std::fpclassify(f)) {
case FP_SUBNORMAL: case FP_SUBNORMAL:
case FP_INFINITE: case FP_INFINITE:
case FP_NAN: case FP_NAN:
@@ -224,7 +224,7 @@ bool Cop1::CheckCVTArg<s64>(double &f) {
template <typename T> template <typename T>
bool Cop1::CheckArg(T &f) { bool Cop1::CheckArg(T &f) {
switch (fpclassify(f)) { switch (std::fpclassify(f)) {
case FP_SUBNORMAL: case FP_SUBNORMAL:
SetCauseUnimplemented(); SetCauseUnimplemented();
regs.cop0.FireException(ExceptionCode::FloatingPointError, 0, regs.oldPC); regs.cop0.FireException(ExceptionCode::FloatingPointError, 0, regs.oldPC);

View File

@@ -5,11 +5,10 @@ set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD_REQUIRED ON)
find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets) find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
find_package(SDL2 CONFIG REQUIRED)
if(WIN32) if (WIN32)
add_compile_definitions(NOMINMAX) add_compile_definitions(NOMINMAX)
endif() endif ()
include_directories( include_directories(
. .
@@ -36,7 +35,7 @@ include_directories(
../../external/parallel-rdp/parallel-rdp-standalone/vulkan-headers/include ../../external/parallel-rdp/parallel-rdp-standalone/vulkan-headers/include
../../external/parallel-rdp/parallel-rdp-standalone/util ../../external/parallel-rdp/parallel-rdp-standalone/util
../../external/unarr ../../external/unarr
${SDL2_INCLUDE_DIRS} ../../external/SDL/include
) )
option(RAPIDJSON_BUILD_DOC "Build rapidjson documentation." OFF) option(RAPIDJSON_BUILD_DOC "Build rapidjson documentation." OFF)
@@ -51,6 +50,8 @@ add_subdirectory(../../external/mio mio)
add_subdirectory(../backend backend) add_subdirectory(../backend backend)
add_subdirectory(../../external/parallel-rdp parallel-rdp) add_subdirectory(../../external/parallel-rdp parallel-rdp)
add_subdirectory(../../external/unarr unarr) add_subdirectory(../../external/unarr unarr)
add_subdirectory(../../external/SDL SDL)
set(CMAKE_AUTOMOC ON) set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON) set(CMAKE_AUTORCC ON)
@@ -86,13 +87,13 @@ if (HAS_SSE4_1)
target_compile_options(kaizen-qt PUBLIC -msse3 -msse4.1) target_compile_options(kaizen-qt PUBLIC -msse3 -msse4.1)
endif () endif ()
if(${CMAKE_BUILD_TYPE} MATCHES Debug) if (${CMAKE_BUILD_TYPE} MATCHES Debug)
target_compile_definitions(kaizen-qt PUBLIC VULKAN_DEBUG) target_compile_definitions(kaizen-qt PUBLIC VULKAN_DEBUG)
#target_compile_options(kaizen-qt PUBLIC -fsanitize=address -fsanitize=undefined) #target_compile_options(kaizen-qt PUBLIC -fsanitize=address -fsanitize=undefined)
#target_link_options(kaizen-qt PUBLIC -fsanitize=address -fsanitize=undefined) #target_link_options(kaizen-qt PUBLIC -fsanitize=address -fsanitize=undefined)
endif() endif ()
target_link_libraries(kaizen-qt PUBLIC Qt6::Core Qt6::Gui Qt6::Widgets discord-rpc fmt mio nlohmann_json parallel-rdp backend) target_link_libraries(kaizen-qt PUBLIC SDL3::SDL3 SDL3::SDL3-static Qt6::Core Qt6::Gui Qt6::Widgets discord-rpc fmt mio nlohmann_json parallel-rdp backend)
target_compile_definitions(kaizen-qt PUBLIC SDL_MAIN_HANDLED) target_compile_definitions(kaizen-qt PUBLIC SDL_MAIN_HANDLED)
file(COPY ../../resources/ DESTINATION ${PROJECT_BINARY_DIR}/resources/) file(COPY ../../resources/ DESTINATION ${PROJECT_BINARY_DIR}/resources/)

View File

@@ -1,5 +1,5 @@
#include <EmuThread.hpp> #include <EmuThread.hpp>
#include <SDL2/SDL.h> #include <SDL3/SDL.h>
EmuThread::EmuThread(const std::shared_ptr<QtInstanceFactory> &instance_, EmuThread::EmuThread(const std::shared_ptr<QtInstanceFactory> &instance_,
const std::shared_ptr<Vulkan::WSIPlatform> &wsiPlatform_, const std::shared_ptr<Vulkan::WSIPlatform> &wsiPlatform_,
@@ -8,10 +8,10 @@ EmuThread::EmuThread(const std::shared_ptr<QtInstanceFactory> &instance_,
[[noreturn]] void EmuThread::run() noexcept { [[noreturn]] void EmuThread::run() noexcept {
parallel.Init(instance, wsiPlatform, windowInfo, core.cpu->GetMem().GetRDRAMPtr()); parallel.Init(instance, wsiPlatform, windowInfo, core.cpu->GetMem().GetRDRAMPtr());
SDL_InitSubSystem(SDL_INIT_GAMECONTROLLER); SDL_InitSubSystem(SDL_INIT_GAMEPAD);
bool controllerConnected = false; bool controllerConnected = false;
if (SDL_GameControllerAddMappingsFromFile("resources/gamecontrollerdb.txt") < 0) { if (SDL_AddGamepadMappingsFromFile("resources/gamecontrollerdb.txt") < 0) {
Util::warn("[SDL] Could not load game controller DB"); Util::warn("[SDL] Could not load game controller DB");
} }
@@ -19,24 +19,24 @@ EmuThread::EmuThread(const std::shared_ptr<QtInstanceFactory> &instance_,
SDL_Event e; SDL_Event e;
while (SDL_PollEvent(&e)) { while (SDL_PollEvent(&e)) {
switch (e.type) { switch (e.type) {
case SDL_CONTROLLERDEVICEADDED: case SDL_EVENT_GAMEPAD_ADDED:
{ {
const int index = e.cdevice.which; const int index = e.gdevice.which;
controller = SDL_GameControllerOpen(index); controller = SDL_OpenGamepad(index);
Util::info("Found controller!"); Util::info("Found controller!");
auto serial = SDL_GameControllerGetSerial(controller); auto serial = SDL_GetGamepadSerial(controller);
auto name = SDL_GameControllerName(controller); auto name = SDL_GetGamepadName(controller);
auto path = SDL_GameControllerPath(controller); auto path = SDL_GetGamepadPath(controller);
Util::info("\tName: {}", name ? name : "Not available"); Util::info("\tName: {}", name ? name : "Not available");
Util::info("\tSerial: {}", serial ? serial : "Not available"); Util::info("\tSerial: {}", serial ? serial : "Not available");
Util::info("\tPath: {}", path ? path : "Not available"); Util::info("\tPath: {}", path ? path : "Not available");
controllerConnected = true; controllerConnected = true;
} }
break; break;
case SDL_CONTROLLERDEVICEREMOVED: case SDL_EVENT_GAMEPAD_REMOVED:
{ {
controllerConnected = false; controllerConnected = false;
SDL_GameControllerClose(controller); SDL_CloseGamepad(controller);
} }
break; break;
} }
@@ -59,43 +59,34 @@ EmuThread::EmuThread(const std::shared_ptr<QtInstanceFactory> &instance_,
if (controllerConnected) { if (controllerConnected) {
n64::PIF &pif = core.cpu->GetMem().mmio.si.pif; n64::PIF &pif = core.cpu->GetMem().mmio.si.pif;
pif.UpdateButton(0, n64::Controller::Key::A, SDL_GameControllerGetButton(controller, SDL_CONTROLLER_BUTTON_A)); pif.UpdateButton(0, n64::Controller::Key::A, SDL_GetGamepadButton(controller, SDL_GAMEPAD_BUTTON_SOUTH));
pif.UpdateButton(0, n64::Controller::Key::B, SDL_GameControllerGetButton(controller, SDL_CONTROLLER_BUTTON_X)); pif.UpdateButton(0, n64::Controller::Key::B, SDL_GetGamepadButton(controller, SDL_GAMEPAD_BUTTON_WEST));
pif.UpdateButton(0, n64::Controller::Key::Z, pif.UpdateButton(0, n64::Controller::Key::Z,
SDL_GameControllerGetAxis(controller, SDL_CONTROLLER_AXIS_TRIGGERLEFT) == SDL_JOYSTICK_AXIS_MAX); SDL_GetGamepadAxis(controller, SDL_GAMEPAD_AXIS_LEFT_TRIGGER) == SDL_JOYSTICK_AXIS_MAX);
pif.UpdateButton(0, n64::Controller::Key::Start, pif.UpdateButton(0, n64::Controller::Key::Start, SDL_GetGamepadButton(controller, SDL_GAMEPAD_BUTTON_START));
SDL_GameControllerGetButton(controller, SDL_CONTROLLER_BUTTON_START)); pif.UpdateButton(0, n64::Controller::Key::DUp, SDL_GetGamepadButton(controller, SDL_GAMEPAD_BUTTON_DPAD_UP));
pif.UpdateButton(0, n64::Controller::Key::DUp, pif.UpdateButton(0, n64::Controller::Key::DDown, SDL_GetGamepadButton(controller, SDL_GAMEPAD_BUTTON_DPAD_DOWN));
SDL_GameControllerGetButton(controller, SDL_CONTROLLER_BUTTON_DPAD_UP)); pif.UpdateButton(0, n64::Controller::Key::DLeft, SDL_GetGamepadButton(controller, SDL_GAMEPAD_BUTTON_DPAD_LEFT));
pif.UpdateButton(0, n64::Controller::Key::DDown,
SDL_GameControllerGetButton(controller, SDL_CONTROLLER_BUTTON_DPAD_DOWN));
pif.UpdateButton(0, n64::Controller::Key::DLeft,
SDL_GameControllerGetButton(controller, SDL_CONTROLLER_BUTTON_DPAD_LEFT));
pif.UpdateButton(0, n64::Controller::Key::DRight, pif.UpdateButton(0, n64::Controller::Key::DRight,
SDL_GameControllerGetButton(controller, SDL_CONTROLLER_BUTTON_DPAD_RIGHT)); SDL_GetGamepadButton(controller, SDL_GAMEPAD_BUTTON_DPAD_RIGHT));
pif.UpdateButton(0, n64::Controller::Key::LT, pif.UpdateButton(0, n64::Controller::Key::LT, SDL_GetGamepadButton(controller, SDL_GAMEPAD_BUTTON_LEFT_SHOULDER));
SDL_GameControllerGetButton(controller, SDL_CONTROLLER_BUTTON_LEFTSHOULDER));
pif.UpdateButton(0, n64::Controller::Key::RT, pif.UpdateButton(0, n64::Controller::Key::RT,
SDL_GameControllerGetButton(controller, SDL_CONTROLLER_BUTTON_RIGHTSHOULDER)); SDL_GetGamepadButton(controller, SDL_GAMEPAD_BUTTON_RIGHT_SHOULDER));
pif.UpdateButton(0, n64::Controller::Key::CUp, pif.UpdateButton(0, n64::Controller::Key::CUp, SDL_GetGamepadAxis(controller, SDL_GAMEPAD_AXIS_RIGHTY) <= -127);
SDL_GameControllerGetAxis(controller, SDL_CONTROLLER_AXIS_RIGHTY) <= -127); pif.UpdateButton(0, n64::Controller::Key::CDown, SDL_GetGamepadAxis(controller, SDL_GAMEPAD_AXIS_RIGHTY) >= 127);
pif.UpdateButton(0, n64::Controller::Key::CDown, pif.UpdateButton(0, n64::Controller::Key::CLeft, SDL_GetGamepadAxis(controller, SDL_GAMEPAD_AXIS_RIGHTX) <= -127);
SDL_GameControllerGetAxis(controller, SDL_CONTROLLER_AXIS_RIGHTY) >= 127); pif.UpdateButton(0, n64::Controller::Key::CRight, SDL_GetGamepadAxis(controller, SDL_GAMEPAD_AXIS_RIGHTX) >= 127);
pif.UpdateButton(0, n64::Controller::Key::CLeft,
SDL_GameControllerGetAxis(controller, SDL_CONTROLLER_AXIS_RIGHTX) <= -127);
pif.UpdateButton(0, n64::Controller::Key::CRight,
SDL_GameControllerGetAxis(controller, SDL_CONTROLLER_AXIS_RIGHTX) >= 127);
float xclamped = SDL_GameControllerGetAxis(controller, SDL_CONTROLLER_AXIS_LEFTX); float xclamped = SDL_GetGamepadAxis(controller, SDL_GAMEPAD_AXIS_LEFTX);
if (xclamped < 0) { if (xclamped < 0) {
xclamped /= float(std::abs(SDL_JOYSTICK_AXIS_MIN)); xclamped /= float(std::abs(SDL_JOYSTICK_AXIS_MAX));
} else { } else {
xclamped /= SDL_JOYSTICK_AXIS_MAX; xclamped /= SDL_JOYSTICK_AXIS_MAX;
} }
xclamped *= 86; xclamped *= 86;
float yclamped = SDL_GameControllerGetAxis(controller, SDL_CONTROLLER_AXIS_LEFTY); float yclamped = SDL_GetGamepadAxis(controller, SDL_GAMEPAD_AXIS_LEFTY);
if (yclamped < 0) { if (yclamped < 0) {
yclamped /= float(std::abs(SDL_JOYSTICK_AXIS_MIN)); yclamped /= float(std::abs(SDL_JOYSTICK_AXIS_MIN));
} else { } else {

View File

@@ -3,7 +3,7 @@
#include <Discord.hpp> #include <Discord.hpp>
#include <QThread> #include <QThread>
#include <RenderWidget.hpp> #include <RenderWidget.hpp>
#include <SDL2/SDL_gamecontroller.h> #include <SDL3/SDL_gamepad.h>
#include <SettingsWindow.hpp> #include <SettingsWindow.hpp>
#include <memory> #include <memory>
@@ -20,7 +20,7 @@ public:
[[noreturn]] void run() noexcept override; [[noreturn]] void run() noexcept override;
SDL_GameController *controller = nullptr; SDL_Gamepad *controller = nullptr;
ParallelRDP parallel; ParallelRDP parallel;
n64::Core core; n64::Core core;
SettingsWindow &settings; SettingsWindow &settings;