#ifndef KEYS_H
#define KEYS_H

#include <cpctelera.h>

// Control flags used for control detection.
#define CONTROL_UP_FLAG 1
#define CONTROL_DOWN_FLAG 2
#define CONTROL_LEFT_FLAG 4
#define CONTROL_RIGHT_FLAG 8
#define CONTROL_USE_FLAG 16
#define CONTROL_SHOOT_FLAG 32
#define CONTROL_JUMP_FLAG 64
#define CONTROL_EXIT_FLAG 128

typedef struct Keys Keys;

// Defines the controls used in the game.
struct Keys
{
    // Key values for setting custom controls.
    cpct_keyID up;
    cpct_keyID down;
    cpct_keyID left;
    cpct_keyID right;
    cpct_keyID use;
    cpct_keyID shoot;
    cpct_keyID jump;
    cpct_keyID exit;

    // Flags indicating what controls are down.
    u8 controlFlags;
};

// Player selected controls for movement and actions.
extern Keys gameControls;

// Initialises key values to ensure that no keys are currently pressed at the start of the game.
void initKeys();

// Sets the default player controls for the game (if the user does not customise the controls).
void setDefaultKeys();

// Updat the controls flags based on the keys that are currently down.
void readGameControls();

#endif