return last keycode if buffer is empty

This commit is contained in:
Julian Hinxlage 2020-01-07 10:54:25 +01:00
parent 32e31201ff
commit 50b24b5644

View File

@ -325,6 +325,14 @@ namespace vkvm {
if (reg->keyboardBuffer_index_read >= keyboardBufferSize) { if (reg->keyboardBuffer_index_read >= keyboardBufferSize) {
reg->keyboardBuffer_index_read = 0; reg->keyboardBuffer_index_read = 0;
} }
}else{
if(reg->keyboardBuffer_index_read == 0){
auto code = reg->keyboardBuffer[keyboardBufferSize - 1];
keyCode = KeyCode(code);
}else{
auto code = reg->keyboardBuffer[reg->keyboardBuffer_index_read - 1];
keyCode = KeyCode(code);
}
} }
unlockSharedMemory(); unlockSharedMemory();
return keyCode; return keyCode;