diff --git a/FlippR-Driver/contrib/Input_Matrix_Config.json b/FlippR-Driver/contrib/Input_Matrix_Config.json index 7cc5ba2..3287ea4 100644 --- a/FlippR-Driver/contrib/Input_Matrix_Config.json +++ b/FlippR-Driver/contrib/Input_Matrix_Config.json @@ -1,227 +1,192 @@ { + "global_bounce_time" : 10, "input_matrix" : [ { "name" : "Out hole", "address" : 16, "priority" : 1, - "deactivation_time" : 50 + "bounce_time" : 10 }, { "name" : "Left outer exit canal", "address" : 17, - "priority" : 2, - "deactivation_time" : 50 + "priority" : 2 }, { "name" : "Inner left canal", "address" : 18, - "priority" : 2, - "deactivation_time" : 50 + "priority" : 2 }, { "name" : "Left flap contacts", "address" : 19, - "priority" : 2, - "deactivation_time" : 50 + "priority" : 2 }, { "name" : "Right flap contacts", "address" : 20, - "priority" : 2, - "deactivation_time" : 50 + "priority" : 2 }, { "name" : "Right inner canal", "address" : 21, - "priority" : 2, - "deactivation_time" : 50 + "priority" : 2 }, { "name" : "Right central exit canal", "address" : 22, - "priority" : 2, - "deactivation_time" : 50 + "priority" : 2 }, { "name" : "Right kicker contact", "address" : 23, - "priority" : 2, - "deactivation_time" : 50 + "priority" : 2 }, { "name" : "Contacts", "address" : 24, - "priority" : 2, - "deactivation_time" : 50 + "priority" : 2 }, { "name" : "1st moving target bottom left bank", "address" : 25, - "priority" : 2, - "deactivation_time" : 50 + "priority" : 2 }, { "name" : "2nd moving target bottom left bank", "address" : 26, - "priority" : 2, - "deactivation_time" : 50 + "priority" : 2 }, { "name" : "3rd moving target bottom left bank", "address" : 27, - "priority" : 2, - "deactivation_time" : 50 + "priority" : 2 }, { "name" : "4th moving target bottom left bank", "address" : 28, - "priority" : 2, - "deactivation_time" : 50 + "priority" : 2 }, { "name" : "Fixed special red target", "address" : 29, - "priority" : 2, - "deactivation_time" : 50 + "priority" : 2 }, { "name" : "Fixed special orange target", "address" : 30, - "priority" : 2, - "deactivation_time" : 50 + "priority" : 2 }, { "name" : "1st moving target bottom right bank", "address" : 31, - "priority" : 2, - "deactivation_time" : 50 + "priority" : 2 }, { "name" : "2nd moving target bottom right bank", "address" : 32, - "priority" : 2, - "deactivation_time" : 50 + "priority" : 2 }, { "name" : "3rd moving target bottom right bank", "address" : 33, - "priority" : 2, - "deactivation_time" : 50 + "priority" : 2 }, { "name" : "Spinning target", "address" : 34, - "priority" : 2, - "deactivation_time" : 50 + "priority" : 2 }, { "name" : "1st button", "address" : 35, - "priority" : 2, - "deactivation_time" : 50 + "priority" : 2 }, { "name" : "2nd button", "address" : 36, - "priority" : 2, - "deactivation_time" : 50 + "priority" : 2 }, { "name" : "3rd button", "address" : 37, - "priority" : 2, - "deactivation_time" : 50 + "priority" : 2 }, { "name" : "4th button", "address" : 38, - "priority" : 2, - "deactivation_time" : 50 + "priority" : 2 }, { "name" : "5th button", "address" : 39, - "priority" : 2, - "deactivation_time" : 50 + "priority" : 2 }, { "name" : "1st moving target top central bank", "address" : 40, - "priority" : 2, - "deactivation_time" : 50 + "priority" : 2 }, { "name" : "2nd moving target top central bank", "address" : 41, - "priority" : 2, - "deactivation_time" : 50 + "priority" : 2 }, { "name" : "3rd moving target top central bank", "address" : 42, - "priority" : 2, - "deactivation_time" : 50 + "priority" : 2 }, { "name" : "4th moving target top central bank", "address" : 43, - "priority" : 2, - "deactivation_time" : 50 + "priority" : 2 }, { "name" : "5th moving target top central bank", "address" : 44, - "priority" : 2, - "deactivation_time" : 50 + "priority" : 2 }, { "name" : "1st fixed target", "address" : 45, - "priority" : 2, - "deactivation_time" : 50 + "priority" : 2 }, { "name" : "2nd fixed target", "address" : 46, - "priority" : 2, - "deactivation_time" : 50 + "priority" : 2 }, { "name" : "Top left pop contact", "address" : 47, - "priority" : 2, - "deactivation_time" : 50 + "priority" : 2 }, { "name" : "Bottom right pop contact", "address" : 48, - "priority" : 2, - "deactivation_time" : 50 + "priority" : 2 }, { "name" : "5th fixed target", "address" : 49, - "priority" : 2, - "deactivation_time" : 50 + "priority" : 2 }, { "name" : "4th fixed target", "address" : 50, - "priority" : 2, - "deactivation_time" : 50 + "priority" : 2 }, { "name" : "3rd fixed target", "address" : 51, - "priority" : 2, - "deactivation_time" : 50 + "priority" : 2 }, { "name" : "Rising ball contact", "address" : 52, - "priority" : 2, - "deactivation_time" : 50 + "priority" : 2 } ] } diff --git a/FlippR-Driver/src/input/DistributingEvent.cpp b/FlippR-Driver/src/input/DistributingEvent.cpp index e5e8844..812b9eb 100644 --- a/FlippR-Driver/src/input/DistributingEvent.cpp +++ b/FlippR-Driver/src/input/DistributingEvent.cpp @@ -5,8 +5,11 @@ #include "DistributingEvent.h" FlippR_Driver::Input::DistributingEvent::DistributingEvent(char address, int priority, std::string name, - std::chrono::milliseconds bounce_time, std::shared_ptr event_notifier) -: Event(address, priority, name), bounce_time(bounce_time), event_notifier(event_notifier) + std::chrono::milliseconds bounce_time, std::shared_ptr event_notifier): + Event(address, priority, name), + bounce_time(bounce_time), + event_notifier(event_notifier), + activation_state(NOT_ACTIVATED) {} void FlippR_Driver::Input::DistributingEvent::distribute() diff --git a/FlippR-Driver/src/input/InputDriverFactory.cpp b/FlippR-Driver/src/input/InputDriverFactory.cpp index 201b79e..9f96e1f 100644 --- a/FlippR-Driver/src/input/InputDriverFactory.cpp +++ b/FlippR-Driver/src/input/InputDriverFactory.cpp @@ -50,19 +50,25 @@ void InputDriverFactory::create_input_events(json matrix_config, std::vector>& name_event_map, std::shared_ptr event_notifier) { + int global_bounce_time = matrix_config.at("global_bounce_time").get(); auto& event_array = matrix_config.at("input_matrix"); for (auto &json_event : event_array) { - try { std::string name = json_event.at("name"); char address = json_event.at("address").get(); int priority = json_event.at("priority").get(); - int deactivation_time = json_event.at("deactivation_time").get(); + int bounce_time = global_bounce_time; + + auto it_bounce_time = json_event.find("bounce_time"); + if (it_bounce_time != json_event.end()) + { + bounce_time = it_bounce_time->get(); + } std::shared_ptr event_ptr(new DistributingEvent(address, priority, name, - std::chrono::milliseconds(deactivation_time), event_notifier)); + std::chrono::milliseconds(bounce_time), event_notifier)); events.push_back(event_ptr); name_event_map.emplace(name, event_ptr); @@ -76,4 +82,4 @@ void InputDriverFactory::create_input_events(json matrix_config, std::vector