Added some more patch functionality, added recomp namespace

This commit is contained in:
Mr-Wiseguy
2023-11-24 17:10:21 -05:00
parent 3b06ad52f0
commit ec23ef02fd
18 changed files with 628 additions and 230 deletions
+5 -1
View File
@@ -2,6 +2,7 @@
#define __RECOMP_HELPERS__
#include "recomp.h"
#include "../ultramodern/ultra64.h"
template<int index, typename T>
T _arg(uint8_t* rdram, recomp_context* ctx) {
@@ -13,7 +14,10 @@ T _arg(uint8_t* rdram, recomp_context* ctx) {
return ctx->f12.fl;
}
else {
return std::bit_cast<T>(raw_arg);
// static_assert in else workaround
[] <bool flag = false>() {
static_assert(flag, "Floats in a2/a3 not supported");
}();
}
}
else if constexpr (std::is_pointer_v<T>) {
+63
View File
@@ -0,0 +1,63 @@
#ifndef __RECOMP_INPUT_H__
#define __RECOMP_INPUT_H__
#include <cstdint>
#include <variant>
#include <vector>
#include <type_traits>
namespace recomp {
struct ControllerState {
enum Button : uint32_t {
BUTTON_NORTH = 1 << 0,
BUTTON_SOUTH = 1 << 1,
BUTTON_EAST = 1 << 2,
BUTTON_WEST = 1 << 3,
BUTTON_L1 = 1 << 4, // Left Bumper
BUTTON_R1 = 1 << 5, // Right Bumper
BUTTON_L2 = 1 << 6, // Left Trigger Press
BUTTON_R2 = 1 << 7, // Right Trigger Press
BUTTON_L3 = 1 << 8, // Left Joystick Press
BUTTON_R3 = 1 << 9, // Right Joystick Press
BUTTON_DPAD_UP = 1 << 10,
BUTTON_DPAD_DOWN = 1 << 11,
BUTTON_DPAD_RIGHT = 1 << 12,
BUTTON_DPAD_LEFT = 1 << 13,
BUTTON_START = 1 << 14,
};
enum Axis : size_t {
AXIS_LEFT_X,
AXIS_LEFT_Y,
AXIS_RIGHT_X,
AXIS_RIGHT_Y,
AXIS_LEFT_TRIGGER,
AXIS_RIGHT_TRIGGER,
AXIS_MAX
};
uint32_t buttons;
float axes[AXIS_MAX];
};
struct MouseState {
enum Button : uint32_t {
LEFT = 1 << 0,
RIGHT = 1 << 1,
MIDDLE = 1 << 2,
BACK = 1 << 3,
FORWARD = 1 << 4,
};
int32_t wheel_pos;
int32_t position_x;
int32_t position_y;
uint32_t buttons;
};
using InputState = std::variant<ControllerState, MouseState>;
void get_keyboard_input(uint16_t* buttons_out, float* x_out, float* y_out);
void get_n64_input(uint16_t* buttons_out, float* x_out, float* y_out);
std::vector<InputState> get_input_states();
void handle_events();
}
#endif
+13 -10
View File
@@ -5,22 +5,25 @@
#include "SDL.h"
void queue_event(const SDL_Event& event);
bool try_deque_event(SDL_Event& out);
namespace Rml {
class ElementDocument;
class EventListenerInstancer;
}
std::unique_ptr<Rml::EventListenerInstancer> make_event_listener_instancer();
namespace recomp {
enum class Menu {
Launcher,
None
};
void queue_event(const SDL_Event& event);
bool try_deque_event(SDL_Event& out);
void set_current_menu(Menu menu);
void destroy_ui();
std::unique_ptr<Rml::EventListenerInstancer> make_event_listener_instancer();
enum class Menu {
Launcher,
None
};
void set_current_menu(Menu menu);
void destroy_ui();
}
#endif