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; } }