41 lines
499 B
C++
41 lines
499 B
C++
#include "Input.hpp"
|
|
|
|
|
|
void Input::Strobe(uint8_t* but)
|
|
{
|
|
if (strobe)
|
|
{
|
|
for (int i = 0; i < 8; ++i)
|
|
{
|
|
buttons[i] = but[i];
|
|
}
|
|
}
|
|
}
|
|
|
|
uint8_t Input::Poll()
|
|
{
|
|
uint8_t buttonState;
|
|
|
|
// Strobe set - return state of A button
|
|
if (strobe)
|
|
{
|
|
buttonState = buttons[Buttons::A];
|
|
}
|
|
|
|
// All 8 bits read - return 1u
|
|
else if (buttonIndex > Buttons::Right)
|
|
{
|
|
buttonState = 1u;
|
|
}
|
|
|
|
// Return next bit
|
|
else
|
|
{
|
|
buttonState = buttons[buttonIndex];
|
|
|
|
++buttonIndex;
|
|
}
|
|
|
|
return buttonState;
|
|
}
|