~pmdj/ubuntu/trusty/qemu/2.9+applesmc+fadtv3

« back to all changes in this revision

Viewing changes to roms/openhackware/src/dev/char/kbd.h

  • Committer: Phil Dennis-Jordan
  • Date: 2017-07-21 08:03:43 UTC
  • mfrom: (1.1.1)
  • Revision ID: phil@philjordan.eu-20170721080343-2yr2vdj7713czahv
New upstream release 2.9.0.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
20
 */
 
21
 
 
22
#if !defined (__OHW_KBD_H__)
 
23
#define __OHW_KBD_H__
 
24
 
 
25
typedef struct kbd_t kbd_t;
 
26
typedef struct keymap_t keymap_t;
 
27
struct kbd_t {
 
28
    uint32_t mod_state;
 
29
    /* Modifier state              
 
30
     *                0x00 kk ll rr
 
31
     *                   |  |  |  |
 
32
     * Not used for now -+  |  |  |
 
33
     * Locks ---------------+  |  |
 
34
     * Left modifiers ---------+  |
 
35
     * Right modifiers -----------+
 
36
     */
 
37
    int nb_keys;
 
38
    keymap_t *keymap;
 
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
};
 
71
 
 
72
#define KBD_MOD_MAP(mod) \
 
73
KBD_SH_NONE, { (mod), (mod), (mod), (mod), (mod), (mod), (mod), (mod), \
 
74
               (mod), (mod), (mod), (mod), (mod), (mod), (mod), (mod), \
 
75
               (mod), (mod), (mod), (mod), (mod), (mod), (mod), (mod), \
 
76
               (mod), (mod), (mod), (mod), (mod), (mod), (mod), (mod), }
 
77
#define KBD_MOD_MAP_LSHIFT KBD_MOD_MAP(KBD_TYPE_LMOD | KBD_MOD_SHIFT)
 
78
#define KBD_MOD_MAP_RSHIFT KBD_MOD_MAP(KBD_TYPE_RMOD | (KBD_MOD_SHIFT << 8))
 
79
#define KBD_MOD_MAP_LCTRL  KBD_MOD_MAP(KBD_TYPE_LMOD | KBD_MOD_CTRL)
 
80
#define KBD_MOD_MAP_RCTRL  KBD_MOD_MAP(KBD_TYPE_RMOD | (KBD_MOD_CTRL << 8))
 
81
#define KBD_MOD_MAP_LALT   KBD_MOD_MAP(KBD_TYPE_LMOD | KBD_MOD_ALT)
 
82
#define KBD_MOD_MAP_RALT   KBD_MOD_MAP(KBD_TYPE_RMOD | (KBD_MOD_ALT << 8))
 
83
#define KBD_MOD_MAP_LCMD   KBD_MOD_MAP(KBD_TYPE_LMOD | KBD_MOD_CMD)
 
84
#define KBD_MOD_MAP_RCMD   KBD_MOD_MAP(KBD_TYPE_RMOD | (KBD_MOD_CMD << 8))
 
85
#define KBD_MOD_MAP_LOPT   KBD_MOD_MAP(KBD_TYPE_LMOD | KBD_MOD_OPT)
 
86
#define KBD_MOD_MAP_ROPT   KBD_MOD_MAP(KBD_TYPE_RMOD | (KBD_MOD_OPT << 8))
 
87
#define KBD_MOD_MAP_CAPS   KBD_MOD_MAP(KBD_TYPE_LOCK | (KBD_LCK_CAPS << 16))
 
88
#define KBD_MOD_MAP_NUML   KBD_MOD_MAP(KBD_TYPE_LOCK | (KBD_LCK_NUML << 16))
 
89
#define KBD_MOD_MAP_SCROLL KBD_MOD_MAP(KBD_TYPE_LOCK | (KBD_LCK_SCRL << 16))
 
90
#define KBD_MAP_NONE KBD_MOD_MAP(-1)
 
91
 
 
92
/* Keymap definition */
 
93
struct keymap_t {
 
94
    /* Set the lock which applies to this key (if any) */
 
95
    int lck_shift;
 
96
    /* Key translations */
 
97
    uint32_t trans[32];
 
98
};
 
99
 
 
100
void *kbd_new (int len);
 
101
int kbd_set_keymap (kbd_t *kbd, int nb_keys, keymap_t *keymap);
 
102
int kbd_translate_key (kbd_t *kbd, int keycode, int up_down);
 
103
 
 
104
#endif /* !defined (__OHW_KBD_H__) */