Ignore:
File:
1 edited

Legend:

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

    r707ffcf r66d5062  
    4343#include <io/console.h>
    4444#include <errno.h>
    45 #include <str_error.h>
    4645#include <fibril.h>
    4746#include <usb/classes/hid.h>
     
    5049#include <usb/descriptor.h>
    5150#include <io/console.h>
    52 #include "hid.h"
    5351#include "descparser.h"
    5452#include "descdump.h"
     
    381379        if (rc < 0) {
    382380                printf("Problem setting phone to HC.\n");
    383                 goto error_leave;
     381                free(kbd_dev);
     382                return NULL;
    384383        }
    385384
     
    387386        if (rc < 0) {
    388387                printf("Problem getting address of the device.\n");
    389                 goto error_leave;
     388                free(kbd_dev);
     389                return NULL;
    390390        }
    391391
     
    397397//      }
    398398
     399        // default endpoint
     400        kbd_dev->poll_endpoint = GUESSED_POLL_ENDPOINT;
     401       
    399402        /*
    400403         * will need all descriptors:
     
    407410        usbkbd_process_descriptors(kbd_dev);
    408411
    409 
    410 
    411         /*
    412          * Initialize the backing connection to the host controller.
    413          */
    414         rc = usb_device_connection_initialize(&kbd_dev->wire, dev);
    415         if (rc != EOK) {
    416                 printf("Problem initializing connection to device: %s.\n",
    417                     str_error(rc));
    418                 goto error_leave;
    419         }
    420 
    421         /*
    422          * Initialize device pipes.
    423          */
    424         rc = usb_endpoint_pipe_initialize(&kbd_dev->poll_pipe, &kbd_dev->wire,
    425             GUESSED_POLL_ENDPOINT, USB_TRANSFER_INTERRUPT, USB_DIRECTION_IN);
    426         if (rc != EOK) {
    427                 printf("Failed to initialize interrupt in pipe: %s.\n",
    428                     str_error(rc));
    429                 goto error_leave;
    430         }
    431 
    432 
    433412        return kbd_dev;
    434 
    435 error_leave:
    436         free(kbd_dev);
    437         return NULL;
    438413}
    439414
     
    460435static void usbkbd_poll_keyboard(usb_hid_dev_kbd_t *kbd_dev)
    461436{
    462         int rc, sess_rc;
     437        int rc;
     438        usb_handle_t handle;
    463439        uint8_t buffer[BUFFER_SIZE];
    464440        size_t actual_size;
     441        //usb_endpoint_t poll_endpoint = 1;
     442
     443//      usb_address_t my_address = usb_drv_get_my_address(dev->parent_phone,
     444//          dev);
     445//      if (my_address < 0) {
     446//              return;
     447//      }
     448
     449        usb_target_t poll_target = {
     450                .address = kbd_dev->address,
     451                .endpoint = kbd_dev->poll_endpoint
     452        };
    465453
    466454        printf("Polling keyboard...\n");
     
    468456        while (true) {
    469457                async_usleep(1000 * 1000 * 2);
    470 
    471                 sess_rc = usb_endpoint_pipe_start_session(&kbd_dev->poll_pipe);
    472                 if (sess_rc != EOK) {
    473                         printf("Failed to start a session: %s.\n",
    474                             str_error(sess_rc));
     458                rc = usb_drv_async_interrupt_in(kbd_dev->device->parent_phone,
     459                    poll_target, buffer, BUFFER_SIZE, &actual_size, &handle);
     460
     461                if (rc != EOK) {
     462                        printf("Error in usb_drv_async_interrupt_in(): %d\n", rc);
    475463                        continue;
    476464                }
    477465
    478                 rc = usb_endpoint_pipe_read(&kbd_dev->poll_pipe, buffer,
    479                     BUFFER_SIZE, &actual_size);
    480                 sess_rc = usb_endpoint_pipe_end_session(&kbd_dev->poll_pipe);
    481 
     466                rc = usb_drv_async_wait_for(handle);
    482467                if (rc != EOK) {
    483                         printf("Error polling the keyboard: %s.\n",
    484                             str_error(rc));
    485                         continue;
    486                 }
    487 
    488                 if (sess_rc != EOK) {
    489                         printf("Error closing session: %s.\n",
    490                             str_error(sess_rc));
     468                        printf("Error in usb_drv_async_wait_for(): %d\n", rc);
    491469                        continue;
    492470                }
Note: See TracChangeset for help on using the changeset viewer.