From 128951d856670652a15670279d7aa2ad25bd8a21 Mon Sep 17 00:00:00 2001 From: Julian Hinxlage Date: Wed, 4 Dec 2019 12:32:54 +0100 Subject: [PATCH] ~ fixed keyboard buffer error --- src/internal.cpp | 4 ++-- src/vkvm.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/internal.cpp b/src/internal.cpp index 436c76e..40f6c73 100644 --- a/src/internal.cpp +++ b/src/internal.cpp @@ -74,10 +74,10 @@ namespace vkvm { auto buttonPressed(KeyCode keyCode) -> void { lockSharedMemory(); auto reg = getRegisters(); - if (reg->keyboardBuffer_index_write >= sizeof(reg->keyboardBuffer)) { + reg->keyboardBuffer[reg->keyboardBuffer_index_write++] = keyCode; + if (reg->keyboardBuffer_index_write >= keyboardBufferSize) { reg->keyboardBuffer_index_write = 0; } - reg->keyboardBuffer[reg->keyboardBuffer_index_write++] = keyCode; unlockSharedMemory(); } diff --git a/src/vkvm.cpp b/src/vkvm.cpp index 6337c99..3d0455d 100644 --- a/src/vkvm.cpp +++ b/src/vkvm.cpp @@ -326,7 +326,7 @@ namespace vkvm { auto reg = getRegisters(); if (reg->keyboardBuffer_index_read != reg->keyboardBuffer_index_write) { keyCode = static_cast(reg->keyboardBuffer[reg->keyboardBuffer_index_read++]); - if (reg->keyboardBuffer_index_read >= sizeof(reg->keyboardBuffer)) { + if (reg->keyboardBuffer_index_read >= keyboardBufferSize) { reg->keyboardBuffer_index_read = 0; } }