* Its use should be as simple as the following (but also see below):
* - Create a new input object.
* - Provide a callback function to receive the events.
- * - Connect the input object to a kmscon_eloop.
+ * - Connect the input object to a ev_eloop.
* - Wake up the input object to begin receiving input events through the
* event loop.
*
#define KMSCON_INPUT_H
#include <inttypes.h>
+#include <limits.h>
#include <stdbool.h>
#include "eloop.h"
struct kmscon_input;
+enum kmscon_modifier {
+ KMSCON_SHIFT_MASK = (1 << 0),
+ KMSCON_LOCK_MASK = (1 << 1),
+ KMSCON_CONTROL_MASK = (1 << 2),
+ KMSCON_MOD1_MASK = (1 << 3),
+ KMSCON_MOD2_MASK = (1 << 4),
+ KMSCON_MOD3_MASK = (1 << 5),
+ KMSCON_MOD4_MASK = (1 << 6),
+ KMSCON_MOD5_MASK = (1 << 7),
+};
+
#define KMSCON_INPUT_INVALID 0xffffffff
struct kmscon_input_event {
uint16_t keycode; /* linux keycode - KEY_* - linux/input.h */
uint32_t keysym; /* X keysym - XK_* - X11/keysym.h */
- uint8_t modifiers; /* xkbcommon modifiers - XKB_COMMON_*_MASK */
+ unsigned int mods; /* active modifiers - kmscon_modifier mask */
uint32_t unicode; /* UCS-4 unicode value or KMSCON_INPUT_INVALID */
};
typedef void (*kmscon_input_cb) (struct kmscon_input *input,
struct kmscon_input_event *ev, void *data);
-/*
- * These are the values sent by the kernel in the /value/ field of the
- * /input_event/ struct.
- * See Documentation/input/event-codes.txt in the kernel tree.
- */
-enum kmscon_key_state {
- KMSCON_KEY_RELEASED = 0,
- KMSCON_KEY_PRESSED = 1,
- KMSCON_KEY_REPEATED = 2,
-};
-
int kmscon_input_new(struct kmscon_input **out);
void kmscon_input_ref(struct kmscon_input *input);
void kmscon_input_unref(struct kmscon_input *input);
int kmscon_input_connect_eloop(struct kmscon_input *input,
- struct kmscon_eloop *eloop, kmscon_input_cb cb, void *data);
+ struct ev_eloop *eloop, kmscon_input_cb cb, void *data);
void kmscon_input_disconnect_eloop(struct kmscon_input *input);
void kmscon_input_sleep(struct kmscon_input *input);
void kmscon_input_wake_up(struct kmscon_input *input);
bool kmscon_input_is_asleep(struct kmscon_input *input);
+/* Querying the results of evdev ioctl's. Also used by kbd backends. */
+static inline bool kmscon_evdev_bit_is_set(const unsigned long *array, int bit)
+{
+ return !!(array[bit / LONG_BIT] & (1LL << (bit % LONG_BIT)));
+}
+
#endif /* KMSCON_INPUT_H */