Ignore:
Timestamp:
2020-06-18T15:39:50Z (4 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
ce52c333
Parents:
4f663f3e
Message:

Use char32_t instead of wchat_t to represent UTF-32 strings

The intention of the native HelenOS string API has been always to
support Unicode in the UTF-8 and UTF-32 encodings as the sole character
representations and ignore the obsolete mess of older single-byte and
multibyte character encodings. Before C11, the wchar_t type has been
slightly misused for the purpose of the UTF-32 strings. The newer
char32_t type is obviously a much more suitable option. The standard
defines char32_t as uint_least32_t, thus we can take the liberty to fix
it to uint32_t.

To maintain compatilibity with the C Standard, the putwchar(wchar_t)
functions has been replaced by our custom putuchar(char32_t) functions
where appropriate.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/hid/input/layout/fr_azerty.c

    r4f663f3e r28a5ebd  
    4343static errno_t fr_azerty_create (layout_t *);
    4444static void fr_azerty_destroy (layout_t *);
    45 static wchar_t fr_azerty_parse_ev (layout_t *, kbd_event_t *);
     45static char32_t fr_azerty_parse_ev (layout_t *, kbd_event_t *);
    4646
    4747layout_ops_t fr_azerty_ops = {
     
    5151};
    5252
    53 static wchar_t map_lcase[] = {
     53static char32_t map_lcase[] = {
    5454        [KC_Q] = 'a',
    5555        [KC_W] = 'z',
     
    8282};
    8383
    84 static wchar_t map_ucase[] = {
     84static char32_t map_ucase[] = {
    8585        [KC_Q] = 'A',
    8686        [KC_W] = 'Z',
     
    117117};
    118118
    119 static wchar_t map_not_shifted[] = {
     119static char32_t map_not_shifted[] = {
    120120        [KC_BACKTICK] = L'²',
    121121
     
    146146};
    147147
    148 static wchar_t map_shifted[] = {
     148static char32_t map_shifted[] = {
    149149        [KC_M] = '?',
    150150        [KC_BACKTICK] = '~',
     
    176176};
    177177
    178 static wchar_t map_neutral[] = {
     178static char32_t map_neutral[] = {
    179179        [KC_BACKSPACE] = '\b',
    180180        [KC_TAB] = '\t',
     
    189189};
    190190
    191 static wchar_t map_numeric[] = {
     191static char32_t map_numeric[] = {
    192192        [KC_N7] = '7',
    193193        [KC_N8] = '8',
     
    204204};
    205205
    206 static wchar_t translate (unsigned int key, wchar_t *map, size_t map_len)
     206static char32_t translate (unsigned int key, char32_t *map, size_t map_len)
    207207{
    208208        if (key >= map_len)
     
    221221}
    222222
    223 static wchar_t fr_azerty_parse_ev (layout_t *s, kbd_event_t *e)
     223static char32_t fr_azerty_parse_ev (layout_t *s, kbd_event_t *e)
    224224{
    225225        if ((e->mods & (KM_CTRL | KM_ALT)))
    226226                return 0; // Produce no characters when Ctrl or Alt is pressed
    227227
    228         wchar_t c = translate (e->key, map_neutral, sizeof (map_neutral) / sizeof (wchar_t));
     228        char32_t c = translate (e->key, map_neutral, sizeof (map_neutral) / sizeof (char32_t));
    229229        if (c)
    230230                return c;
    231231
    232232        if ((e->mods & KM_SHIFT))
    233                 c = translate (e->key, map_shifted, sizeof (map_shifted) / sizeof (wchar_t));
     233                c = translate (e->key, map_shifted, sizeof (map_shifted) / sizeof (char32_t));
    234234        else
    235                 c = translate (e->key, map_not_shifted, sizeof (map_not_shifted) / sizeof (wchar_t));
     235                c = translate (e->key, map_not_shifted, sizeof (map_not_shifted) / sizeof (char32_t));
    236236
    237237        if (c)
     
    239239
    240240        if (((e->mods & KM_SHIFT)) ^ ((e->mods & KM_CAPS_LOCK)))
    241                 c = translate (e->key, map_ucase, sizeof (map_ucase) / sizeof (wchar_t));
     241                c = translate (e->key, map_ucase, sizeof (map_ucase) / sizeof (char32_t));
    242242        else
    243                 c = translate (e->key, map_lcase, sizeof (map_lcase) / sizeof (wchar_t));
     243                c = translate (e->key, map_lcase, sizeof (map_lcase) / sizeof (char32_t));
    244244
    245245        if (c)
     
    247247
    248248        if ((e->mods & KM_NUM_LOCK))
    249                 c = translate (e->key, map_numeric, sizeof (map_numeric) / sizeof (wchar_t));
     249                c = translate (e->key, map_numeric, sizeof (map_numeric) / sizeof (char32_t));
    250250        else
    251251                c = 0;
Note: See TracChangeset for help on using the changeset viewer.