+ read and write keyboard buffer
This commit is contained in:
parent
82bab57e98
commit
32b66cf8bf
|
@ -74,7 +74,7 @@ namespace vkvm {
|
|||
auto buttonPressed(KeyCode keyCode) -> void {
|
||||
lockSharedMemory();
|
||||
auto reg = getRegisters();
|
||||
if (reg->keyboardBuffer_index_write == sizeof(reg->keyboardBuffer)) {
|
||||
if (reg->keyboardBuffer_index_write >= sizeof(reg->keyboardBuffer)) {
|
||||
reg->keyboardBuffer_index_write = 0;
|
||||
}
|
||||
reg->keyboardBuffer[reg->keyboardBuffer_index_write++] = keyCode;
|
||||
|
|
13
src/vkvm.cpp
13
src/vkvm.cpp
|
@ -210,8 +210,17 @@ namespace vkvm {
|
|||
}
|
||||
|
||||
auto getLastPressedKey() -> KeyCode {
|
||||
//TODO(julian): get key properly
|
||||
return KeyCode(0);
|
||||
lockSharedMemory();
|
||||
auto reg = getRegisters();
|
||||
if(reg->keyboardBuffer_index_read == reg->keyboardBuffer_index_write){
|
||||
return KeyCode(0);
|
||||
}
|
||||
KeyCode keyCode = (KeyCode)reg->keyboardBuffer[reg->keyboardBuffer_index_read++];
|
||||
if(reg->keyboardBuffer_index_read >= sizeof(reg->keyboardBuffer)){
|
||||
reg->keyboardBuffer_index_read = 0;
|
||||
}
|
||||
unlockSharedMemory();
|
||||
return keyCode;
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue