36 |
static uint8 keymap[KEYMAP_SIZE]; |
static uint8 keymap[KEYMAP_SIZE]; |
37 |
static unsigned int min_keycode; |
static unsigned int min_keycode; |
38 |
|
|
39 |
static BOOL xkeymap_read(char *mapname) |
static BOOL |
40 |
|
xkeymap_read(char *mapname) |
41 |
{ |
{ |
42 |
FILE *fp; |
FILE *fp; |
43 |
char line[PATH_MAX], path[PATH_MAX]; |
char line[PATH_MAX], path[PATH_MAX]; |
73 |
|
|
74 |
keysym = XStringToKeysym(keyname); |
keysym = XStringToKeysym(keyname); |
75 |
if (keysym == NoSymbol) |
if (keysym == NoSymbol) |
76 |
error("Bad keysym %s in keymap %s\n", keyname, mapname); |
error("Bad keysym %s in keymap %s\n", |
77 |
|
keyname, mapname); |
78 |
|
|
79 |
keymap[keysym & KEYMAP_MASK] = keycode; |
keymap[keysym & KEYMAP_MASK] = keycode; |
80 |
keyname = p; |
keyname = p; |
81 |
|
|
82 |
} while (keyname != NULL); |
} |
83 |
|
while (keyname != NULL); |
84 |
} |
} |
85 |
else if (strncmp(line, "include ", 8) == 0) |
else if (strncmp(line, "include ", 8) == 0) |
86 |
{ |
{ |
87 |
if (!xkeymap_read(line+8)) |
if (!xkeymap_read(line + 8)) |
88 |
return False; |
return False; |
89 |
} |
} |
90 |
else if (strncmp(line, "map ", 4) == 0) |
else if (strncmp(line, "map ", 4) == 0) |
91 |
{ |
{ |
92 |
keylayout = strtol(line+4, NULL, 16); |
keylayout = strtol(line + 4, NULL, 16); |
93 |
} |
} |
94 |
else if (line[0] != '#') |
else if (line[0] != '#') |
95 |
{ |
{ |
101 |
return True; |
return True; |
102 |
} |
} |
103 |
|
|
104 |
void xkeymap_init(void) |
void |
105 |
|
xkeymap_init(void) |
106 |
{ |
{ |
107 |
unsigned int max_keycode; |
unsigned int max_keycode; |
108 |
|
|
112 |
xkeymap_read(keymapname); |
xkeymap_read(keymapname); |
113 |
} |
} |
114 |
|
|
115 |
uint8 xkeymap_translate_key(unsigned int keysym, unsigned int keycode, uint16 *flags) |
uint8 |
116 |
|
xkeymap_translate_key(unsigned int keysym, unsigned int keycode, |
117 |
|
uint16 * flags) |
118 |
{ |
{ |
119 |
uint8 scancode; |
uint8 scancode; |
120 |
|
|
130 |
/* not in keymap, try to interpret the raw scancode */ |
/* not in keymap, try to interpret the raw scancode */ |
131 |
|
|
132 |
if ((keycode >= min_keycode) && (keycode <= 0x60)) |
if ((keycode >= min_keycode) && (keycode <= 0x60)) |
133 |
return (uint8)(keycode - min_keycode); |
return (uint8) (keycode - min_keycode); |
134 |
|
|
135 |
*flags |= KBD_FLAG_EXT; |
*flags |= KBD_FLAG_EXT; |
136 |
|
|
179 |
return 0; |
return 0; |
180 |
} |
} |
181 |
|
|
182 |
uint16 xkeymap_translate_button(unsigned int button) |
uint16 |
183 |
|
xkeymap_translate_button(unsigned int button) |
184 |
{ |
{ |
185 |
switch (button) |
switch (button) |
186 |
{ |
{ |
187 |
case Button1: /* left */ |
case Button1: /* left */ |
188 |
return MOUSE_FLAG_BUTTON1; |
return MOUSE_FLAG_BUTTON1; |
189 |
case Button2: /* middle */ |
case Button2: /* middle */ |
190 |
return MOUSE_FLAG_BUTTON3; |
return MOUSE_FLAG_BUTTON3; |
191 |
case Button3: /* right */ |
case Button3: /* right */ |
192 |
return MOUSE_FLAG_BUTTON2; |
return MOUSE_FLAG_BUTTON2; |
193 |
case Button4: /* wheel up */ |
case Button4: /* wheel up */ |
194 |
return MOUSE_FLAG_BUTTON4; |
return MOUSE_FLAG_BUTTON4; |
195 |
case Button5: /* wheel down */ |
case Button5: /* wheel down */ |
196 |
return MOUSE_FLAG_BUTTON5; |
return MOUSE_FLAG_BUTTON5; |
197 |
} |
} |
198 |
|
|