implemented cli
This commit is contained in:
@@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.6.2)
|
||||
project(FlippR_Driver_CLI)
|
||||
|
||||
set(EXECUTABLE_OUTPUT_PATH ${CMAKE_SOURCE_DIR}/${OUTPUT_PATH}/cli)
|
||||
add_executable(${PROJECT_NAME} main.cpp)
|
||||
add_executable(${PROJECT_NAME} main.cpp PrintHandler.cpp)
|
||||
|
||||
target_include_directories(${PROJECT_NAME} PRIVATE ${CMAKE_SOURCE_DIR}/include)
|
||||
target_link_libraries(${PROJECT_NAME} PRIVATE FlippR-Driver)
|
||||
|
||||
11
FlippR-Driver/cli/PrintHandler.cpp
Normal file
11
FlippR-Driver/cli/PrintHandler.cpp
Normal file
@@ -0,0 +1,11 @@
|
||||
//
|
||||
// Created by rhetenor on 13.09.18.
|
||||
//
|
||||
|
||||
#include "PrintHandler.h"
|
||||
#include <iostream>
|
||||
|
||||
void PrintHandler::handle(FlippR_Driver::Input::Event &event)
|
||||
{
|
||||
std::cout << "Event " << event.name << " (" << event.address << ") occured!";
|
||||
}
|
||||
17
FlippR-Driver/cli/PrintHandler.h
Normal file
17
FlippR-Driver/cli/PrintHandler.h
Normal file
@@ -0,0 +1,17 @@
|
||||
//
|
||||
// Created by rhetenor on 13.09.18.
|
||||
//
|
||||
|
||||
#ifndef FLIPPR_DRIVER_PRINTHANDLER_H
|
||||
#define FLIPPR_DRIVER_PRINTHANDLER_H
|
||||
|
||||
#include "IEventHandler.h"
|
||||
|
||||
class PrintHandler : public IEventHandler
|
||||
{
|
||||
public:
|
||||
virtual void handle(FlippR_Driver::Input::Event& event);
|
||||
};
|
||||
|
||||
|
||||
#endif //FLIPPR_DRIVER_PRINTHANDLER_H
|
||||
@@ -4,18 +4,30 @@
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <memory>
|
||||
#include <signal.h>
|
||||
|
||||
#include "DriverFactory.h"
|
||||
#include "IInputDriver.h"
|
||||
|
||||
#include "PrintHandler.h"
|
||||
|
||||
using namespace FlippR_Driver;
|
||||
|
||||
void siginthandler(int param)
|
||||
{
|
||||
printf("Caught SIGINT... aborting!\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
int main (int argc, char *argv[])
|
||||
{
|
||||
if(argc != 3)
|
||||
{
|
||||
std::cout << "Usage: " << argv[0] << " <input_config_file> <matrix_config_file>";
|
||||
}
|
||||
|
||||
signal(SIGINT, siginthandler);
|
||||
|
||||
std::string input_config_file = argv[1];
|
||||
std::string matrix_config_file = argv[2];
|
||||
|
||||
@@ -29,9 +41,16 @@ int main (int argc, char *argv[])
|
||||
catch(const std::exception& e)
|
||||
{
|
||||
std::cout << e.what();
|
||||
exit(1);
|
||||
exit(2);
|
||||
}
|
||||
|
||||
std::shared_ptr<Input::IInputDriver> driver = FlippR_Driver::get_InputDriver(input_config, matrix_config);
|
||||
|
||||
PrintHandler* print_handler = new PrintHandler();
|
||||
|
||||
driver->register_event_handler(print_handler);
|
||||
|
||||
while(1);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user