Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset 101ef25c in mainline


Ignore:
Timestamp:
2010-12-10T17:02:22Z (11 years ago)
Author:
Lubos Slovak <lubos.slovak@…>
Branches:
lfn, master
Children:
243cb86
Parents:
70c85211
Message:

Cosmetic changes.

Loop in poll_keyboard(), etc.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/usbkbd/main.c

    r70c85211 r101ef25c  
    5050        kbd_dev->device = dev;
    5151
     52        // get phone to my HC and save it as my parent's phone
     53        // TODO: maybe not a good idea if DDF will use parent_phone
     54        kbd_dev->device->parent_phone = usb_drv_hc_connect(dev, 0);
     55
    5256        kbd_dev->address = usb_drv_get_my_address(dev->parent_phone,
    5357            dev);
    5458
    55         if (kbd_dev->address < 0) {
    56                 fprintf(stderr, NAME ": No device address!\n");
    57                 free(kbd_dev);
    58                 return NULL;
    59         }
     59        // doesn't matter now that we have no address
     60//      if (kbd_dev->address < 0) {
     61//              fprintf(stderr, NAME ": No device address!\n");
     62//              free(kbd_dev);
     63//              return NULL;
     64//      }
    6065
    6166        // default endpoint
     
    6974}
    7075
    71 /* Call this periodically to check keyboard status changes. */
     76static void usbkbd_process_interrupt_in(usb_hid_dev_kbd_t *kbd_dev,
     77                                        char *buffer, size_t actual_size)
     78{
     79        /*
     80         * here, the parser will be called, probably with some callbacks
     81         * now only take last 6 bytes and process, i.e. send to kbd
     82         */
     83}
     84
    7285static void usbkbd_poll_keyboard(usb_hid_dev_kbd_t *kbd_dev)
    7386{
     
    89102        };
    90103
    91         rc = usb_drv_async_interrupt_in(kbd_dev->device->parent_phone,
    92             poll_target, buffer, BUFFER_SIZE, &actual_size, &handle);
    93 
    94         if (rc != EOK) {
    95                 return;
    96         }
    97 
    98         rc = usb_drv_async_wait_for(handle);
    99         if (rc != EOK) {
    100                 return;
    101         }
    102 
    103         /*
    104          * If the keyboard answered with NAK, it returned no data.
    105          * This implies that no change happened since last query.
    106          */
    107         if (actual_size == 0) {
    108                 return;
    109         }
    110 
    111         /*
    112          * TODO: Process pressed keys.
    113          */
     104        while (true) {
     105                rc = usb_drv_async_interrupt_in(kbd_dev->device->parent_phone,
     106                    poll_target, buffer, BUFFER_SIZE, &actual_size, &handle);
     107
     108                if (rc != EOK) {
     109                        continue;
     110                }
     111
     112                rc = usb_drv_async_wait_for(handle);
     113                if (rc != EOK) {
     114                        continue;
     115                }
     116
     117                /*
     118                 * If the keyboard answered with NAK, it returned no data.
     119                 * This implies that no change happened since last query.
     120                 */
     121                if (actual_size == 0) {
     122                        continue;
     123                }
     124
     125                /*
     126                 * TODO: Process pressed keys.
     127                 */
     128                usbkbd_process_interrupt_in(kbd_dev, buffer, actual_size);
     129        }
     130
     131        // not reached
     132        assert(0);
    114133}
    115134
     
    136155{
    137156        /* For now, fail immediately. */
    138         return ENOTSUP;
     157        //return ENOTSUP;
    139158
    140159        /*
Note: See TracChangeset for help on using the changeset viewer.