MCPcopy Create free account
hub / github.com/Santroller/Santroller / process

Method process

src/usb/device/switch_device.cpp:104–169  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

102 return response;
103}
104void 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 {

Callers

nothing calls this directly

Calls 4

memcpyFunction · 0.85
send_reportFunction · 0.85
updateMethod · 0.45
update_switchMethod · 0.45

Tested by

no test coverage detected