Files
basic1/lib/input_manager.h
2026-01-30 21:33:42 -05:00

65 lines
1.9 KiB
C++

// ============================================================================
// INPUT MANAGER HEADER
// ============================================================================
// Handles all input processing and debouncing for touch and button inputs
// Converts hardware events into InputEvent objects for games to consume
#ifndef INPUT_MANAGER_H
#define INPUT_MANAGER_H
#include <stdint.h>
#include "input_event.h"
#include "display/low_level_touch.h"
// Forward declaration - avoid pulling in full basic1.cpp
struct GameConfig;
/**
* @brief Input Manager - Processes touch and button inputs
*
* Responsibilities:
* - Reading touch controller data
* - Debouncing touch and button events
* - Converting raw inputs to InputEvent objects
* - Gesture recognition
*
* Does NOT handle:
* - Button GPIO initialization (stays in basic1.cpp)
* - Interrupt handler registration (stays in basic1.cpp)
*/
class InputManager {
public:
/**
* @brief Construct InputManager with hardware references
* @param touch Pointer to touch controller interface
* @param config Pointer to game configuration
*/
InputManager(LowLevelTouch* touch, const GameConfig* config);
/**
* @brief Process touch input from controller
* @param last_time Pointer to last touch timestamp for debouncing
* @return InputEvent (valid=false if no valid input)
*/
InputEvent process_touch_input(uint32_t* last_time);
/**
* @brief Process button input from GPIO flags
* @return InputEvent (valid=false if no valid input)
*/
InputEvent process_button_input();
/**
* @brief Get human-readable gesture name
* @param gesture_code Gesture code from touch controller
* @return Constant string with gesture name
*/
static const char* get_gesture_name(uint8_t gesture_code);
private:
LowLevelTouch* touch;
const GameConfig* config;
};
#endif // INPUT_MANAGER_H