Merge remote-tracking branch 'origin/dev' into dev

This commit is contained in:
Julian Hinxlage 2019-11-27 13:08:39 +01:00
commit e0b0ee11d0
6 changed files with 3740 additions and 1 deletions

1
.gitignore vendored
View File

@ -10,6 +10,5 @@ CmakeCache.txt
bin/
lib/
include/
build/

View File

@ -8,6 +8,12 @@ if ("${CMAKE_BINARY_DIR}" STREQUAL "${CMAKE_SOURCE_DIR}")
endif()
set_property(DIRECTORY APPEND PROPERTY ADDITIONAL_MAKE_CLEAN_FILES "bin" "doc" "CMakeFiles" "lib" "include")
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")
#set(CMAKE_CXX_COMPILER "clang++")
#set(CMAKE_C_COMPILER "/usr/bin/clang")
#set(CMAKE_CXX_COMPILER "/usr/bin/clang++")
project(Shared_Memory)
set(CMAKE_CXX_STANDARD 14)
@ -32,3 +38,6 @@ target_link_libraries(UnitTests Catch2::Catch2)
include(CTest)
include(Catch)
catch_discover_tests(UnitTests)
#toml
include_directories(lib/toml)

3668
lib/toml/cpptoml.h Normal file

File diff suppressed because it is too large Load Diff

15
res/config.toml Normal file
View File

@ -0,0 +1,15 @@
#defaultKey = 12345
newKey = 0
layoutVersion = 0
width = 0
height = 0
mode = 0
redrawInterval = 0
timerInterruptInterval = 0
backgroundColor = 0
foregroundColor = 0
charactersPerRow = 0
charactersPerColumn = 0
font = 0
mousePositionX = 0
mousePositionY = 0

View File

@ -2,6 +2,11 @@
#include "SharedMemory.h"
#include <iostream>
#include <fstream>
#include <cpptoml.h>
#include <vkvm.hpp>
key_t changedKey()
{
@ -15,6 +20,10 @@ key_t changedKey()
std::cout <<"New Key is -> " << newKey << std::endl;
keyFile << newKey;
keyFile.close();
auto config = cpptoml::parse_file(configFile);
newKey = config->get_as<int>("newKey").value_or(0); //toml
return key_t(newKey);
}
@ -83,3 +92,40 @@ void deleteSharedMemory(void)
}
}
void getConfig(){
auto config = cpptoml::parse_file(configFile);
int layoutVersion = config->get_as<int>("layoutVersion").value_or(0);
int width = config->get_as<int>("width").value_or(0);
int height = config->get_as<int>("height").value_or(0);
int mode = config->get_as<int>("mode").value_or(0);
int timerInterruptInterval = config->get_as<int>("timerInterruptInterval").value_or(0);
int backgroundColor = config->get_as<int>("backgroundColor").value_or(0);
int foregroundColor = config->get_as<int>("foregroundColor").value_or(0);
int charactersPerRow = config->get_as<int>("charactersPerRow").value_or(0);
int charactersPerColumn = config->get_as<int>("charactersPerColumn").value_or(0);
int font = config->get_as<int>("font").value_or(0);
int mousePositionX = config->get_as<int>("mousePositionX").value_or(0);
int mousePositionY = config->get_as<int>("mousePositionY").value_or(0);
/*
//convert to hex
std::string result;
std::stringstream ss;
ss << std::hex << result;
ss >> result;
*/
vkvm::setLayoutVersion((vkvm::LayoutVersion) layoutVersion);
vkvm::setWidth(width);
vkvm::setHeight(height);
vkvm::setMode((vkvm::GraphicMode) mode);
vkvm::setTimerInterruptInterval(timerInterruptInterval);
vkvm::setBackgroundColor(vkvm::Color(backgroundColor));
vkvm::setForegroundColor(vkvm::Color(foregroundColor));
vkvm::setCharactersPerRow(charactersPerRow);
vkvm::setCharactersPerColumn(charactersPerColumn);
vkvm::setFont(vkvm::FontType(font,"",0,0));
vkvm::setMousePosition(mousePositionX, mousePositionY);
}

View File

@ -13,4 +13,6 @@ void deleteSharedMemory(void);
void initSharedMemory(void);
key_t changedKey();
std::string getAnswerFromUser();
//Config File
#define configFile "res/config.toml"
#endif //SHARED_MEMORY_H