Skip to content

Instantly share code, notes, and snippets.

@yabberyabber
Created January 29, 2019 01:32
Show Gist options
  • Save yabberyabber/5835dc5e468e1e466cc087e887a09b98 to your computer and use it in GitHub Desktop.
Save yabberyabber/5835dc5e468e1e466cc087e887a09b98 to your computer and use it in GitHub Desktop.
void ObservableDualActionJoystick::TaskPrePeriodic(RobotMode mode) {
uint32_t currBtn = GetAllButtons();
if (m_observer != nullptr) {
int mask = 1, buttonId = 0;
for ( int buttonId = 0; buttonId < 64; buttonId++ ) {
if (m_prevBtn & mask != currBtn & mask) {
m_observer->ObserveDualActionJoystickStateChange(m_port, buttonId, currBtn & mask);
}
mask <<= 1;
}
}
m_prevBtn = currBtn;
if (m_logCell) {
m_logCell->LogPrintf("%x", currBtn);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment