Changeset 902f0906 in mainline for uspace/lib/c/generic/io/console.c


Ignore:
Timestamp:
2013-04-12T19:05:06Z (11 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
3f06dae
Parents:
07b7c48
Message:

Multiple event type support in console IPC stubs.

File:
1 edited

Legend:

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

    r07b7c48 r902f0906  
    154154}
    155155
     156static int console_ev_decode(ipc_call_t *call, cons_event_t *event)
     157{
     158        event->type = IPC_GET_ARG1(*call);
     159
     160        switch (event->type) {
     161        case CEV_KEY:
     162                event->ev.key.type = IPC_GET_ARG2(*call);
     163                event->ev.key.key = IPC_GET_ARG3(*call);
     164                event->ev.key.mods = IPC_GET_ARG4(*call);
     165                event->ev.key.c = IPC_GET_ARG5(*call);
     166                break;
     167        case CEV_POS:
     168                event->ev.pos.pos_id = IPC_GET_ARG2(*call) >> 16;
     169                event->ev.pos.type = IPC_GET_ARG2(*call) & 0xffff;
     170                event->ev.pos.btn_num = IPC_GET_ARG3(*call);
     171                event->ev.pos.hpos = IPC_GET_ARG4(*call);
     172                event->ev.pos.vpos = IPC_GET_ARG5(*call);
     173                break;
     174        default:
     175                return EIO;
     176        }
     177
     178        return EOK;
     179}
     180
    156181bool console_get_event(console_ctrl_t *ctrl, cons_event_t *event)
    157182{
    158183        if (ctrl->input_aid == 0) {
    159                 sysarg_t type;
    160                 sysarg_t key;
    161                 sysarg_t mods;
    162                 sysarg_t c;
     184                ipc_call_t result;
    163185               
    164186                async_exch_t *exch = async_exchange_begin(ctrl->input_sess);
    165                 int rc = async_req_0_4(exch, CONSOLE_GET_EVENT, &type, &key, &mods, &c);
     187                aid_t aid = async_send_0(exch, CONSOLE_GET_EVENT, &result);
    166188                async_exchange_end(exch);
     189               
     190                sysarg_t rc;
     191                async_wait_for(aid, &rc);
    167192               
    168193                if (rc != EOK) {
     
    171196                }
    172197               
    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;
     198                rc = console_ev_decode(&result, event);
     199                if (rc != EOK) {
     200                        errno = rc;
     201                        return false;
     202                }
    178203        } else {
    179204                sysarg_t retval;
     
    187212                }
    188213               
    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);
     214                int rc = console_ev_decode(&ctrl->input_call, event);
     215                if (rc != EOK) {
     216                        errno = rc;
     217                        return false;
     218                }
    194219        }
    195220       
     
    225250        }
    226251       
    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);
     252        rc = console_ev_decode(&ctrl->input_call, event);
     253        if (rc != EOK) {
     254                errno = rc;
     255                return false;
     256        }
    232257       
    233258        /* Update timeout */
Note: See TracChangeset for help on using the changeset viewer.