|
|
1.1 root 1: /*
2: * <kbd.h>
3: *
4: * Open Hack'Ware BIOS generic keyboard management definitions.
5: *
6: * Copyright (c) 2005 Jocelyn Mayer
7: *
8: * This program is free software; you can redistribute it and/or
9: * modify it under the terms of the GNU General Public License V2
10: * as published by the Free Software Foundation
11: *
12: * This program is distributed in the hope that it will be useful,
13: * but WITHOUT ANY WARRANTY; without even the implied warranty of
14: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15: * GNU General Public License for more details.
16: *
17: * You should have received a copy of the GNU General Public License
18: * along with this program; if not, write to the Free Software
19: * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA, 02110-1301 USA
20: */
21:
22: #if !defined (__OHW_KBD_H__)
23: #define __OHW_KBD_H__
24: typedef struct kbd_t kbd_t;
25: typedef struct keymap_t keymap_t;
26: struct kbd_t {
27: uint32_t mod_state;
28: /* Modifier state
29: * 0x00 kk ll rr
30: * | | | |
31: * Not used for now -+ | | |
32: * Locks ---------------+ | |
33: * Left modifiers ---------+ |
34: * Right modifiers -----------+
35: */
36: int nb_keys;
37: const keymap_t *keymap;
38: const char **sequences;
39: };
40:
41: /* Modifiers */
42: typedef enum {
43: KBD_MOD_SHIFT = 0x01,
44: KBD_MOD_CTRL = 0x02,
45: KBD_MOD_ALT = 0x04,
46: KBD_MOD_CMD = 0x08,
47: KBD_MOD_OPT = 0x10,
48: } kbd_modifiers;
49:
50: /* Locks */
51: typedef enum {
52: KBD_LCK_CAPS = 0x01,
53: KBD_LCK_NUM = 0x02,
54: KBD_LCK_SCROLL = 0x04,
55: } kbd_locks;
56:
57: /* Lock shifts */
58: typedef enum {
59: KBD_SH_NONE = -1,
60: KBD_SH_CAPS = 0,
61: KBD_SH_NUML = 1,
62: KBD_SH_SCRL = 2,
63: } kbd_lck_shifts;
64:
65: enum {
66: KBD_TYPE_REGULAR = 0 << 24,
67: KBD_TYPE_LMOD = 1 << 24,
68: KBD_TYPE_RMOD = 2 << 24,
69: KBD_TYPE_LOCK = 3 << 24,
70: KBD_TYPE_SEQUENCE = 4 << 24,
71: };
72:
73: #define KBD_SEQUENCE(sequence) (KBD_TYPE_SEQUENCE | (sequence))
74:
75: #define KBD_MOD_MAP(mod) \
76: KBD_SH_NONE, { (mod), (mod), (mod), (mod), (mod), (mod), (mod), (mod), \
77: (mod), (mod), (mod), (mod), (mod), (mod), (mod), (mod), \
78: (mod), (mod), (mod), (mod), (mod), (mod), (mod), (mod), \
79: (mod), (mod), (mod), (mod), (mod), (mod), (mod), (mod), }
80: #define KBD_MOD_MAP_LSHIFT KBD_MOD_MAP(KBD_TYPE_LMOD | KBD_MOD_SHIFT)
81: #define KBD_MOD_MAP_RSHIFT KBD_MOD_MAP(KBD_TYPE_RMOD | (KBD_MOD_SHIFT << 8))
82: #define KBD_MOD_MAP_LCTRL KBD_MOD_MAP(KBD_TYPE_LMOD | KBD_MOD_CTRL)
83: #define KBD_MOD_MAP_RCTRL KBD_MOD_MAP(KBD_TYPE_RMOD | (KBD_MOD_CTRL << 8))
84: #define KBD_MOD_MAP_LALT KBD_MOD_MAP(KBD_TYPE_LMOD | KBD_MOD_ALT)
85: #define KBD_MOD_MAP_RALT KBD_MOD_MAP(KBD_TYPE_RMOD | (KBD_MOD_ALT << 8))
86: #define KBD_MOD_MAP_LCMD KBD_MOD_MAP(KBD_TYPE_LMOD | KBD_MOD_CMD)
87: #define KBD_MOD_MAP_RCMD KBD_MOD_MAP(KBD_TYPE_RMOD | (KBD_MOD_CMD << 8))
88: #define KBD_MOD_MAP_LOPT KBD_MOD_MAP(KBD_TYPE_LMOD | KBD_MOD_OPT)
89: #define KBD_MOD_MAP_ROPT KBD_MOD_MAP(KBD_TYPE_RMOD | (KBD_MOD_OPT << 8))
90: #define KBD_MOD_MAP_CAPS KBD_MOD_MAP(KBD_TYPE_LOCK | (KBD_LCK_CAPS << 16))
91: #define KBD_MOD_MAP_NUML KBD_MOD_MAP(KBD_TYPE_LOCK | (KBD_LCK_NUML << 16))
92: #define KBD_MOD_MAP_SCROLL KBD_MOD_MAP(KBD_TYPE_LOCK | (KBD_LCK_SCRL << 16))
93: #define KBD_MAP_NONE KBD_MOD_MAP(-1)
94:
95: /* Keymap definition */
96: struct keymap_t {
97: /* Set the lock which applies to this key (if any) */
98: int lck_shift;
99: /* Key translations */
100: uint32_t trans[32];
101: };
102:
103: void *kbd_new (int len);
104: int kbd_set_keymap (kbd_t *kbd, int nb_keys, const keymap_t *keymap,
105: const char **sequences);
106: int kbd_translate_key (kbd_t *kbd, int keycode, int up_down, char *sequence);
107:
108: #endif /* !defined (__OHW_KBD_H__) */
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.