joeylib2/include/joey/input.h

47 lines
1.3 KiB
C

// Keyboard input polling.
//
// Call joeyInputPoll() once per frame (typically right before
// drawing) to refresh the keyboard state. After polling, the
// joeyKey* predicates return the current state of every key:
//
// joeyKeyDown(k) -- is key k held down right now
// joeyKeyPressed(k) -- rising edge since the previous poll
// joeyKeyReleased(k) -- falling edge since the previous poll
//
// Edge predicates are one-shot: they return true only in the
// frame the transition occurred and false thereafter.
#ifndef JOEYLIB_INPUT_H
#define JOEYLIB_INPUT_H
#include "platform.h"
#include "types.h"
typedef enum {
KEY_NONE = 0,
KEY_A, KEY_B, KEY_C, KEY_D, KEY_E, KEY_F, KEY_G, KEY_H, KEY_I,
KEY_J, KEY_K, KEY_L, KEY_M, KEY_N, KEY_O, KEY_P, KEY_Q, KEY_R,
KEY_S, KEY_T, KEY_U, KEY_V, KEY_W, KEY_X, KEY_Y, KEY_Z,
KEY_0, KEY_1, KEY_2, KEY_3, KEY_4,
KEY_5, KEY_6, KEY_7, KEY_8, KEY_9,
KEY_SPACE, KEY_ESCAPE, KEY_RETURN, KEY_TAB, KEY_BACKSPACE,
KEY_UP, KEY_DOWN, KEY_LEFT, KEY_RIGHT,
KEY_LSHIFT, KEY_RSHIFT, KEY_LCTRL, KEY_LALT,
KEY_F1, KEY_F2, KEY_F3, KEY_F4, KEY_F5,
KEY_F6, KEY_F7, KEY_F8, KEY_F9, KEY_F10,
KEY_COUNT
} JoeyKeyE;
void joeyInputPoll(void);
bool joeyKeyDown(JoeyKeyE key);
bool joeyKeyPressed(JoeyKeyE key);
bool joeyKeyReleased(JoeyKeyE key);
#endif