/trunk/uspace/srv/kbd/include/layout.h |
---|
40,8 → 40,14 |
#include <kbd/kbd.h> |
#include <sys/types.h> |
extern wchar_t layout_parse_ev(kbd_event_t *); |
typedef struct { |
wchar_t (*parse_ev)(kbd_event_t *); |
} layout_op_t; |
extern layout_op_t us_qwerty_op; |
extern layout_op_t us_dvorak_op; |
extern layout_op_t cz_op; |
#endif |
/** |
/trunk/uspace/srv/kbd/generic/kbd.c |
---|
70,6 → 70,16 |
int cir_service = 0; |
int cir_phone = -1; |
#define NUM_LAYOUTS 3 |
static layout_op_t *layout[NUM_LAYOUTS] = { |
&us_qwerty_op, |
&us_dvorak_op, |
&cz_op |
}; |
static int active_layout = 0; |
void kbd_push_scancode(int scancode) |
{ |
/* printf("scancode: 0x%x\n", scancode);*/ |
123,11 → 133,29 |
printf("mods: 0x%x\n", mods); |
printf("keycode: %u\n", key); |
*/ |
if (type == KE_PRESS && (mods & KM_LCTRL) && |
key == KC_F1) { |
active_layout = 0; |
return; |
} |
if (type == KE_PRESS && (mods & KM_LCTRL) && |
key == KC_F2) { |
active_layout = 1; |
return; |
} |
if (type == KE_PRESS && (mods & KM_LCTRL) && |
key == KC_F3) { |
active_layout = 2; |
return; |
} |
ev.type = type; |
ev.key = key; |
ev.mods = mods; |
ev.c = layout_parse_ev(&ev); |
ev.c = layout[active_layout]->parse_ev(&ev); |
async_msg_4(phone2cons, KBD_EVENT, ev.type, ev.key, ev.mods, ev.c); |
} |
/trunk/uspace/srv/kbd/Makefile |
---|
49,18 → 49,11 |
generic/key_buffer.c |
ARCH_SOURCES = |
GENARCH_SOURCES = |
GENARCH_SOURCES = \ |
layout/cz.c \ |
layout/us_qwerty.c \ |
layout/us_dvorak.c |
ifeq ($(KBD_LAYOUT), cz) |
GENARCH_SOURCES += layout/cz.c |
endif |
ifeq ($(KBD_LAYOUT), us_qwerty) |
GENARCH_SOURCES += layout/us_qwerty.c |
endif |
ifeq ($(KBD_LAYOUT), us_dvorak) |
GENARCH_SOURCES += layout/us_dvorak.c |
endif |
ifeq ($(UARCH), amd64) |
GENARCH_SOURCES += \ |
port/i8042.c \ |
/trunk/uspace/srv/kbd/layout/us_qwerty.c |
---|
36,6 → 36,12 |
#include <kbd/keycode.h> |
#include <layout.h> |
static wchar_t layout_parse_ev(kbd_event_t *ev); |
layout_op_t us_qwerty_op = { |
layout_parse_ev |
}; |
static wchar_t map_lcase[] = { |
[KC_Q] = 'q', |
[KC_W] = 'w', |
191,7 → 197,7 |
return map[key]; |
} |
wchar_t layout_parse_ev(kbd_event_t *ev) |
static wchar_t layout_parse_ev(kbd_event_t *ev) |
{ |
wchar_t c; |
/trunk/uspace/srv/kbd/layout/cz.c |
---|
36,6 → 36,12 |
#include <kbd/keycode.h> |
#include <layout.h> |
static wchar_t layout_parse_ev(kbd_event_t *ev); |
layout_op_t cz_op = { |
layout_parse_ev |
}; |
static wchar_t map_lcase[] = { |
[KC_2] = L'ě', |
[KC_3] = L'š', |
201,7 → 207,7 |
return map[key]; |
} |
wchar_t layout_parse_ev(kbd_event_t *ev) |
static wchar_t layout_parse_ev(kbd_event_t *ev) |
{ |
wchar_t c; |
/trunk/uspace/srv/kbd/layout/us_dvorak.c |
---|
36,6 → 36,12 |
#include <kbd/keycode.h> |
#include <layout.h> |
static wchar_t layout_parse_ev(kbd_event_t *ev); |
layout_op_t us_dvorak_op = { |
layout_parse_ev |
}; |
static wchar_t map_lcase[] = { |
[KC_R] = 'p', |
[KC_T] = 'y', |
197,7 → 203,7 |
return map[key]; |
} |
wchar_t layout_parse_ev(kbd_event_t *ev) |
static wchar_t layout_parse_ev(kbd_event_t *ev) |
{ |
wchar_t c; |