+ 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 {
|
auto buttonPressed(KeyCode keyCode) -> void {
|
||||||
lockSharedMemory();
|
lockSharedMemory();
|
||||||
auto reg = getRegisters();
|
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_index_write = 0;
|
||||||
}
|
}
|
||||||
reg->keyboardBuffer[reg->keyboardBuffer_index_write++] = keyCode;
|
reg->keyboardBuffer[reg->keyboardBuffer_index_write++] = keyCode;
|
||||||
|
11
src/vkvm.cpp
11
src/vkvm.cpp
@ -210,8 +210,17 @@ namespace vkvm {
|
|||||||
}
|
}
|
||||||
|
|
||||||
auto getLastPressedKey() -> KeyCode {
|
auto getLastPressedKey() -> KeyCode {
|
||||||
//TODO(julian): get key properly
|
lockSharedMemory();
|
||||||
|
auto reg = getRegisters();
|
||||||
|
if(reg->keyboardBuffer_index_read == reg->keyboardBuffer_index_write){
|
||||||
return KeyCode(0);
|
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
Block a user