Changeset 7da3219 in mainline
- Timestamp:
- 2010-10-13T21:29:00Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 1880c65
- Parents:
- 2c381250
- Location:
- uspace/app/virtusbkbd
- Files:
-
- 2 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/virtusbkbd/Makefile
r2c381250 r7da3219 37 37 SOURCES = \ 38 38 kbdconfig.c \ 39 keys.c \ 39 40 virtusbkbd.c 40 41 -
uspace/app/virtusbkbd/kbdconfig.c
r2c381250 r7da3219 35 35 */ 36 36 #include "kbdconfig.h" 37 #include "keys.h" 37 38 #include <usb/hcd.h> 38 39 #include <usb/hid.h> … … 96 97 /* LED states padding */ 97 98 OUTPUT(IOF_CONSTANT), 98 REPORT_COUNT1( 6),99 REPORT_COUNT1(KB_MAX_KEYS_AT_ONCE), 99 100 REPORT_SIZE1(8), 100 101 LOGICAL_MINIMUM1(0), -
uspace/app/virtusbkbd/virtusbkbd.c
r2c381250 r7da3219 53 53 54 54 #include "kbdconfig.h" 55 #include "keys.h" 55 56 56 57 #define LOOPS 5 … … 136 137 137 138 139 /** Callback when keyboard status changed. 140 * 141 * @param status Current keyboard status. 142 */ 143 static void on_keyboard_change(kb_status_t *status) 144 { 145 printf("%s: Current keyboard status: %08hhb", NAME, status->modifiers); 146 size_t i; 147 for (i = 0; i < KB_MAX_KEYS_AT_ONCE; i++) { 148 printf(" 0x%02X", (int)status->pressed_keys[i]); 149 } 150 printf("\n"); 151 152 uint8_t data[3 + KB_MAX_KEYS_AT_ONCE]; 153 data[0] = status->modifiers; 154 data[1] = 0; 155 data[2] = 0; 156 for (i = 0; i < KB_MAX_KEYS_AT_ONCE; i++) { 157 data[3 + i] = status->pressed_keys[i]; 158 } 159 160 int rc = keyboard_dev.send_data(&keyboard_dev, 0, data, sizeof(data)); 161 printf("%s: Sent to VHCD (%s).\n", NAME, str_error(rc)); 162 163 fibril_sleep(1); 164 } 165 166 /** Simulated keyboard events. */ 167 static kb_event_t keyboard_events[] = { 168 /* Switch to VT6 (Alt+F6) */ 169 M_DOWN(KB_MOD_LEFT_ALT), 170 K_PRESS(63), 171 M_UP(KB_MOD_LEFT_ALT), 172 /* Type the word 'Hello' */ 173 M_DOWN(KB_MOD_LEFT_SHIFT), 174 K_PRESS(KB_KEY_H), 175 M_UP(KB_MOD_LEFT_SHIFT), 176 K_PRESS(KB_KEY_E), 177 K_PRESS(KB_KEY_L), 178 K_PRESS(KB_KEY_L), 179 K_PRESS(KB_KEY_O) 180 }; 181 static size_t keyboard_events_count = 182 sizeof(keyboard_events)/sizeof(keyboard_events[0]); 183 184 185 138 186 int main(int argc, char * argv[]) 139 187 { … … 156 204 } 157 205 158 159 for (i = 0; i < LOOPS; i++) { 160 size_t size = 5; 161 char *data = (char *) "Hullo, World!"; 162 163 if (i > 0) { 164 fibril_sleep(2); 165 } 166 167 printf("%s: Will send data to VHCD...\n", NAME); 168 int rc = keyboard_dev.send_data(&keyboard_dev, 0, data, size); 169 printf("%s: ...data sent (%s).\n", NAME, str_error(rc)); 170 } 171 172 fibril_sleep(1); 206 kb_status_t status; 207 kb_init(&status); 208 209 printf("%s: Simulating keyboard events...\n", NAME); 210 kb_process_events(&status, keyboard_events, keyboard_events_count, 211 on_keyboard_change); 212 173 213 printf("%s: Terminating...\n", NAME); 174 214
Note:
See TracChangeset
for help on using the changeset viewer.