Ignore:
File:
1 edited

Legend:

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

    rbc255aa rfaa44e58  
    9393             0, 0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
    9494};
    95 static 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 };
     95static size_t in_data_count = sizeof(in_data)/INPUT_SIZE;
     96// FIXME - locking
     97static size_t in_data_position = 0;
     98
     99static 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}
    102125
    103126static int on_data_out(vuhid_interface_t *iface,
     
    118141}
    119142
     143
     144static 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
    120156vuhid_interface_t vuhid_interface_bootkbd = {
    121157        .id = "boot",
     
    128164
    129165        .in_data_size = INPUT_SIZE,
    130         .on_data_in = interface_live_on_data_in,
     166        .on_data_in = on_data_in,
    131167
    132168        .out_data_size = 1,
    133169        .on_data_out = on_data_out,
    134170
    135         .live = interface_life_live,
     171        .live = live,
    136172
    137         .interface_data = &boot_life,
    138173        .vuhid_data = NULL
    139174};
Note: See TracChangeset for help on using the changeset viewer.