#define TABSIZE 4
/* you are welcome to make this nice :) */
char str[7];
- u16 i, j, y=STDOUT_BORDER_TOP, x=STDOUT_BORDER_LEFT;
+ u16 i, j, ret=0, y=STDOUT_BORDER_TOP, x=STDOUT_BORDER_LEFT;
u16 old_x, old_y;
- struct kbrep *k;
+ struct kbrep *k, *old=NULL;
while(1) {
memset(str, '\0', 7);
- j=0;
k = usb_hidkb_getChars();
+ j=0;
old_x = x; /* save actual x and y position for printing after the loop */
old_y = y;
for(i=0; k->keys[i]>0; i++) {
+
+ /* dropping char's if necessary */
+ if(old) {
+ for(j=0; j < 6; j++) {
+ if(old->keys[j] == k->keys[i]) {
+ ret = 1;
+ break;
+ }
+ }
+ }
+ if(ret) {
+ ret = 0;
+ continue;
+ }
+ j = 0;
+
unsigned char key = usb_hidkb_get_char_from_keycode(k->keys[i],
(k->mod & MOD_lshift) || (k->mod & MOD_rshift));
/* no key or key not relevant? next, please. */
if (key == '\n') {
x = STDOUT_BORDER_LEFT;
y += FONT_HEIGHT;
+ printf("\n");
/* TAB pressed? */
} else if (key == '\t') {
x += (TABSIZE*FONT_WIDTH);
+ printf("\t");
/* BACKSPACE pressed? */
} else if (key == '\r') {
y = STDOUT_BORDER_TOP;
}
}
- free(k);
+ if(old) {
+ free(old);
+ }
+ old = k;
if(j > 0) { /* when there was any printable stuff, show it */
print_str_noscroll(old_x, old_y, str);
- printf("y: %d\n", y);
+ printf("%s", str);
}
-
}
#if 0
return (void*) -1;
}
-//#define WTF
+#define WTF
#ifdef WTF
volatile u8 wzf = 11;
if(0 == wzf) {
dev->conf->intf->bInterfaceSubClass == 1 && /* keyboard support boot protocol? */
dev->conf->intf->bInterfaceProtocol == 1) { /* keyboard? */
hidkb.data = (void*) dev;
+ usb_hidkb_set_idle(dev, 1);
}
iterator=iterator->next;
}
}
+void usb_hidkb_set_idle(struct usb_device *dev, u8 duration) {
+#define SET_IDLE 0x0A
+ u8 buf[8];
+ memset(buf, 0, 8);
+ usb_control_msg(dev, 0x21, SET_IDLE, (duration << 8), 0, 0, buf, 0);
+ hexdump((void*) buf, 8);
+}
+
void usb_hidkb_check()
{
}
memset(ret, 0, 8);
s8 epnum = dev->conf->intf->endp->bEndpointAddress & 0xf;
(void) usb_interrupt_read(dev, epnum, (u8*) ret, 8, 0);
+#if 0
printf("============\nusb_interrupt_read:\n");
hexdump((void*)ret, 8);
-
+#endif
return ret;
}
unsigned char usb_hidkb_get_char_from_keycode(u8 keycode, int shifted)
{
unsigned char result = 0;
- if (keycode < 57)
+ if (keycode >= 0x3 && keycode < 57) {
result = code_translation_table[!!shifted][keycode];
+ }
return result;
}
struct kbrep *usb_hidkb_getChars();
unsigned char usb_hidkb_get_char_from_keycode(u8 keycode, int shifted);
+void usb_hidkb_set_idle(struct usb_device *dev, u8 duration);
#endif /* __HID_H */