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