Changes in uspace/app/virtusbkbd/virtusbkbd.c [2aee3e06:9223dc5c] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/virtusbkbd/virtusbkbd.c
r2aee3e06 r9223dc5c 55 55 #include "stdreq.h" 56 56 57 /** Pause between individual key-presses in seconds. */ 58 #define KEY_PRESS_DELAY 2 57 #define LOOPS 5 59 58 #define NAME "virt-usb-kbd" 60 59 … … 84 83 } 85 84 86 /** Compares current and last status of pressed keys.87 *88 * @warning Has side-efect - changes status_last field.89 *90 * @param status_now Status now.91 * @param status_last Last status.92 * @param len Size of status.93 * @return Whether they are the same.94 */95 static bool keypress_check_with_last_request(uint8_t *status_now,96 uint8_t *status_last, size_t len)97 {98 bool same = true;99 size_t i;100 for (i = 0; i < len; i++) {101 if (status_now[i] != status_last[i]) {102 status_last[i] = status_now[i];103 same = false;104 }105 }106 return same;107 }108 109 85 static int on_request_for_data(struct usbvirt_device *dev, 110 86 usb_endpoint_t endpoint, void *buffer, size_t size, size_t *actual_size) 111 87 { 112 static uint8_t last_data[2 + KB_MAX_KEYS_AT_ONCE];113 114 88 if (size < 2 + KB_MAX_KEYS_AT_ONCE) { 115 89 return EINVAL; … … 127 101 } 128 102 129 if (keypress_check_with_last_request(data, last_data,130 2 + KB_MAX_KEYS_AT_ONCE)) {131 *actual_size = 0;132 return EOK;133 }134 135 103 memcpy(buffer, &data, *actual_size); 136 104 … … 184 152 .ops = &keyboard_ops, 185 153 .descriptors = &descriptors, 186 .lib_debug_level = 3,187 .lib_debug_enabled_tags = USBVIRT_DEBUGTAG_ALL,188 154 .name = "keyboard" 189 155 }; … … 211 177 printf("\n"); 212 178 213 fibril_sleep( KEY_PRESS_DELAY);179 fibril_sleep(1); 214 180 } 215 181 … … 257 223 258 224 printf("%s: Simulating keyboard events...\n", NAME); 259 while (1){225 while(1){ 260 226 kb_process_events(&status, keyboard_events, keyboard_events_count, 261 227 on_keyboard_change);
Note:
See TracChangeset
for help on using the changeset viewer.