Changeset bc255aa in mainline


Ignore:
Timestamp:
2011-09-20T19:24:15Z (13 years ago)
Author:
Vojtech Horky <vojtechhorky@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
7d364fb8
Parents:
a347a11
Message:

Virt USB HID: boot kbd uses the generic functions

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/vuhid/hids/bootkbd.c

    ra347a11 rbc255aa  
    9393             0, 0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
    9494};
    95 static size_t in_data_count = sizeof(in_data)/INPUT_SIZE;
    96 // FIXME - locking
    97 static size_t in_data_position = 0;
    98 
    99 static int on_data_in(vuhid_interface_t *iface,
    100     void *buffer, size_t buffer_size, size_t *act_buffer_size)
    101 {
    102         static size_t last_pos = (size_t) -1;
    103         size_t pos = in_data_position;
    104         if (pos >= in_data_count) {
    105                 return EBADCHECKSUM;
    106         }
    107 
    108         if (last_pos == pos) {
    109                 return ENAK;
    110         }
    111 
    112         if (buffer_size > INPUT_SIZE) {
    113                 buffer_size = INPUT_SIZE;
    114         }
    115 
    116         if (act_buffer_size != NULL) {
    117                 *act_buffer_size = buffer_size;
    118         }
    119 
    120         memcpy(buffer, in_data + pos * INPUT_SIZE, buffer_size);
    121         last_pos = pos;
    122 
    123         return EOK;
    124 }
     95static vuhid_interface_life_t boot_life = {
     96        .data_in = in_data,
     97        .data_in_count = sizeof(in_data)/INPUT_SIZE,
     98        .data_in_pos_change_delay = 500,
     99        .msg_born = "Boot keyboard comes to life...",
     100        .msg_die = "Boot keyboard died."
     101};
    125102
    126103static int on_data_out(vuhid_interface_t *iface,
     
    141118}
    142119
    143 
    144 static void live(vuhid_interface_t *iface)
    145 {
    146         async_usleep(1000 * 1000 * 5);
    147         usb_log_debug("Boot keyboard comes to life...\n");
    148         while (in_data_position < in_data_count) {
    149                 async_usleep(1000 * 500);
    150                 in_data_position++;
    151         }
    152         usb_log_debug("Boot keyboard died.\n");
    153 }
    154 
    155 
    156120vuhid_interface_t vuhid_interface_bootkbd = {
    157121        .id = "boot",
     
    164128
    165129        .in_data_size = INPUT_SIZE,
    166         .on_data_in = on_data_in,
     130        .on_data_in = interface_live_on_data_in,
    167131
    168132        .out_data_size = 1,
    169133        .on_data_out = on_data_out,
    170134
    171         .live = live,
     135        .live = interface_life_live,
    172136
     137        .interface_data = &boot_life,
    173138        .vuhid_data = NULL
    174139};
Note: See TracChangeset for help on using the changeset viewer.