73 lines
2.9 KiB
C
73 lines
2.9 KiB
C
/*
|
|
* FnixLib - estado del teclado y del ratón.
|
|
*
|
|
* Las consultas se refieren al estado tras el último fnix_begin_frame():
|
|
* - down: la tecla/botón está mantenida ahora mismo.
|
|
* - pressed: pasó de suelta a pulsada en este fotograma (el autorepeat del
|
|
* teclado NO la vuelve a activar).
|
|
* - released: pasó de pulsada a suelta en este fotograma. También se activa
|
|
* para todo lo que estaba pulsado cuando la ventana pierde el foco.
|
|
*
|
|
* Las teclas se identifican por el símbolo que produce cada una SIN modificadores
|
|
* en la distribución de teclado activa: con una distribución no QWERTY, la tecla
|
|
* física que antes era "A" puede cambiar de identificador.
|
|
*
|
|
* Todas las funciones aceptan window == NULL o valores inválidos y devuelven 0/false.
|
|
*/
|
|
#ifndef FNIX_INPUT_H
|
|
#define FNIX_INPUT_H
|
|
|
|
#include "fnix/types.h"
|
|
|
|
FNIX_BEGIN_DECLS
|
|
|
|
typedef enum FnixKey {
|
|
FNIX_KEY_UNKNOWN = 0,
|
|
/* Las letras, los dígitos y F1..F12 son contiguos: no reordenar. */
|
|
FNIX_KEY_A, FNIX_KEY_B, FNIX_KEY_C, FNIX_KEY_D, FNIX_KEY_E, FNIX_KEY_F,
|
|
FNIX_KEY_G, FNIX_KEY_H, FNIX_KEY_I, FNIX_KEY_J, FNIX_KEY_K, FNIX_KEY_L,
|
|
FNIX_KEY_M, FNIX_KEY_N, FNIX_KEY_O, FNIX_KEY_P, FNIX_KEY_Q, FNIX_KEY_R,
|
|
FNIX_KEY_S, FNIX_KEY_T, FNIX_KEY_U, FNIX_KEY_V, FNIX_KEY_W, FNIX_KEY_X,
|
|
FNIX_KEY_Y, FNIX_KEY_Z,
|
|
FNIX_KEY_0, FNIX_KEY_1, FNIX_KEY_2, FNIX_KEY_3, FNIX_KEY_4,
|
|
FNIX_KEY_5, FNIX_KEY_6, FNIX_KEY_7, FNIX_KEY_8, FNIX_KEY_9,
|
|
FNIX_KEY_F1, FNIX_KEY_F2, FNIX_KEY_F3, FNIX_KEY_F4, FNIX_KEY_F5,
|
|
FNIX_KEY_F6, FNIX_KEY_F7, FNIX_KEY_F8, FNIX_KEY_F9, FNIX_KEY_F10,
|
|
FNIX_KEY_F11, FNIX_KEY_F12,
|
|
FNIX_KEY_SPACE, FNIX_KEY_ENTER, FNIX_KEY_ESCAPE, FNIX_KEY_TAB,
|
|
FNIX_KEY_BACKSPACE,
|
|
FNIX_KEY_LEFT, FNIX_KEY_RIGHT, FNIX_KEY_UP, FNIX_KEY_DOWN,
|
|
FNIX_KEY_LEFT_SHIFT, FNIX_KEY_RIGHT_SHIFT,
|
|
FNIX_KEY_LEFT_CTRL, FNIX_KEY_RIGHT_CTRL,
|
|
FNIX_KEY_LEFT_ALT, FNIX_KEY_RIGHT_ALT,
|
|
FNIX_KEY_COUNT
|
|
} FnixKey;
|
|
|
|
typedef enum FnixMouseButton {
|
|
FNIX_MOUSE_LEFT = 0,
|
|
FNIX_MOUSE_MIDDLE,
|
|
FNIX_MOUSE_RIGHT,
|
|
FNIX_MOUSE_BUTTON_COUNT
|
|
} FnixMouseButton;
|
|
|
|
bool fnix_key_down(const FnixWindow *window, FnixKey key);
|
|
bool fnix_key_pressed(const FnixWindow *window, FnixKey key);
|
|
bool fnix_key_released(const FnixWindow *window, FnixKey key);
|
|
|
|
bool fnix_mouse_down(const FnixWindow *window, FnixMouseButton button);
|
|
bool fnix_mouse_pressed(const FnixWindow *window, FnixMouseButton button);
|
|
bool fnix_mouse_released(const FnixWindow *window, FnixMouseButton button);
|
|
|
|
/* Posición del cursor en píxeles de la ventana (origen arriba a la izquierda).
|
|
* Puede quedar fuera de la ventana mientras se arrastra con un botón pulsado. */
|
|
int fnix_mouse_x(const FnixWindow *window);
|
|
int fnix_mouse_y(const FnixWindow *window);
|
|
|
|
/* Desplazamiento de la rueda acumulado en este fotograma: positivo hacia
|
|
* arriba (alejándose del usuario), negativo hacia abajo. */
|
|
int fnix_mouse_wheel(const FnixWindow *window);
|
|
|
|
FNIX_END_DECLS
|
|
|
|
#endif /* FNIX_INPUT_H */
|