aboutsummaryrefslogtreecommitdiff
path: root/include/input33.h
diff options
context:
space:
mode:
authorpk33 <pk33@pk33.space>2024-11-11 18:06:18 +0100
committerpk33 <pk33@pk33.space>2024-11-11 18:06:18 +0100
commit5a54774474f43ae29716751d6415563a59b92c7d (patch)
tree151e865845b09b85992d8be20d8cc771d4110448 /include/input33.h
parent146a683b8d8315ef15dc1c9286f0983834f48d88 (diff)
downloadengine33-5a54774474f43ae29716751d6415563a59b92c7d.tar.gz
tidying up and basic input
Diffstat (limited to 'include/input33.h')
-rw-r--r--include/input33.h63
1 files changed, 63 insertions, 0 deletions
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__ **/