Library for ELEC2645 Gamepad PCB. University of Leeds
Dependents: Project_MaZe1_copy Labirint Game_Controller_Project 200943373MAZE ... more
Diff: Gamepad.h
- Revision:
- 19:c2bb79a10b3c
- Parent:
- 18:e0a4f15a7750
- Child:
- 20:c0959710291b
diff -r e0a4f15a7750 -r c2bb79a10b3c Gamepad.h --- a/Gamepad.h Sun Mar 05 19:28:14 2017 +0000 +++ b/Gamepad.h Tue Apr 25 10:19:47 2017 +0000 @@ -50,8 +50,8 @@ */ class Gamepad { - public: - /** Gamepad events +public: +/** Gamepad events * @brief List of events that can be registered on the gamepad */ enum GamepadEvent { @@ -66,6 +66,7 @@ JOY_PRESSED, ///< Joystick button has been pressed N_EVENTS ///< A dummy flag that marks the end of the list }; + private: mbed::PwmOut *_led1; mbed::PwmOut *_led2; @@ -99,7 +100,6 @@ float _y0; public: - /** Constructor */ Gamepad(); @@ -144,10 +144,23 @@ */ bool check_event(GamepadEvent const id); + /** + * @brief Get the raw binary event state + * @return The event state as a binary code + * @details The check_event() function is likely to be more useful than + * this, for testing whether a given event has occurred. It can be + * useful for debugging via the terminal, however, for example: + * @code + * std::cout << gamepad.get_raw_event_state() << std::endl; + * @endcode + */ + inline std::bitset<N_EVENTS> get_raw_event_state() const { + return _event_state; + } + /** Get magnitude of joystick movement * @returns value in range 0.0 to 1.0 */ - float get_mag(); /** Get angle of joystick movement