diff --git a/include/generic/readers.cpp b/include/generic/readers.cpp index 9602f1c..ad919e6 100644 --- a/include/generic/readers.cpp +++ b/include/generic/readers.cpp @@ -377,48 +377,14 @@ int mouse_generic::read_settings(){ _s_speed_levels[i-1] = buffer_in1[i][13]; // lightmode - if( buffer_in1[i][11] == 0x00 && buffer_in1[i][13] == 0x00 ) - _s_lightmodes[i-1] = lightmode_off; - else if( buffer_in1[i][11] == 0x01 && buffer_in1[i][13] == 0x04 ) - _s_lightmodes[i-1] = lightmode_breathing; - else if( buffer_in1[i][11] == 0x01 && buffer_in1[i][13] == 0x08 ) - _s_lightmodes[i-1] = lightmode_rainbow; - else if( buffer_in1[i][11] == 0x01 && buffer_in1[i][13] == 0x02 ) - _s_lightmodes[i-1] = lightmode_static; - else if( buffer_in1[i][11] == 0x02 && buffer_in1[i][13] == 0x00 ) - _s_lightmodes[i-1] = lightmode_wave; - else if( buffer_in1[i][11] == 0x06 && buffer_in1[i][13] == 0x00 ) - _s_lightmodes[i-1] = lightmode_alternating; - else if( buffer_in1[i][11] == 0x07 && buffer_in1[i][13] == 0x00 ) - _s_lightmodes[i-1] = lightmode_reactive; - else if( buffer_in1[i][11] == 0x01 && buffer_in1[i][13] == 0x10 ) - _s_lightmodes[i-1] = lightmode_flashing; + std::array lightmode_bytes = {buffer_in1[i][11], buffer_in1[i][13]}; + if( _c_lightmode_values.find(lightmode_bytes) != _c_lightmode_values.end() ) + _s_lightmodes[i-1] = _c_lightmode_values.at(lightmode_bytes); // polling rate (report rate) - if( i < 4 ){ - - if( buffer_in1[6][6+(2*i)] == 8 ) - _s_report_rates[i-1] = r_125Hz; - else if( buffer_in1[6][6+(2*i)] == 4 ) - _s_report_rates[i-1] = r_250Hz; - else if( buffer_in1[6][6+(2*i)] == 2 ) - _s_report_rates[i-1] = r_500Hz; - else if( buffer_in1[6][6+(2*i)] == 1 ) - _s_report_rates[i-1] = r_1000Hz; - - } else{ - - if( buffer_in1[7][(2*i)] == 8 ) - _s_report_rates[i-1] = r_125Hz; - else if( buffer_in1[7][(2*i)] == 4 ) - _s_report_rates[i-1] = r_250Hz; - else if( buffer_in1[7][(2*i)] == 2 ) - _s_report_rates[i-1] = r_500Hz; - else if( buffer_in1[7][(2*i)] == 1 ) - _s_report_rates[i-1] = r_1000Hz; - - } - + uint8_t report_rate_byte = (i < 4) ? buffer_in1[6][6+(2*i)] : buffer_in1[7][(2*i)]; + if( _c_report_rate_values.find(report_rate_byte) != _c_report_rate_values.end() ) + _s_report_rates[i-1] = _c_report_rate_values.at(report_rate_byte); // dpi for( int j = 1; j < 6; j++ ){ @@ -444,8 +410,6 @@ int mouse_generic::read_settings(){ } } - // macros - // macros std::array< std::vector< uint8_t >, 15 > macro_bytes; int macronumber = 1; diff --git a/include/m709/readers.cpp b/include/m709/readers.cpp index 30d1028..2d6bf51 100644 --- a/include/m709/readers.cpp +++ b/include/m709/readers.cpp @@ -377,48 +377,14 @@ int mouse_m709::read_settings(){ _s_speed_levels[i-1] = buffer_in1[i][13]; // lightmode - if( buffer_in1[i][11] == 0x00 && buffer_in1[i][13] == 0x00 ) - _s_lightmodes[i-1] = lightmode_off; - else if( buffer_in1[i][11] == 0x01 && buffer_in1[i][13] == 0x04 ) - _s_lightmodes[i-1] = lightmode_breathing; - else if( buffer_in1[i][11] == 0x01 && buffer_in1[i][13] == 0x08 ) - _s_lightmodes[i-1] = lightmode_rainbow; - else if( buffer_in1[i][11] == 0x01 && buffer_in1[i][13] == 0x02 ) - _s_lightmodes[i-1] = lightmode_static; - else if( buffer_in1[i][11] == 0x02 && buffer_in1[i][13] == 0x00 ) - _s_lightmodes[i-1] = lightmode_wave; - else if( buffer_in1[i][11] == 0x06 && buffer_in1[i][13] == 0x00 ) - _s_lightmodes[i-1] = lightmode_alternating; - else if( buffer_in1[i][11] == 0x07 && buffer_in1[i][13] == 0x00 ) - _s_lightmodes[i-1] = lightmode_reactive; - else if( buffer_in1[i][11] == 0x01 && buffer_in1[i][13] == 0x10 ) - _s_lightmodes[i-1] = lightmode_flashing; + std::array lightmode_bytes = {buffer_in1[i][11], buffer_in1[i][13]}; + if( _c_lightmode_values.find(lightmode_bytes) != _c_lightmode_values.end() ) + _s_lightmodes[i-1] = _c_lightmode_values.at(lightmode_bytes); // polling rate (report rate) - if( i < 4 ){ - - if( buffer_in1[6][6+(2*i)] == 8 ) - _s_report_rates[i-1] = r_125Hz; - else if( buffer_in1[6][6+(2*i)] == 4 ) - _s_report_rates[i-1] = r_250Hz; - else if( buffer_in1[6][6+(2*i)] == 2 ) - _s_report_rates[i-1] = r_500Hz; - else if( buffer_in1[6][6+(2*i)] == 1 ) - _s_report_rates[i-1] = r_1000Hz; - - } else{ - - if( buffer_in1[7][(2*i)] == 8 ) - _s_report_rates[i-1] = r_125Hz; - else if( buffer_in1[7][(2*i)] == 4 ) - _s_report_rates[i-1] = r_250Hz; - else if( buffer_in1[7][(2*i)] == 2 ) - _s_report_rates[i-1] = r_500Hz; - else if( buffer_in1[7][(2*i)] == 1 ) - _s_report_rates[i-1] = r_1000Hz; - - } - + uint8_t report_rate_byte = (i < 4) ? buffer_in1[6][6+(2*i)] : buffer_in1[7][(2*i)]; + if( _c_report_rate_values.find(report_rate_byte) != _c_report_rate_values.end() ) + _s_report_rates[i-1] = _c_report_rate_values.at(report_rate_byte); // dpi for( int j = 1; j < 6; j++ ){ @@ -444,8 +410,6 @@ int mouse_m709::read_settings(){ } } - // macros - // macros std::array< std::vector< uint8_t >, 15 > macro_bytes; int macronumber = 1; diff --git a/include/m715/readers.cpp b/include/m715/readers.cpp index 454c5d1..8d19c81 100644 --- a/include/m715/readers.cpp +++ b/include/m715/readers.cpp @@ -210,7 +210,7 @@ int mouse_m715::read_and_print_settings( std::ostream& output ){ std::string report_rate_string = ""; _i_decode_report_rate(report_rate_byte, report_rate_string); output << "report_rate=" << report_rate_string << "\n"; - + // dpi output << "\n# DPI settings\n"; output << "# Active dpi level for this profile: " << (int)buffer_in2[i-1][8]+1 << "\n"; @@ -381,47 +381,14 @@ int mouse_m715::read_settings(){ _s_speed_levels[i-1] = buffer_in1[i][13]; // lightmode - if( buffer_in1[i][11] == 0x00 && buffer_in1[i][13] == 0x00 ) - _s_lightmodes[i-1] = lightmode_off; - else if( buffer_in1[i][11] == 0x01 && buffer_in1[i][13] == 0x04 ) - _s_lightmodes[i-1] = lightmode_breathing; - else if( buffer_in1[i][11] == 0x01 && buffer_in1[i][13] == 0x08 ) - _s_lightmodes[i-1] = lightmode_rainbow; - else if( buffer_in1[i][11] == 0x01 && buffer_in1[i][13] == 0x02 ) - _s_lightmodes[i-1] = lightmode_static; - else if( buffer_in1[i][11] == 0x02 && buffer_in1[i][13] == 0x00 ) - _s_lightmodes[i-1] = lightmode_wave; - else if( buffer_in1[i][11] == 0x06 && buffer_in1[i][13] == 0x00 ) - _s_lightmodes[i-1] = lightmode_alternating; - else if( buffer_in1[i][11] == 0x07 && buffer_in1[i][13] == 0x00 ) - _s_lightmodes[i-1] = lightmode_reactive; - else if( buffer_in1[i][11] == 0x01 && buffer_in1[i][13] == 0x10 ) - _s_lightmodes[i-1] = lightmode_flashing; + std::array lightmode_bytes = {buffer_in1[i][11], buffer_in1[i][13]}; + if( _c_lightmode_values.find(lightmode_bytes) != _c_lightmode_values.end() ) + _s_lightmodes[i-1] = _c_lightmode_values.at(lightmode_bytes); // polling rate (report rate) - if( i < 4 ){ - - if( buffer_in1[6][6+(2*i)] == 8 ) - _s_report_rates[i-1] = r_125Hz; - else if( buffer_in1[6][6+(2*i)] == 4 ) - _s_report_rates[i-1] = r_250Hz; - else if( buffer_in1[6][6+(2*i)] == 2 ) - _s_report_rates[i-1] = r_500Hz; - else if( buffer_in1[6][6+(2*i)] == 1 ) - _s_report_rates[i-1] = r_1000Hz; - - } else{ - - if( buffer_in1[7][(2*i)] == 8 ) - _s_report_rates[i-1] = r_125Hz; - else if( buffer_in1[7][(2*i)] == 4 ) - _s_report_rates[i-1] = r_250Hz; - else if( buffer_in1[7][(2*i)] == 2 ) - _s_report_rates[i-1] = r_500Hz; - else if( buffer_in1[7][(2*i)] == 1 ) - _s_report_rates[i-1] = r_1000Hz; - - } + uint8_t report_rate_byte = (i < 4) ? buffer_in1[6][6+(2*i)] : buffer_in1[7][(2*i)]; + if( _c_report_rate_values.find(report_rate_byte) != _c_report_rate_values.end() ) + _s_report_rates[i-1] = _c_report_rate_values.at(report_rate_byte); // dpi @@ -452,8 +419,6 @@ int mouse_m715::read_settings(){ */ } - // macros - // macros std::array< std::vector< uint8_t >, 15 > macro_bytes; int macronumber = 1; diff --git a/include/m908/readers.cpp b/include/m908/readers.cpp index 99a3aa7..84ea48c 100644 --- a/include/m908/readers.cpp +++ b/include/m908/readers.cpp @@ -375,48 +375,14 @@ int mouse_m908::read_settings(){ _s_speed_levels[i-1] = buffer_in1[i][13]; // lightmode - if( buffer_in1[i][11] == 0x00 && buffer_in1[i][13] == 0x00 ) - _s_lightmodes[i-1] = lightmode_off; - else if( buffer_in1[i][11] == 0x01 && buffer_in1[i][13] == 0x04 ) - _s_lightmodes[i-1] = lightmode_breathing; - else if( buffer_in1[i][11] == 0x01 && buffer_in1[i][13] == 0x08 ) - _s_lightmodes[i-1] = lightmode_rainbow; - else if( buffer_in1[i][11] == 0x01 && buffer_in1[i][13] == 0x02 ) - _s_lightmodes[i-1] = lightmode_static; - else if( buffer_in1[i][11] == 0x02 && buffer_in1[i][13] == 0x00 ) - _s_lightmodes[i-1] = lightmode_wave; - else if( buffer_in1[i][11] == 0x06 && buffer_in1[i][13] == 0x00 ) - _s_lightmodes[i-1] = lightmode_alternating; - else if( buffer_in1[i][11] == 0x07 && buffer_in1[i][13] == 0x00 ) - _s_lightmodes[i-1] = lightmode_reactive; - else if( buffer_in1[i][11] == 0x01 && buffer_in1[i][13] == 0x10 ) - _s_lightmodes[i-1] = lightmode_flashing; + std::array lightmode_bytes = {buffer_in1[i][11], buffer_in1[i][13]}; + if( _c_lightmode_values.find(lightmode_bytes) != _c_lightmode_values.end() ) + _s_lightmodes[i-1] = _c_lightmode_values.at(lightmode_bytes); // polling rate (report rate) - if( i < 4 ){ - - if( buffer_in1[6][6+(2*i)] == 8 ) - _s_report_rates[i-1] = r_125Hz; - else if( buffer_in1[6][6+(2*i)] == 4 ) - _s_report_rates[i-1] = r_250Hz; - else if( buffer_in1[6][6+(2*i)] == 2 ) - _s_report_rates[i-1] = r_500Hz; - else if( buffer_in1[6][6+(2*i)] == 1 ) - _s_report_rates[i-1] = r_1000Hz; - - } else{ - - if( buffer_in1[7][(2*i)] == 8 ) - _s_report_rates[i-1] = r_125Hz; - else if( buffer_in1[7][(2*i)] == 4 ) - _s_report_rates[i-1] = r_250Hz; - else if( buffer_in1[7][(2*i)] == 2 ) - _s_report_rates[i-1] = r_500Hz; - else if( buffer_in1[7][(2*i)] == 1 ) - _s_report_rates[i-1] = r_1000Hz; - - } - + uint8_t report_rate_byte = (i < 4) ? buffer_in1[6][6+(2*i)] : buffer_in1[7][(2*i)]; + if( _c_report_rate_values.find(report_rate_byte) != _c_report_rate_values.end() ) + _s_report_rates[i-1] = _c_report_rate_values.at(report_rate_byte); // dpi for( int j = 1; j < 6; j++ ){ @@ -442,8 +408,6 @@ int mouse_m908::read_settings(){ } } - // macros - // macros std::array< std::vector< uint8_t >, 15 > macro_bytes; int macronumber = 1; diff --git a/include/m990/readers.cpp b/include/m990/readers.cpp index 139b819..deda9ae 100644 --- a/include/m990/readers.cpp +++ b/include/m990/readers.cpp @@ -386,48 +386,14 @@ int mouse_m990::read_settings(){ _s_speed_levels[i-1] = buffer_in1[i][13]; // lightmode - if( buffer_in1[i][11] == 0x00 && buffer_in1[i][13] == 0x00 ) - _s_lightmodes[i-1] = lightmode_off; - else if( buffer_in1[i][11] == 0x01 && buffer_in1[i][13] == 0x04 ) - _s_lightmodes[i-1] = lightmode_breathing; - else if( buffer_in1[i][11] == 0x01 && buffer_in1[i][13] == 0x08 ) - _s_lightmodes[i-1] = lightmode_rainbow; - else if( buffer_in1[i][11] == 0x01 && buffer_in1[i][13] == 0x02 ) - _s_lightmodes[i-1] = lightmode_static; - else if( buffer_in1[i][11] == 0x02 && buffer_in1[i][13] == 0x00 ) - _s_lightmodes[i-1] = lightmode_wave; - else if( buffer_in1[i][11] == 0x06 && buffer_in1[i][13] == 0x00 ) - _s_lightmodes[i-1] = lightmode_alternating; - else if( buffer_in1[i][11] == 0x07 && buffer_in1[i][13] == 0x00 ) - _s_lightmodes[i-1] = lightmode_reactive; - else if( buffer_in1[i][11] == 0x01 && buffer_in1[i][13] == 0x10 ) - _s_lightmodes[i-1] = lightmode_flashing; + std::array lightmode_bytes = {buffer_in1[i][11], buffer_in1[i][13]}; + if( _c_lightmode_values.find(lightmode_bytes) != _c_lightmode_values.end() ) + _s_lightmodes[i-1] = _c_lightmode_values.at(lightmode_bytes); // polling rate (report rate) - if( i < 4 ){ - - if( buffer_in1[6][6+(2*i)] == 8 ) - _s_report_rates[i-1] = r_125Hz; - else if( buffer_in1[6][6+(2*i)] == 4 ) - _s_report_rates[i-1] = r_250Hz; - else if( buffer_in1[6][6+(2*i)] == 2 ) - _s_report_rates[i-1] = r_500Hz; - else if( buffer_in1[6][6+(2*i)] == 1 ) - _s_report_rates[i-1] = r_1000Hz; - - } else{ - - if( buffer_in1[7][(2*i)] == 8 ) - _s_report_rates[i-1] = r_125Hz; - else if( buffer_in1[7][(2*i)] == 4 ) - _s_report_rates[i-1] = r_250Hz; - else if( buffer_in1[7][(2*i)] == 2 ) - _s_report_rates[i-1] = r_500Hz; - else if( buffer_in1[7][(2*i)] == 1 ) - _s_report_rates[i-1] = r_1000Hz; - - } - + uint8_t report_rate_byte = (i < 4) ? buffer_in1[6][6+(2*i)] : buffer_in1[7][(2*i)]; + if( _c_report_rate_values.find(report_rate_byte) != _c_report_rate_values.end() ) + _s_report_rates[i-1] = _c_report_rate_values.at(report_rate_byte); // dpi for( int j = 1; j < 6; j++ ){ @@ -453,8 +419,6 @@ int mouse_m990::read_settings(){ } } - // macros - // macros std::array< std::vector< uint8_t >, 15 > macro_bytes; int macronumber = 1; diff --git a/include/m990chroma/readers.cpp b/include/m990chroma/readers.cpp index ffcdbc4..935f6dd 100644 --- a/include/m990chroma/readers.cpp +++ b/include/m990chroma/readers.cpp @@ -380,48 +380,14 @@ int mouse_m990chroma::read_settings(){ _s_speed_levels[i-1] = buffer_in1[i][13]; // lightmode - if( buffer_in1[i][11] == 0x00 && buffer_in1[i][13] == 0x00 ) - _s_lightmodes[i-1] = lightmode_off; - else if( buffer_in1[i][11] == 0x01 && buffer_in1[i][13] == 0x04 ) - _s_lightmodes[i-1] = lightmode_breathing; - else if( buffer_in1[i][11] == 0x01 && buffer_in1[i][13] == 0x08 ) - _s_lightmodes[i-1] = lightmode_rainbow; - else if( buffer_in1[i][11] == 0x01 && buffer_in1[i][13] == 0x02 ) - _s_lightmodes[i-1] = lightmode_static; - else if( buffer_in1[i][11] == 0x02 && buffer_in1[i][13] == 0x00 ) - _s_lightmodes[i-1] = lightmode_wave; - else if( buffer_in1[i][11] == 0x06 && buffer_in1[i][13] == 0x00 ) - _s_lightmodes[i-1] = lightmode_alternating; - else if( buffer_in1[i][11] == 0x07 && buffer_in1[i][13] == 0x00 ) - _s_lightmodes[i-1] = lightmode_reactive; - else if( buffer_in1[i][11] == 0x01 && buffer_in1[i][13] == 0x10 ) - _s_lightmodes[i-1] = lightmode_flashing; + std::array lightmode_bytes = {buffer_in1[i][11], buffer_in1[i][13]}; + if( _c_lightmode_values.find(lightmode_bytes) != _c_lightmode_values.end() ) + _s_lightmodes[i-1] = _c_lightmode_values.at(lightmode_bytes); // polling rate (report rate) - if( i < 4 ){ - - if( buffer_in1[6][6+(2*i)] == 8 ) - _s_report_rates[i-1] = r_125Hz; - else if( buffer_in1[6][6+(2*i)] == 4 ) - _s_report_rates[i-1] = r_250Hz; - else if( buffer_in1[6][6+(2*i)] == 2 ) - _s_report_rates[i-1] = r_500Hz; - else if( buffer_in1[6][6+(2*i)] == 1 ) - _s_report_rates[i-1] = r_1000Hz; - - } else{ - - if( buffer_in1[7][(2*i)] == 8 ) - _s_report_rates[i-1] = r_125Hz; - else if( buffer_in1[7][(2*i)] == 4 ) - _s_report_rates[i-1] = r_250Hz; - else if( buffer_in1[7][(2*i)] == 2 ) - _s_report_rates[i-1] = r_500Hz; - else if( buffer_in1[7][(2*i)] == 1 ) - _s_report_rates[i-1] = r_1000Hz; - - } - + uint8_t report_rate_byte = (i < 4) ? buffer_in1[6][6+(2*i)] : buffer_in1[7][(2*i)]; + if( _c_report_rate_values.find(report_rate_byte) != _c_report_rate_values.end() ) + _s_report_rates[i-1] = _c_report_rate_values.at(report_rate_byte); // dpi for( int j = 1; j < 6; j++ ){ @@ -447,8 +413,6 @@ int mouse_m990chroma::read_settings(){ } } - // macros - // macros std::array< std::vector< uint8_t >, 15 > macro_bytes; int macronumber = 1;