Rev 3923 | Rev 3942 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 3923 | Rev 3933 | ||
---|---|---|---|
Line 55... | Line 55... | ||
55 | 55 | ||
56 | #define NAME "kbd" |
56 | #define NAME "kbd" |
57 | 57 | ||
58 | int cons_connected = 0; |
58 | int cons_connected = 0; |
59 | int phone2cons = -1; |
59 | int phone2cons = -1; |
60 | keybuffer_t keybuffer; |
60 | keybuffer_t keybuffer; |
- | 61 | ||
- | 62 | /** Currently active modifiers. */ |
|
- | 63 | static unsigned mods; |
|
61 | 64 | ||
62 | void kbd_push_scancode(int scancode) |
65 | void kbd_push_scancode(int scancode) |
63 | { |
66 | { |
64 | printf("scancode: 0x%x\n", scancode); |
67 | printf("scancode: 0x%x\n", scancode); |
65 | kbd_ctl_parse_scancode(scancode); |
68 | kbd_ctl_parse_scancode(scancode); |
66 | } |
69 | } |
67 | 70 | ||
68 | #include <kbd/keycode.h> |
71 | #include <kbd/keycode.h> |
69 | void kbd_push_ev(int type, unsigned int key, unsigned int mods) |
72 | void kbd_push_ev(int type, unsigned int key) |
70 | { |
73 | { |
71 | kbd_event_t ev; |
74 | kbd_event_t ev; |
- | 75 | unsigned mod_mask; |
|
- | 76 | ||
- | 77 | switch (key) { |
|
- | 78 | case KC_LCTRL: mod_mask = KM_LCTRL; break; |
|
- | 79 | case KC_RCTRL: mod_mask = KM_RCTRL; break; |
|
- | 80 | case KC_LSHIFT: mod_mask = KM_LSHIFT; break; |
|
- | 81 | case KC_RSHIFT: mod_mask = KM_RSHIFT; break; |
|
- | 82 | case KC_LALT: mod_mask = KM_LALT; break; |
|
- | 83 | case KC_RALT: mod_mask = KM_RALT; break; |
|
- | 84 | default: mod_mask = 0; break; |
|
- | 85 | } |
|
- | 86 | ||
- | 87 | if (mod_mask != 0) { |
|
- | 88 | if (type == KE_PRESS) |
|
- | 89 | mods = mods | mod_mask; |
|
- | 90 | else |
|
- | 91 | mods = mods & ~mod_mask; |
|
- | 92 | } |
|
- | 93 | ||
- | 94 | switch (key) { |
|
- | 95 | case KC_CAPS_LOCK: mod_mask = KM_CAPS_LOCK; break; |
|
- | 96 | case KC_NUM_LOCK: mod_mask = KM_NUM_LOCK; break; |
|
- | 97 | case KC_SCROLL_LOCK: mod_mask = KM_SCROLL_LOCK; break; |
|
- | 98 | default: mod_mask = 0; break; |
|
- | 99 | } |
|
- | 100 | ||
- | 101 | if (mod_mask != 0 && type == KE_PRESS) |
|
- | 102 | mods = mods ^ mod_mask; |
|
72 | 103 | ||
73 | printf("type: %d\n", type); |
104 | printf("type: %d\n", type); |
74 | printf("mods: 0x%x\n", mods); |
105 | printf("mods: 0x%x\n", mods); |
75 | printf("keycode: %u\n", key); |
106 | printf("keycode: %u\n", key); |
76 | 107 | ||
Line 81... | Line 112... | ||
81 | ev.c = layout_parse_ev(&ev); |
112 | ev.c = layout_parse_ev(&ev); |
82 | 113 | ||
83 | async_msg_4(phone2cons, KBD_EVENT, ev.type, ev.key, ev.mods, ev.c); |
114 | async_msg_4(phone2cons, KBD_EVENT, ev.type, ev.key, ev.mods, ev.c); |
84 | } |
115 | } |
85 | 116 | ||
86 | //static void irq_handler(ipc_callid_t iid, ipc_call_t *call) |
- | |
87 | //{ |
- | |
88 | // kbd_event_t ev; |
- | |
89 | // |
- | |
90 | // kbd_arch_process(&keybuffer, call); |
- | |
91 | // |
- | |
92 | // if (cons_connected && phone2cons != -1) { |
- | |
93 | // /* |
- | |
94 | // * One interrupt can produce more than one event so the result |
- | |
95 | // * is stored in a FIFO. |
- | |
96 | // */ |
- | |
97 | // while (!keybuffer_empty(&keybuffer)) { |
- | |
98 | // if (!keybuffer_pop(&keybuffer, &ev)) |
- | |
99 | // break; |
- | |
100 | // |
- | |
101 | // async_msg_4(phone2cons, KBD_EVENT, ev.type, ev.key, |
- | |
102 | // ev.mods, ev.c); |
- | |
103 | // } |
- | |
104 | // } |
- | |
105 | //} |
- | |
106 | - | ||
107 | static void console_connection(ipc_callid_t iid, ipc_call_t *icall) |
117 | static void console_connection(ipc_callid_t iid, ipc_call_t *icall) |
108 | { |
118 | { |
109 | ipc_callid_t callid; |
119 | ipc_callid_t callid; |
110 | ipc_call_t call; |
120 | ipc_call_t call; |
111 | int retval; |
121 | int retval; |
Line 140... | Line 150... | ||
140 | ipc_answer_0(callid, retval); |
150 | ipc_answer_0(callid, retval); |
141 | } |
151 | } |
142 | } |
152 | } |
143 | 153 | ||
144 | 154 | ||
145 | - | ||
146 | int main(int argc, char **argv) |
155 | int main(int argc, char **argv) |
147 | { |
156 | { |
148 | printf(NAME ": HelenOS Keyboard service\n"); |
157 | printf(NAME ": HelenOS Keyboard service\n"); |
149 | 158 | ||
150 | ipcarg_t phonead; |
159 | ipcarg_t phonead; |