GameboyInput.h 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. /******************************************************************************
  2. * M5Snake : Input management from Gameboy faces *
  3. * --------------------------------------------- *
  4. * Management of input coming from the face Gameboy *
  5. * Author: Olivier Staquet *
  6. * Last version available on https://github.com/ostaquet/M5Snake *
  7. *****************************************************************************/
  8. #ifndef _GAMEBOYINPUT_H_
  9. #define _GAMEBOYINPUT_H_
  10. #include <Arduino.h>
  11. #include "Wire.h"
  12. #define GAMEBOY_KEY_NONE 0x00
  13. #define GAMEBOY_KEY_RELEASED 0xFF
  14. #define GAMEBOY_KEY_START 0x7F
  15. #define GAMEBOY_KEY_SELECT 0xBF
  16. #define GAMEBOY_KEY_A 0xEF
  17. #define GAMEBOY_KEY_B 0xDF
  18. #define GAMEBOY_KEY_UP 0xFE
  19. #define GAMEBOY_KEY_DOWN 0xFD
  20. #define GAMEBOY_KEY_LEFT 0xFB
  21. #define GAMEBOY_KEY_RIGHT 0xF7
  22. class GameboyInputClass {
  23. public:
  24. // Initialize
  25. void begin(uint8_t _i2c_address = 0x08, uint8_t _pin_int_face = 5);
  26. // Check if button pressed and return which one
  27. uint8_t getActivity();
  28. private:
  29. // I2C address
  30. uint8_t i2c_address = 0x00;
  31. // PIN for interrupt of the Face
  32. uint8_t pin_int_face = 0x00;
  33. };
  34. extern GameboyInputClass GameboyInput;
  35. #endif // _GAMEBOYINPUT_H_