finished input
This commit is contained in:
@@ -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_ */
|
||||
|
||||
Reference in New Issue
Block a user