Changeset 8565a42 in mainline for uspace/srv/hid/input


Ignore:
Timestamp:
2018-03-02T20:34:50Z (8 years ago)
Author:
GitHub <noreply@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
a1a81f69, d5e5fd1
Parents:
3061bc1 (diff), 34e1206 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
git-author:
Jiří Zárevúcky <zarevucky.jiri@…> (2018-03-02 20:34:50)
git-committer:
GitHub <noreply@…> (2018-03-02 20:34:50)
Message:

Remove all trailing whitespace, everywhere.

See individual commit messages for details.

Location:
uspace/srv/hid/input
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/hid/input/ctl/kbdev.c

    r3061bc1 r8565a42  
    6666        /** Link to generic keyboard device */
    6767        kbd_dev_t *kbd_dev;
    68        
     68
    6969        /** Session with kbdev device */
    7070        async_sess_t *sess;
     
    7676        if (kbdev == NULL)
    7777                return NULL;
    78        
     78
    7979        kbdev->kbd_dev = kdev;
    8080
     
    8686        if (kbdev->sess != NULL)
    8787                async_hangup(kbdev->sess);
    88        
     88
    8989        free(kbdev);
    9090}
     
    9999                return ENOENT;
    100100        }
    101        
     101
    102102        kbdev_t *kbdev = kbdev_new(kdev);
    103103        if (kbdev == NULL) {
     
    107107                return ENOMEM;
    108108        }
    109        
     109
    110110        kbdev->sess = sess;
    111        
     111
    112112        async_exch_t *exch = async_exchange_begin(sess);
    113113        if (exch == NULL) {
     
    117117                return ENOENT;
    118118        }
    119        
     119
    120120        port_id_t port;
    121121        errno_t rc = async_create_callback_port(exch, INTERFACE_KBD_CB, 0, 0,
    122122            kbdev_callback_conn, kbdev, &port);
    123        
     123
    124124        if (rc != EOK) {
    125125                printf("%s: Failed creating callback connection from '%s'.\n",
     
    129129                return rc;
    130130        }
    131        
     131
    132132        async_exchange_end(exch);
    133        
     133
    134134        kdev->ctl_private = (void *) kbdev;
    135135        return 0;
     
    142142        if (!exch)
    143143                return;
    144        
     144
    145145        async_msg_1(exch, KBDEV_SET_IND, mods);
    146146        async_exchange_end(exch);
  • uspace/srv/hid/input/gsp.c

    r3061bc1 r8565a42  
    7979        trans_key_t *trans_key = (trans_key_t *)key;
    8080        gsp_trans_t *t = hash_table_get_inst(item, gsp_trans_t, link);
    81        
     81
    8282        return trans_key->input == t->input && trans_key->old_state == t->old_state;
    8383}
     
    245245{
    246246        ht_link_t *item;
    247        
     247
    248248        trans_key_t key = {
    249249                .input = input,
  • uspace/srv/hid/input/input.c

    r3061bc1 r8565a42  
    7878        /** Link into the list of clients */
    7979        link_t link;
    80        
     80
    8181        /** Indicate whether the client is active */
    8282        bool active;
    83        
     83
    8484        /** Client callback session */
    8585        async_sess_t *sess;
     
    112112        if (client == NULL)
    113113                return NULL;
    114        
     114
    115115        link_initialize(&client->link);
    116116        client->active = false;
    117117        client->sess = NULL;
    118        
     118
    119119        list_append(&client->link, &clients);
    120        
     120
    121121        return client;
    122122}
     
    125125{
    126126        client_t *client = (client_t *) data;
    127        
     127
    128128        list_remove(&client->link);
    129129        free(client);
     
    144144        kbd_event_t ev;
    145145        unsigned int mod_mask;
    146        
     146
    147147        switch (key) {
    148148        case KC_LCTRL:
     
    167167                mod_mask = 0;
    168168        }
    169        
     169
    170170        if (mod_mask != 0) {
    171171                if (type == KEY_PRESS)
     
    174174                        kdev->mods = kdev->mods & ~mod_mask;
    175175        }
    176        
     176
    177177        switch (key) {
    178178        case KC_CAPS_LOCK:
     
    188188                mod_mask = 0;
    189189        }
    190        
     190
    191191        if (mod_mask != 0) {
    192192                if (type == KEY_PRESS) {
     
    198198                        kdev->mods = kdev->mods ^ (mod_mask & ~kdev->lock_keys);
    199199                        kdev->lock_keys = kdev->lock_keys | mod_mask;
    200                        
     200
    201201                        /* Update keyboard lock indicator lights. */
    202202                        (*kdev->ctl_ops->set_ind)(kdev, kdev->mods);
     
    205205                }
    206206        }
    207        
     207
    208208        // TODO: More elegant layout switching
    209        
     209
    210210        if ((type == KEY_PRESS) && (kdev->mods & KM_LCTRL) &&
    211211            (key == KC_F1)) {
     
    214214                return;
    215215        }
    216        
     216
    217217        if ((type == KEY_PRESS) && (kdev->mods & KM_LCTRL) &&
    218218            (key == KC_F2)) {
     
    221221                return;
    222222        }
    223        
     223
    224224        if ((type == KEY_PRESS) && (kdev->mods & KM_LCTRL) &&
    225225            (key == KC_F3)) {
     
    228228                return;
    229229        }
    230        
     230
    231231        if ((type == KEY_PRESS) && (kdev->mods & KM_LCTRL) &&
    232232            (key == KC_F4)) {
     
    235235                return;
    236236        }
    237        
     237
    238238        ev.type = type;
    239239        ev.key = key;
    240240        ev.mods = kdev->mods;
    241        
     241
    242242        ev.c = layout_parse_ev(kdev->active_layout, &ev);
    243        
     243
    244244        list_foreach(clients, link, client_t, client) {
    245245                if (client->active) {
     
    257257                if (client->active) {
    258258                        async_exch_t *exch = async_exchange_begin(client->sess);
    259                        
     259
    260260                        if ((dx) || (dy))
    261261                                async_msg_2(exch, INPUT_EVENT_MOVE, dx, dy);
    262                        
     262
    263263                        if (dz) {
    264264                                // TODO: Implement proper wheel support
    265265                                keycode_t code = dz > 0 ? KC_UP : KC_DOWN;
    266                                
     266
    267267                                for (unsigned int i = 0; i < 3; i++)
    268268                                        async_msg_4(exch, INPUT_EVENT_KEY, KEY_PRESS, code, 0, 0);
    269                                
     269
    270270                                async_msg_4(exch, INPUT_EVENT_KEY, KEY_RELEASE, code, 0, 0);
    271271                        }
    272                        
     272
    273273                        async_exchange_end(exch);
    274274                }
     
    309309        list_foreach(clients, link, client_t, client)
    310310                client->active = ((active) && (client == active_client));
    311        
     311
    312312        /* Notify clients about the arbitration */
    313313        list_foreach(clients, link, client_t, client) {
     
    327327                return;
    328328        }
    329        
     329
    330330        async_answer_0(iid, EOK);
    331        
     331
    332332        while (true) {
    333333                ipc_call_t call;
    334334                ipc_callid_t callid = async_get_call(&call);
    335                
     335
    336336                if (!IPC_GET_IMETHOD(call)) {
    337337                        if (client->sess != NULL) {
     
    339339                                client->sess = NULL;
    340340                        }
    341                        
     341
    342342                        async_answer_0(callid, EOK);
    343343                        return;
    344344                }
    345                
     345
    346346                async_sess_t *sess =
    347347                    async_callback_receive_start(EXCHANGE_SERIALIZE, &call);
     
    375375                active = true;
    376376        }
    377        
     377
    378378        client_arbitration();
    379379}
     
    387387                return NULL;
    388388        }
    389        
     389
    390390        link_initialize(&kdev->link);
    391        
     391
    392392        kdev->mods = KM_NUM_LOCK;
    393393        kdev->lock_keys = 0;
    394394        kdev->active_layout = layout_create(layout[0]);
    395        
     395
    396396        return kdev;
    397397}
     
    405405                return NULL;
    406406        }
    407        
     407
    408408        link_initialize(&mdev->link);
    409        
     409
    410410        return mdev;
    411411}
     
    419419                return NULL;
    420420        }
    421        
     421
    422422        sdev->kdev = kbd_dev_new();
    423423        if (sdev->kdev == NULL) {
     
    427427
    428428        link_initialize(&sdev->link);
    429        
     429
    430430        return sdev;
    431431}
     
    437437        if (kdev == NULL)
    438438                return;
    439        
     439
    440440        kdev->port_ops = port;
    441441        kdev->ctl_ops = ctl;
    442442        kdev->svc_id = 0;
    443        
     443
    444444        /* Initialize port driver. */
    445445        if ((*kdev->port_ops->init)(kdev) != 0)
    446446                goto fail;
    447        
     447
    448448        /* Initialize controller driver. */
    449449        if ((*kdev->ctl_ops->init)(kdev) != 0) {
     
    451451                goto fail;
    452452        }
    453        
     453
    454454        list_append(&kdev->link, &kbd_devs);
    455455        return;
    456        
     456
    457457fail:
    458458        free(kdev);
     
    469469        if (kdev == NULL)
    470470                return -1;
    471        
     471
    472472        kdev->svc_id = service_id;
    473473        kdev->port_ops = NULL;
    474474        kdev->ctl_ops = &kbdev_ctl;
    475        
     475
    476476        errno_t rc = loc_service_get_name(service_id, &kdev->svc_name);
    477477        if (rc != EOK) {
     
    479479                goto fail;
    480480        }
    481        
     481
    482482        /* Initialize controller driver. */
    483483        if ((*kdev->ctl_ops->init)(kdev) != 0) {
    484484                goto fail;
    485485        }
    486        
     486
    487487        list_append(&kdev->link, &kbd_devs);
    488488        *kdevp = kdev;
    489489        return 0;
    490        
     490
    491491fail:
    492492        if (kdev->svc_name != NULL)
     
    506506        if (mdev == NULL)
    507507                return -1;
    508        
     508
    509509        mdev->svc_id = service_id;
    510510        mdev->port_ops = NULL;
    511511        mdev->proto_ops = &mousedev_proto;
    512        
     512
    513513        errno_t rc = loc_service_get_name(service_id, &mdev->svc_name);
    514514        if (rc != EOK) {
     
    516516                goto fail;
    517517        }
    518        
     518
    519519        /* Initialize controller driver. */
    520520        if ((*mdev->proto_ops->init)(mdev) != 0) {
    521521                goto fail;
    522522        }
    523        
     523
    524524        list_append(&mdev->link, &mouse_devs);
    525525        *mdevp = mdev;
    526526        return 0;
    527        
     527
    528528fail:
    529529        free(mdev);
     
    560560        if (sdev == NULL)
    561561                return -1;
    562        
     562
    563563        sdev->kdev->svc_id = service_id;
    564        
     564
    565565        rc = loc_service_get_name(service_id, &sdev->kdev->svc_name);
    566566        if (rc != EOK)
     
    598598                fibril_add_ready(fid);
    599599        }
    600        
     600
    601601        *sdevp = sdev;
    602602        return 0;
    603        
     603
    604604fail:
    605605        if (sdev->kdev->svc_name != NULL)
     
    641641        bool already_known;
    642642        errno_t rc;
    643        
     643
    644644        rc = loc_category_get_id("keyboard", &keyboard_cat, IPC_FLAG_BLOCKING);
    645645        if (rc != EOK) {
     
    647647                return ENOENT;
    648648        }
    649        
     649
    650650        /*
    651651         * Check for new keyboard devices
     
    660660        for (i = 0; i < count; i++) {
    661661                already_known = false;
    662                
     662
    663663                /* Determine whether we already know this device. */
    664664                list_foreach(kbd_devs, link, kbd_dev_t, kdev) {
     
    668668                        }
    669669                }
    670                
     670
    671671                if (!already_known) {
    672672                        kbd_dev_t *kdev;
     
    677677                }
    678678        }
    679        
     679
    680680        free(svcs);
    681        
     681
    682682        /* XXX Handle device removal */
    683        
     683
    684684        return EOK;
    685685}
     
    692692        bool already_known;
    693693        errno_t rc;
    694        
     694
    695695        rc = loc_category_get_id("mouse", &mouse_cat, IPC_FLAG_BLOCKING);
    696696        if (rc != EOK) {
     
    698698                return ENOENT;
    699699        }
    700        
     700
    701701        /*
    702702         * Check for new mouse devices
     
    708708                return EIO;
    709709        }
    710        
     710
    711711        for (i = 0; i < count; i++) {
    712712                already_known = false;
    713                
     713
    714714                /* Determine whether we already know this device. */
    715715                list_foreach(mouse_devs, link, mouse_dev_t, mdev) {
     
    719719                        }
    720720                }
    721                
     721
    722722                if (!already_known) {
    723723                        mouse_dev_t *mdev;
     
    728728                }
    729729        }
    730        
     730
    731731        free(svcs);
    732        
     732
    733733        /* XXX Handle device removal */
    734        
     734
    735735        return EOK;
    736736}
     
    743743        bool already_known;
    744744        errno_t rc;
    745        
     745
    746746        rc = loc_category_get_id("serial", &serial_cat, IPC_FLAG_BLOCKING);
    747747        if (rc != EOK) {
     
    749749                return ENOENT;
    750750        }
    751        
     751
    752752        /*
    753753         * Check for new serial devices
     
    762762        for (i = 0; i < count; i++) {
    763763                already_known = false;
    764                
     764
    765765                /* Determine whether we already know this device. */
    766766                list_foreach(serial_devs, link, serial_dev_t, sdev) {
     
    770770                        }
    771771                }
    772                
     772
    773773                if (!already_known) {
    774774                        serial_dev_t *sdev;
     
    779779                }
    780780        }
    781        
     781
    782782        free(svcs);
    783        
     783
    784784        /* XXX Handle device removal */
    785        
     785
    786786        return EOK;
    787787}
     
    790790{
    791791        errno_t rc;
    792        
     792
    793793        fibril_mutex_lock(&discovery_lock);
    794        
     794
    795795        if (!serial_console) {
    796796                rc = dev_check_new_kbdevs();
     
    799799                        return rc;
    800800                }
    801        
     801
    802802                rc = dev_check_new_mousedevs();
    803803                if (rc != EOK) {
     
    812812                }
    813813        }
    814        
     814
    815815        fibril_mutex_unlock(&discovery_lock);
    816        
     816
    817817        return EOK;
    818818}
     
    832832                return rc;
    833833        }
    834        
     834
    835835        return dev_check_new();
    836836}
     
    849849                return 1;
    850850        }
    851        
     851
    852852        printf("%s: HelenOS input service\n", NAME);
    853        
     853
    854854        list_initialize(&clients);
    855855        list_initialize(&kbd_devs);
    856856        list_initialize(&mouse_devs);
    857857        list_initialize(&serial_devs);
    858        
     858
    859859        serial_console = config_get_value("console");
    860        
     860
    861861        /* Add legacy keyboard devices. */
    862862        kbd_add_legacy_devs();
    863        
     863
    864864        /* Register driver */
    865865        async_set_client_data_constructor(client_data_create);
    866866        async_set_client_data_destructor(client_data_destroy);
    867867        async_set_fallback_port_handler(client_connection, NULL);
    868        
     868
    869869        rc = loc_server_register(NAME);
    870870        if (rc != EOK) {
     
    872872                return rc;
    873873        }
    874        
     874
    875875        service_id_t service_id;
    876876        rc = loc_service_register(argv[1], &service_id);
     
    879879                return rc;
    880880        }
    881        
     881
    882882        /* Receive kernel notifications */
    883883        rc = async_event_subscribe(EVENT_KCONSOLE, kconsole_event_handler, NULL);
     
    885885                printf("%s: Failed to register kconsole notifications (%s)\n",
    886886                    NAME, str_error(rc));
    887        
     887
    888888        /* Start looking for new input devices */
    889889        input_start_dev_discovery();
    890        
     890
    891891        printf("%s: Accepting connections\n", NAME);
    892892        task_retval(0);
    893893        async_manager();
    894        
     894
    895895        /* Not reached. */
    896896        return 0;
  • uspace/srv/hid/input/layout/ar.c

    r3061bc1 r8565a42  
    7676        [KC_PERIOD] = L'ز',
    7777        [KC_SLASH] = L'ظ',
    78        
     78
    7979        [KC_Q] = L'ض',
    8080        [KC_W] = L'ص',
     
    134134        [KC_PERIOD] = '.',
    135135        [KC_SLASH] = L'؟',
    136        
     136
    137137        [KC_Q] = L'َ',
    138138        [KC_W] = L'ً',
     
    220220        if (c != 0)
    221221                return c;
    222        
     222
    223223        if ((ev->mods & KM_SHIFT) != 0)
    224224                c = translate(ev->key, map_shifted, sizeof(map_shifted) / sizeof(wchar_t));
  • uspace/srv/hid/input/layout/cz.c

    r3061bc1 r8565a42  
    412412        if (ev->type != KEY_PRESS)
    413413                return 0;
    414        
     414
    415415        if (key_is_mod(ev->key))
    416416                return 0;
    417        
     417
    418418        switch (cz_state->mstate) {
    419419        case ms_start:
     
    424424                return parse_ms_carka(cz_state, ev);
    425425        }
    426        
     426
    427427        return 0;
    428428}
  • uspace/srv/hid/input/mouse.h

    r3061bc1 r8565a42  
    4747        /** Link to mouse_devs list */
    4848        link_t link;
    49        
     49
    5050        /** Service ID (only for mousedev devices) */
    5151        service_id_t svc_id;
    52        
     52
    5353        /** Device service name (only for mousedev devices) */
    5454        char *svc_name;
    55        
     55
    5656        /** Port ops */
    5757        struct mouse_port_ops *port_ops;
    58        
     58
    5959        /** Protocol ops */
    6060        struct mouse_proto_ops *proto_ops;
  • uspace/srv/hid/input/port/chardev.c

    r3061bc1 r8565a42  
    7575        fid_t fid;
    7676        errno_t rc;
    77        
     77
    7878        kbd_dev = kdev;
    7979again:
     
    8383                        break;
    8484        }
    85        
     85
    8686        if (i >= num_devs) {
    8787                /* XXX This is just a hack. */
     
    9090                goto again;
    9191        }
    92        
     92
    9393        dev_sess = loc_service_connect(service_id, INTERFACE_DDF,
    9494            IPC_FLAG_BLOCKING);
     
    9797                return ENOENT;
    9898        }
    99        
     99
    100100        rc = chardev_open(dev_sess, &chardev);
    101101        if (rc != EOK) {
     
    104104                return ENOMEM;
    105105        }
    106        
     106
    107107        fid = fibril_create(kbd_port_fibril, NULL);
    108108        if (fid == 0) {
     
    114114
    115115        fibril_add_ready(fid);
    116        
     116
    117117        printf("%s: Found input device '%s'\n", NAME, in_devs[i]);
    118118        return 0;
  • uspace/srv/hid/input/proto/mousedev.c

    r3061bc1 r8565a42  
    5959        if (mousedev == NULL)
    6060                return NULL;
    61        
     61
    6262        mousedev->mouse_dev = mdev;
    63        
     63
    6464        return mousedev;
    6565}
     
    7575        /* Mousedev device structure */
    7676        mousedev_t *mousedev = (mousedev_t *) arg;
    77        
     77
    7878        while (true) {
    7979                ipc_call_t call;
    8080                ipc_callid_t callid = async_get_call(&call);
    81                
     81
    8282                if (!IPC_GET_IMETHOD(call)) {
    8383                        mousedev_destroy(mousedev);
    8484                        return;
    8585                }
    86                
     86
    8787                errno_t retval;
    88                
     88
    8989                switch (IPC_GET_IMETHOD(call)) {
    9090                case MOUSEEV_MOVE_EVENT:
     
    109109                        break;
    110110                }
    111                
     111
    112112                async_answer_0(callid, retval);
    113113        }
     
    122122                return ENOENT;
    123123        }
    124        
     124
    125125        mousedev_t *mousedev = mousedev_new(mdev);
    126126        if (mousedev == NULL) {
     
    130130                return ENOMEM;
    131131        }
    132        
     132
    133133        async_exch_t *exch = async_exchange_begin(sess);
    134134        if (exch == NULL) {
     
    139139                return ENOENT;
    140140        }
    141        
     141
    142142        port_id_t port;
    143143        errno_t rc = async_create_callback_port(exch, INTERFACE_MOUSE_CB, 0, 0,
    144144            mousedev_callback_conn, mousedev, &port);
    145        
     145
    146146        async_exchange_end(exch);
    147147        async_hangup(sess);
    148        
     148
    149149        if (rc != EOK) {
    150150                printf("%s: Failed creating callback connection from '%s'.\n",
     
    153153                return rc;
    154154        }
    155        
     155
    156156        return EOK;
    157157}
Note: See TracChangeset for help on using the changeset viewer.