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

Changeset dd3eda2 in mainline


Ignore:
Timestamp:
2011-05-06T10:30:00Z (11 years ago)
Author:
Lubos Slovak <lubos.slovak@…>
Branches:
lfn, master
Children:
04c1524
Parents:
166c4752
Message:

Report recieving tracked for each device separately.

Location:
uspace/drv/usbhid
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/usbhid/generic/hiddev.c

    r166c4752 rdd3eda2  
    3939#include <errno.h>
    4040#include <str_error.h>
     41#include <bool.h>
    4142
    4243#include <usbhid_iface.h>
     
    6465    size_t size, size_t *act_size, unsigned int flags);
    6566
     67static int usb_generic_hid_client_connected(ddf_fun_t *fun);
     68
    6669/*----------------------------------------------------------------------------*/
    6770
     
    7275
    7376static ddf_dev_ops_t usb_generic_hid_ops = {
    74         .interfaces[USBHID_DEV_IFACE] = &usb_generic_iface
     77        .interfaces[USBHID_DEV_IFACE] = &usb_generic_iface,
     78        .open = usb_generic_hid_client_connected
    7579};
    7680
     
    104108       
    105109        /*! @todo This should probably be atomic. */
    106         memcpy(buffer, hid_dev->input_report, hid_dev->input_report_size);
    107         *act_size = hid_dev->input_report_size;
     110        if (usb_hid_report_ready()) {
     111                memcpy(buffer, hid_dev->input_report,
     112                    hid_dev->input_report_size);
     113                *act_size = hid_dev->input_report_size;
     114                usb_hid_report_received();
     115        }
    108116       
    109117        // clear the buffer so that it will not be received twice
    110         memset(hid_dev->input_report, 0, hid_dev->input_report_size);
     118        //memset(hid_dev->input_report, 0, hid_dev->input_report_size);
    111119       
     120        // note that we already received this report
     121//      report_received = true;
     122       
     123        return EOK;
     124}
     125
     126/*----------------------------------------------------------------------------*/
     127
     128static int usb_generic_hid_client_connected(ddf_fun_t *fun)
     129{
     130        usb_hid_report_received();
    112131        return EOK;
    113132}
  • uspace/drv/usbhid/usbhid.c

    r166c4752 rdd3eda2  
    6363static const int USB_HID_MAX_SUBDRIVERS = 10;
    6464
     65static fibril_local bool report_received;
     66
    6567/*----------------------------------------------------------------------------*/
    6668
     
    509511                                free(input_old);
    510512                        }
     513                        usb_hid_new_report();
    511514                }
    512515        }
     
    589592/*----------------------------------------------------------------------------*/
    590593
     594void usb_hid_new_report(void)
     595{
     596        report_received = false;
     597}
     598
     599/*----------------------------------------------------------------------------*/
     600
     601void usb_hid_report_received(void)
     602{
     603        report_received = true;
     604}
     605
     606/*----------------------------------------------------------------------------*/
     607
     608bool usb_hid_report_ready(void)
     609{
     610        return !report_received;
     611}
     612
     613/*----------------------------------------------------------------------------*/
     614
    591615void usb_hid_free(usb_hid_dev_t **hid_dev)
    592616{
  • uspace/drv/usbhid/usbhid.h

    r166c4752 rdd3eda2  
    4444#include <usb/devdrv.h>
    4545#include <usb/classes/hid.h>
     46#include <bool.h>
    4647
    4748struct usb_hid_dev;
     
    128129//const char *usb_hid_get_class_name(const usb_hid_dev_t *hid_dev);
    129130
     131void usb_hid_new_report(void);
     132
     133void usb_hid_report_received(void);
     134
     135bool usb_hid_report_ready(void);
     136
    130137void usb_hid_free(usb_hid_dev_t **hid_dev);
    131138
Note: See TracChangeset for help on using the changeset viewer.