Changeset a35b458 in mainline for uspace/srv/hid/input/input.c


Ignore:
Timestamp:
2018-03-02T20:10:49Z (7 years ago)
Author:
Jiří Zárevúcky <zarevucky.jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
f1380b7
Parents:
3061bc1
git-author:
Jiří Zárevúcky <zarevucky.jiri@…> (2018-02-28 17:38:31)
git-committer:
Jiří Zárevúcky <zarevucky.jiri@…> (2018-03-02 20:10:49)
Message:

style: Remove trailing whitespace on _all_ lines, including empty ones, for particular file types.

Command used: tools/srepl '\s\+$' '' -- *.c *.h *.py *.sh *.s *.S *.ag

Currently, whitespace on empty lines is very inconsistent.
There are two basic choices: Either remove the whitespace, or keep empty lines
indented to the level of surrounding code. The former is AFAICT more common,
and also much easier to do automatically.

Alternatively, we could write script for automatic indentation, and use that
instead. However, if such a script exists, it's possible to use the indented
style locally, by having the editor apply relevant conversions on load/save,
without affecting remote repository. IMO, it makes more sense to adopt
the simpler rule.

File:
1 edited

Legend:

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

    r3061bc1 ra35b458  
    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;
Note: See TracChangeset for help on using the changeset viewer.