Changeset a35b458 in mainline for uspace/drv/hid/xtkbd


Ignore:
Timestamp:
2018-03-02T20:10:49Z (8 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/drv/hid/xtkbd/xtkbd.c

    r3061bc1 ra35b458  
    4747static const unsigned int scanmap_simple[] = {
    4848        [0x29] = KC_BACKTICK,
    49        
     49
    5050        [0x02] = KC_1,
    5151        [0x03] = KC_2,
     
    5858        [0x0a] = KC_9,
    5959        [0x0b] = KC_0,
    60        
     60
    6161        [0x0c] = KC_MINUS,
    6262        [0x0d] = KC_EQUALS,
    6363        [0x0e] = KC_BACKSPACE,
    64        
     64
    6565        [0x0f] = KC_TAB,
    66        
     66
    6767        [0x10] = KC_Q,
    6868        [0x11] = KC_W,
     
    7575        [0x18] = KC_O,
    7676        [0x19] = KC_P,
    77        
     77
    7878        [0x1a] = KC_LBRACKET,
    7979        [0x1b] = KC_RBRACKET,
    80        
     80
    8181        [0x3a] = KC_CAPS_LOCK,
    82        
     82
    8383        [0x1e] = KC_A,
    8484        [0x1f] = KC_S,
     
    9090        [0x25] = KC_K,
    9191        [0x26] = KC_L,
    92        
     92
    9393        [0x27] = KC_SEMICOLON,
    9494        [0x28] = KC_QUOTE,
    9595        [0x2b] = KC_BACKSLASH,
    96        
     96
    9797        [0x2a] = KC_LSHIFT,
    98        
     98
    9999        [0x2c] = KC_Z,
    100100        [0x2d] = KC_X,
     
    104104        [0x31] = KC_N,
    105105        [0x32] = KC_M,
    106        
     106
    107107        [0x33] = KC_COMMA,
    108108        [0x34] = KC_PERIOD,
    109109        [0x35] = KC_SLASH,
    110        
     110
    111111        [0x36] = KC_RSHIFT,
    112        
     112
    113113        [0x1d] = KC_LCTRL,
    114114        [0x38] = KC_LALT,
    115115        [0x39] = KC_SPACE,
    116        
     116
    117117        [0x01] = KC_ESCAPE,
    118        
     118
    119119        [0x3b] = KC_F1,
    120120        [0x3c] = KC_F2,
     
    124124        [0x40] = KC_F6,
    125125        [0x41] = KC_F7,
    126        
     126
    127127        [0x42] = KC_F8,
    128128        [0x43] = KC_F9,
    129129        [0x44] = KC_F10,
    130        
     130
    131131        [0x57] = KC_F11,
    132132        [0x58] = KC_F12,
    133        
     133
    134134        [0x46] = KC_SCROLL_LOCK,
    135        
     135
    136136        [0x1c] = KC_ENTER,
    137        
     137
    138138        [0x45] = KC_NUM_LOCK,
    139139        [0x37] = KC_NTIMES,
     
    162162        [0x38] = KC_RALT,
    163163        [0x1d] = KC_RCTRL,
    164        
     164
    165165        [0x37] = KC_SYSREQ,
    166        
     166
    167167        [0x52] = KC_INSERT,
    168168        [0x47] = KC_HOME,
    169169        [0x49] = KC_PAGE_UP,
    170        
     170
    171171        [0x53] = KC_DELETE,
    172172        [0x4f] = KC_END,
    173173        [0x51] = KC_PAGE_DOWN,
    174        
     174
    175175        [0x48] = KC_UP,
    176176        [0x4b] = KC_LEFT,
    177177        [0x50] = KC_DOWN,
    178178        [0x4d] = KC_RIGHT,
    179        
     179
    180180        [0x35] = KC_NSLASH,
    181181        [0x1c] = KC_NENTER
     
    210210        size_t nread;
    211211        errno_t rc;
    212        
     212
    213213        while (true) {
    214214                const unsigned int *map = scanmap_simple;
    215215                size_t map_size = sizeof(scanmap_simple) / sizeof(unsigned int);
    216                
     216
    217217                uint8_t code = 0;
    218218                rc = chardev_read(kbd->chardev, &code, 1, &nread);
    219219                if (rc != EOK)
    220220                        return EIO;
    221                
     221
    222222                /* Ignore AT command reply */
    223223                if ((code == KBD_ACK) || (code == KBD_RESEND))
    224224                        continue;
    225                
     225
    226226                /* Extended set */
    227227                if (code == KBD_SCANCODE_SET_EXTENDED) {
    228228                        map = scanmap_e0;
    229229                        map_size = sizeof(scanmap_e0) / sizeof(unsigned int);
    230                        
    231                         rc = chardev_read(kbd->chardev, &code, 1, &nread);
    232                         if (rc != EOK)
    233                                 return EIO;
    234                        
     230
     231                        rc = chardev_read(kbd->chardev, &code, 1, &nread);
     232                        if (rc != EOK)
     233                                return EIO;
     234
    235235                        /* Handle really special keys */
    236                        
     236
    237237                        if (code == 0x2a) {  /* Print Screen */
    238238                                rc = chardev_read(kbd->chardev, &code, 1, &nread);
    239239                                if (rc != EOK)
    240240                                        return EIO;
    241                                
     241
    242242                                if (code != 0xe0)
    243243                                        continue;
    244                                
     244
    245245                                rc = chardev_read(kbd->chardev, &code, 1, &nread);
    246246                                if (rc != EOK)
    247247                                        return EIO;
    248                                
     248
    249249                                if (code == 0x37)
    250250                                        push_event(kbd->client_sess, KEY_PRESS, KC_PRTSCR);
    251                                
     251
    252252                                continue;
    253253                        }
    254                        
     254
    255255                        if (code == 0x46) {  /* Break */
    256256                                rc = chardev_read(kbd->chardev, &code, 1, &nread);
    257257                                if (rc != EOK)
    258258                                        return EIO;
    259                                
     259
    260260                                if (code != 0xe0)
    261261                                        continue;
    262                                
     262
    263263                                rc = chardev_read(kbd->chardev, &code, 1, &nread);
    264264                                if (rc != EOK)
    265265                                        return EIO;
    266                                
     266
    267267                                if (code == 0xc6)
    268268                                        push_event(kbd->client_sess, KEY_PRESS, KC_BREAK);
    269                                
     269
    270270                                continue;
    271271                        }
    272272                }
    273                
     273
    274274                /* Extended special set */
    275275                if (code == KBD_SCANCODE_SET_EXTENDED_SPECIAL) {
     
    277277                        if (rc != EOK)
    278278                                return EIO;
    279                        
     279
    280280                        if (code != 0x1d)
    281281                                continue;
    282                        
    283                         rc = chardev_read(kbd->chardev, &code, 1, &nread);
    284                         if (rc != EOK)
    285                                 return EIO;
    286                        
     282
     283                        rc = chardev_read(kbd->chardev, &code, 1, &nread);
     284                        if (rc != EOK)
     285                                return EIO;
     286
    287287                        if (code != 0x45)
    288288                                continue;
    289                        
    290                         rc = chardev_read(kbd->chardev, &code, 1, &nread);
    291                         if (rc != EOK)
    292                                 return EIO;
    293                        
     289
     290                        rc = chardev_read(kbd->chardev, &code, 1, &nread);
     291                        if (rc != EOK)
     292                                return EIO;
     293
    294294                        if (code != 0xe1)
    295295                                continue;
    296                        
    297                         rc = chardev_read(kbd->chardev, &code, 1, &nread);
    298                         if (rc != EOK)
    299                                 return EIO;
    300                        
     296
     297                        rc = chardev_read(kbd->chardev, &code, 1, &nread);
     298                        if (rc != EOK)
     299                                return EIO;
     300
    301301                        if (code != 0x9d)
    302302                                continue;
    303                        
    304                         rc = chardev_read(kbd->chardev, &code, 1, &nread);
    305                         if (rc != EOK)
    306                                 return EIO;
    307                        
     303
     304                        rc = chardev_read(kbd->chardev, &code, 1, &nread);
     305                        if (rc != EOK)
     306                                return EIO;
     307
    308308                        if (code == 0xc5)
    309309                                push_event(kbd->client_sess, KEY_PRESS, KC_PAUSE);
    310                        
     310
    311311                        continue;
    312312                }
    313                
     313
    314314                /* Bit 7 indicates press/release */
    315315                const kbd_event_type_t type =
    316316                    (code & 0x80) ? KEY_RELEASE : KEY_PRESS;
    317317                code &= ~0x80;
    318                
     318
    319319                const unsigned int key = (code < map_size) ? map[code] : 0;
    320                
     320
    321321                if (key != 0)
    322322                        push_event(kbd->client_sess, type, key);
     
    351351                    ((mods & KM_SCROLL_LOCK) ? LI_SCROLL : 0);
    352352                uint8_t cmds[] = { KBD_CMD_SET_LEDS, status };
    353                
     353
    354354                size_t nwr;
    355355                errno_t rc = chardev_write(kbd->chardev, &cmds[0], 1, &nwr);
     
    370370                async_sess_t *sess =
    371371                    async_callback_receive_start(EXCHANGE_SERIALIZE, icall);
    372                
     372
    373373                /* Probably ENOMEM error, try again. */
    374374                if (sess == NULL) {
     
    378378                        break;
    379379                }
    380                
     380
    381381                if (kbd->client_sess == NULL) {
    382382                        kbd->client_sess = sess;
     
    387387                        async_answer_0(icallid, ELIMIT);
    388388                }
    389                
     389
    390390                break;
    391391        }
     
    415415        bool bound = false;
    416416        errno_t rc;
    417        
     417
    418418        kbd->client_sess = NULL;
    419        
     419
    420420        parent_sess = ddf_dev_parent_sess_get(dev);
    421421        if (parent_sess == NULL) {
     
    424424                goto error;
    425425        }
    426        
     426
    427427        rc = chardev_open(parent_sess, &kbd->chardev);
    428428        if (rc != EOK) {
     
    430430                goto error;
    431431        }
    432        
     432
    433433        kbd->kbd_fun = ddf_fun_create(dev, fun_exposed, "kbd");
    434434        if (kbd->kbd_fun == NULL) {
     
    437437                goto error;
    438438        }
    439        
     439
    440440        ddf_fun_set_ops(kbd->kbd_fun, &kbd_ops);
    441        
     441
    442442        rc = ddf_fun_bind(kbd->kbd_fun);
    443443        if (rc != EOK) {
     
    445445                goto error;
    446446        }
    447        
     447
    448448        rc = ddf_fun_add_to_category(kbd->kbd_fun, "keyboard");
    449449        if (rc != EOK) {
     
    452452                goto error;
    453453        }
    454        
     454
    455455        kbd->polling_fibril = fibril_create(polling, kbd);
    456456        if (kbd->polling_fibril == 0) {
     
    459459                goto error;
    460460        }
    461        
     461
    462462        fibril_add_ready(kbd->polling_fibril);
    463463        return EOK;
Note: See TracChangeset for help on using the changeset viewer.