fork/GramFirmware
git clone https://git.julia.blue/fork/GramFirmware
1f92ae6
v0.1.1
1#include "core/InputMode.hpp" 2 3#include "core/socd.hpp" 4#include "core/state.hpp" 5 6InputMode ::InputMode () {} 7 8InputMode ::~InputMode () { 9delete []_socd_pairs ; 10delete []_socd_states ; 11} 12 13void InputMode ::HandleSocd (InputState & inputs ) { 14if (_socd_pairs == nullptr ) { 15return ; 16 } 17 18// Initialize SOCD states if they aren't initialized. 19if (_socd_states == nullptr ) { 20_socd_states = new socd::SocdState [_socd_pair_count ]; 21 } 22 23// Handle SOCD resolution for each SOCD button pair. 24for (size_t i = 0 ;i < _socd_pair_count ;i ++ ) { 25 socd::SocdPair pair = _socd_pairs [i ]; 26switch (pair .socd_type ) { 27case socd::SOCD_NEUTRAL : 28 socd::neutral (inputs .*(pair .input_dir1 ),inputs .*( pair . input_dir2 )); 29break ; 30case socd:: SOCD_2IP : 31socd::second_input_priority( 32inputs .*( pair . input_dir1 ), 33inputs .*( pair . input_dir2 ), 34_socd_states [ i ] 35); 36break ; 37case socd:: SOCD_2IP_NO_REAC : 38socd::second_input_priority_no_reactivation( 39inputs .*( pair . input_dir1 ), 40inputs .*( pair . input_dir2 ), 41_socd_states [ i ] 42); 43break ; 44case socd:: SOCD_DIR1_PRIORITY : 45socd::dir1_priority( inputs .*( pair . input_dir1 ), inputs .*( pair . input_dir2 )); 46break ; 47case socd:: SOCD_DIR2_PRIORITY : 48socd::dir1_priority( inputs .*( pair . input_dir2 ), inputs .*( pair . input_dir1 )); 49break ; 50case socd:: SOCD_NONE : 51break ; 52 } 53 } 54}