#include "KControl.hpp" ➔ class KControl

KControl

KControl is a class that holds state of keyboard and mouse.

class KControl {
    struct {
        int x, y;
        bool l, m, r;
    } mouse;
    bool operator[](KKey::Id keyId)
};

Member

struct {
    int x, y;
    bool l, m, r;
} mouse;

A struct that holds mouse state.
x and y store the position of the mouse pointer.
l, m and r store which button is being pressed (left, middle or right).

Method

void update();

Fills the class with a snapshot of the keyboard and mouse state.

Operator

bool operator[](KKey::Id keyId)

Returns whether the specified key is being pressed or not.

Example

KControl control;
control.update();

std::cout << control.mouse.x << " - " << control.mouse.y << std::endl;

if (control[KKey::Escape]) {
    std::cout << "Escape key pressed." << std::endl;
}