IR: pass in Core::Timing for ExtraHID
This commit is contained in:
parent
ea496507d5
commit
d6f3ac1f4e
3 changed files with 13 additions and 12 deletions
|
@ -64,7 +64,7 @@ enum class ResponseID : u8 {
|
|||
ReadCalibrationData = 0x11,
|
||||
};
|
||||
|
||||
ExtraHID::ExtraHID(SendFunc send_func) : IRDevice(send_func) {
|
||||
ExtraHID::ExtraHID(SendFunc send_func, Core::Timing& timing) : IRDevice(send_func), timing(timing) {
|
||||
LoadInputDevices();
|
||||
|
||||
// The data below was retrieved from a New 3DS
|
||||
|
@ -145,11 +145,11 @@ ExtraHID::ExtraHID(SendFunc send_func) : IRDevice(send_func) {
|
|||
0x65,
|
||||
}};
|
||||
|
||||
hid_polling_callback_id = Core::System::GetInstance().CoreTiming().RegisterEvent(
|
||||
"ExtraHID::SendHIDStatus", [this](u64, s64 cycles_late) {
|
||||
hid_polling_callback_id =
|
||||
timing.RegisterEvent("ExtraHID::SendHIDStatus", [this](u64, s64 cycles_late) {
|
||||
SendHIDStatus();
|
||||
Core::System::GetInstance().CoreTiming().ScheduleEvent(
|
||||
msToCycles(hid_period) - cycles_late, hid_polling_callback_id);
|
||||
this->timing.ScheduleEvent(msToCycles(hid_period) - cycles_late,
|
||||
hid_polling_callback_id);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -160,7 +160,7 @@ ExtraHID::~ExtraHID() {
|
|||
void ExtraHID::OnConnect() {}
|
||||
|
||||
void ExtraHID::OnDisconnect() {
|
||||
Core::System::GetInstance().CoreTiming().UnscheduleEvent(hid_polling_callback_id, 0);
|
||||
timing.UnscheduleEvent(hid_polling_callback_id, 0);
|
||||
}
|
||||
|
||||
void ExtraHID::HandleConfigureHIDPollingRequest(const std::vector<u8>& request) {
|
||||
|
@ -171,10 +171,9 @@ void ExtraHID::HandleConfigureHIDPollingRequest(const std::vector<u8>& request)
|
|||
}
|
||||
|
||||
// Change HID input polling interval
|
||||
Core::System::GetInstance().CoreTiming().UnscheduleEvent(hid_polling_callback_id, 0);
|
||||
timing.UnscheduleEvent(hid_polling_callback_id, 0);
|
||||
hid_period = request[1];
|
||||
Core::System::GetInstance().CoreTiming().ScheduleEvent(msToCycles(hid_period),
|
||||
hid_polling_callback_id);
|
||||
timing.ScheduleEvent(msToCycles(hid_period), hid_polling_callback_id);
|
||||
}
|
||||
|
||||
void ExtraHID::HandleReadCalibrationDataRequest(const std::vector<u8>& request_buf) {
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
|
||||
namespace Core {
|
||||
struct TimingEventType;
|
||||
class Timing;
|
||||
} // namespace Core
|
||||
|
||||
namespace Service::IR {
|
||||
|
@ -40,7 +41,7 @@ static_assert(sizeof(ExtraHIDResponse) == 6, "HID status response has wrong size
|
|||
*/
|
||||
class ExtraHID final : public IRDevice {
|
||||
public:
|
||||
explicit ExtraHID(SendFunc send_func);
|
||||
explicit ExtraHID(SendFunc send_func, Core::Timing& timing);
|
||||
~ExtraHID();
|
||||
|
||||
void OnConnect() override;
|
||||
|
@ -56,6 +57,7 @@ private:
|
|||
void HandleReadCalibrationDataRequest(const std::vector<u8>& request);
|
||||
void LoadInputDevices();
|
||||
|
||||
Core::Timing& timing;
|
||||
u8 hid_period;
|
||||
Core::TimingEventType* hid_polling_callback_id;
|
||||
std::array<u8, 0x40> calibration_data;
|
||||
|
|
|
@ -418,8 +418,8 @@ IR_USER::IR_USER(Core::System& system) : ServiceFramework("ir:USER", 1) {
|
|||
send_event = system.Kernel().CreateEvent(ResetType::OneShot, "IR:SendEvent");
|
||||
receive_event = system.Kernel().CreateEvent(ResetType::OneShot, "IR:ReceiveEvent");
|
||||
|
||||
extra_hid =
|
||||
std::make_unique<ExtraHID>([this](const std::vector<u8>& data) { PutToReceive(data); });
|
||||
extra_hid = std::make_unique<ExtraHID>(
|
||||
[this](const std::vector<u8>& data) { PutToReceive(data); }, system.CoreTiming());
|
||||
}
|
||||
|
||||
IR_USER::~IR_USER() {
|
||||
|
|
Loading…
Reference in a new issue