Changes in / [ed267bc:166a1f57] in mainline


Ignore:
Location:
uspace
Files:
1 deleted
23 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/bdsh/cmds/modules/cat/cat.c

    red267bc r166a1f57  
    117117static void waitkey()
    118118{
    119         cons_event_t ev;
    120         kbd_event_t *kev;
     119        kbd_event_t ev;
    121120       
    122121        while (true) {
    123                 if (!console_get_event(console, &ev)) {
     122                if (!console_get_kbd_event(console, &ev)) {
    124123                        return;
    125124                }
    126                 if (ev.type == CEV_KEY && ev.ev.key.type == KEY_PRESS) {
    127                         kev = &ev.ev.key;
    128                        
    129                         if (kev->key == KC_ESCAPE || kev->key == KC_Q) {
     125                if (ev.type == KEY_PRESS) {
     126                        if (ev.key == KC_ESCAPE || ev.key == KC_Q) {
    130127                                should_quit = true;
    131128                                return;
    132129                        }
    133                         if (kev->key == KC_C) {
     130                        if (ev.key == KC_C) {
    134131                                paging_enabled = false;
    135132                                return;
    136133                        }
    137                         if (kev->key == KC_ENTER || kev->key == KC_SPACE ||
    138                             kev->key == KC_PAGE_DOWN) {
     134                        if (ev.key == KC_ENTER || ev.key == KC_SPACE ||
     135                            ev.key == KC_PAGE_DOWN) {
    139136                                return;
    140137                        }
  • uspace/app/bdsh/cmds/modules/cp/cp.c

    red267bc r166a1f57  
    152152
    153153        while (true) {
    154                 cons_event_t ev;
     154                kbd_event_t ev;
    155155                console_flush(con);
    156                 console_get_event(con, &ev);
    157                 if (ev.type != CEV_KEY || ev.ev.key.type != KEY_PRESS ||
    158                     (ev.ev.key.mods & (KM_CTRL | KM_ALT)) != 0) {
     156                console_get_kbd_event(con, &ev);
     157                if ((ev.type != KEY_PRESS)
     158                    || (ev.mods & (KM_CTRL | KM_ALT)) != 0) {
    159159                        continue;
    160160                }
    161161
    162                 switch(ev.ev.key.key) {
     162                switch(ev.key) {
    163163                case KC_Y:
    164164                        printf("y\n");
  • uspace/app/edit/edit.c

    red267bc r166a1f57  
    8080        tag_t sel_start;
    8181
    82         /** Active keyboard modifiers */
    83         keymod_t keymod;
    84 
    8582        /**
    8683         * Ideal column where the caret should try to get. This is used
     
    122119static void cursor_setvis(bool visible);
    123120
    124 static void key_handle_press(kbd_event_t *ev);
    125121static void key_handle_unmod(kbd_event_t const *ev);
    126122static void key_handle_ctrl(kbd_event_t const *ev);
     
    128124static void key_handle_shift_ctrl(kbd_event_t const *ev);
    129125static void key_handle_movement(unsigned int key, bool shift);
    130 
    131 static void pos_handle(pos_event_t *ev);
    132126
    133127static int file_save(char const *fname);
     
    188182int main(int argc, char *argv[])
    189183{
    190         cons_event_t ev;
     184        kbd_event_t ev;
    191185        bool new_file;
    192186        int rc;
     
    251245
    252246        while (!done) {
    253                 console_get_event(con, &ev);
     247                console_get_kbd_event(con, &ev);
    254248                pane.rflags = 0;
    255249
    256                 switch (ev.type) {
    257                 case CEV_KEY:
    258                         pane.keymod = ev.ev.key.mods;
    259                         if (ev.ev.key.type == KEY_PRESS)
    260                                 key_handle_press(&ev.ev.key);
    261                         break;
    262                 case CEV_POS:
    263                         pos_handle(&ev.ev.pos);
    264                         break;
     250                if (ev.type == KEY_PRESS) {
     251                        /* Handle key press. */
     252                        if (((ev.mods & KM_ALT) == 0) &&
     253                            ((ev.mods & KM_SHIFT) == 0) &&
     254                             (ev.mods & KM_CTRL) != 0) {
     255                                key_handle_ctrl(&ev);
     256                        } else if (((ev.mods & KM_ALT) == 0) &&
     257                            ((ev.mods & KM_CTRL) == 0) &&
     258                             (ev.mods & KM_SHIFT) != 0) {
     259                                key_handle_shift(&ev);
     260                        } else if (((ev.mods & KM_ALT) == 0) &&
     261                            ((ev.mods & KM_CTRL) != 0) &&
     262                             (ev.mods & KM_SHIFT) != 0) {
     263                                key_handle_shift_ctrl(&ev);
     264                        } else if ((ev.mods & (KM_CTRL | KM_ALT | KM_SHIFT)) == 0) {
     265                                key_handle_unmod(&ev);
     266                        }
    265267                }
    266268
     
    284286
    285287        return 0;
    286 }
    287 
    288 /* Handle key press. */
    289 static void key_handle_press(kbd_event_t *ev)
    290 {
    291         if (((ev->mods & KM_ALT) == 0) &&
    292             ((ev->mods & KM_SHIFT) == 0) &&
    293              (ev->mods & KM_CTRL) != 0) {
    294                 key_handle_ctrl(ev);
    295         } else if (((ev->mods & KM_ALT) == 0) &&
    296             ((ev->mods & KM_CTRL) == 0) &&
    297              (ev->mods & KM_SHIFT) != 0) {
    298                 key_handle_shift(ev);
    299         } else if (((ev->mods & KM_ALT) == 0) &&
    300             ((ev->mods & KM_CTRL) != 0) &&
    301              (ev->mods & KM_SHIFT) != 0) {
    302                 key_handle_shift_ctrl(ev);
    303         } else if ((ev->mods & (KM_CTRL | KM_ALT | KM_SHIFT)) == 0) {
    304                 key_handle_unmod(ev);
    305         }
    306288}
    307289
     
    480462}
    481463
    482 static void pos_handle(pos_event_t *ev)
    483 {
    484         coord_t bc;
    485         spt_t pt;
    486         bool select;
    487 
    488         if (ev->type == POS_PRESS && ev->vpos < (unsigned)pane.rows) {
    489                 bc.row = pane.sh_row + ev->vpos;
    490                 bc.column = pane.sh_column + ev->hpos;
    491                 sheet_get_cell_pt(doc.sh, &bc, dir_before, &pt);
    492 
    493                 select = (pane.keymod & KM_SHIFT) != 0;
    494 
    495                 caret_move(pt, select, true);
    496         }
    497 }
    498 
    499464/** Move caret while preserving or resetting selection. */
    500465static void caret_move(spt_t new_caret_pt, bool select, bool update_ideal_column)
     
    627592static char *prompt(char const *prompt, char const *init_value)
    628593{
    629         cons_event_t ev;
    630         kbd_event_t *kev;
     594        kbd_event_t ev;
    631595        char *str;
    632596        wchar_t buffer[INFNAME_MAX_LEN + 1];
     
    648612
    649613        while (!done) {
    650                 console_get_event(con, &ev);
    651 
    652                 if (ev.type == CEV_KEY && ev.ev.key.type == KEY_PRESS) {
    653                         kev = &ev.ev.key;
    654 
     614                console_get_kbd_event(con, &ev);
     615
     616                if (ev.type == KEY_PRESS) {
    655617                        /* Handle key press. */
    656                         if (((kev->mods & KM_ALT) == 0) &&
    657                              (kev->mods & KM_CTRL) != 0) {
     618                        if (((ev.mods & KM_ALT) == 0) &&
     619                             (ev.mods & KM_CTRL) != 0) {
    658620                                ;
    659                         } else if ((kev->mods & (KM_CTRL | KM_ALT)) == 0) {
    660                                 switch (kev->key) {
     621                        } else if ((ev.mods & (KM_CTRL | KM_ALT)) == 0) {
     622                                switch (ev.key) {
    661623                                case KC_ESCAPE:
    662624                                        return NULL;
     
    672634                                        break;
    673635                                default:
    674                                         if (kev->c >= 32 && nc < max_len) {
    675                                                 putchar(kev->c);
     636                                        if (ev.c >= 32 && nc < max_len) {
     637                                                putchar(ev.c);
    676638                                                console_flush(con);
    677                                                 buffer[nc++] = kev->c;
     639                                                buffer[nc++] = ev.c;
    678640                                        }
    679641                                        break;
  • uspace/app/mkbd/main.c

    red267bc r166a1f57  
    178178
    179179        while (1) {
    180                 cons_event_t ev;
    181                 bool ok = console_get_event(con, &ev);
     180                kbd_event_t ev;
     181                bool ok = console_get_kbd_event(con, &ev);
    182182                if (!ok) {
    183183                        printf("Connection with console broken: %s.\n",
     
    186186                }
    187187
    188                 if (ev.type == CEV_KEY && ev.ev.key.type == KEY_PRESS &&
    189                     ev.ev.key.key == KC_ESCAPE) {
     188                if (ev.key == KC_ESCAPE) {
    190189                        break;
    191190                }
  • uspace/app/msim/arch_helenos/input.c

    red267bc r166a1f57  
    9191bool stdin_poll(char *key)
    9292{
    93         cons_event_t ev;
     93        kbd_event_t ev;
    9494        suseconds_t timeout = 0;
    9595        errno = EOK;
    9696        console_flush(input_prompt->console);
    97         bool has_input = console_get_event_timeout(input_prompt->console, &ev, &timeout);
     97        bool has_input = console_get_kbd_event_timeout(input_prompt->console, &ev, &timeout);
    9898        if (!has_input) {
    9999                return false;
    100100        }
    101101
    102         if (ev.type != CEV_KEY || ev.ev.key.type != KEY_PRESS)
     102        if (ev.type != KEY_PRESS)
    103103                return false;
    104104
    105         *key = ev.ev.key.c;
     105        *key = ev.c;
    106106
    107107        return true;
  • uspace/app/nterm/nterm.c

    red267bc r166a1f57  
    109109int main(int argc, char *argv[])
    110110{
    111         cons_event_t ev;
     111        kbd_event_t ev;
    112112        int rc;
    113113
     
    129129        done = false;
    130130        while (!done) {
    131                 console_get_event(con, &ev);
    132                 if (ev.type == CEV_KEY && ev.ev.key.type == KEY_PRESS)
    133                         key_handle(&ev.ev.key);
     131                console_get_kbd_event(con, &ev);
     132                if (ev.type == KEY_PRESS)
     133                        key_handle(&ev);
    134134        }
    135135
  • uspace/app/ping/ping.c

    red267bc r166a1f57  
    188188{
    189189        console_ctrl_t *con;
    190         cons_event_t ev;
     190        kbd_event_t ev;
    191191
    192192        con = console_init(stdin, stdout);
     
    194194
    195195        while (true) {
    196                 if (!console_get_event(con, &ev))
     196                if (!console_get_kbd_event(con, &ev))
    197197                        break;
    198198
    199                 if (ev.type == CEV_KEY && ev.ev.key.type == KEY_PRESS &&
    200                     (ev.ev.key.mods & (KM_ALT | KM_SHIFT)) ==
    201                     0 && (ev.ev.key.mods & KM_CTRL) != 0) {
     199                if (ev.type == KEY_PRESS && (ev.mods & (KM_ALT | KM_SHIFT)) ==
     200                    0 && (ev.mods & KM_CTRL) != 0) {
    202201                        /* Ctrl+key */
    203                         if (ev.ev.key.key == KC_Q) {
     202                        if (ev.key == KC_Q) {
    204203                                ping_signal_done();
    205204                                return 0;
  • uspace/app/tester/ipc/starve.c

    red267bc r166a1f57  
    6262                        break;
    6363               
    64                 cons_event_t ev;
     64                kbd_event_t ev;
    6565                suseconds_t timeout = 0;
    66                 bool has_event = console_get_event_timeout(console, &ev, &timeout);
    67                 if (has_event && ev.type == CEV_KEY && ev.ev.key.type == KEY_PRESS) {
    68                         TPRINTF("Key %d pressed, terminating.\n", ev.ev.key.key);
     66                bool has_event = console_get_kbd_event_timeout(console, &ev, &timeout);
     67                if (has_event && (ev.type == KEY_PRESS)) {
     68                        TPRINTF("Key %d pressed, terminating.\n", ev.key);
    6969                        break;
    7070                }
  • uspace/app/tetris/scores.c

    red267bc r166a1f57  
    125125        int j;
    126126        size_t off;
    127         cons_event_t ev;
    128         kbd_event_t *kev;
     127        kbd_event_t ev;
    129128       
    130129        clear_screen();
     
    142141        while (1) {
    143142                console_flush(console);
    144                 if (!console_get_event(console, &ev))
     143                if (!console_get_kbd_event(console, &ev))
    145144                        exit(1);
    146145               
    147                 if (ev.type != CEV_KEY || ev.ev.key.type == KEY_RELEASE)
     146                if (ev.type == KEY_RELEASE)
    148147                        continue;
    149148               
    150                 kev = &ev.ev.key;
    151                
    152                 if (kev->key == KC_ENTER || kev->key == KC_NENTER)
     149                if (ev.key == KC_ENTER || ev.key == KC_NENTER)
    153150                        break;
    154151               
    155                 if (kev->key == KC_BACKSPACE) {
     152                if (ev.key == KC_BACKSPACE) {
    156153                        if (i > 0) {
    157154                                wchar_t uc;
     
    169166                                scores[NUMSPOTS - 1].hs_name[off] = '\0';
    170167                        }
    171                 } else if (kev->c != '\0') {
     168                } else if (ev.c != '\0') {
    172169                        if (i < (MAXLOGNAME - 1)) {
    173                                 if (chr_encode(kev->c, scores[NUMSPOTS - 1].hs_name,
     170                                if (chr_encode(ev.c, scores[NUMSPOTS - 1].hs_name,
    174171                                    &off, STR_BOUNDS(MAXLOGNAME) + 1) == EOK) {
    175172                                        ++i;
  • uspace/app/tetris/screen.c

    red267bc r166a1f57  
    344344       
    345345        while (timeout > 0) {
    346                 cons_event_t event;
    347                
    348                 if (!console_get_event_timeout(console, &event, &timeout))
     346                kbd_event_t event;
     347               
     348                if (!console_get_kbd_event_timeout(console, &event, &timeout))
    349349                        break;
    350350        }
     
    376376       
    377377        while (c == 0) {
    378                 cons_event_t event;
    379                
    380                 if (!console_get_event_timeout(console, &event, &timeleft)) {
     378                kbd_event_t event;
     379               
     380                if (!console_get_kbd_event_timeout(console, &event, &timeleft)) {
    381381                        timeleft = 0;
    382382                        return -1;
    383383                }
    384384               
    385                 if (event.type == CEV_KEY && event.ev.key.type == KEY_PRESS)
    386                         c = event.ev.key.c;
     385                if (event.type == KEY_PRESS)
     386                        c = event.c;
    387387        }
    388388       
     
    398398       
    399399        while (c == 0) {
    400                 cons_event_t event;
    401                
    402                 if (!console_get_event(console, &event))
     400                kbd_event_t event;
     401               
     402                if (!console_get_kbd_event(console, &event))
    403403                        return -1;
    404404               
    405                 if (event.type == CEV_KEY && event.ev.key.type == KEY_PRESS)
    406                         c = event.ev.key.c;
     405                if (event.type == KEY_PRESS)
     406                        c = event.c;
    407407        }
    408408       
  • uspace/app/top/screen.c

    red267bc r166a1f57  
    556556       
    557557        while (c == 0) {
    558                 cons_event_t event;
     558                kbd_event_t event;
    559559               
    560560                warning_timeleft -= timeleft;
    561                 if (!console_get_event_timeout(console, &event, &timeleft)) {
     561                if (!console_get_kbd_event_timeout(console, &event, &timeleft)) {
    562562                        timeleft = 0;
    563563                        return -1;
     
    565565                warning_timeleft += timeleft;
    566566               
    567                 if (event.type == CEV_KEY && event.ev.key.type == KEY_PRESS)
    568                         c = event.ev.key.c;
     567                if (event.type == KEY_PRESS)
     568                        c = event.c;
    569569        }
    570570       
  • uspace/app/trace/trace.c

    red267bc r166a1f57  
    565565static int cev_fibril(void *arg)
    566566{
    567         cons_event_t event;
    568 
    569567        (void) arg;
    570568       
     
    577575                fibril_mutex_unlock(&state_lock);
    578576               
    579                 if (!console_get_event(console, &event))
     577                if (!console_get_kbd_event(console, &cev))
    580578                        return -1;
    581579               
    582                 if (event.type == CEV_KEY) {
    583                         fibril_mutex_lock(&state_lock);
    584                         cev = event.ev.key;
    585                         cev_valid = true;
    586                         fibril_condvar_broadcast(&state_cv);
    587                         fibril_mutex_unlock(&state_lock);
    588                 }
     580                fibril_mutex_lock(&state_lock);
     581                cev_valid = true;
     582                fibril_condvar_broadcast(&state_cv);
     583                fibril_mutex_unlock(&state_lock);
    589584        }
    590585}
  • uspace/dist/src/c/demos/tetris/scores.c

    red267bc r166a1f57  
    125125        int j;
    126126        size_t off;
    127         cons_event_t ev;
    128         kbd_event_t *kev;
     127        kbd_event_t ev;
    129128       
    130129        clear_screen();
     
    142141        while (1) {
    143142                console_flush(console);
    144                 if (!console_get_event(console, &ev))
     143                if (!console_get_kbd_event(console, &ev))
    145144                        exit(1);
    146145               
    147                 if (ev.type != CEV_KEY || ev.ev.key.type == KEY_RELEASE)
     146                if (ev.type == KEY_RELEASE)
    148147                        continue;
    149148               
    150                 kev = &ev.ev.key;
    151                
    152                 if (kev->key == KC_ENTER || kev->key == KC_NENTER)
     149                if (ev.key == KC_ENTER || ev.key == KC_NENTER)
    153150                        break;
    154151               
    155                 if (kev->key == KC_BACKSPACE) {
     152                if (ev.key == KC_BACKSPACE) {
    156153                        if (i > 0) {
    157154                                wchar_t uc;
     
    169166                                scores[NUMSPOTS - 1].hs_name[off] = '\0';
    170167                        }
    171                 } else if (kev->c != '\0') {
     168                } else if (ev.c != '\0') {
    172169                        if (i < (MAXLOGNAME - 1)) {
    173                                 if (chr_encode(kev->c, scores[NUMSPOTS - 1].hs_name,
     170                                if (chr_encode(ev.c, scores[NUMSPOTS - 1].hs_name,
    174171                                    &off, STR_BOUNDS(MAXLOGNAME) + 1) == EOK) {
    175172                                        ++i;
  • uspace/dist/src/c/demos/top/screen.c

    red267bc r166a1f57  
    553553       
    554554        while (c == 0) {
    555                 cons_event_t event;
    556                
    557                 if (!console_get_event_timeout(console, &event, &timeleft)) {
     555                kbd_event_t event;
     556               
     557                if (!console_get_kbd_event_timeout(console, &event, &timeleft)) {
    558558                        timeleft = 0;
    559559                        return -1;
    560560                }
    561561               
    562                 if (event.type == CEV_KEY && event.ev.key.type == KEY_PRESS)
    563                         c = event.ev.key.c;
     562                if (event.type == KEY_PRESS)
     563                        c = event.c;
    564564        }
    565565       
  • uspace/lib/c/generic/io/con_srv.c

    red267bc r166a1f57  
    3535 */
    3636#include <errno.h>
    37 #include <io/cons_event.h>
    3837#include <ipc/console.h>
    3938#include <stdlib.h>
     
    4140
    4241#include <io/con_srv.h>
    43 
    44 static 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 }
    6742
    6843static void con_read_srv(con_srv_t *srv, ipc_callid_t callid,
     
    298273{
    299274        int rc;
    300         cons_event_t event;
    301         ipc_call_t result;
     275        kbd_event_t event;
    302276
    303277        if (srv->srvs->ops->get_event == NULL) {
     
    307281
    308282        rc = srv->srvs->ops->get_event(srv, &event);
    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));
     283        async_answer_4(callid, rc, event.type, event.key, event.mods, event.c);
    322284}
    323285
  • uspace/lib/c/generic/io/console.c

    red267bc r166a1f57  
    154154}
    155155
    156 static 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 
    181 bool console_get_event(console_ctrl_t *ctrl, cons_event_t *event)
     156bool console_get_kbd_event(console_ctrl_t *ctrl, kbd_event_t *event)
    182157{
    183158        if (ctrl->input_aid == 0) {
    184                 ipc_call_t result;
     159                sysarg_t type;
     160                sysarg_t key;
     161                sysarg_t mods;
     162                sysarg_t c;
    185163               
    186164                async_exch_t *exch = async_exchange_begin(ctrl->input_sess);
    187                 aid_t aid = async_send_0(exch, CONSOLE_GET_EVENT, &result);
     165                int rc = async_req_0_4(exch, CONSOLE_GET_EVENT, &type, &key, &mods, &c);
    188166                async_exchange_end(exch);
    189                
    190                 sysarg_t rc;
    191                 async_wait_for(aid, &rc);
    192167               
    193168                if (rc != EOK) {
     
    196171                }
    197172               
    198                 rc = console_ev_decode(&result, event);
    199                 if (rc != EOK) {
    200                         errno = rc;
    201                         return false;
    202                 }
     173                event->type = type;
     174                event->key = key;
     175                event->mods = mods;
     176                event->c = c;
    203177        } else {
    204178                sysarg_t retval;
     
    212186                }
    213187               
    214                 int rc = console_ev_decode(&ctrl->input_call, event);
    215                 if (rc != EOK) {
    216                         errno = rc;
    217                         return false;
    218                 }
     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);
    219192        }
    220193       
     
    222195}
    223196
    224 bool console_get_event_timeout(console_ctrl_t *ctrl, cons_event_t *event,
     197bool console_get_kbd_event_timeout(console_ctrl_t *ctrl, kbd_event_t *event,
    225198    suseconds_t *timeout)
    226199{
     
    250223        }
    251224       
    252         rc = console_ev_decode(&ctrl->input_call, event);
    253         if (rc != EOK) {
    254                 errno = rc;
    255                 return false;
    256         }
     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);
    257229       
    258230        /* Update timeout */
  • uspace/lib/c/include/io/con_srv.h

    red267bc r166a1f57  
    4141#include <io/color.h>
    4242#include <io/concaps.h>
    43 #include <io/cons_event.h>
     43#include <io/kbd_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 *, cons_event_t *);
     84        int (*get_event)(con_srv_t *, kbd_event_t *);
    8585} con_ops_t;
    8686
  • uspace/lib/c/include/io/console.h

    red267bc r166a1f57  
    3939#include <io/concaps.h>
    4040#include <io/kbd_event.h>
    41 #include <io/cons_event.h>
    4241#include <io/keycode.h>
    4342#include <async.h>
     
    8382extern void console_cursor_visibility(console_ctrl_t *, bool);
    8483extern int console_get_color_cap(console_ctrl_t *, sysarg_t *);
    85 extern bool console_get_event(console_ctrl_t *, cons_event_t *);
    86 extern bool console_get_event_timeout(console_ctrl_t *, cons_event_t *,
     84extern bool console_get_kbd_event(console_ctrl_t *, kbd_event_t *);
     85extern bool console_get_kbd_event_timeout(console_ctrl_t *, kbd_event_t *,
    8786    suseconds_t *);
    8887
  • uspace/lib/clui/tinput.c

    red267bc r166a1f57  
    4545#define LIN_TO_COL(ti, lpos) ((lpos) % ((ti)->con_cols))
    4646#define LIN_TO_ROW(ti, lpos) ((lpos) / ((ti)->con_cols))
    47 #define LIN_POS(ti, col, row) ((col) + (row) * (ti)->con_cols)
    4847
    4948/** Seek direction */
     
    381380        }
    382381       
    383         tinput_post_seek(ti, shift_held);
    384 }
    385 
    386 static void tinput_seek_scrpos(tinput_t *ti, int col, int line, bool shift_held)
    387 {
    388         unsigned lpos;
    389         tinput_pre_seek(ti, shift_held);
    390 
    391         lpos = LIN_POS(ti, col, line);
    392 
    393         if (lpos > ti->text_coord)
    394                 ti->pos = lpos -  ti->text_coord;
    395         else
    396                 ti->pos = 0;
    397         if (ti->pos > ti->nc)
    398                 ti->pos = ti->nc;
    399 
    400382        tinput_post_seek(ti, shift_held);
    401383}
     
    805787}
    806788
    807 /** Handle key press event. */
    808 static void tinput_key_press(tinput_t *ti, kbd_event_t *kev)
    809 {
    810         if (kev->key == KC_LSHIFT)
    811                 ti->lshift_held = true;
    812         if (kev->key == KC_RSHIFT)
    813                 ti->rshift_held = true;
    814 
    815         if (((kev->mods & KM_CTRL) != 0) &&
    816             ((kev->mods & (KM_ALT | KM_SHIFT)) == 0))
    817                 tinput_key_ctrl(ti, kev);
    818        
    819         if (((kev->mods & KM_SHIFT) != 0) &&
    820             ((kev->mods & (KM_CTRL | KM_ALT)) == 0))
    821                 tinput_key_shift(ti, kev);
    822        
    823         if (((kev->mods & KM_CTRL) != 0) &&
    824             ((kev->mods & KM_SHIFT) != 0) &&
    825             ((kev->mods & KM_ALT) == 0))
    826                 tinput_key_ctrl_shift(ti, kev);
    827        
    828         if ((kev->mods & (KM_CTRL | KM_ALT | KM_SHIFT)) == 0)
    829                 tinput_key_unmod(ti, kev);
    830        
    831         if (kev->c >= ' ') {
    832                 tinput_sel_delete(ti);
    833                 tinput_insert_char(ti, kev->c);
    834         }
    835 }
    836 
    837 /** Handle key release event. */
    838 static void tinput_key_release(tinput_t *ti, kbd_event_t *kev)
    839 {
    840         if (kev->key == KC_LSHIFT)
    841                 ti->lshift_held = false;
    842         if (kev->key == KC_RSHIFT)
    843                 ti->rshift_held = false;
    844 }
    845 
    846 /** Position event */
    847 static void tinput_pos(tinput_t *ti, pos_event_t *ev)
    848 {
    849         if (ev->type == POS_PRESS) {
    850                 tinput_seek_scrpos(ti, ev->hpos, ev->vpos,
    851                     ti->lshift_held || ti->rshift_held);
    852         }
    853 }
    854 
    855789/** Read in one line of input.
    856790 *
     
    882816                console_flush(ti->console);
    883817               
    884                 cons_event_t ev;
    885                 if (!console_get_event(ti->console, &ev))
     818                kbd_event_t ev;
     819                if (!console_get_kbd_event(ti->console, &ev))
    886820                        return EIO;
    887821               
    888                 switch (ev.type) {
    889                 case CEV_KEY:
    890                         if (ev.ev.key.type == KEY_PRESS)
    891                                 tinput_key_press(ti, &ev.ev.key);
    892                         else
    893                                 tinput_key_release(ti, &ev.ev.key);
    894                         break;
    895                 case CEV_POS:
    896                         tinput_pos(ti, &ev.ev.pos);
    897                         break;
     822                if (ev.type != KEY_PRESS)
     823                        continue;
     824               
     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 >= ' ') {
     842                        tinput_sel_delete(ti);
     843                        tinput_insert_char(ti, ev.c);
    898844                }
    899845        }
  • uspace/lib/clui/tinput.h

    red267bc r166a1f57  
    146146        /** @c true if user requested to abort interactive loop */
    147147        bool exit_clui;
    148 
    149         /** @c true if left shift key is currently held */
    150         bool lshift_held;
    151 
    152         /** @c true if right shift key is currently held */
    153         bool rshift_held;
    154148} tinput_t;
    155149
  • uspace/lib/gui/terminal.c

    red267bc r166a1f57  
    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 *, cons_event_t *);
     79static int term_get_event(con_srv_t *, kbd_event_t *);
    8080
    8181static con_ops_t con_ops = {
     
    420420                if (pos < size) {
    421421                        link_t *link = prodcons_consume(&term->input_pc);
    422                         cons_event_t *event = list_get_instance(link, cons_event_t, link);
     422                        kbd_event_t *event = list_get_instance(link, kbd_event_t, link);
    423423                       
    424424                        /* Accept key presses of printable chars only. */
    425                         if (event->type == CEV_KEY && event->ev.key.type == KEY_PRESS &&
    426                             event->ev.key.c != 0) {
     425                        if ((event->type == KEY_PRESS) && (event->c != 0)) {
    427426                                wchar_t tmp[2] = {
    428                                         event->ev.key.c,
     427                                        event->c,
    429428                                        0
    430429                                };
     
    580579}
    581580
    582 static int term_get_event(con_srv_t *srv, cons_event_t *event)
     581static int term_get_event(con_srv_t *srv, kbd_event_t *event)
    583582{
    584583        terminal_t *term = srv_to_terminal(srv);
    585584        link_t *link = prodcons_consume(&term->input_pc);
    586         cons_event_t *ev = list_get_instance(link, cons_event_t, link);
    587        
    588         *event = *ev;
    589         free(ev);
     585        kbd_event_t *kevent = list_get_instance(link, kbd_event_t, link);
     586       
     587        *event = *kevent;
     588        free(kevent);
    590589        return EOK;
    591590}
     
    635634}
    636635
    637 static void terminal_queue_cons_event(terminal_t *term, cons_event_t *ev)
    638 {
     636static void terminal_handle_keyboard_event(widget_t *widget,
     637    kbd_event_t kbd_event)
     638{
     639        terminal_t *term = (terminal_t *) widget;
     640       
    639641        /* Got key press/release event */
    640         cons_event_t *event =
    641             (cons_event_t *) malloc(sizeof(cons_event_t));
     642        kbd_event_t *event =
     643            (kbd_event_t *) malloc(sizeof(kbd_event_t));
    642644        if (event == NULL)
    643645                return;
    644646       
    645         *event = *ev;
    646647        link_initialize(&event->link);
     648        event->type = kbd_event.type;
     649        event->key = kbd_event.key;
     650        event->mods = kbd_event.mods;
     651        event->c = kbd_event.c;
    647652       
    648653        prodcons_produce(&term->input_pc, &event->link);
    649654}
    650655
    651 /* Got key press/release event */
    652 static void terminal_handle_keyboard_event(widget_t *widget,
    653     kbd_event_t kbd_event)
    654 {
    655         terminal_t *term = (terminal_t *) widget;
    656         cons_event_t event;
    657        
    658         event.type = CEV_KEY;
    659         event.ev.key = kbd_event;
    660        
    661         terminal_queue_cons_event(term, &event);
    662 }
    663 
    664 static void terminal_handle_position_event(widget_t *widget, pos_event_t pos_event)
    665 {
    666         cons_event_t event;
    667         terminal_t *term = (terminal_t *) widget;
    668         sysarg_t sx = term->widget.hpos;
    669         sysarg_t sy = term->widget.vpos;
    670 
    671         if (pos_event.type == POS_PRESS) {
    672                 event.type = CEV_POS;
    673                 event.ev.pos.type = pos_event.type;
    674                 event.ev.pos.pos_id = pos_event.pos_id;
    675                 event.ev.pos.btn_num = pos_event.btn_num;
    676 
    677                 event.ev.pos.hpos = (pos_event.hpos - sx) / FONT_WIDTH;
    678                 event.ev.pos.vpos = (pos_event.vpos - sy) / FONT_SCANLINES;
    679                 terminal_queue_cons_event(term, &event);
    680         }
     656static void terminal_handle_position_event(widget_t *widget, pos_event_t event)
     657{
     658        /*
     659         * Mouse events are ignored so far.
     660         * There is no consumer for it.
     661         */
    681662}
    682663
  • uspace/srv/hid/console/console.c

    red267bc r166a1f57  
    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 *, cons_event_t *);
     131static int cons_get_event(con_srv_t *, kbd_event_t *);
    132132
    133133static con_ops_t con_ops = {
     
    490490}
    491491
    492 static int cons_get_event(con_srv_t *srv, cons_event_t *event)
     492static int cons_get_event(con_srv_t *srv, kbd_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->type = CEV_KEY;
    499         event->ev.key = *kevent;
     498        *event = *kevent;
    500499        free(kevent);
    501500        return EOK;
  • uspace/srv/hid/remcons/remcons.c

    red267bc r166a1f57  
    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 *, cons_event_t *);
     82static int remcons_get_event(con_srv_t *, kbd_event_t *);
    8383
    8484static con_ops_t con_ops = {
     
    185185}
    186186
    187 static 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;
     187static int remcons_get_event(con_srv_t *srv, kbd_event_t *event)
     188{
     189        telnet_user_t *user = srv_to_user(srv);
    191190        int rc;
    192191
    193         rc = telnet_user_get_next_keyboard_event(user, &kevent);
     192        rc = telnet_user_get_next_keyboard_event(user, event);
    194193        if (rc != EOK) {
    195194                /* XXX What? */
     
    197196                return EOK;
    198197        }
    199 
    200         event->type = CEV_KEY;
    201         event->ev.key = kevent;
    202198
    203199        return EOK;
Note: See TracChangeset for help on using the changeset viewer.