Changeset 00aece0 in mainline for uspace/app/vuhid/life.c


Ignore:
Timestamp:
2012-02-18T16:47:38Z (14 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/fix-logger-deadlock, topic/msim-upgrade, topic/simplify-dev-export
Children:
4449c6c
Parents:
bd5f3b7 (diff), f943dd3 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge mainline changes.

File:
1 moved

Legend:

Unmodified
Added
Removed
  • uspace/app/vuhid/life.c

    rbd5f3b7 r00aece0  
    2727 */
    2828
    29 /** @addtogroup drvusbmouse
     29/** @addtogroup usbvirthid
    3030 * @{
    3131 */
    3232/**
    3333 * @file
    34  * Common definitions for USB mouse driver.
     34 *
    3535 */
     36#include <errno.h>
     37#include <usb/debug.h>
     38#include "virthid.h"
    3639
    37 #ifndef USBMOUSE_MOUSE_H_
    38 #define USBMOUSE_MOUSE_H_
    3940
    40 #include <usb/dev/driver.h>
    41 #include <usb/dev/pipes.h>
    42 #include <time.h>
    43 #include <async.h>
     41void interface_life_live(vuhid_interface_t *iface)
     42{
     43        vuhid_interface_life_t *data = iface->interface_data;
     44        data->data_in_pos = 0;
     45        data->data_in_last_pos = (size_t) -1;
     46        async_usleep(1000 * 1000 * 5);
     47        usb_log_debug("%s\n", data->msg_born);
     48        while (data->data_in_pos < data->data_in_count) {
     49                async_usleep(1000 * data->data_in_pos_change_delay);
     50                // FIXME: proper locking
     51                data->data_in_pos++;
     52        }
     53        usb_log_debug("%s\n", data->msg_die);
     54}
    4455
    45 #define POLL_PIPE(dev) \
    46         ((dev)->pipes[0].pipe)
    4756
    48 /** Container for USB mouse device. */
    49 typedef struct {
    50         /** Generic device container. */
    51         usb_device_t *dev;
    52        
    53         /** Function representing the device. */
    54         ddf_fun_t *mouse_fun;
    55        
    56         /** Polling interval in microseconds. */
    57         suseconds_t poll_interval_us;
    58        
    59         /** Callback session to console (consumer). */
    60         async_sess_t *console_sess;
    61 } usb_mouse_t;
    6257
    63 extern usb_endpoint_description_t poll_endpoint_description;
     58int interface_live_on_data_in(vuhid_interface_t *iface,
     59    void *buffer, size_t buffer_size, size_t *act_buffer_size)
     60{
     61        vuhid_interface_life_t *life = iface->interface_data;
     62        size_t pos = life->data_in_pos;
     63        if (pos >= life->data_in_count) {
     64                return EBADCHECKSUM;
     65        }
    6466
    65 extern int usb_mouse_create(usb_device_t *);
    66 extern bool usb_mouse_polling_callback(usb_device_t *, uint8_t *, size_t,
    67     void *);
    68 extern void usb_mouse_polling_ended_callback(usb_device_t *, bool, void *);
     67        if (pos == life->data_in_last_pos) {
     68                return ENAK;
     69        }
    6970
    70 #endif
     71        if (buffer_size > iface->in_data_size) {
     72                buffer_size = iface->in_data_size;
     73        }
    7174
    72 /**
    73  * @}
     75        if (act_buffer_size != NULL) {
     76                *act_buffer_size = buffer_size;
     77        }
     78
     79        memcpy(buffer, life->data_in + pos * iface->in_data_size, buffer_size);
     80        life->data_in_last_pos = pos;
     81
     82        return EOK;
     83}
     84
     85/** @}
    7486 */
Note: See TracChangeset for help on using the changeset viewer.