X-Git-Url: http://git.squeep.com/?p=dcpu16;a=blobdiff_plain;f=hw_keyboard.c;h=f69b8f4227e7eaa07a69ce7ffcfdc3ab9f5c0004;hp=aaf2f2c88f5a24cd5139517343bd15348d165205;hb=8265806f12a2ae59501cdcf2300b42d4d1c3a120;hpb=49be905f037fbd22b6ae0275efbab2ed95d4d9b7 diff --git a/hw_keyboard.c b/hw_keyboard.c index aaf2f2c..f69b8f4 100644 --- a/hw_keyboard.c +++ b/hw_keyboard.c @@ -70,7 +70,9 @@ void keyboard_rfbevent_(rfbBool down, rfbKeySym key, rfbClientPtr cl) { struct dcpu16_hw *hw = (struct dcpu16_hw *)cl->screen->screenData; struct keyboard_ *keyboard = (struct keyboard_ *)hw->data; - hw->vm->trace_cb_("%s>> down:%u rfb_key:0x%04x", down, key); +#ifdef DEBUG + hw->vm->msg_cb_(MSG_DEBUG, "%s>> down:%u rfb_key:0x%04x", down, key); +#endif /* DEBUG */ if (keysym_rfbtodcpu(key, &dcpu_key)) { /* unhandled key event */ @@ -80,7 +82,7 @@ void keyboard_rfbevent_(rfbBool down, rfbKeySym key, rfbClientPtr cl) { keyboard->keys_pressed[dcpu_key] = (down ? 1 : 0); if (down) { if ((keyboard->buf_tail + 1) % keyboard->buf_sz == keyboard->buf_head) { - hw->vm->warn_cb_("keyboard buffer overflow"); + hw->vm->msg_cb_(MSG_INFO, "keyboard buffer overflow"); return; } keyboard->buf[keyboard->buf_tail] = dcpu_key; @@ -150,13 +152,13 @@ int keyboard_data_init_(struct dcpu16_hw *hw, void *data) { hw->data = calloc(1, sizeof(struct keyboard_)); if (hw->data == NULL) { - hw->vm->warn_cb_("%s():%s", "calloc", strerror(errno)); + hw->vm->msg_cb_(MSG_ERROR, "%s():%s", "calloc", strerror(errno)); return -1; } ((struct keyboard_ *)(hw->data))->buf = malloc(buf_sz * sizeof *((struct keyboard_ *)(hw->data))->buf); if (((struct keyboard_ *)(hw->data))->buf == NULL) { - hw->vm->warn_cb_("%s():%s", "malloc", strerror(errno)); + hw->vm->msg_cb_(MSG_ERROR, "%s():%s", "malloc", strerror(errno)); free(hw->data); hw->data = NULL; return -1; @@ -199,11 +201,13 @@ int keyboard_data_ctl_(struct dcpu16_hw *hw, const char *cmd, void *data_in, voi } if (buf_sz_in) { - hw->vm->trace_cb_("%s>> resizing buffer from %zu to %zu", __func__, keyboard->buf_sz, *buf_sz_in); +#ifdef DEBUG + hw->vm->msg_cb_(MSG_DEBUG, "%s>> resizing buffer from %zu to %zu", __func__, keyboard->buf_sz, *buf_sz_in); +#endif /* DEBUG */ tmp_ptr = realloc(keyboard->buf, *buf_sz_in); if (tmp_ptr == NULL) { - hw->vm->warn_cb_("%s():%s", "realloc", strerror(errno)); + hw->vm->msg_cb_(MSG_DEBUG, "%s():%s", "realloc", strerror(errno)); return -1; } keyboard->buf = tmp_ptr;