/branches/tracing/uspace/srv/kbd/ctl/pl050.c |
---|
0,0 → 1,262 |
/* |
* Copyright (c) 2009 Vineeth Pillai |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms, with or without |
* modification, are permitted provided that the following conditions |
* are met: |
* |
* - Redistributions of source code must retain the above copyright |
* notice, this list of conditions and the following disclaimer. |
* - Redistributions in binary form must reproduce the above copyright |
* notice, this list of conditions and the following disclaimer in the |
* documentation and/or other materials provided with the distribution. |
* - The name of the author may not be used to endorse or promote products |
* derived from this software without specific prior written permission. |
* |
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
*/ |
/** @addtogroup kbd_ctl |
* @ingroup kbd |
* @{ |
*/ |
/** |
* @file |
* @brief PL050 keyboard controller driver. |
*/ |
#include <kbd.h> |
#include <io/console.h> |
#include <io/keycode.h> |
#include <kbd_ctl.h> |
#include <gsp.h> |
#include <stdio.h> |
#define PL050_CAPS_SCAN_CODE 0x58 |
#define PL050_NUM_SCAN_CODE 0x77 |
#define PL050_SCROLL_SCAN_CODE 0x7E |
static bool is_lock_key(int); |
enum dec_state { |
ds_s, |
ds_e |
}; |
static enum dec_state ds; |
static int scanmap_simple[] = { |
[0x0e] = KC_BACKTICK, |
[0x16] = KC_1, |
[0x1e] = KC_2, |
[0x26] = KC_3, |
[0x25] = KC_4, |
[0x2e] = KC_5, |
[0x36] = KC_6, |
[0x3d] = KC_7, |
[0x3e] = KC_8, |
[0x46] = KC_9, |
[0x45] = KC_0, |
[0x4e] = KC_MINUS, |
[0x55] = KC_EQUALS, |
[0x66] = KC_BACKSPACE, |
[0x0d] = KC_TAB, |
[0x15] = KC_Q, |
[0x1d] = KC_W, |
[0x24] = KC_E, |
[0x2d] = KC_R, |
[0x2c] = KC_T, |
[0x35] = KC_Y, |
[0x3c] = KC_U, |
[0x43] = KC_I, |
[0x44] = KC_O, |
[0x4d] = KC_P, |
[0x54] = KC_LBRACKET, |
[0x5b] = KC_RBRACKET, |
[0x58] = KC_CAPS_LOCK, |
[0x1c] = KC_A, |
[0x1b] = KC_S, |
[0x23] = KC_D, |
[0x2b] = KC_F, |
[0x34] = KC_G, |
[0x33] = KC_H, |
[0x3b] = KC_J, |
[0x42] = KC_K, |
[0x4b] = KC_L, |
[0x4c] = KC_SEMICOLON, |
[0x52] = KC_QUOTE, |
[0x5d] = KC_BACKSLASH, |
[0x12] = KC_LSHIFT, |
[0x1a] = KC_Z, |
[0x22] = KC_X, |
[0x21] = KC_C, |
[0x2a] = KC_V, |
[0x32] = KC_B, |
[0x31] = KC_N, |
[0x3a] = KC_M, |
[0x41] = KC_COMMA, |
[0x49] = KC_PERIOD, |
[0x4a] = KC_SLASH, |
[0x59] = KC_RSHIFT, |
[0x14] = KC_LCTRL, |
[0x11] = KC_LALT, |
[0x29] = KC_SPACE, |
[0x76] = KC_ESCAPE, |
[0x05] = KC_F1, |
[0x06] = KC_F2, |
[0x04] = KC_F3, |
[0x0c] = KC_F4, |
[0x03] = KC_F5, |
[0x0b] = KC_F6, |
[0x02] = KC_F7, |
[0x0a] = KC_F8, |
[0x01] = KC_F9, |
[0x09] = KC_F10, |
[0x78] = KC_F11, |
[0x07] = KC_F12, |
[0x60] = KC_SCROLL_LOCK, |
[0x5a] = KC_ENTER, |
[0x77] = KC_NUM_LOCK, |
[0x7c] = KC_NTIMES, |
[0x7b] = KC_NMINUS, |
[0x79] = KC_NPLUS, |
[0x6c] = KC_N7, |
[0x75] = KC_N8, |
[0x7d] = KC_N9, |
[0x6b] = KC_N4, |
[0x73] = KC_N5, |
[0x74] = KC_N6, |
[0x69] = KC_N1, |
[0x72] = KC_N2, |
[0x7a] = KC_N3, |
[0x70] = KC_N0, |
[0x71] = KC_NPERIOD |
}; |
static int scanmap_e0[] = { |
[0x65] = KC_RALT, |
[0x59] = KC_RSHIFT, |
[0x64] = KC_PRTSCR, |
[0x70] = KC_INSERT, |
[0x6c] = KC_HOME, |
[0x7d] = KC_PAGE_UP, |
[0x71] = KC_DELETE, |
[0x69] = KC_END, |
[0x7a] = KC_PAGE_DOWN, |
[0x75] = KC_UP, |
[0x6b] = KC_LEFT, |
[0x72] = KC_DOWN, |
[0x74] = KC_RIGHT, |
[0x4a] = KC_NSLASH, |
[0x5a] = KC_NENTER |
}; |
int kbd_ctl_init(void) |
{ |
ds = ds_s; |
return 0; |
} |
void kbd_ctl_parse_scancode(int scancode) |
{ |
static int key_release_flag = 0; |
static int is_locked = 0; |
console_ev_type_t type; |
unsigned int key; |
int *map; |
size_t map_length; |
if (scancode == 0xe0) { |
ds = ds_e; |
return; |
} |
switch (ds) { |
case ds_s: |
map = scanmap_simple; |
map_length = sizeof(scanmap_simple) / sizeof(int); |
break; |
case ds_e: |
map = scanmap_e0; |
map_length = sizeof(scanmap_e0) / sizeof(int); |
break; |
default: |
map = NULL; |
map_length = 0; |
} |
ds = ds_s; |
if (scancode == 0xf0) { |
key_release_flag = 1; |
return; |
} else { |
if (key_release_flag) { |
type = KEY_RELEASE; |
key_release_flag = 0; |
if (is_lock_key(scancode)) { |
if (!is_locked) { |
is_locked = 1; |
} else { |
is_locked = 0; |
return; |
} |
} |
} else { |
if (is_lock_key(scancode) && is_locked) |
return; |
type = KEY_PRESS; |
} |
} |
if (scancode < 0) |
return; |
key = map[scancode]; |
if (key != 0) |
kbd_push_ev(type, key); |
} |
static bool is_lock_key(int sc) |
{ |
return ((sc == PL050_CAPS_SCAN_CODE) || (sc == PL050_NUM_SCAN_CODE) || |
(sc == PL050_SCROLL_SCAN_CODE)); |
} |
/** |
* @} |
*/ |
/branches/tracing/uspace/srv/kbd/ctl/pc.c |
---|
32,12 → 32,12 |
*/ |
/** |
* @file |
* @brief PC keyboard controller driver. |
* @brief PC keyboard controller driver. |
*/ |
#include <kbd.h> |
#include <kbd/kbd.h> |
#include <kbd/keycode.h> |
#include <io/console.h> |
#include <io/keycode.h> |
#include <kbd_ctl.h> |
#include <gsp.h> |
188,7 → 188,7 |
void kbd_ctl_parse_scancode(int scancode) |
{ |
kbd_ev_type_t type; |
console_ev_type_t type; |
unsigned int key; |
int *map; |
size_t map_length; |
207,6 → 207,9 |
map = scanmap_e0; |
map_length = sizeof(scanmap_e0) / sizeof(int); |
break; |
default: |
map = NULL; |
map_length = 0; |
} |
ds = ds_s; |
213,12 → 216,12 |
if (scancode & 0x80) { |
scancode &= ~0x80; |
type = KE_RELEASE; |
type = KEY_RELEASE; |
} else { |
type = KE_PRESS; |
type = KEY_PRESS; |
} |
if (scancode < 0 || scancode >= map_length) |
if ((scancode < 0) || ((size_t) scancode >= map_length)) |
return; |
key = map[scancode]; |
/branches/tracing/uspace/srv/kbd/ctl/stty.c |
---|
36,8 → 36,7 |
*/ |
#include <kbd.h> |
#include <kbd/kbd.h> |
#include <kbd/keycode.h> |
#include <io/keycode.h> |
#include <kbd_ctl.h> |
#include <gsp.h> |
#include <stroke.h> |
/branches/tracing/uspace/srv/kbd/ctl/sun.c |
---|
36,8 → 36,8 |
*/ |
#include <kbd.h> |
#include <kbd/kbd.h> |
#include <kbd/keycode.h> |
#include <io/console.h> |
#include <io/keycode.h> |
#include <kbd_ctl.h> |
#define KBD_KEY_RELEASE 0x80 |
52,7 → 52,7 |
void kbd_ctl_parse_scancode(int scancode) |
{ |
kbd_ev_type_t type; |
console_ev_type_t type; |
unsigned int key; |
if (scancode < 0 || scancode >= 0x100) |
63,9 → 63,9 |
if (scancode & KBD_KEY_RELEASE) { |
scancode &= ~KBD_KEY_RELEASE; |
type = KE_RELEASE; |
type = KEY_RELEASE; |
} else { |
type = KE_PRESS; |
type = KEY_PRESS; |
} |
key = scanmap_simple[scancode]; |
/branches/tracing/uspace/srv/kbd/ctl/gxe_fb.c |
---|
36,8 → 36,8 |
*/ |
#include <kbd.h> |
#include <kbd/kbd.h> |
#include <kbd/keycode.h> |
#include <io/console.h> |
#include <io/keycode.h> |
#include <kbd_ctl.h> |
#include <gsp.h> |
#include <stroke.h> |
/branches/tracing/uspace/srv/kbd/include/key_buffer.h |
---|
File deleted |
/branches/tracing/uspace/srv/kbd/include/gsp.h |
---|
37,7 → 37,7 |
#ifndef KBD_GSP_H_ |
#define KBD_GSP_H_ |
#include <libadt/hash_table.h> |
#include <adt/hash_table.h> |
enum { |
GSP_END = -1, /**< Terminates a sequence. */ |
/branches/tracing/uspace/srv/kbd/include/layout.h |
---|
27,10 → 27,10 |
*/ |
/** @addtogroup kbdgen generic |
* @brief HelenOS generic uspace keyboard handler. |
* @ingroup kbd |
* @brief HelenOS generic uspace keyboard handler. |
* @ingroup kbd |
* @{ |
*/ |
*/ |
/** @file |
*/ |
37,12 → 37,12 |
#ifndef KBD_LAYOUT_H_ |
#define KBD_LAYOUT_H_ |
#include <kbd/kbd.h> |
#include <sys/types.h> |
#include <io/console.h> |
typedef struct { |
void (*reset)(void); |
wchar_t (*parse_ev)(kbd_event_t *); |
wchar_t (*parse_ev)(console_event_t *); |
} layout_op_t; |
extern layout_op_t us_qwerty_op; |
53,5 → 53,4 |
/** |
* @} |
*/ |
*/ |
/branches/tracing/uspace/srv/kbd/include/kbd.h |
---|
27,10 → 27,10 |
*/ |
/** @addtogroup kbdgen generic |
* @brief HelenOS generic uspace keyboard handler. |
* @ingroup kbd |
* @brief HelenOS generic uspace keyboard handler. |
* @ingroup kbd |
* @{ |
*/ |
*/ |
/** @file |
*/ |
37,17 → 37,17 |
#ifndef KBD_KBD_H_ |
#define KBD_KBD_H_ |
#include <key_buffer.h> |
#include <keybuffer.h> |
#include <ipc/ipc.h> |
#define KBD_EVENT 1024 |
#define KBD_MS_LEFT 1025 |
#define KBD_MS_RIGHT 1026 |
#define KBD_MS_MIDDLE 1027 |
#define KBD_MS_MOVE 1028 |
#define KBD_EVENT 1024 |
#define KBD_MS_LEFT 1025 |
#define KBD_MS_RIGHT 1026 |
#define KBD_MS_MIDDLE 1027 |
#define KBD_MS_MOVE 1028 |
typedef enum { |
KBD_YIELD = IPC_FIRST_USER_METHOD, |
KBD_YIELD = IPC_FIRST_USER_METHOD, |
KBD_RECLAIM |
} kbd_request_t; |
61,5 → 61,4 |
/** |
* @} |
*/ |
*/ |
/branches/tracing/uspace/srv/kbd/include/keybuffer.h |
---|
0,0 → 1,65 |
/* |
* Copyright (c) 2006 Josef Cejka |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms, with or without |
* modification, are permitted provided that the following conditions |
* are met: |
* |
* - Redistributions of source code must retain the above copyright |
* notice, this list of conditions and the following disclaimer. |
* - Redistributions in binary form must reproduce the above copyright |
* notice, this list of conditions and the following disclaimer in the |
* documentation and/or other materials provided with the distribution. |
* - The name of the author may not be used to endorse or promote products |
* derived from this software without specific prior written permission. |
* |
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
*/ |
/** @addtogroup kbdgen |
* @brief HelenOS generic uspace keyboard handler. |
* @ingroup kbd |
* @{ |
*/ |
/** @file |
*/ |
#ifndef __KEYBUFFER_H__ |
#define __KEYBUFFER_H__ |
#include <sys/types.h> |
#include <io/console.h> |
#include <bool.h> |
/** Size of buffer for pressed keys */ |
#define KEYBUFFER_SIZE 128 |
typedef struct { |
console_event_t fifo[KEYBUFFER_SIZE]; |
unsigned long head; |
unsigned long tail; |
unsigned long items; |
} keybuffer_t; |
extern void keybuffer_free(keybuffer_t *); |
extern void keybuffer_init(keybuffer_t *); |
extern size_t keybuffer_available(keybuffer_t *); |
extern bool keybuffer_empty(keybuffer_t *); |
extern void keybuffer_push(keybuffer_t *, const console_event_t *); |
extern bool keybuffer_pop(keybuffer_t *, console_event_t *); |
#endif |
/** |
* @} |
*/ |
/branches/tracing/uspace/srv/kbd/port/pl050.c |
---|
0,0 → 1,114 |
/* |
* Copyright (c) 2009 Vineeth Pillai |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms, with or without |
* modification, are permitted provided that the following conditions |
* are met: |
* |
* - Redistributions of source code must retain the above copyright |
* notice, this list of conditions and the following disclaimer. |
* - Redistributions in binary form must reproduce the above copyright |
* notice, this list of conditions and the following disclaimer in the |
* documentation and/or other materials provided with the distribution. |
* - The name of the author may not be used to endorse or promote products |
* derived from this software without specific prior written permission. |
* |
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
*/ |
/** @addtogroup kbd_port |
* @ingroup kbd |
* @{ |
*/ |
/** @file |
* @brief pl050 port driver. |
*/ |
#include <ddi.h> |
#include <libarch/ddi.h> |
#include <ipc/ipc.h> |
#include <async.h> |
#include <unistd.h> |
#include <sysinfo.h> |
#include <kbd_port.h> |
#include <kbd.h> |
#include <ddi.h> |
#include <stdio.h> |
#define PL050_STAT_RXFULL (1 << 4) |
static irq_cmd_t pl050_cmds[] = { |
{ |
.cmd = CMD_PIO_READ_8, |
.addr = NULL, |
.dstarg = 1 |
}, |
{ |
.cmd = CMD_BTEST, |
.value = PL050_STAT_RXFULL, |
.srcarg = 1, |
.dstarg = 3 |
}, |
{ |
.cmd = CMD_PREDICATE, |
.value = 2, |
.srcarg = 3 |
}, |
{ |
.cmd = CMD_PIO_READ_8, |
.addr = NULL, /* will be patched in run-time */ |
.dstarg = 2 |
}, |
{ |
.cmd = CMD_ACCEPT |
} |
}; |
static irq_code_t pl050_kbd = { |
sizeof(pl050_cmds) / sizeof(irq_cmd_t), |
pl050_cmds |
}; |
static void pl050_irq_handler(ipc_callid_t iid, ipc_call_t *call); |
int kbd_port_init(void) |
{ |
pl050_kbd.cmds[0].addr = (void *) sysinfo_value("kbd.address.status"); |
pl050_kbd.cmds[3].addr = (void *) sysinfo_value("kbd.address.data"); |
async_set_interrupt_received(pl050_irq_handler); |
ipc_register_irq(sysinfo_value("kbd.inr"), device_assign_devno(), 0, &pl050_kbd); |
return 0; |
} |
void kbd_port_yield(void) |
{ |
} |
void kbd_port_reclaim(void) |
{ |
} |
static void pl050_irq_handler(ipc_callid_t iid, ipc_call_t *call) |
{ |
int scan_code = IPC_GET_ARG2(*call); |
kbd_push_scancode(scan_code); |
return; |
} |
/** |
* @} |
*/ |
/branches/tracing/uspace/srv/kbd/port/i8042.c |
---|
135,8 → 135,8 |
(void) pio_read_8(&i8042->data); |
/* Enable kbd */ |
i8042_kbd.cmds[0].addr = &((i8042_t *) i8042_kernel)->status; |
i8042_kbd.cmds[3].addr = &((i8042_t *) i8042_kernel)->data; |
i8042_kbd.cmds[0].addr = (void *) &((i8042_t *) i8042_kernel)->status; |
i8042_kbd.cmds[3].addr = (void *) &((i8042_t *) i8042_kernel)->data; |
ipc_register_irq(sysinfo_value("kbd.inr"), device_assign_devno(), 0, &i8042_kbd); |
int newcontrol = i8042_KBD_IE | i8042_KBD_TRANSLATE; |
/branches/tracing/uspace/srv/kbd/genarch/stroke.c |
---|
31,17 → 31,18 |
*/ |
/** |
* @file |
* @brief Stroke simulator. |
* @brief Stroke simulator. |
* |
* When simulating a keyboard using a serial TTY we need to convert the |
* recognized strokes (such as Shift-A) to sequences of key presses and |
* releases (such as 'press Shift, press A, release A, release Shift'). |
* |
*/ |
#include <stroke.h> |
#include <kbd.h> |
#include <kbd/kbd.h> |
#include <kbd/keycode.h> |
#include <io/console.h> |
#include <io/keycode.h> |
/** Correspondence between modifers and the modifier keycodes. */ |
static unsigned int mods_keys[][2] = { |
58,7 → 59,7 |
i = 0; |
while (mods_keys[i][0] != 0) { |
if (mod & mods_keys[i][0]) { |
kbd_push_ev(KE_PRESS, mods_keys[i][1]); |
kbd_push_ev(KEY_PRESS, mods_keys[i][1]); |
} |
++i; |
} |
65,8 → 66,8 |
/* Simulate key press and release. */ |
if (key != 0) { |
kbd_push_ev(KE_PRESS, key); |
kbd_push_ev(KE_RELEASE, key); |
kbd_push_ev(KEY_PRESS, key); |
kbd_push_ev(KEY_RELEASE, key); |
} |
/* Simulate modifier releases. */ |
73,7 → 74,7 |
i = 0; |
while (mods_keys[i][0] != 0) { |
if (mod & mods_keys[i][0]) { |
kbd_push_ev(KE_RELEASE, mods_keys[i][1]); |
kbd_push_ev(KEY_RELEASE, mods_keys[i][1]); |
} |
++i; |
} |
81,4 → 82,4 |
/** |
* @} |
*/ |
*/ |
/branches/tracing/uspace/srv/kbd/genarch/gsp.c |
---|
49,7 → 49,7 |
*/ |
#include <gsp.h> |
#include <libadt/hash_table.h> |
#include <adt/hash_table.h> |
#include <stdlib.h> |
#include <stdio.h> |
244,7 → 244,7 |
key[0] = t->old_state; |
key[1] = t->input; |
hash_table_insert(&p->trans, &key, &t->link); |
hash_table_insert(&p->trans, key, &t->link); |
} |
/** Allocate transition structure. */ |
276,7 → 276,8 |
gsp_trans_t *t; |
t = hash_table_get_instance(item, gsp_trans_t, link); |
return (key[0] == t->old_state && key[1] == t->input); |
return ((key[0] == (unsigned long) t->old_state) |
&& (key[1] == (unsigned long) t->input)); |
} |
static void trans_op_remove_callback(link_t *item) |
/branches/tracing/uspace/srv/kbd/generic/key_buffer.c |
---|
File deleted |
/branches/tracing/uspace/srv/kbd/generic/kbd.c |
---|
28,10 → 28,10 |
/** |
* @addtogroup kbdgen generic |
* @brief HelenOS generic uspace keyboard handler. |
* @ingroup kbd |
* @brief HelenOS generic uspace keyboard handler. |
* @ingroup kbd |
* @{ |
*/ |
*/ |
/** @file |
*/ |
45,12 → 45,12 |
#include <ipc/ns.h> |
#include <async.h> |
#include <errno.h> |
#include <libadt/fifo.h> |
#include <kbd/kbd.h> |
#include <kbd/keycode.h> |
#include <adt/fifo.h> |
#include <io/console.h> |
#include <io/keycode.h> |
#include <kbd.h> |
#include <key_buffer.h> |
#include <keybuffer.h> |
#include <kbd_port.h> |
#include <kbd_ctl.h> |
#include <layout.h> |
88,7 → 88,7 |
void kbd_push_ev(int type, unsigned int key) |
{ |
kbd_event_t ev; |
console_event_t ev; |
unsigned mod_mask; |
switch (key) { |
102,7 → 102,7 |
} |
if (mod_mask != 0) { |
if (type == KE_PRESS) |
if (type == KEY_PRESS) |
mods = mods | mod_mask; |
else |
mods = mods & ~mod_mask; |
116,7 → 116,7 |
} |
if (mod_mask != 0) { |
if (type == KE_PRESS) { |
if (type == KEY_PRESS) { |
/* |
* Only change lock state on transition from released |
* to pressed. This prevents autorepeat from messing |
133,7 → 133,7 |
printf("mods: 0x%x\n", mods); |
printf("keycode: %u\n", key); |
*/ |
if (type == KE_PRESS && (mods & KM_LCTRL) && |
if (type == KEY_PRESS && (mods & KM_LCTRL) && |
key == KC_F1) { |
active_layout = 0; |
layout[active_layout]->reset(); |
140,7 → 140,7 |
return; |
} |
if (type == KE_PRESS && (mods & KM_LCTRL) && |
if (type == KEY_PRESS && (mods & KM_LCTRL) && |
key == KC_F2) { |
active_layout = 1; |
layout[active_layout]->reset(); |
147,7 → 147,7 |
return; |
} |
if (type == KE_PRESS && (mods & KM_LCTRL) && |
if (type == KEY_PRESS && (mods & KM_LCTRL) && |
key == KC_F3) { |
active_layout = 2; |
layout[active_layout]->reset(); |
/branches/tracing/uspace/srv/kbd/generic/keybuffer.c |
---|
0,0 → 1,132 |
/* |
* Copyright (c) 2006 Josef Cejka |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms, with or without |
* modification, are permitted provided that the following conditions |
* are met: |
* |
* - Redistributions of source code must retain the above copyright |
* notice, this list of conditions and the following disclaimer. |
* - Redistributions in binary form must reproduce the above copyright |
* notice, this list of conditions and the following disclaimer in the |
* documentation and/or other materials provided with the distribution. |
* - The name of the author may not be used to endorse or promote products |
* derived from this software without specific prior written permission. |
* |
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
*/ |
/** @addtogroup kbdgen |
* @brief HelenOS generic uspace keyboard handler. |
* @ingroup kbd |
* @{ |
*/ |
/** @file |
*/ |
#include <keybuffer.h> |
#include <futex.h> |
atomic_t keybuffer_futex = FUTEX_INITIALIZER; |
/** Clear key buffer. |
*/ |
void keybuffer_free(keybuffer_t *keybuffer) |
{ |
futex_down(&keybuffer_futex); |
keybuffer->head = 0; |
keybuffer->tail = 0; |
keybuffer->items = 0; |
futex_up(&keybuffer_futex); |
} |
/** Key buffer initialization. |
* |
*/ |
void keybuffer_init(keybuffer_t *keybuffer) |
{ |
keybuffer_free(keybuffer); |
} |
/** Get free space in buffer. |
* |
* This function is useful for processing some scancodes that are translated |
* to more than one character. |
* |
* @return empty buffer space |
* |
*/ |
size_t keybuffer_available(keybuffer_t *keybuffer) |
{ |
return KEYBUFFER_SIZE - keybuffer->items; |
} |
/** |
* |
* @return nonzero, if buffer is not empty. |
* |
*/ |
bool keybuffer_empty(keybuffer_t *keybuffer) |
{ |
return (keybuffer->items == 0); |
} |
/** Push key event to key buffer. |
* |
* If the buffer is full, the event is ignored. |
* |
* @param keybuffer The keybuffer. |
* @param ev The event to push. |
* |
*/ |
void keybuffer_push(keybuffer_t *keybuffer, const console_event_t *ev) |
{ |
futex_down(&keybuffer_futex); |
if (keybuffer->items < KEYBUFFER_SIZE) { |
keybuffer->fifo[keybuffer->tail] = *ev; |
keybuffer->tail = (keybuffer->tail + 1) % KEYBUFFER_SIZE; |
keybuffer->items++; |
} |
futex_up(&keybuffer_futex); |
} |
/** Pop event from buffer. |
* |
* @param edst Pointer to where the event should be saved. |
* |
* @return True if an event was popped. |
* |
*/ |
bool keybuffer_pop(keybuffer_t *keybuffer, console_event_t *edst) |
{ |
futex_down(&keybuffer_futex); |
if (keybuffer->items > 0) { |
keybuffer->items--; |
*edst = (keybuffer->fifo[keybuffer->head]); |
keybuffer->head = (keybuffer->head + 1) % KEYBUFFER_SIZE; |
futex_up(&keybuffer_futex); |
return true; |
} |
futex_up(&keybuffer_futex); |
return false; |
} |
/** |
* @} |
*/ |
/branches/tracing/uspace/srv/kbd/Makefile |
---|
34,7 → 34,7 |
include $(LIBC_PREFIX)/Makefile.toolchain |
CFLAGS += -Iinclude -I../libadt/include |
CFLAGS += -Iinclude |
LIBS = $(LIBC_PREFIX)/libc.a |
46,7 → 46,7 |
generic/kbd.c \ |
genarch/gsp.c \ |
genarch/stroke.c \ |
generic/key_buffer.c |
generic/keybuffer.c |
ARCH_SOURCES = |
GENARCH_SOURCES = \ |
61,6 → 61,7 |
endif |
ifeq ($(UARCH), arm32) |
ifeq ($(MACHINE), testarm) |
GENARCH_SOURCES += \ |
port/gxemul.c |
72,6 → 73,12 |
ctl/stty.c |
endif |
endif |
ifeq ($(MACHINE), integratorcp) |
GENARCH_SOURCES += \ |
port/pl050.c \ |
ctl/pl050.c |
endif |
endif |
ifeq ($(UARCH), ia32) |
GENARCH_SOURCES += \ |
167,7 → 174,7 |
disasm: $(OUTPUT).disasm |
$(OUTPUT).disasm: $(OUTPUT) |
$(OBJDUMP) -d $< >$@ |
$(OBJDUMP) -d $< > $@ |
%.o: %.S |
$(CC) $(DEFS) $(AFLAGS) $(CFLAGS) -D__ASM__ -c $< -o $@ |
/branches/tracing/uspace/srv/kbd/layout/us_qwerty.c |
---|
27,17 → 27,17 |
*/ |
/** @addtogroup kbd |
* @brief US QWERTY leyout. |
* @brief US QWERTY layout. |
* @{ |
*/ |
#include <kbd.h> |
#include <kbd/kbd.h> |
#include <kbd/keycode.h> |
#include <io/console.h> |
#include <io/keycode.h> |
#include <layout.h> |
static void layout_reset(void); |
static wchar_t layout_parse_ev(kbd_event_t *ev); |
static wchar_t layout_parse_ev(console_event_t *ev); |
layout_op_t us_qwerty_op = { |
layout_reset, |
203,7 → 203,7 |
{ |
} |
static wchar_t layout_parse_ev(kbd_event_t *ev) |
static wchar_t layout_parse_ev(console_event_t *ev) |
{ |
wchar_t c; |
/branches/tracing/uspace/srv/kbd/layout/cz.c |
---|
27,23 → 27,23 |
*/ |
/** @addtogroup kbd |
* @brief US QWERTY leyout. |
* @brief Czech QWERTZ layout. |
* @{ |
*/ |
*/ |
#include <kbd.h> |
#include <kbd/kbd.h> |
#include <kbd/keycode.h> |
#include <io/console.h> |
#include <io/keycode.h> |
#include <bool.h> |
#include <layout.h> |
static void layout_reset(void); |
static wchar_t layout_parse_ev(kbd_event_t *ev); |
static wchar_t layout_parse_ev(console_event_t *ev); |
enum m_state { |
ms_start, |
ms_hacek, |
ms_carka |
ms_carka |
}; |
static enum m_state mstate; |
272,7 → 272,7 |
return map[key]; |
} |
static wchar_t parse_ms_hacek(kbd_event_t *ev) |
static wchar_t parse_ms_hacek(console_event_t *ev) |
{ |
wchar_t c; |
290,7 → 290,7 |
return c; |
} |
static wchar_t parse_ms_carka(kbd_event_t *ev) |
static wchar_t parse_ms_carka(console_event_t *ev) |
{ |
wchar_t c; |
308,7 → 308,7 |
return c; |
} |
static wchar_t parse_ms_start(kbd_event_t *ev) |
static wchar_t parse_ms_start(console_event_t *ev) |
{ |
wchar_t c; |
383,21 → 383,26 |
mstate = ms_start; |
} |
static wchar_t layout_parse_ev(kbd_event_t *ev) |
static wchar_t layout_parse_ev(console_event_t *ev) |
{ |
if (ev->type != KE_PRESS) |
return '\0'; |
if (ev->type != KEY_PRESS) |
return 0; |
if (key_is_mod(ev->key)) |
return '\0'; |
return 0; |
switch (mstate) { |
case ms_start: return parse_ms_start(ev); |
case ms_hacek: return parse_ms_hacek(ev); |
case ms_carka: return parse_ms_carka(ev); |
case ms_start: |
return parse_ms_start(ev); |
case ms_hacek: |
return parse_ms_hacek(ev); |
case ms_carka: |
return parse_ms_carka(ev); |
} |
return 0; |
} |
/** |
* @} |
*/ |
*/ |
/branches/tracing/uspace/srv/kbd/layout/us_dvorak.c |
---|
32,12 → 32,12 |
*/ |
#include <kbd.h> |
#include <kbd/kbd.h> |
#include <kbd/keycode.h> |
#include <io/console.h> |
#include <io/keycode.h> |
#include <layout.h> |
static void layout_reset(void); |
static wchar_t layout_parse_ev(kbd_event_t *ev); |
static wchar_t layout_parse_ev(console_event_t *ev); |
layout_op_t us_dvorak_op = { |
layout_reset, |
209,7 → 209,7 |
{ |
} |
static wchar_t layout_parse_ev(kbd_event_t *ev) |
static wchar_t layout_parse_ev(console_event_t *ev) |
{ |
wchar_t c; |