q = &(state->kbd_queue);
}
- if (q->count == QUEUE_SIZE) {
+ if (q->count >= QUEUE_SIZE) {
return 0;
}
state->status.cmd = 0;
}
- q->queue[q->end++] = value;
+ q->queue[q->end] = value;
+
+ if (q->end >= (QUEUE_SIZE - 1)) {
+ q->end = 0;
+ } else {
+ q->end++;
+ }
+
q->count++;
return 0;
}
- *value = q->queue[q->start++];
+ *value = q->queue[q->start];
+
+ if (q->start >= (QUEUE_SIZE - 1)) {
+ q->start = 0;
+ } else {
+ q->start++;
+ }
+
q->count--;
keyboard_state = (struct keyboard_internal *)V3_Malloc(sizeof(struct keyboard_internal));
+ memset(keyboard_state, 0, sizeof(struct keyboard_internal));
+
keyboard_state->mouse_queue.start = 0;
keyboard_state->mouse_queue.end = 0;
keyboard_state->mouse_queue.count = 0;