| 102 | return response; |
| 103 | } |
| 104 | void SwitchGamepadDevice::process() |
| 105 | { |
| 106 | uint32_t now = to_ms_since_boot(get_absolute_time()); |
| 107 | reportSent = false; |
| 108 | if (isReportQueued) |
| 109 | { |
| 110 | if ((now - last_report_timer) > SWITCH_PRO_KEEPALIVE_TIMER) |
| 111 | { |
| 112 | if (ready()) |
| 113 | { |
| 114 | sendReport(queuedReportID, report, 64); |
| 115 | } |
| 116 | isReportQueued = false; |
| 117 | last_report_timer = now; |
| 118 | } |
| 119 | reportSent = true; |
| 120 | } |
| 121 | |
| 122 | if (isReady && !reportSent) |
| 123 | { |
| 124 | for (const auto &profile : profiles) |
| 125 | { |
| 126 | for (const auto &mapping : profile->mappings) |
| 127 | { |
| 128 | mapping->update(false, false); |
| 129 | mapping->update_switch((uint8_t *)&switchReport.inputs); |
| 130 | } |
| 131 | for (const auto &led : profile->leds) |
| 132 | { |
| 133 | led->update(false, false); |
| 134 | } |
| 135 | } |
| 136 | if ((now - last_report_timer) > SWITCH_PRO_KEEPALIVE_TIMER) |
| 137 | { |
| 138 | switchReport.timestamp = last_report_counter; |
| 139 | void *inputReport = &switchReport; |
| 140 | uint16_t report_size = sizeof(switchReport); |
| 141 | if (memcmp(last_report, inputReport, report_size) != 0) |
| 142 | { |
| 143 | // HID ready + report sent, copy previous report |
| 144 | if (ready() && sendReport(0, inputReport, report_size) == true) |
| 145 | { |
| 146 | memcpy(last_report, inputReport, report_size); |
| 147 | reportSent = true; |
| 148 | } |
| 149 | |
| 150 | last_report_timer = now; |
| 151 | } |
| 152 | } |
| 153 | } |
| 154 | else |
| 155 | { |
| 156 | if (!isInitialized) |
| 157 | { |
| 158 | // send identification |
| 159 | sendIdentify(); |
| 160 | if (ready() && send_report(64, 0, report)) |
| 161 | { |
nothing calls this directly
no test coverage detected