mirror of
https://github.com/wheremyfoodat/Panda3DS.git
synced 2025-07-04 14:26:20 +12:00
IR: Move to scheduler
This commit is contained in:
parent
b2904f391f
commit
dc7f8a48bd
7 changed files with 29 additions and 14 deletions
|
@ -44,7 +44,10 @@ namespace IR {
|
|||
virtual void disconnect() override;
|
||||
virtual void receivePayload(Payload payload) override;
|
||||
|
||||
CirclePadPro(SendCallback sendCallback) : IR::Device(sendCallback) {}
|
||||
CirclePadPro(SendCallback sendCallback, Scheduler& scheduler) : IR::Device(sendCallback, scheduler) {}
|
||||
|
||||
ButtonState state;
|
||||
// The current polling period in cycles, configured via the ConfigurePolling command
|
||||
s64 period = Scheduler::nsToCycles(16000);
|
||||
};
|
||||
} // namespace IR
|
|
@ -3,6 +3,7 @@
|
|||
#include <span>
|
||||
|
||||
#include "helpers.hpp"
|
||||
#include "scheduler.hpp"
|
||||
|
||||
namespace IR {
|
||||
class Device {
|
||||
|
@ -11,6 +12,7 @@ namespace IR {
|
|||
|
||||
protected:
|
||||
using SendCallback = std::function<void(Payload)>; // Callback for sending data from IR device->3DS
|
||||
Scheduler& scheduler;
|
||||
SendCallback sendCallback;
|
||||
|
||||
public:
|
||||
|
@ -18,6 +20,6 @@ namespace IR {
|
|||
virtual void disconnect() = 0;
|
||||
virtual void receivePayload(Payload payload) = 0;
|
||||
|
||||
Device(SendCallback sendCallback) : sendCallback(sendCallback) {}
|
||||
Device(SendCallback sendCallback, Scheduler& scheduler) : sendCallback(sendCallback), scheduler(scheduler) {}
|
||||
};
|
||||
} // namespace IR
|
|
@ -16,6 +16,7 @@
|
|||
class Kernel;
|
||||
|
||||
class IRUserService {
|
||||
using Payload = IR::Device::Payload;
|
||||
using Handle = HorizonHandle;
|
||||
|
||||
enum class DeviceID : u8 {
|
||||
|
@ -75,14 +76,11 @@ class IRUserService {
|
|||
// The IR service uses CRC8 with generator polynomial = 0x07 for verifying packets received from IR devices
|
||||
static u8 crc8(std::span<const u8> data);
|
||||
|
||||
// IR service calls this to send a console->device payload
|
||||
void receivePayload(std::span<const u8> data);
|
||||
// IR devices call this to send a device->console payload
|
||||
void sendPayload(std::span<const u8> payload);
|
||||
void sendPayload(Payload payload);
|
||||
|
||||
public:
|
||||
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); }) {}
|
||||
IRUserService(Memory& mem, HIDService& hid, const EmulatorConfig& config, Kernel& kernel);
|
||||
|
||||
void setCStickX(s16 value) { cpp.state.cStick.x = value; }
|
||||
void setCStickY(s16 value) { cpp.state.cStick.y = value; }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue