Changeset 07b7c48 in mainline for uspace/lib


Ignore:
Timestamp:
2013-04-12T09:01:10Z (12 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
902f0906
Parents:
bc4bf97
Message:

Extend console library API to support different event types.

Location:
uspace/lib
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/c/generic/io/console.c

    rbc4bf97 r07b7c48  
    154154}
    155155
    156 bool console_get_kbd_event(console_ctrl_t *ctrl, kbd_event_t *event)
     156bool console_get_event(console_ctrl_t *ctrl, cons_event_t *event)
    157157{
    158158        if (ctrl->input_aid == 0) {
     
    171171                }
    172172               
    173                 event->type = type;
    174                 event->key = key;
    175                 event->mods = mods;
    176                 event->c = c;
     173                event->type = CEV_KEY;
     174                event->ev.key.type = type;
     175                event->ev.key.key = key;
     176                event->ev.key.mods = mods;
     177                event->ev.key.c = c;
    177178        } else {
    178179                sysarg_t retval;
     
    186187                }
    187188               
    188                 event->type = IPC_GET_ARG1(ctrl->input_call);
    189                 event->key = IPC_GET_ARG2(ctrl->input_call);
    190                 event->mods = IPC_GET_ARG3(ctrl->input_call);
    191                 event->c = IPC_GET_ARG4(ctrl->input_call);
     189                event->type = CEV_KEY;
     190                event->ev.key.type = IPC_GET_ARG1(ctrl->input_call);
     191                event->ev.key.key = IPC_GET_ARG2(ctrl->input_call);
     192                event->ev.key.mods = IPC_GET_ARG3(ctrl->input_call);
     193                event->ev.key.c = IPC_GET_ARG4(ctrl->input_call);
    192194        }
    193195       
     
    195197}
    196198
    197 bool console_get_kbd_event_timeout(console_ctrl_t *ctrl, kbd_event_t *event,
     199bool console_get_event_timeout(console_ctrl_t *ctrl, cons_event_t *event,
    198200    suseconds_t *timeout)
    199201{
     
    223225        }
    224226       
    225         event->type = IPC_GET_ARG1(ctrl->input_call);
    226         event->key = IPC_GET_ARG2(ctrl->input_call);
    227         event->mods = IPC_GET_ARG3(ctrl->input_call);
    228         event->c = IPC_GET_ARG4(ctrl->input_call);
     227        event->type = CEV_KEY;
     228        event->ev.key.type = IPC_GET_ARG1(ctrl->input_call);
     229        event->ev.key.key = IPC_GET_ARG2(ctrl->input_call);
     230        event->ev.key.mods = IPC_GET_ARG3(ctrl->input_call);
     231        event->ev.key.c = IPC_GET_ARG4(ctrl->input_call);
    229232       
    230233        /* Update timeout */
  • uspace/lib/c/include/io/console.h

    rbc4bf97 r07b7c48  
    3939#include <io/concaps.h>
    4040#include <io/kbd_event.h>
     41#include <io/cons_event.h>
    4142#include <io/keycode.h>
    4243#include <async.h>
     
    8283extern void console_cursor_visibility(console_ctrl_t *, bool);
    8384extern int console_get_color_cap(console_ctrl_t *, sysarg_t *);
    84 extern bool console_get_kbd_event(console_ctrl_t *, kbd_event_t *);
    85 extern bool console_get_kbd_event_timeout(console_ctrl_t *, kbd_event_t *,
     85extern bool console_get_event(console_ctrl_t *, cons_event_t *);
     86extern bool console_get_event_timeout(console_ctrl_t *, cons_event_t *,
    8687    suseconds_t *);
    8788
  • uspace/lib/clui/tinput.c

    rbc4bf97 r07b7c48  
    816816                console_flush(ti->console);
    817817               
    818                 kbd_event_t ev;
    819                 if (!console_get_kbd_event(ti->console, &ev))
     818                cons_event_t ev;
     819                if (!console_get_event(ti->console, &ev))
    820820                        return EIO;
    821821               
    822                 if (ev.type != KEY_PRESS)
     822                if (ev.type != CEV_KEY || ev.ev.key.type != KEY_PRESS)
    823823                        continue;
    824824               
    825                 if (((ev.mods & KM_CTRL) != 0) &&
    826                     ((ev.mods & (KM_ALT | KM_SHIFT)) == 0))
    827                         tinput_key_ctrl(ti, &ev);
    828                
    829                 if (((ev.mods & KM_SHIFT) != 0) &&
    830                     ((ev.mods & (KM_CTRL | KM_ALT)) == 0))
    831                         tinput_key_shift(ti, &ev);
    832                
    833                 if (((ev.mods & KM_CTRL) != 0) &&
    834                     ((ev.mods & KM_SHIFT) != 0) &&
    835                     ((ev.mods & KM_ALT) == 0))
    836                         tinput_key_ctrl_shift(ti, &ev);
    837                
    838                 if ((ev.mods & (KM_CTRL | KM_ALT | KM_SHIFT)) == 0)
    839                         tinput_key_unmod(ti, &ev);
    840                
    841                 if (ev.c >= ' ') {
     825                kbd_event_t *kev = &ev.ev.key;
     826               
     827                if (((kev->mods & KM_CTRL) != 0) &&
     828                    ((kev->mods & (KM_ALT | KM_SHIFT)) == 0))
     829                        tinput_key_ctrl(ti, kev);
     830               
     831                if (((kev->mods & KM_SHIFT) != 0) &&
     832                    ((kev->mods & (KM_CTRL | KM_ALT)) == 0))
     833                        tinput_key_shift(ti, kev);
     834               
     835                if (((kev->mods & KM_CTRL) != 0) &&
     836                    ((kev->mods & KM_SHIFT) != 0) &&
     837                    ((kev->mods & KM_ALT) == 0))
     838                        tinput_key_ctrl_shift(ti, kev);
     839               
     840                if ((kev->mods & (KM_CTRL | KM_ALT | KM_SHIFT)) == 0)
     841                        tinput_key_unmod(ti, kev);
     842               
     843                if (kev->c >= ' ') {
    842844                        tinput_sel_delete(ti);
    843                         tinput_insert_char(ti, ev.c);
     845                        tinput_insert_char(ti, kev->c);
    844846                }
    845847        }
Note: See TracChangeset for help on using the changeset viewer.