Changeset 9db4079 in mainline


Ignore:
Timestamp:
2009-04-05T09:27:12Z (15 years ago)
Author:
Jiri Svoboda <jirik.svoboda@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
cee8d3e
Parents:
b27eb71
Message:

UCS in keyboard driver.

Location:
uspace
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/libc/include/kbd/kbd.h

    rb27eb71 r9db4079  
    3636#define LIBC_KBD_H_
    3737
     38#include <sys/types.h>
     39
    3840typedef enum kbd_ev_type {
    3941        KE_PRESS,
     
    5355
    5456        /** The character that was generated or '\0' for none. */
    55         char c;
     57        wchar_t c;
    5658} kbd_event_t;
    5759
  • uspace/srv/kbd/generic/key_buffer.c

    rb27eb71 r9db4079  
    9494}
    9595
    96 void keybuffer_push0(keybuffer_t *keybuffer, int c)
    97 {
    98         kbd_event_t ev;
    99 
    100         ev.key = c; ev.mods = 0; ev.c = c;
    101         keybuffer_push(keybuffer, &ev);
    102 }
    103 
    10496/** Pop event from buffer.
    10597 *
  • uspace/srv/kbd/include/key_buffer.h

    rb27eb71 r9db4079  
    5656extern int keybuffer_empty(keybuffer_t *);
    5757extern void keybuffer_push(keybuffer_t *, const kbd_event_t *);
    58 extern void keybuffer_push0(keybuffer_t *, int c);
    5958extern int keybuffer_pop(keybuffer_t *, kbd_event_t *);
    6059
  • uspace/srv/kbd/include/layout.h

    rb27eb71 r9db4079  
    3939
    4040#include <kbd/kbd.h>
     41#include <sys/types.h>
    4142
    42 extern char layout_parse_ev(kbd_event_t *);
     43extern wchar_t layout_parse_ev(kbd_event_t *);
    4344
    4445#endif
  • uspace/srv/kbd/layout/us_dvorak.c

    rb27eb71 r9db4079  
    3737#include <layout.h>
    3838
    39 static char map_lcase[] = {
     39static wchar_t map_lcase[] = {
    4040        [KC_R] = 'p',
    4141        [KC_T] = 'y',
     
    7070};
    7171
    72 static char map_ucase[] = {
     72static wchar_t map_ucase[] = {
    7373        [KC_R] = 'P',
    7474        [KC_T] = 'Y',
     
    103103};
    104104
    105 static char map_not_shifted[] = {
     105static wchar_t map_not_shifted[] = {
    106106        [KC_BACKTICK] = '`',
    107107
     
    133133};
    134134
    135 static char map_shifted[] = {
     135static wchar_t map_shifted[] = {
    136136        [KC_BACKTICK] = '~',
    137137
     
    163163};
    164164
    165 static char map_neutral[] = {
     165static wchar_t map_neutral[] = {
    166166        [KC_BACKSPACE] = '\b',
    167167        [KC_TAB] = '\t',
     
    176176};
    177177
    178 static char map_numeric[] = {
     178static wchar_t map_numeric[] = {
    179179        [KC_N7] = '7',
    180180        [KC_N8] = '8',
     
    191191};
    192192
    193 static int translate(unsigned int key, char *map, size_t map_length)
     193static wchar_t translate(unsigned int key, wchar_t *map, size_t map_length)
    194194{
    195195        if (key >= map_length)
     
    198198}
    199199
    200 char layout_parse_ev(kbd_event_t *ev)
     200wchar_t layout_parse_ev(kbd_event_t *ev)
    201201{
    202         char c;
     202        wchar_t c;
    203203
    204204        /* Produce no characters when Ctrl or Alt is pressed. */
     
    206206                return 0;
    207207
    208         c = translate(ev->key, map_neutral, sizeof(map_neutral) / sizeof(char));
     208        c = translate(ev->key, map_neutral, sizeof(map_neutral) / sizeof(wchar_t));
    209209        if (c != 0)
    210210                return c;
    211211
    212212        if (((ev->mods & KM_SHIFT) != 0) ^ ((ev->mods & KM_CAPS_LOCK) != 0))
    213                 c = translate(ev->key, map_ucase, sizeof(map_ucase) / sizeof(char));
     213                c = translate(ev->key, map_ucase, sizeof(map_ucase) / sizeof(wchar_t));
    214214        else
    215                 c = translate(ev->key, map_lcase, sizeof(map_lcase) / sizeof(char));
     215                c = translate(ev->key, map_lcase, sizeof(map_lcase) / sizeof(wchar_t));
    216216
    217217        if (c != 0)
     
    219219
    220220        if ((ev->mods & KM_SHIFT) != 0)
    221                 c = translate(ev->key, map_shifted, sizeof(map_shifted) / sizeof(char));
     221                c = translate(ev->key, map_shifted, sizeof(map_shifted) / sizeof(wchar_t));
    222222        else
    223                 c = translate(ev->key, map_not_shifted, sizeof(map_not_shifted) / sizeof(char));
     223                c = translate(ev->key, map_not_shifted, sizeof(map_not_shifted) / sizeof(wchar_t));
    224224
    225225        if (c != 0)
     
    227227
    228228        if ((ev->mods & KM_NUM_LOCK) != 0)
    229                 c = translate(ev->key, map_numeric, sizeof(map_numeric) / sizeof(char));
     229                c = translate(ev->key, map_numeric, sizeof(map_numeric) / sizeof(wchar_t));
    230230        else
    231231                c = 0;
  • uspace/srv/kbd/layout/us_qwerty.c

    rb27eb71 r9db4079  
    3737#include <layout.h>
    3838
    39 static char map_lcase[] = {
     39static wchar_t map_lcase[] = {
    4040        [KC_Q] = 'q',
    4141        [KC_W] = 'w',
     
    6868};
    6969
    70 static char map_ucase[] = {
     70static wchar_t map_ucase[] = {
    7171        [KC_Q] = 'Q',
    7272        [KC_W] = 'W',
     
    9999};
    100100
    101 static char map_not_shifted[] = {
     101static wchar_t map_not_shifted[] = {
    102102        [KC_BACKTICK] = '`',
    103103
     
    128128};
    129129
    130 static char map_shifted[] = {
     130static wchar_t map_shifted[] = {
    131131        [KC_BACKTICK] = '~',
    132132
     
    157157};
    158158
    159 static char map_neutral[] = {
     159static wchar_t map_neutral[] = {
    160160        [KC_BACKSPACE] = '\b',
    161161        [KC_TAB] = '\t',
     
    170170};
    171171
    172 static char map_numeric[] = {
     172static wchar_t map_numeric[] = {
    173173        [KC_N7] = '7',
    174174        [KC_N8] = '8',
     
    185185};
    186186
    187 static int translate(unsigned int key, char *map, size_t map_length)
     187static wchar_t translate(unsigned int key, wchar_t *map, size_t map_length)
    188188{
    189         if (key >= map_length) return 0;
    190         return map[key];       
     189        if (key >= map_length)
     190                return 0;
     191        return map[key];
    191192}
    192193
    193 char layout_parse_ev(kbd_event_t *ev)
     194wchar_t layout_parse_ev(kbd_event_t *ev)
    194195{
    195         char c;
     196        wchar_t c;
    196197
    197198        /* Produce no characters when Ctrl or Alt is pressed. */
     
    199200                return 0;
    200201
    201         c = translate(ev->key, map_neutral, sizeof(map_neutral) / sizeof(char));
    202         if (c != 0) return c;
     202        c = translate(ev->key, map_neutral, sizeof(map_neutral) / sizeof(wchar_t));
     203        if (c != 0)
     204                return c;
    203205
    204206        if (((ev->mods & KM_SHIFT) != 0) ^ ((ev->mods & KM_CAPS_LOCK) != 0))
    205                 c = translate(ev->key, map_ucase, sizeof(map_ucase) / sizeof(char));
     207                c = translate(ev->key, map_ucase, sizeof(map_ucase) / sizeof(wchar_t));
    206208        else
    207                 c = translate(ev->key, map_lcase, sizeof(map_lcase) / sizeof(char));
    208 
    209         if (c != 0) return c;
     209                c = translate(ev->key, map_lcase, sizeof(map_lcase) / sizeof(wchar_t));
     210
     211        if (c != 0)
     212                return c;
    210213
    211214        if ((ev->mods & KM_SHIFT) != 0)
    212                 c = translate(ev->key, map_shifted, sizeof(map_shifted) / sizeof(char));
     215                c = translate(ev->key, map_shifted, sizeof(map_shifted) / sizeof(wchar_t));
    213216        else
    214                 c = translate(ev->key, map_not_shifted, sizeof(map_not_shifted) / sizeof(char));
    215 
    216         if (c != 0) return c;
     217                c = translate(ev->key, map_not_shifted, sizeof(map_not_shifted) / sizeof(wchar_t));
     218
     219        if (c != 0)
     220                return c;
    217221
    218222        if ((ev->mods & KM_NUM_LOCK) != 0)
    219                 c = translate(ev->key, map_numeric, sizeof(map_numeric) / sizeof(char));
     223                c = translate(ev->key, map_numeric, sizeof(map_numeric) / sizeof(wchar_t));
    220224        else
    221225                c = 0;
Note: See TracChangeset for help on using the changeset viewer.