remove json lib

This commit is contained in:
irisz64
2025-06-26 23:33:03 +02:00
parent df55ee6d9b
commit 4e7afcd49e
1175 changed files with 125 additions and 183754 deletions

View File

@@ -5,11 +5,13 @@
#include <ImGuiImpl/GUI.hpp>
bool HandleInput(void *userdata, SDL_Event *event);
bool QueryDevices(void *userdata, SDL_Event *event);
KaizenGui::KaizenGui() noexcept : window("Kaizen", 800, 600), core(std::make_shared<n64::Core>()), vulkanWidget(core, window.getHandle()), emuThread(core, fpsCounter, vulkanWidget, settingsWindow) {
gui::Initialize(core->parallel.wsi, window.getHandle());
SDL_AddEventWatch(HandleInput, this);
SDL_AddEventWatch(QueryDevices, this);
actionPause.setFunc([&]() {
if(ImGui::IsItemClicked()) {
@@ -87,26 +89,50 @@ KaizenGui::KaizenGui() noexcept : window("Kaizen", 800, 600), core(std::make_sha
KaizenGui::~KaizenGui() {
gui::Cleanup();
SDL_RemoveEventWatch(HandleInput, this);
SDL_RemoveEventWatch(QueryDevices, this);
SDL_Quit();
}
bool QueryDevices(void *userdata, SDL_Event *event) {
auto _this = (KaizenGui*)userdata;
switch (event->type) {
case SDL_EVENT_GAMEPAD_ADDED:
{
const auto index = event->gdevice.which;
auto gamepad = SDL_OpenGamepad(index);
Util::info("Found controller!");
const auto serial = SDL_GetGamepadSerial(gamepad);
const auto name = SDL_GetGamepadName(gamepad);
const auto path = SDL_GetGamepadPath(gamepad);
_this->gamepad = gamepad;
}
return true;
case SDL_EVENT_GAMEPAD_REMOVED:
SDL_CloseGamepad(_this->gamepad);
return true;
default:
return false;
}
}
bool HandleInput(void *userdata, SDL_Event *event) {
auto _this = (KaizenGui*)userdata;
InputSettings& inputSettings = _this->settingsWindow.inputSettings;
n64::PIF &pif = _this->core->cpu->GetMem().mmio.si.pif;
switch(event->type) {
case SDL_EVENT_GAMEPAD_AXIS_MOTION:
if(!inputSettings.selectedDeviceIsNotKeyboard)
if(!_this->gamepad)
return false;
{
_this->core->pause = true;
pif.UpdateButton(0, n64::Controller::Key::Z, SDL_GetGamepadAxis(inputSettings.gamepads[inputSettings.currentlySelectedDeviceIndex], SDL_GAMEPAD_AXIS_LEFT_TRIGGER) == SDL_JOYSTICK_AXIS_MAX);
pif.UpdateButton(0, n64::Controller::Key::CUp, SDL_GetGamepadAxis(inputSettings.gamepads[inputSettings.currentlySelectedDeviceIndex], SDL_GAMEPAD_AXIS_RIGHTY) <= -127);
pif.UpdateButton(0, n64::Controller::Key::CDown, SDL_GetGamepadAxis(inputSettings.gamepads[inputSettings.currentlySelectedDeviceIndex], SDL_GAMEPAD_AXIS_RIGHTY) >= 127);
pif.UpdateButton(0, n64::Controller::Key::CLeft, SDL_GetGamepadAxis(inputSettings.gamepads[inputSettings.currentlySelectedDeviceIndex], SDL_GAMEPAD_AXIS_RIGHTX) <= -127);
pif.UpdateButton(0, n64::Controller::Key::CRight, SDL_GetGamepadAxis(inputSettings.gamepads[inputSettings.currentlySelectedDeviceIndex], SDL_GAMEPAD_AXIS_RIGHTX) >= 127);
pif.UpdateButton(0, n64::Controller::Key::Z, SDL_GetGamepadAxis(_this->gamepad, SDL_GAMEPAD_AXIS_LEFT_TRIGGER) == SDL_JOYSTICK_AXIS_MAX);
pif.UpdateButton(0, n64::Controller::Key::CUp, SDL_GetGamepadAxis(_this->gamepad, SDL_GAMEPAD_AXIS_RIGHTY) <= -127);
pif.UpdateButton(0, n64::Controller::Key::CDown, SDL_GetGamepadAxis(_this->gamepad, SDL_GAMEPAD_AXIS_RIGHTY) >= 127);
pif.UpdateButton(0, n64::Controller::Key::CLeft, SDL_GetGamepadAxis(_this->gamepad, SDL_GAMEPAD_AXIS_RIGHTX) <= -127);
pif.UpdateButton(0, n64::Controller::Key::CRight, SDL_GetGamepadAxis(_this->gamepad, SDL_GAMEPAD_AXIS_RIGHTX) >= 127);
float xclamped = SDL_GetGamepadAxis(inputSettings.gamepads[inputSettings.currentlySelectedDeviceIndex], SDL_GAMEPAD_AXIS_LEFTX);
float xclamped = SDL_GetGamepadAxis(_this->gamepad, SDL_GAMEPAD_AXIS_LEFTX);
if (xclamped < 0) {
xclamped /= float(std::abs(SDL_JOYSTICK_AXIS_MAX));
} else {
@@ -115,7 +141,7 @@ bool HandleInput(void *userdata, SDL_Event *event) {
xclamped *= 86;
float yclamped = SDL_GetGamepadAxis(inputSettings.gamepads[inputSettings.currentlySelectedDeviceIndex], SDL_GAMEPAD_AXIS_LEFTY);
float yclamped = SDL_GetGamepadAxis(_this->gamepad, SDL_GAMEPAD_AXIS_LEFTY);
if (yclamped < 0) {
yclamped /= float(std::abs(SDL_JOYSTICK_AXIS_MIN));
} else {
@@ -130,25 +156,25 @@ bool HandleInput(void *userdata, SDL_Event *event) {
}
return true;
case SDL_EVENT_GAMEPAD_BUTTON_DOWN:
if(!inputSettings.selectedDeviceIsNotKeyboard)
if(!_this->gamepad)
return false;
{
_this->core->pause = true;
pif.UpdateButton(0, n64::Controller::Key::A, SDL_GetGamepadButton(inputSettings.gamepads[inputSettings.currentlySelectedDeviceIndex], SDL_GAMEPAD_BUTTON_SOUTH));
pif.UpdateButton(0, n64::Controller::Key::B, SDL_GetGamepadButton(inputSettings.gamepads[inputSettings.currentlySelectedDeviceIndex], SDL_GAMEPAD_BUTTON_WEST));
pif.UpdateButton(0, n64::Controller::Key::Start, SDL_GetGamepadButton(inputSettings.gamepads[inputSettings.currentlySelectedDeviceIndex], SDL_GAMEPAD_BUTTON_START));
pif.UpdateButton(0, n64::Controller::Key::DUp, SDL_GetGamepadButton(inputSettings.gamepads[inputSettings.currentlySelectedDeviceIndex], SDL_GAMEPAD_BUTTON_DPAD_UP));
pif.UpdateButton(0, n64::Controller::Key::DDown, SDL_GetGamepadButton(inputSettings.gamepads[inputSettings.currentlySelectedDeviceIndex], SDL_GAMEPAD_BUTTON_DPAD_DOWN));
pif.UpdateButton(0, n64::Controller::Key::DLeft, SDL_GetGamepadButton(inputSettings.gamepads[inputSettings.currentlySelectedDeviceIndex], SDL_GAMEPAD_BUTTON_DPAD_LEFT));
pif.UpdateButton(0, n64::Controller::Key::DRight, SDL_GetGamepadButton(inputSettings.gamepads[inputSettings.currentlySelectedDeviceIndex], SDL_GAMEPAD_BUTTON_DPAD_RIGHT));
pif.UpdateButton(0, n64::Controller::Key::LT, SDL_GetGamepadButton(inputSettings.gamepads[inputSettings.currentlySelectedDeviceIndex], SDL_GAMEPAD_BUTTON_LEFT_SHOULDER));
pif.UpdateButton(0, n64::Controller::Key::RT, SDL_GetGamepadButton(inputSettings.gamepads[inputSettings.currentlySelectedDeviceIndex], SDL_GAMEPAD_BUTTON_RIGHT_SHOULDER));
pif.UpdateButton(0, n64::Controller::Key::A, SDL_GetGamepadButton(_this->gamepad, SDL_GAMEPAD_BUTTON_SOUTH));
pif.UpdateButton(0, n64::Controller::Key::B, SDL_GetGamepadButton(_this->gamepad, SDL_GAMEPAD_BUTTON_WEST));
pif.UpdateButton(0, n64::Controller::Key::Start, SDL_GetGamepadButton(_this->gamepad, SDL_GAMEPAD_BUTTON_START));
pif.UpdateButton(0, n64::Controller::Key::DUp, SDL_GetGamepadButton(_this->gamepad, SDL_GAMEPAD_BUTTON_DPAD_UP));
pif.UpdateButton(0, n64::Controller::Key::DDown, SDL_GetGamepadButton(_this->gamepad, SDL_GAMEPAD_BUTTON_DPAD_DOWN));
pif.UpdateButton(0, n64::Controller::Key::DLeft, SDL_GetGamepadButton(_this->gamepad, SDL_GAMEPAD_BUTTON_DPAD_LEFT));
pif.UpdateButton(0, n64::Controller::Key::DRight, SDL_GetGamepadButton(_this->gamepad, SDL_GAMEPAD_BUTTON_DPAD_RIGHT));
pif.UpdateButton(0, n64::Controller::Key::LT, SDL_GetGamepadButton(_this->gamepad, SDL_GAMEPAD_BUTTON_LEFT_SHOULDER));
pif.UpdateButton(0, n64::Controller::Key::RT, SDL_GetGamepadButton(_this->gamepad, SDL_GAMEPAD_BUTTON_RIGHT_SHOULDER));
_this->core->pause = false;
}
return true;
case SDL_EVENT_KEY_DOWN:
case SDL_EVENT_KEY_UP:
if(inputSettings.selectedDeviceIsNotKeyboard)
if(_this->gamepad)
return false;
{
_this->core->pause = true;