From 5a54774474f43ae29716751d6415563a59b92c7d Mon Sep 17 00:00:00 2001 From: pk33 Date: Mon, 11 Nov 2024 18:06:18 +0100 Subject: tidying up and basic input --- include/input33.h | 63 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 include/input33.h (limited to 'include/input33.h') diff --git a/include/input33.h b/include/input33.h new file mode 100644 index 0000000..e0d7df0 --- /dev/null +++ b/include/input33.h @@ -0,0 +1,63 @@ +#ifndef __INPUT_H__ +#define __INPUT_H__ + + +#include "linux/input.h" + +#include "types33.h" + + +//#define MAX_INPUT_EVENTS 32 +//#define INPUT_BUFFLEN 32 + +#define _KBBUFF_LEN 32 /* must be ^2 */ +#define _MAX_DEVS 8 + +//#define KEYBOARD 0x01 +//#define MOUSE 0x02 + +#define _RELEASE 0x00 +#define _PRESS 0x01 +#define _REPEAT 0x02 + +#define _SCROLLL 0x01 +#define _NUML 0x02 +#define _CAPSL 0x04 +/* TODO move these */ +#define _CAN_CAPSL 0x0B + + +#define KEYDOWN(K) (__input.keyStates[K] >= _PRESS) +#define KEYUP(K) (__input.keyStates[K] == _RELEASE) +#define KEYREP(K) (__input.keyStates[K] == _REPEAT) +#define MOUSE1 (__input.keyStates[BTN_LEFT] == 1) +#define MOUSE2 (__input.keyStates[BTN_RIGHT] == 1) +#define MOUSE3 (__input.keyStates[BTN_MIDDLE] == 1) +#define MOUSEX (__input.relStates[REL_X]) +#define MOUSEY (__input.relStates[REL_Y]) +#define SCROLLW (__input.relStates[REL_WHEEL]) + + +typedef struct { + int devices[ _MAX_DEVS ]; + Size deviceCount; + + Bitfield cnsFlags; /* [0x7] :: Caps Num Scrl */ + Bitfield modFlags; /* [0x1FF] :: CS AR AL SR SL A C AGr S */ + + int keyStates[ KEY_MAX ]; + int relStates[ REL_MAX ]; + + __u16 buffer[ _KBBUFF_LEN ]; + Size head, tail; +} Input33; + +extern Input33 __input; + + +Error input33_init( void ); +void input33_poll( void ); +void input33_term( void ); + + +#endif /** __INPUT_H__ **/ -- cgit v1.2.3