finished input

This commit is contained in:
Jonas Zeunert
2018-04-27 01:46:43 +02:00
parent 65bf3e5958
commit 20b5be8bfa
4 changed files with 17373 additions and 21 deletions

View File

@@ -7,9 +7,14 @@
#ifndef INPUTFACTORY_H_
#define INPUTFACTORY_H_
#include <vector>
#include "InputEvent.h"
#include <fstream>
#include "Detector.h"
#include "../lib/json/json.hpp"
using namespace nlohmann;
namespace Input
{
@@ -17,17 +22,35 @@ class InputFactory
{
public:
InputFactory();
~InputFactory();
static Detector* get_detector(std::string& input_config_path, std::string& matrix_config_path)
{
std::ifstream input_config_stream(input_config_path);
json input_config;
input_config << input_config_stream;
std::vector<InputEvent*> get_input_events();
std::ifstream matrix_config_stream(input_config_path);
json matrix_config;
matrix_config << matrix_config_stream;
std::vector<InputEvent> input_events = create_input_events(matrix_config);
return new Detector(input_config, input_events);
}
private:
std::vector<InputEvent*> input_events;
static std::vector<InputEvent> create_input_events(json matrix_config)
{
std::vector<InputEvent> input_events;
for(auto& key : matrix_config)
{
InputEvent event(matrix_config[key], key);
}
return input_events;
}
};
}
#endif /* INPUTFACTORY_H_ */