Changeset 902f0906 in mainline


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.

Location:
uspace
Files:
6 edited

Legend:

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

    r07b7c48 r902f0906  
    3535 */
    3636#include <errno.h>
     37#include <io/cons_event.h>
    3738#include <ipc/console.h>
    3839#include <stdlib.h>
     
    4041
    4142#include <io/con_srv.h>
     43
     44static int console_ev_encode(cons_event_t *event, ipc_call_t *call)
     45{
     46        IPC_SET_ARG1(*call, event->type);
     47
     48        switch (event->type) {
     49        case CEV_KEY:
     50                IPC_SET_ARG2(*call, event->ev.key.type);
     51                IPC_SET_ARG3(*call, event->ev.key.key);
     52                IPC_SET_ARG4(*call, event->ev.key.mods);
     53                IPC_SET_ARG5(*call, event->ev.key.c);
     54                break;
     55        case CEV_POS:
     56                IPC_SET_ARG2(*call, (event->ev.pos.pos_id << 16) | (event->ev.pos.type & 0xffff));
     57                IPC_SET_ARG3(*call, event->ev.pos.btn_num);
     58                IPC_SET_ARG4(*call, event->ev.pos.hpos);
     59                IPC_SET_ARG5(*call, event->ev.pos.vpos);
     60                break;
     61        default:
     62                return EIO;
     63        }
     64
     65        return EOK;
     66}
    4267
    4368static void con_read_srv(con_srv_t *srv, ipc_callid_t callid,
     
    273298{
    274299        int rc;
    275         kbd_event_t event;
     300        cons_event_t event;
     301        ipc_call_t result;
    276302
    277303        if (srv->srvs->ops->get_event == NULL) {
     
    281307
    282308        rc = srv->srvs->ops->get_event(srv, &event);
    283         async_answer_4(callid, rc, event.type, event.key, event.mods, event.c);
     309        if (rc != EOK) {
     310                async_answer_0(callid, rc);
     311                return;
     312        }
     313
     314        rc = console_ev_encode(&event, &result);
     315        if (rc != EOK) {
     316                async_answer_0(callid, rc);
     317                return;
     318        }
     319
     320        async_answer_5(callid, rc, IPC_GET_ARG1(result), IPC_GET_ARG2(result),
     321            IPC_GET_ARG3(result), IPC_GET_ARG4(result), IPC_GET_ARG5(result));
    284322}
    285323
  • 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 */
  • uspace/lib/c/include/io/con_srv.h

    r07b7c48 r902f0906  
    4141#include <io/color.h>
    4242#include <io/concaps.h>
    43 #include <io/kbd_event.h>
     43#include <io/cons_event.h>
    4444#include <io/pixel.h>
    4545#include <io/style.h>
     
    8282        void (*set_rgb_color)(con_srv_t *, pixel_t, pixel_t);
    8383        void (*set_cursor_visibility)(con_srv_t *, bool);
    84         int (*get_event)(con_srv_t *, kbd_event_t *);
     84        int (*get_event)(con_srv_t *, cons_event_t *);
    8585} con_ops_t;
    8686
  • uspace/lib/gui/terminal.c

    r07b7c48 r902f0906  
    7777static void term_set_rgb_color(con_srv_t *, pixel_t, pixel_t);
    7878static void term_set_cursor_visibility(con_srv_t *, bool);
    79 static int term_get_event(con_srv_t *, kbd_event_t *);
     79static int term_get_event(con_srv_t *, cons_event_t *);
    8080
    8181static con_ops_t con_ops = {
     
    579579}
    580580
    581 static int term_get_event(con_srv_t *srv, kbd_event_t *event)
     581static int term_get_event(con_srv_t *srv, cons_event_t *event)
    582582{
    583583        terminal_t *term = srv_to_terminal(srv);
     
    585585        kbd_event_t *kevent = list_get_instance(link, kbd_event_t, link);
    586586       
    587         *event = *kevent;
     587        event->type = CEV_KEY;
     588        event->ev.key = *kevent;
    588589        free(kevent);
    589590        return EOK;
  • uspace/srv/hid/console/console.c

    r07b7c48 r902f0906  
    129129static void cons_set_rgb_color(con_srv_t *, pixel_t, pixel_t);
    130130static void cons_set_cursor_visibility(con_srv_t *, bool);
    131 static int cons_get_event(con_srv_t *, kbd_event_t *);
     131static int cons_get_event(con_srv_t *, cons_event_t *);
    132132
    133133static con_ops_t con_ops = {
     
    490490}
    491491
    492 static int cons_get_event(con_srv_t *srv, kbd_event_t *event)
     492static int cons_get_event(con_srv_t *srv, cons_event_t *event)
    493493{
    494494        console_t *cons = srv_to_console(srv);
     
    496496        kbd_event_t *kevent = list_get_instance(link, kbd_event_t, link);
    497497       
    498         *event = *kevent;
     498        event->type = CEV_KEY;
     499        event->ev.key = *kevent;
    499500        free(kevent);
    500501        return EOK;
  • uspace/srv/hid/remcons/remcons.c

    r07b7c48 r902f0906  
    8080static int remcons_get_size(con_srv_t *, sysarg_t *, sysarg_t *);
    8181static int remcons_get_color_cap(con_srv_t *, console_caps_t *);
    82 static int remcons_get_event(con_srv_t *, kbd_event_t *);
     82static int remcons_get_event(con_srv_t *, cons_event_t *);
    8383
    8484static con_ops_t con_ops = {
     
    185185}
    186186
    187 static int remcons_get_event(con_srv_t *srv, kbd_event_t *event)
    188 {
    189         telnet_user_t *user = srv_to_user(srv);
     187static int remcons_get_event(con_srv_t *srv, cons_event_t *event)
     188{
     189        telnet_user_t *user = srv_to_user(srv);
     190        kbd_event_t kevent;
    190191        int rc;
    191192
    192         rc = telnet_user_get_next_keyboard_event(user, event);
     193        rc = telnet_user_get_next_keyboard_event(user, &kevent);
    193194        if (rc != EOK) {
    194195                /* XXX What? */
     
    196197                return EOK;
    197198        }
     199
     200        event->type = CEV_KEY;
     201        event->ev.key = kevent;
    198202
    199203        return EOK;
Note: See TracChangeset for help on using the changeset viewer.