~ fixed keyboard buffer error

This commit is contained in:
Julian Hinxlage 2019-12-04 12:32:54 +01:00
parent 868682e9d9
commit 128951d856
2 changed files with 3 additions and 3 deletions

View File

@ -74,10 +74,10 @@ namespace vkvm {
auto buttonPressed(KeyCode keyCode) -> void { auto buttonPressed(KeyCode keyCode) -> void {
lockSharedMemory(); lockSharedMemory();
auto reg = getRegisters(); 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_index_write = 0;
} }
reg->keyboardBuffer[reg->keyboardBuffer_index_write++] = keyCode;
unlockSharedMemory(); unlockSharedMemory();
} }

View File

@ -326,7 +326,7 @@ namespace vkvm {
auto reg = getRegisters(); auto reg = getRegisters();
if (reg->keyboardBuffer_index_read != reg->keyboardBuffer_index_write) { if (reg->keyboardBuffer_index_read != reg->keyboardBuffer_index_write) {
keyCode = static_cast<KeyCode>(reg->keyboardBuffer[reg->keyboardBuffer_index_read++]); keyCode = static_cast<KeyCode>(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; reg->keyboardBuffer_index_read = 0;
} }
} }