aboutsummaryrefslogtreecommitdiff
path: root/src/keyboard.h
blob: 755bae2c13d7db0d15eed50b07a045bc308d67c4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#ifndef IMV_KEYBOARD_H
#define IMV_KEYBOARD_H

#include <stdbool.h>
#include <unistd.h>

struct imv_keyboard;

/* Create a keyboard instance */
struct imv_keyboard *imv_keyboard_create(void);

/* Clean up a keyboard */
void imv_keyboard_free(struct imv_keyboard *keyboard);

/* Notify the keyboard of the state of a key */
void imv_keyboard_update_key(struct imv_keyboard *keyboard, int scancode, bool pressed);

/* Write the null-terminated name of the key corresponding to scancode into buf */
size_t imv_keyboard_keyname(struct imv_keyboard *keyboard, int scancode, char *buf, size_t buflen);

/* Describe the key corresponding to scancode, with modifier keys prefixed */
char *imv_keyboard_describe_key(struct imv_keyboard *keyboard, int scancode);

/* Write the null-terminated text generated by scancode being pressed into buf */
size_t imv_keyboard_get_text(struct imv_keyboard *keyboard, int scancode, char *buf, size_t buflen);

#endif