More CirclePad Pro improvements

This commit is contained in:
wheremyfoodat 2025-07-03 00:52:55 +03:00
parent 935e088ca1
commit 0ab8a6d956
14 changed files with 155 additions and 81 deletions

View file

@ -8,7 +8,6 @@ namespace IR {
public:
struct ButtonState {
static constexpr int C_STICK_CENTER = 0x800;
static constexpr int C_STICK_RADIUS = 0x7FF;
union {
BitField<0, 8, u32> header;

View file

@ -8,6 +8,7 @@
#include "logger.hpp"
#include "memory.hpp"
#include "result/result.hpp"
#include "services/hid.hpp"
#include "services/ir/circlepad_pro.hpp"
// Circular dependencies in this project? Never
@ -23,6 +24,8 @@ class IRUserService {
Handle handle = KernelHandles::IR_USER;
Memory& mem;
Kernel& kernel;
// The IR service has a reference to the HID service as that's where the frontends store CirclePad Pro button state in
HIDService& hid;
const EmulatorConfig& config;
MAKE_LOG_FUNCTION(log, irUserLogger)
@ -76,11 +79,9 @@ class IRUserService {
void sendPayload(std::span<const u8> payload);
public:
IRUserService(Memory& mem, const EmulatorConfig& config, Kernel& kernel)
: mem(mem), config(config), kernel(kernel), cpp([&](IR::Device::Payload payload) { sendPayload(payload); }) {}
IRUserService(Memory& mem, HIDService& hid, const EmulatorConfig& config, Kernel& kernel)
: mem(mem), hid(hid), config(config), kernel(kernel), cpp([&](IR::Device::Payload payload) { sendPayload(payload); }) {}
void setZRPressed(bool pressed) { cpp.state.buttons.zrNotPressed = pressed ? 0 : 1; }
void setZLPressed(bool pressed) { cpp.state.buttons.zrNotPressed = pressed ? 0 : 1; }
void setCStickX(s16 value) { cpp.state.cStick.x = value; }
void setCStickY(s16 value) { cpp.state.cStick.y = value; }