diff --git a/src/userland/hlib/stdio.c b/src/userland/hlib/stdio.c index 85c14dd..2035921 100644 --- a/src/userland/hlib/stdio.c +++ b/src/userland/hlib/stdio.c @@ -68,11 +68,15 @@ (*write)++; } -void putInt(char **write, uintptr_t x) { +void putInt(char **write, intptr_t x) { if (x == 0) { addChar(write, '0'); return; } + if (x < 0) { + addChar(write, '-'); + x *= -1; + } for (intptr_t i = 10; i >= 0; i--) { uintptr_t n = x / power(10, i); if (n) { @@ -81,7 +85,7 @@ } } -uint32_t getInsertLength(char insertType, uintptr_t x) { +uint32_t getInsertLength(char insertType, intptr_t x) { switch (insertType) { case 's': return strlen((char *)x); @@ -90,7 +94,7 @@ case 'c': return 1; case 'i': - return intLength(x); + return intLength(x) + (x < 0); } return 0; } diff --git a/src/userland/hlib/stdio.c b/src/userland/hlib/stdio.c index 85c14dd..2035921 100644 --- a/src/userland/hlib/stdio.c +++ b/src/userland/hlib/stdio.c @@ -68,11 +68,15 @@ (*write)++; } -void putInt(char **write, uintptr_t x) { +void putInt(char **write, intptr_t x) { if (x == 0) { addChar(write, '0'); return; } + if (x < 0) { + addChar(write, '-'); + x *= -1; + } for (intptr_t i = 10; i >= 0; i--) { uintptr_t n = x / power(10, i); if (n) { @@ -81,7 +85,7 @@ } } -uint32_t getInsertLength(char insertType, uintptr_t x) { +uint32_t getInsertLength(char insertType, intptr_t x) { switch (insertType) { case 's': return strlen((char *)x); @@ -90,7 +94,7 @@ case 'c': return 1; case 'i': - return intLength(x); + return intLength(x) + (x < 0); } return 0; } diff --git a/src/userland/usb/xhci/xhci.c b/src/userland/usb/xhci/xhci.c index 6cb456b..24abc7a 100644 --- a/src/userland/usb/xhci/xhci.c +++ b/src/userland/usb/xhci/xhci.c @@ -208,21 +208,10 @@ slot->controller->doorbells[slot->slotIndex] = endpointIndex + 1; await(serviceId, eventId); MouseReport *report = buffer; - printf("event: buttons: %i, ", report->buttons); - // TODO add negative number printing support to printf - if (report->x < 0) { - printf("x: -%i, ", -report->x); - } else { - printf("x: %i, ", report->x); - } - if (report->y < 0) { - printf("y: -%i\n", -report->y); - } else { - printf("y: %i\n", report->y); - } + printf("event: buttons: %i, x: %i, y: %i\n", report->buttons, report->x, report->y); // todo: sleep for at least endpoint->interval? // todo: start this loop in a fork? - sleep(100); + sleep(10); } }