Changeset bff90ba in mainline


Ignore:
Timestamp:
2011-12-27T11:36:08Z (12 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
da2d75b
Parents:
a84ddf0
Message:

xtkbd: Cleanup.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/char/xtkbd/xtkbd.c

    ra84ddf0 rbff90ba  
    179179/*----------------------------------------------------------------------------*/
    180180static int polling(void *);
    181 static void default_connection_handler(ddf_fun_t *fun,
    182     ipc_callid_t icallid, ipc_call_t *icall);
     181static void default_connection_handler(ddf_fun_t *, ipc_callid_t, ipc_call_t *);
    183182/*----------------------------------------------------------------------------*/
    184183/** Keyboard function ops. */
     
    241240{
    242241        assert(arg);
    243         xt_kbd_t *kbd = arg;
     242        const xt_kbd_t *kbd = arg;
    244243
    245244        assert(kbd->parent_sess);
     
    255254                        map_size = sizeof(scanmap_e0) / sizeof(int);
    256255                        size = char_dev_read(kbd->parent_sess, &code, 1);
    257                 }
    258 
    259 
    260                 kbd_event_type_t type;
    261                 if (code & 0x80) {
    262                         code &= ~0x80;
    263                         type = KEY_RELEASE;
    264                 } else {
    265                         type = KEY_PRESS;
    266                 }
    267 
    268                 if ((size_t) code >= map_size) {
    269                         ddf_msg(LVL_WARN,
    270                             "Unknown scancode: %hhx, size: %zd", code, size);
     256                        // TODO handle print screen
     257                }
     258
     259                /* Invalid read. */
     260                if (size != 1) {
    271261                        continue;
    272262                }
    273263
    274                 const unsigned key = map[code];
     264
     265                /* Bit 7 indicates press/release */
     266                const kbd_event_type_t type =
     267                    (code & 0x80) ? KEY_RELEASE : KEY_PRESS;
     268                code &= ~0x80;
     269
     270                const unsigned key = (code < map_size) ? map[code] : 0;
    275271                if (key != 0) {
    276272                        async_exch_t *exch =
     
    283279                        async_msg_4(exch, KBDEV_EVENT, type, key, 0, 0);
    284280                        async_exchange_end(exch);
     281                } else {
     282                        ddf_msg(LVL_WARN, "Unknown scancode: %hhx", code);
    285283                }
    286284        }
Note: See TracChangeset for help on using the changeset viewer.