Merge remote-tracking branch 'origin/dev' into dev
This commit is contained in:
commit
987d03f665
|
@ -1,24 +0,0 @@
|
|||
#include "FontType.hpp"
|
||||
|
||||
namespace vkvm {
|
||||
|
||||
FontType::FontType(int id, const char * name, int height, int width) noexcept : id(id), name(name), height(height), width(width) {
|
||||
}
|
||||
|
||||
auto FontType::getId() const -> int {
|
||||
return id;
|
||||
}
|
||||
|
||||
auto FontType::getName() const -> std::string {
|
||||
return std::string(name);
|
||||
}
|
||||
|
||||
auto FontType::getHeight() const -> int {
|
||||
return height;
|
||||
}
|
||||
|
||||
auto FontType::getWidth() const -> int {
|
||||
return width;
|
||||
}
|
||||
|
||||
}
|
|
@ -2,32 +2,14 @@
|
|||
|
||||
#define LIBRARY_FONT_H
|
||||
|
||||
#include <string>
|
||||
#include <utility>
|
||||
|
||||
namespace vkvm {
|
||||
|
||||
class FontType {
|
||||
private:
|
||||
int id;
|
||||
const char * name;
|
||||
int height;
|
||||
int width;
|
||||
|
||||
public:
|
||||
FontType(int id, const char * name, int height, int width) noexcept;
|
||||
|
||||
auto getId() const -> int;
|
||||
|
||||
auto getName() const -> std::string;
|
||||
|
||||
auto getHeight() const -> int;
|
||||
|
||||
auto getWidth() const -> int;
|
||||
|
||||
enum FontType {
|
||||
FuturisticBlack = 1,
|
||||
//TODO(julian): find name of this font
|
||||
NoNameFound = 2,
|
||||
ProFontIIX = 3
|
||||
};
|
||||
|
||||
static const FontType font_1 = FontType(1, "DummyFont", 10, 5);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -19,9 +19,9 @@ namespace vkvm {
|
|||
setMousePosition(42, 42);
|
||||
setBackgroundColor(black);
|
||||
setForegroundColor(white);
|
||||
setRedrawInterval(20);
|
||||
setTimerInterruptInterval(10);
|
||||
setFont(FontType(3, "", 0, 0));
|
||||
setRedrawInterval(500);
|
||||
setTimerInterruptInterval(1000);
|
||||
setFont(FontType::FuturisticBlack);
|
||||
}
|
||||
impl.localMemoryWarn = true;
|
||||
}
|
||||
|
|
|
@ -38,7 +38,7 @@ constexpr int keyboardBufferSize = 16;
|
|||
int textMode_font_height;
|
||||
int mouse_pos_x;
|
||||
int mouse_pos_y;
|
||||
std::array<int16_t, keyboardBufferSize> keyboardBuffer;
|
||||
std::array<int32_t, keyboardBufferSize> keyboardBuffer;
|
||||
int keyboardBuffer_index_write;
|
||||
int keyboardBuffer_index_read;
|
||||
};
|
||||
|
@ -130,7 +130,7 @@ constexpr int keyboardBufferSize = 16;
|
|||
auto buttonPressed(KeyCode keyCode) -> void;
|
||||
|
||||
/**
|
||||
* get registered Prosesses for a given event type.
|
||||
* get registered Processes for a given event type.
|
||||
* @param eventType.
|
||||
*/
|
||||
auto getRegisteredProcesses(EventType eventType) -> std::vector<int>;
|
||||
|
|
|
@ -301,14 +301,12 @@ namespace vkvm {
|
|||
}
|
||||
|
||||
auto getFont() -> FontType {
|
||||
//TODO(julian): get font properly
|
||||
return {getRegisters()->textMode_font, "", 0, 0};
|
||||
return FontType(getRegisters()->textMode_font);
|
||||
}
|
||||
|
||||
auto setFont(const FontType &newValue) -> void {
|
||||
//TODO(julian): setFont properly
|
||||
lockSharedMemory();
|
||||
getRegisters()->textMode_font = newValue.getId();
|
||||
getRegisters()->textMode_font = newValue;
|
||||
unlockSharedMemory();
|
||||
callEvent(EventType::UpdateControlRegisters);
|
||||
}
|
||||
|
@ -322,7 +320,8 @@ namespace vkvm {
|
|||
auto keyCode = KeyCode(0);
|
||||
auto reg = getRegisters();
|
||||
if (reg->keyboardBuffer_index_read != reg->keyboardBuffer_index_write) {
|
||||
keyCode = static_cast<KeyCode>(reg->keyboardBuffer[reg->keyboardBuffer_index_read++]);
|
||||
auto code = reg->keyboardBuffer[reg->keyboardBuffer_index_read++];
|
||||
keyCode = KeyCode(code);
|
||||
if (reg->keyboardBuffer_index_read >= keyboardBufferSize) {
|
||||
reg->keyboardBuffer_index_read = 0;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
#include "../src/internal.hpp"
|
||||
#include "../src/vkvm.hpp"
|
||||
#include <catch2/catch.hpp>
|
||||
|
||||
|
||||
TEST_CASE("Keyboard Buffer") {
|
||||
SECTION("write") {
|
||||
vkvm::setLogLevel(vkvm::DEBUG);
|
||||
vkvm::buttonPressed(vkvm::A);
|
||||
vkvm::buttonPressed(vkvm::B);
|
||||
vkvm::buttonPressed(vkvm::C);
|
||||
}
|
||||
|
||||
SECTION("read") {
|
||||
CHECK(vkvm::getLastPressedKey() == vkvm::A);
|
||||
CHECK(vkvm::getLastPressedKey() == vkvm::B);
|
||||
CHECK(vkvm::getLastPressedKey() == vkvm::C);
|
||||
}
|
||||
}
|
|
@ -15,9 +15,9 @@ TEST_CASE("Default values") {
|
|||
REQUIRE(vkvm::getMousePosition().y == 42);
|
||||
REQUIRE(vkvm::getBackgroundColor() == vkvm::black);
|
||||
REQUIRE(vkvm::getForegroundColor() == vkvm::white);
|
||||
REQUIRE(vkvm::getRedrawInterval() == 20);
|
||||
REQUIRE(vkvm::getTimerInterruptInterval() == 10);
|
||||
REQUIRE(vkvm::getFont().getId() == 3);
|
||||
REQUIRE(vkvm::getRedrawInterval() == 500);
|
||||
REQUIRE(vkvm::getTimerInterruptInterval() == 1000);
|
||||
REQUIRE(vkvm::getFont() == vkvm::FuturisticBlack);
|
||||
}
|
||||
|
||||
SECTION("change") {
|
||||
|
@ -31,7 +31,7 @@ TEST_CASE("Default values") {
|
|||
vkvm::setForegroundColor(vkvm::blue);
|
||||
vkvm::setRedrawInterval(1);
|
||||
vkvm::setTimerInterruptInterval(2);
|
||||
vkvm::setFont(vkvm::FontType(5, "", 5, 5));
|
||||
vkvm::setFont(vkvm::ProFontIIX);
|
||||
|
||||
|
||||
|
||||
|
@ -46,7 +46,7 @@ TEST_CASE("Default values") {
|
|||
REQUIRE(vkvm::getForegroundColor() == vkvm::blue);
|
||||
REQUIRE(vkvm::getRedrawInterval() == 1);
|
||||
REQUIRE(vkvm::getTimerInterruptInterval() == 2);
|
||||
REQUIRE(vkvm::getFont().getId() == 5);
|
||||
REQUIRE(vkvm::getFont() == vkvm::ProFontIIX);
|
||||
}
|
||||
|
||||
|
||||
|
@ -61,9 +61,9 @@ TEST_CASE("Default values") {
|
|||
REQUIRE(vkvm::getMousePosition().y == 42);
|
||||
REQUIRE(vkvm::getBackgroundColor() == vkvm::black);
|
||||
REQUIRE(vkvm::getForegroundColor() == vkvm::white);
|
||||
REQUIRE(vkvm::getRedrawInterval() == 20);
|
||||
REQUIRE(vkvm::getTimerInterruptInterval() == 10);
|
||||
REQUIRE(vkvm::getFont().getId() == 3);
|
||||
REQUIRE(vkvm::getRedrawInterval() == 500);
|
||||
REQUIRE(vkvm::getTimerInterruptInterval() == 1000);
|
||||
REQUIRE(vkvm::getFont() == vkvm::FuturisticBlack);
|
||||
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue