Added support for Sonata's joystick.
diff --git a/sdk/include/platform/sunburst/platform-gpio.hh b/sdk/include/platform/sunburst/platform-gpio.hh index 3f97f8d..02f1e14 100644 --- a/sdk/include/platform/sunburst/platform-gpio.hh +++ b/sdk/include/platform/sunburst/platform-gpio.hh
@@ -3,6 +3,23 @@ #include <stdint.h> /** + * Represents the state of the Sonata's joystick. + * + * Note, that up to three of the bits may be asserted at any given time. + * There may be up to two cardinal directions asserted when the joystick is + * pushed in a diagonal and the joystick may be pressed while being pushed in a + * given direction. + */ +enum class SonataJoystick : uint8_t +{ + Left = 1 << 0, + Up = 1 << 1, + Pressed = 1 << 2, + Down = 1 << 3, + Right = 1 << 4, +}; + +/** * A Simple Driver for the Sonata's GPIO. * * Documentation source can be found at: @@ -58,4 +75,12 @@ { output = output ^ led_bit(index); } + + /** + * Returns the state of the joystick. + */ + SonataJoystick read_joystick() volatile + { + return static_cast<SonataJoystick>(input & 0x1f); + } };