#pragma once

#include <common.h>

typedef struct {
    bool start;
    bool select;
    bool a;
    bool b;
    bool up;
    bool down;
    bool left;
    bool right;
} gamepad_state;

typedef struct {
    bool button_sel;
    bool dir_sel;
    gamepad_state controller;
    gamepad_state prev;
} gamepad_context;

typedef struct {
    gamepad_context ctx;
} ctlr_state;

void gamepad_save_state(ctlr_state*);
void gamepad_load_state(const ctlr_state*);

void gamepad_init();
bool gamepad_button_sel();
bool gamepad_dir_sel();
void gamepad_set_sel(u8 value);
void gamepad_int_update();

gamepad_state *gamepad_get_state();
u8 gamepad_get_output();