Improve documentation and variable names
This commit is contained in:
parent
ec1ad2818a
commit
dab35e049e
10 changed files with 497 additions and 562 deletions
2
TODO.md
2
TODO.md
|
@ -1,4 +1,2 @@
|
|||
- [ ] Improve build method
|
||||
- [ ] Installation on all supported platforms
|
||||
- [ ] Add more source documentation
|
||||
- [ ] Rename class members to distinguish constants, functions and settings
|
||||
|
|
|
@ -5,6 +5,7 @@ Doxygen is used in places for source code documentation. To build the documentat
|
|||
```
|
||||
doxygen Doxyfile
|
||||
```
|
||||
A directory named doxygen will be created, containing html and latex files.
|
||||
|
||||
## USB Protocol description
|
||||
This directory contains captured usb data (when sending the default settings). For further details look at the write functions in the source code.
|
||||
|
|
|
@ -22,30 +22,30 @@
|
|||
mouse_m908::mouse_m908(){
|
||||
|
||||
//default settings
|
||||
_profile = profile_1;
|
||||
_scrollspeeds.fill( 0x01 );
|
||||
_lightmodes.fill( lightmode_static );
|
||||
_colors.fill( {0xff, 0xff, 0xff} );
|
||||
_brightness_levels.fill( 0x03 );
|
||||
_speed_levels.fill( 0x08 );
|
||||
_dpi_enabled.fill( {true, true, true, true, true} );
|
||||
_dpi_levels.fill( {0x04, 0x16, 0x2d, 0x43, 0x8c} );
|
||||
_s_profile = profile_1;
|
||||
_s_scrollspeeds.fill( 0x01 );
|
||||
_s_lightmodes.fill( lightmode_static );
|
||||
_s_colors.fill( {0xff, 0xff, 0xff} );
|
||||
_s_brightness_levels.fill( 0x03 );
|
||||
_s_speed_levels.fill( 0x08 );
|
||||
_s_dpi_enabled.fill( {true, true, true, true, true} );
|
||||
_s_dpi_levels.fill( {0x04, 0x16, 0x2d, 0x43, 0x8c} );
|
||||
for( int i = 0; i < 5; i++ ){
|
||||
for( int j = 0; j < 20; j++ ){
|
||||
_keymap_data[i][j][0] = _data_settings_3[35+(20*i)+j][8];
|
||||
_keymap_data[i][j][1] = _data_settings_3[35+(20*i)+j][9];
|
||||
_keymap_data[i][j][2] = _data_settings_3[35+(20*i)+j][10];
|
||||
_keymap_data[i][j][3] = _data_settings_3[35+(20*i)+j][11];
|
||||
_s_keymap_data[i][j][0] = _c_data_settings_3[35+(20*i)+j][8];
|
||||
_s_keymap_data[i][j][1] = _c_data_settings_3[35+(20*i)+j][9];
|
||||
_s_keymap_data[i][j][2] = _c_data_settings_3[35+(20*i)+j][10];
|
||||
_s_keymap_data[i][j][3] = _c_data_settings_3[35+(20*i)+j][11];
|
||||
}
|
||||
}
|
||||
_report_rates.fill( r_125Hz );
|
||||
_s_report_rates.fill( r_125Hz );
|
||||
int count = 0;
|
||||
for( auto &i : _macro_data ){
|
||||
std::copy(std::begin(_data_macros_2), std::end(_data_macros_2), std::begin(i));
|
||||
i[2] = _data_macros_codes[count][0];
|
||||
i[3] = _data_macros_codes[count][1];
|
||||
for( auto &i : _s_macro_data ){
|
||||
std::copy(std::begin(_c_data_macros_2), std::end(_c_data_macros_2), std::begin(i));
|
||||
i[2] = _c_data_macros_codes[count][0];
|
||||
i[3] = _c_data_macros_codes[count][1];
|
||||
count++;
|
||||
}
|
||||
_macro_repeat.fill( 0x01 );
|
||||
_s_macro_repeat.fill( 0x01 );
|
||||
|
||||
}
|
||||
|
|
|
@ -23,18 +23,18 @@
|
|||
#include "mouse_m908.h"
|
||||
|
||||
// usb device vars
|
||||
const uint16_t mouse_m908::_mouse_vid = 0x04d9;
|
||||
const uint16_t mouse_m908::_mouse_pid = 0xfc4d;
|
||||
const uint16_t mouse_m908::_c_mouse_vid = 0x04d9;
|
||||
const uint16_t mouse_m908::_c_mouse_pid = 0xfc4d;
|
||||
|
||||
//setting min and max values
|
||||
const uint8_t mouse_m908::_scrollspeed_min = 0x01, mouse_m908::_scrollspeed_max = 0x3f;
|
||||
const uint8_t mouse_m908::_brightness_min = 0x01, mouse_m908::_brightness_max = 0x03;
|
||||
const uint8_t mouse_m908::_speed_min = 0x01, mouse_m908::_speed_max = 0x08;
|
||||
const uint8_t mouse_m908::_level_min = 0, mouse_m908::_level_max = 4;
|
||||
const uint8_t mouse_m908::_dpi_min = 0x04, mouse_m908::_dpi_max = 0x8c;
|
||||
const uint8_t mouse_m908::_c_scrollspeed_min = 0x01, mouse_m908::_c_scrollspeed_max = 0x3f;
|
||||
const uint8_t mouse_m908::_c_brightness_min = 0x01, mouse_m908::_c_brightness_max = 0x03;
|
||||
const uint8_t mouse_m908::_c_speed_min = 0x01, mouse_m908::_c_speed_max = 0x08;
|
||||
const uint8_t mouse_m908::_c_level_min = 0, mouse_m908::_c_level_max = 4;
|
||||
const uint8_t mouse_m908::_c_dpi_min = 0x04, mouse_m908::_c_dpi_max = 0x8c;
|
||||
|
||||
//name → keycode
|
||||
std::map< std::string, std::array<uint8_t, 3> > mouse_m908::_keycodes = {
|
||||
std::map< std::string, std::array<uint8_t, 3> > mouse_m908::_c_keycodes = {
|
||||
{ "forward", { 0x85, 0x00, 0x00 } },
|
||||
{ "backward", { 0x84, 0x00, 0x00 } },
|
||||
{ "dpi+", { 0x8a, 0x00, 0x00 } },
|
||||
|
@ -74,7 +74,7 @@ std::map< std::string, std::array<uint8_t, 3> > mouse_m908::_keycodes = {
|
|||
{ "media_mute", { 0x8e, 0x01, 0xe2 } } };
|
||||
|
||||
//modifier name → value
|
||||
const std::map< std::string, uint8_t > mouse_m908::_keyboard_modifier_values = {
|
||||
const std::map< std::string, uint8_t > mouse_m908::_c_keyboard_modifier_values = {
|
||||
{ "ctrl_l+", 1 },
|
||||
{ "shift_l+", 2 },
|
||||
{ "alt_l+", 4 },
|
||||
|
@ -85,7 +85,7 @@ const std::map< std::string, uint8_t > mouse_m908::_keyboard_modifier_values = {
|
|||
{ "super_r+", 128 } };
|
||||
|
||||
//keyboard key name → value
|
||||
std::map< std::string, uint8_t > mouse_m908::_keyboard_key_values = {
|
||||
std::map< std::string, uint8_t > mouse_m908::_c_keyboard_key_values = {
|
||||
//top row
|
||||
{ "Esc", 0x29 },
|
||||
{ "F1", 0x3a },
|
||||
|
@ -222,7 +222,7 @@ std::map< std::string, uint8_t > mouse_m908::_keyboard_key_values = {
|
|||
{ "F24", 0x73 } };
|
||||
|
||||
// Names of the physical buttons
|
||||
std::map< int, std::string > mouse_m908::_button_names = {
|
||||
std::map< int, std::string > mouse_m908::_c_button_names = {
|
||||
{ 0, "button_left" },
|
||||
{ 1, "button_right" },
|
||||
{ 2, "button_middle" },
|
||||
|
@ -245,7 +245,7 @@ std::map< int, std::string > mouse_m908::_button_names = {
|
|||
{ 19, "scroll_down" } };
|
||||
|
||||
//usb data packets
|
||||
uint8_t mouse_m908::_data_profile[6][16] = {
|
||||
uint8_t mouse_m908::_c_data_s_profile[6][16] = {
|
||||
{0x02, 0xf3, 0x2c, 0x00, 0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
|
||||
{0x02, 0xf1, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
|
||||
{0x02, 0xf1, 0x02, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
|
||||
|
@ -254,7 +254,7 @@ uint8_t mouse_m908::_data_profile[6][16] = {
|
|||
{0x02, 0xf1, 0x02, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}
|
||||
};
|
||||
|
||||
uint8_t mouse_m908::_data_settings_1[15][16] = {
|
||||
uint8_t mouse_m908::_c_data_settings_1[15][16] = {
|
||||
{0x02, 0xf5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
|
||||
{0x02, 0xf3, 0x3e, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
|
||||
{0x02, 0xf3, 0x46, 0x04, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
|
||||
|
@ -272,14 +272,14 @@ uint8_t mouse_m908::_data_settings_1[15][16] = {
|
|||
{0x02, 0xf3, 0x38, 0x00, 0x04, 0x00, 0x00, 0x00, 0x02, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00}
|
||||
};
|
||||
|
||||
uint8_t mouse_m908::_data_settings_2[64] = {
|
||||
uint8_t mouse_m908::_c_data_settings_2[64] = {
|
||||
0x03, 0xf3, 0x20, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00,
|
||||
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
||||
};
|
||||
|
||||
uint8_t mouse_m908::_data_settings_3[140][16] = {
|
||||
uint8_t mouse_m908::_c_data_settings_3[140][16] = {
|
||||
{0x02, 0xf3, 0x42, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
|
||||
{0x02, 0xf3, 0x02, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
|
||||
{0x02, 0xf3, 0xb2, 0x01, 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
|
||||
|
@ -422,10 +422,10 @@ uint8_t mouse_m908::_data_settings_3[140][16] = {
|
|||
{0x02, 0xf5, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}
|
||||
};
|
||||
|
||||
uint8_t mouse_m908::_data_macros_1[16] =
|
||||
uint8_t mouse_m908::_c_data_macros_1[16] =
|
||||
{0x02, 0xf5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
|
||||
|
||||
uint8_t mouse_m908::_data_macros_2[256] = {
|
||||
uint8_t mouse_m908::_c_data_macros_2[256] = {
|
||||
0x04, 0xf3, 0x00, 0x00, 0xc8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
|
@ -444,10 +444,10 @@ uint8_t mouse_m908::_data_macros_2[256] = {
|
|||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
||||
};
|
||||
|
||||
uint8_t mouse_m908::_data_macros_3[16] =
|
||||
uint8_t mouse_m908::_c_data_macros_3[16] =
|
||||
{0x02, 0xf5, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
|
||||
|
||||
uint8_t mouse_m908::_data_macros_codes[15][2] = {
|
||||
uint8_t mouse_m908::_c_data_macros_codes[15][2] = {
|
||||
{0x78, 0x04},
|
||||
{0x40, 0x05},
|
||||
{0x08, 0x06},
|
||||
|
@ -464,10 +464,10 @@ uint8_t mouse_m908::_data_macros_codes[15][2] = {
|
|||
{0xa0, 0x0e},
|
||||
{0x68, 0x0f} };
|
||||
|
||||
uint8_t mouse_m908::_data_macros_repeat[16] =
|
||||
uint8_t mouse_m908::_c_data_macros_repeat[16] =
|
||||
{0x02, 0xf3, 0xa2, 0x00, 0x04, 0x00, 0x00, 0x00, 0x91, 0x05, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00};
|
||||
|
||||
uint8_t mouse_m908::_data_read_1[9][16] = {
|
||||
uint8_t mouse_m908::_c_data_read_1[9][16] = {
|
||||
{0x02, 0xf5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
|
||||
{0x02, 0xf2, 0x2c, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
|
||||
{0x02, 0xf2, 0x49, 0x04, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
|
||||
|
@ -479,7 +479,7 @@ uint8_t mouse_m908::_data_read_1[9][16] = {
|
|||
{0x02, 0xf2, 0x38, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}
|
||||
};
|
||||
|
||||
uint8_t mouse_m908::_data_read_2[85][64] = {
|
||||
uint8_t mouse_m908::_c_data_read_2[85][64] = {
|
||||
{0x03, 0xf2, 0x42, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
|
@ -905,7 +905,7 @@ uint8_t mouse_m908::_data_read_2[85][64] = {
|
|||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} };
|
||||
|
||||
uint8_t mouse_m908::_data_read_3[101][16] = {
|
||||
uint8_t mouse_m908::_c_data_read_3[101][16] = {
|
||||
{0x02, 0xf2, 0x82, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
|
||||
{0x02, 0xf2, 0x86, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
|
||||
{0x02, 0xf2, 0x8a, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
|
||||
|
|
|
@ -19,39 +19,39 @@
|
|||
#include "mouse_m908.h"
|
||||
|
||||
mouse_m908::m908_profile mouse_m908::get_profile(){
|
||||
return _profile;
|
||||
return _s_profile;
|
||||
}
|
||||
|
||||
uint8_t mouse_m908::get_scrollspeed( m908_profile profile ){
|
||||
return _scrollspeeds[profile];
|
||||
return _s_scrollspeeds[profile];
|
||||
}
|
||||
|
||||
mouse_m908::m908_lightmode mouse_m908::get_lightmode( m908_profile profile ){
|
||||
return _lightmodes[profile];
|
||||
return _s_lightmodes[profile];
|
||||
}
|
||||
|
||||
void mouse_m908::get_color( m908_profile profile, std::array<uint8_t, 3> &color ){
|
||||
color = _colors[profile];
|
||||
color = _s_colors[profile];
|
||||
}
|
||||
|
||||
uint8_t mouse_m908::get_brightness( m908_profile profile ){
|
||||
return _brightness_levels[profile];
|
||||
return _s_brightness_levels[profile];
|
||||
}
|
||||
|
||||
uint8_t mouse_m908::get_speed( m908_profile profile ){
|
||||
return _speed_levels[profile];
|
||||
return _s_speed_levels[profile];
|
||||
}
|
||||
|
||||
bool mouse_m908::get_dpi_enable( m908_profile profile, int level ){
|
||||
return _dpi_enabled[profile][level];
|
||||
return _s_dpi_enabled[profile][level];
|
||||
}
|
||||
|
||||
uint8_t mouse_m908::get_dpi( m908_profile profile, int level ){
|
||||
return _dpi_levels[profile][level];
|
||||
return _s_dpi_levels[profile][level];
|
||||
}
|
||||
|
||||
mouse_m908::m908_report_rate mouse_m908::get_report_rate( m908_profile profile ){
|
||||
return _report_rates[profile];
|
||||
return _s_report_rates[profile];
|
||||
}
|
||||
|
||||
uint8_t mouse_m908::get_macro_repeat( int macro_number ){
|
||||
|
@ -61,11 +61,11 @@ uint8_t mouse_m908::get_macro_repeat( int macro_number ){
|
|||
return 1;
|
||||
}
|
||||
|
||||
return _macro_repeat[macro_number];
|
||||
return _s_macro_repeat[macro_number];
|
||||
}
|
||||
|
||||
bool mouse_m908::get_detach_kernel_driver(){
|
||||
return _detach_kernel_driver;
|
||||
return _i_detach_kernel_driver;
|
||||
}
|
||||
|
||||
int mouse_m908::get_key_mapping_raw( mouse_m908::m908_profile profile, int key, std::array<uint8_t, 4>& mapping ){
|
||||
|
@ -73,10 +73,10 @@ int mouse_m908::get_key_mapping_raw( mouse_m908::m908_profile profile, int key,
|
|||
if( key < 0 || key > 19 ) // valid key ?
|
||||
return 1;
|
||||
|
||||
mapping[0] = _keymap_data[profile][key][0];
|
||||
mapping[1] = _keymap_data[profile][key][1];
|
||||
mapping[2] = _keymap_data[profile][key][2];
|
||||
mapping[3] = _keymap_data[profile][key][3];
|
||||
mapping[0] = _s_keymap_data[profile][key][0];
|
||||
mapping[1] = _s_keymap_data[profile][key][1];
|
||||
mapping[2] = _s_keymap_data[profile][key][2];
|
||||
mapping[3] = _s_keymap_data[profile][key][3];
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -86,10 +86,10 @@ int mouse_m908::get_key_mapping( mouse_m908::m908_profile profile, int key, std:
|
|||
if( key < 0 || key > 19 ) // valid key ?
|
||||
return 1;
|
||||
|
||||
uint8_t b1 = _keymap_data[profile][key][0];
|
||||
uint8_t b2 = _keymap_data[profile][key][1];
|
||||
uint8_t b3 = _keymap_data[profile][key][2];
|
||||
uint8_t b4 = _keymap_data[profile][key][3];
|
||||
uint8_t b1 = _s_keymap_data[profile][key][0];
|
||||
uint8_t b2 = _s_keymap_data[profile][key][1];
|
||||
uint8_t b3 = _s_keymap_data[profile][key][2];
|
||||
uint8_t b4 = _s_keymap_data[profile][key][3];
|
||||
bool found_name = false;
|
||||
|
||||
mapping = "";
|
||||
|
@ -108,8 +108,8 @@ int mouse_m908::get_key_mapping( mouse_m908::m908_profile profile, int key, std:
|
|||
mapping += "mouse_middle:";
|
||||
else{
|
||||
|
||||
// iterate over _keyboard_key_values
|
||||
for( auto keycode : _keyboard_key_values ){
|
||||
// iterate over _c_keyboard_key_values
|
||||
for( auto keycode : _c_keyboard_key_values ){
|
||||
|
||||
if( keycode.second == b2 ){
|
||||
|
||||
|
@ -133,8 +133,8 @@ int mouse_m908::get_key_mapping( mouse_m908::m908_profile profile, int key, std:
|
|||
// keyboard key
|
||||
} else if( b1 == 0x90 ){
|
||||
|
||||
// iterate over _keyboard_key_values
|
||||
for( auto keycode : _keyboard_key_values ){
|
||||
// iterate over _c_keyboard_key_values
|
||||
for( auto keycode : _c_keyboard_key_values ){
|
||||
|
||||
if( keycode.second == b3 ){
|
||||
|
||||
|
@ -149,8 +149,8 @@ int mouse_m908::get_key_mapping( mouse_m908::m908_profile profile, int key, std:
|
|||
// modifiers + keyboard key
|
||||
} else if( b1 == 0x8f ){
|
||||
|
||||
// iterate over _keyboard_modifier_values
|
||||
for( auto modifier : _keyboard_modifier_values ){
|
||||
// iterate over _c_keyboard_modifier_values
|
||||
for( auto modifier : _c_keyboard_modifier_values ){
|
||||
|
||||
if( modifier.second & b2 ){
|
||||
mapping += modifier.first;
|
||||
|
@ -158,8 +158,8 @@ int mouse_m908::get_key_mapping( mouse_m908::m908_profile profile, int key, std:
|
|||
|
||||
}
|
||||
|
||||
// iterate over _keyboard_key_values
|
||||
for( auto keycode : _keyboard_key_values ){
|
||||
// iterate over _c_keyboard_key_values
|
||||
for( auto keycode : _c_keyboard_key_values ){
|
||||
|
||||
if( keycode.second == b3 ){
|
||||
|
||||
|
@ -173,8 +173,8 @@ int mouse_m908::get_key_mapping( mouse_m908::m908_profile profile, int key, std:
|
|||
|
||||
} else{ // mousebutton or special function ?
|
||||
|
||||
// iterate over _keycodes
|
||||
for( auto keycode : _keycodes ){
|
||||
// iterate over _c_keycodes
|
||||
for( auto keycode : _c_keycodes ){
|
||||
|
||||
if( keycode.second[0] == b1 &&
|
||||
keycode.second[1] == b2 &&
|
||||
|
@ -207,7 +207,7 @@ int mouse_m908::get_macro_raw( int number, std::array<uint8_t, 256>& macro ){
|
|||
if( number < 1 || number > 15 )
|
||||
return 1;
|
||||
|
||||
std::copy( _macro_data[number-1].begin(), _macro_data[number-1].end(), macro.begin() );
|
||||
std::copy( _s_macro_data[number-1].begin(), _s_macro_data[number-1].end(), macro.begin() );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -217,55 +217,55 @@ int mouse_m908::get_macro( int number, std::string& macro ){
|
|||
std::stringstream output;
|
||||
|
||||
// macro undefined?
|
||||
if( _macro_data[number-1][8] == 0 && _macro_data[number-1][9] == 0 && _macro_data[number-1][10] == 0 )
|
||||
if( _s_macro_data[number-1][8] == 0 && _s_macro_data[number-1][9] == 0 && _s_macro_data[number-1][10] == 0 )
|
||||
return 0;
|
||||
|
||||
for( long unsigned int j = 8; j < _macro_data[number-1].size(); ){
|
||||
for( long unsigned int j = 8; j < _s_macro_data[number-1].size(); ){
|
||||
|
||||
// failsafe
|
||||
if( j >= _macro_data[number-1].size() )
|
||||
if( j >= _s_macro_data[number-1].size() )
|
||||
break;
|
||||
|
||||
if( _macro_data[number-1][j] == 0x81 ){ // mouse button down
|
||||
if( _s_macro_data[number-1][j] == 0x81 ){ // mouse button down
|
||||
|
||||
if( _macro_data[number-1][j] == 0x01 )
|
||||
if( _s_macro_data[number-1][j] == 0x01 )
|
||||
output << "down\tmouse_left\n";
|
||||
else if( _macro_data[number-1][j] == 0x02 )
|
||||
else if( _s_macro_data[number-1][j] == 0x02 )
|
||||
output << "down\tmouse_right\n";
|
||||
else if( _macro_data[number-1][j] == 0x04 )
|
||||
else if( _s_macro_data[number-1][j] == 0x04 )
|
||||
output << "down\tmouse_middle\n";
|
||||
else{
|
||||
output << "unknown, please report as bug: ";
|
||||
output << std::hex << (int)_macro_data[number-1][j] << " ";
|
||||
output << std::hex << (int)_macro_data[number-1][j+1] << " ";
|
||||
output << std::hex << (int)_macro_data[number-1][j+2];
|
||||
output << std::hex << (int)_s_macro_data[number-1][j] << " ";
|
||||
output << std::hex << (int)_s_macro_data[number-1][j+1] << " ";
|
||||
output << std::hex << (int)_s_macro_data[number-1][j+2];
|
||||
output << std::dec << "\n";
|
||||
}
|
||||
|
||||
} else if( _macro_data[number-1][j] == 0x01 ){ // mouse button up
|
||||
} else if( _s_macro_data[number-1][j] == 0x01 ){ // mouse button up
|
||||
|
||||
if( _macro_data[number-1][j] == 0x01 )
|
||||
if( _s_macro_data[number-1][j] == 0x01 )
|
||||
output << "up\tmouse_left\n";
|
||||
else if( _macro_data[number-1][j] == 0x02 )
|
||||
else if( _s_macro_data[number-1][j] == 0x02 )
|
||||
output << "up\tmouse_right\n";
|
||||
else if( _macro_data[number-1][j] == 0x04 )
|
||||
else if( _s_macro_data[number-1][j] == 0x04 )
|
||||
output << "up\tmouse_middle\n";
|
||||
else{
|
||||
output << "unknown, please report as bug: ";
|
||||
output << std::hex << (int)_macro_data[number-1][j] << " ";
|
||||
output << std::hex << (int)_macro_data[number-1][j+1] << " ";
|
||||
output << std::hex << (int)_macro_data[number-1][j+2];
|
||||
output << std::hex << (int)_s_macro_data[number-1][j] << " ";
|
||||
output << std::hex << (int)_s_macro_data[number-1][j+1] << " ";
|
||||
output << std::hex << (int)_s_macro_data[number-1][j+2];
|
||||
output << std::dec << "\n";
|
||||
}
|
||||
|
||||
} else if( _macro_data[number-1][j] == 0x84 ){ // keyboard key down
|
||||
} else if( _s_macro_data[number-1][j] == 0x84 ){ // keyboard key down
|
||||
|
||||
bool found_name = false;
|
||||
|
||||
// iterate over _keyboard_key_values
|
||||
for( auto keycode : _keyboard_key_values ){
|
||||
// iterate over _c_keyboard_key_values
|
||||
for( auto keycode : _c_keyboard_key_values ){
|
||||
|
||||
if( keycode.second == _macro_data[number-1][j+1] ){
|
||||
if( keycode.second == _s_macro_data[number-1][j+1] ){
|
||||
|
||||
output << "down\t" << keycode.first << "\n";
|
||||
found_name = true;
|
||||
|
@ -277,20 +277,20 @@ int mouse_m908::get_macro( int number, std::string& macro ){
|
|||
|
||||
if( !found_name ){
|
||||
output << "unknown, please report as bug: ";
|
||||
output << std::hex << (int)_macro_data[number-1][j] << " ";
|
||||
output << std::hex << (int)_macro_data[number-1][j+1] << " ";
|
||||
output << std::hex << (int)_macro_data[number-1][j+2];
|
||||
output << std::hex << (int)_s_macro_data[number-1][j] << " ";
|
||||
output << std::hex << (int)_s_macro_data[number-1][j+1] << " ";
|
||||
output << std::hex << (int)_s_macro_data[number-1][j+2];
|
||||
output << std::dec << "\n";
|
||||
}
|
||||
|
||||
} else if( _macro_data[number-1][j] == 0x04 ){ // keyboard key up
|
||||
} else if( _s_macro_data[number-1][j] == 0x04 ){ // keyboard key up
|
||||
|
||||
bool found_name = false;
|
||||
|
||||
// iterate over _keyboard_key_values
|
||||
for( auto keycode : _keyboard_key_values ){
|
||||
// iterate over _c_keyboard_key_values
|
||||
for( auto keycode : _c_keyboard_key_values ){
|
||||
|
||||
if( keycode.second == _macro_data[number-1][j+1] ){
|
||||
if( keycode.second == _s_macro_data[number-1][j+1] ){
|
||||
|
||||
output << "up\t" << keycode.first << "\n";
|
||||
found_name = true;
|
||||
|
@ -302,25 +302,25 @@ int mouse_m908::get_macro( int number, std::string& macro ){
|
|||
|
||||
if( !found_name ){
|
||||
output << "unknown, please report as bug: ";
|
||||
output << std::hex << (int)_macro_data[number-1][j] << " ";
|
||||
output << std::hex << (int)_macro_data[number-1][j+1] << " ";
|
||||
output << std::hex << (int)_macro_data[number-1][j+2];
|
||||
output << std::hex << (int)_s_macro_data[number-1][j] << " ";
|
||||
output << std::hex << (int)_s_macro_data[number-1][j+1] << " ";
|
||||
output << std::hex << (int)_s_macro_data[number-1][j+2];
|
||||
output << std::dec << "\n";
|
||||
}
|
||||
|
||||
} else if( _macro_data[number-1][j] == 0x06 ){ // delay
|
||||
} else if( _s_macro_data[number-1][j] == 0x06 ){ // delay
|
||||
|
||||
output << "delay\t" << (int)_macro_data[number-1][j+1] << "\n";
|
||||
output << "delay\t" << (int)_s_macro_data[number-1][j+1] << "\n";
|
||||
|
||||
} else if( _macro_data[number-1][j] == 0x00 ){ // padding
|
||||
} else if( _s_macro_data[number-1][j] == 0x00 ){ // padding
|
||||
|
||||
j++;
|
||||
|
||||
} else{
|
||||
output << "unknown, please report as bug: ";
|
||||
output << std::hex << (int)_macro_data[number-1][j] << " ";
|
||||
output << std::hex << (int)_macro_data[number-1][j+1] << " ";
|
||||
output << std::hex << (int)_macro_data[number-1][j+2];
|
||||
output << std::hex << (int)_s_macro_data[number-1][j] << " ";
|
||||
output << std::hex << (int)_s_macro_data[number-1][j+1] << " ";
|
||||
output << std::hex << (int)_s_macro_data[number-1][j+2];
|
||||
output << std::dec << "\n";
|
||||
}
|
||||
|
||||
|
|
|
@ -33,38 +33,38 @@ int mouse_m908::open_mouse(){
|
|||
}
|
||||
|
||||
//open device
|
||||
_handle = libusb_open_device_with_vid_pid( NULL, _mouse_vid,
|
||||
_mouse_pid );
|
||||
if( !_handle ){
|
||||
_i_handle = libusb_open_device_with_vid_pid( NULL, _c_mouse_vid,
|
||||
_c_mouse_pid );
|
||||
if( !_i_handle ){
|
||||
return 1;
|
||||
}
|
||||
|
||||
if( _detach_kernel_driver ){
|
||||
if( _i_detach_kernel_driver ){
|
||||
//detach kernel driver on interface 0 if active
|
||||
if( libusb_kernel_driver_active( _handle, 0 ) ){
|
||||
res += libusb_detach_kernel_driver( _handle, 0 );
|
||||
if( libusb_kernel_driver_active( _i_handle, 0 ) ){
|
||||
res += libusb_detach_kernel_driver( _i_handle, 0 );
|
||||
if( res == 0 ){
|
||||
_detached_driver_0 = true;
|
||||
_i_detached_driver_0 = true;
|
||||
} else{
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
//detach kernel driver on interface 1 if active
|
||||
if( libusb_kernel_driver_active( _handle, 1 ) ){
|
||||
res += libusb_detach_kernel_driver( _handle, 1 );
|
||||
if( libusb_kernel_driver_active( _i_handle, 1 ) ){
|
||||
res += libusb_detach_kernel_driver( _i_handle, 1 );
|
||||
if( res == 0 ){
|
||||
_detached_driver_1 = true;
|
||||
_i_detached_driver_1 = true;
|
||||
} else{
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
//detach kernel driver on interface 2 if active
|
||||
if( libusb_kernel_driver_active( _handle, 2 ) ){
|
||||
res += libusb_detach_kernel_driver( _handle, 2 );
|
||||
if( libusb_kernel_driver_active( _i_handle, 2 ) ){
|
||||
res += libusb_detach_kernel_driver( _i_handle, 2 );
|
||||
if( res == 0 ){
|
||||
_detached_driver_2 = true;
|
||||
_i_detached_driver_2 = true;
|
||||
} else{
|
||||
return res;
|
||||
}
|
||||
|
@ -72,19 +72,19 @@ int mouse_m908::open_mouse(){
|
|||
}
|
||||
|
||||
//claim interface 0
|
||||
res += libusb_claim_interface( _handle, 0 );
|
||||
res += libusb_claim_interface( _i_handle, 0 );
|
||||
if( res != 0 ){
|
||||
return res;
|
||||
}
|
||||
|
||||
//claim interface 1
|
||||
res += libusb_claim_interface( _handle, 1 );
|
||||
res += libusb_claim_interface( _i_handle, 1 );
|
||||
if( res != 0 ){
|
||||
return res;
|
||||
}
|
||||
|
||||
//claim interface 2
|
||||
res += libusb_claim_interface( _handle, 2 );
|
||||
res += libusb_claim_interface( _i_handle, 2 );
|
||||
if( res != 0 ){
|
||||
return res;
|
||||
}
|
||||
|
@ -104,7 +104,7 @@ int mouse_m908::open_mouse_bus_device( uint8_t bus, uint8_t device ){
|
|||
return res;
|
||||
}
|
||||
|
||||
//open device (_handle)
|
||||
//open device (_i_handle)
|
||||
libusb_device **dev_list; // device list
|
||||
ssize_t num_devs = libusb_get_device_list(NULL, &dev_list); //get device list
|
||||
|
||||
|
@ -118,7 +118,7 @@ int mouse_m908::open_mouse_bus_device( uint8_t bus, uint8_t device ){
|
|||
device == libusb_get_device_address( dev_list[i] ) ){
|
||||
|
||||
// open device
|
||||
if( libusb_open( dev_list[i], &_handle ) != 0 ){
|
||||
if( libusb_open( dev_list[i], &_i_handle ) != 0 ){
|
||||
return 1;
|
||||
} else{
|
||||
break;
|
||||
|
@ -132,32 +132,32 @@ int mouse_m908::open_mouse_bus_device( uint8_t bus, uint8_t device ){
|
|||
libusb_free_device_list( dev_list, 1 );
|
||||
|
||||
|
||||
if( _detach_kernel_driver ){
|
||||
if( _i_detach_kernel_driver ){
|
||||
//detach kernel driver on interface 0 if active
|
||||
if( libusb_kernel_driver_active( _handle, 0 ) ){
|
||||
res += libusb_detach_kernel_driver( _handle, 0 );
|
||||
if( libusb_kernel_driver_active( _i_handle, 0 ) ){
|
||||
res += libusb_detach_kernel_driver( _i_handle, 0 );
|
||||
if( res == 0 ){
|
||||
_detached_driver_0 = true;
|
||||
_i_detached_driver_0 = true;
|
||||
} else{
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
//detach kernel driver on interface 1 if active
|
||||
if( libusb_kernel_driver_active( _handle, 1 ) ){
|
||||
res += libusb_detach_kernel_driver( _handle, 1 );
|
||||
if( libusb_kernel_driver_active( _i_handle, 1 ) ){
|
||||
res += libusb_detach_kernel_driver( _i_handle, 1 );
|
||||
if( res == 0 ){
|
||||
_detached_driver_1 = true;
|
||||
_i_detached_driver_1 = true;
|
||||
} else{
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
//detach kernel driver on interface 2 if active
|
||||
if( libusb_kernel_driver_active( _handle, 2 ) ){
|
||||
res += libusb_detach_kernel_driver( _handle, 2 );
|
||||
if( libusb_kernel_driver_active( _i_handle, 2 ) ){
|
||||
res += libusb_detach_kernel_driver( _i_handle, 2 );
|
||||
if( res == 0 ){
|
||||
_detached_driver_2 = true;
|
||||
_i_detached_driver_2 = true;
|
||||
} else{
|
||||
return res;
|
||||
}
|
||||
|
@ -165,19 +165,19 @@ int mouse_m908::open_mouse_bus_device( uint8_t bus, uint8_t device ){
|
|||
}
|
||||
|
||||
//claim interface 0
|
||||
res += libusb_claim_interface( _handle, 0 );
|
||||
res += libusb_claim_interface( _i_handle, 0 );
|
||||
if( res != 0 ){
|
||||
return res;
|
||||
}
|
||||
|
||||
//claim interface 1
|
||||
res += libusb_claim_interface( _handle, 1 );
|
||||
res += libusb_claim_interface( _i_handle, 1 );
|
||||
if( res != 0 ){
|
||||
return res;
|
||||
}
|
||||
|
||||
//claim interface 2
|
||||
res += libusb_claim_interface( _handle, 2 );
|
||||
res += libusb_claim_interface( _i_handle, 2 );
|
||||
if( res != 0 ){
|
||||
return res;
|
||||
}
|
||||
|
@ -189,24 +189,24 @@ int mouse_m908::open_mouse_bus_device( uint8_t bus, uint8_t device ){
|
|||
int mouse_m908::close_mouse(){
|
||||
|
||||
//release interfaces 0, 1 and 2
|
||||
libusb_release_interface( _handle, 0 );
|
||||
libusb_release_interface( _handle, 1 );
|
||||
libusb_release_interface( _handle, 2 );
|
||||
libusb_release_interface( _i_handle, 0 );
|
||||
libusb_release_interface( _i_handle, 1 );
|
||||
libusb_release_interface( _i_handle, 2 );
|
||||
|
||||
//attach kernel driver for interface 0
|
||||
if( _detached_driver_0 ){
|
||||
libusb_attach_kernel_driver( _handle, 0 );
|
||||
if( _i_detached_driver_0 ){
|
||||
libusb_attach_kernel_driver( _i_handle, 0 );
|
||||
}
|
||||
|
||||
//attach kernel driver for interface 1
|
||||
if( _detached_driver_1 ){
|
||||
libusb_attach_kernel_driver( _handle, 1 );
|
||||
if( _i_detached_driver_1 ){
|
||||
libusb_attach_kernel_driver( _i_handle, 1 );
|
||||
}
|
||||
|
||||
|
||||
//attach kernel driver for interface 2
|
||||
if( _detached_driver_2 ){
|
||||
libusb_attach_kernel_driver( _handle, 2);
|
||||
if( _i_detached_driver_2 ){
|
||||
libusb_attach_kernel_driver( _i_handle, 2);
|
||||
}
|
||||
|
||||
//exit libusb
|
||||
|
@ -220,7 +220,7 @@ int mouse_m908::print_settings( std::ostream& output ){
|
|||
|
||||
// print configuration
|
||||
output << "# Configuration created by mouse_m908::print_settings().\n";
|
||||
output << "# Currently active profile: " << _profile << "\n";
|
||||
output << "# Currently active profile: " << _s_profile << "\n";
|
||||
|
||||
for( int i = 1; i < 6; i++ ){
|
||||
|
||||
|
@ -231,34 +231,34 @@ int mouse_m908::print_settings( std::ostream& output ){
|
|||
|
||||
// color
|
||||
output << "color=";
|
||||
output << std::setfill('0') << std::setw(2) << std::hex << (int)_colors[i-1][0];
|
||||
output << std::setfill('0') << std::setw(2) << std::hex << (int)_colors[i-1][1];
|
||||
output << std::setfill('0') << std::setw(2) << std::hex << (int)_colors[i-1][2];
|
||||
output << std::setfill('0') << std::setw(2) << std::hex << (int)_s_colors[i-1][0];
|
||||
output << std::setfill('0') << std::setw(2) << std::hex << (int)_s_colors[i-1][1];
|
||||
output << std::setfill('0') << std::setw(2) << std::hex << (int)_s_colors[i-1][2];
|
||||
output << std::setfill(' ') << std::setw(0) << std::dec << "\n";
|
||||
|
||||
// brightness
|
||||
output << "brightness=" << (int)_brightness_levels[i-1] << "\n";
|
||||
output << "brightness=" << (int)_s_brightness_levels[i-1] << "\n";
|
||||
|
||||
// speed
|
||||
output << "speed=" << (int)_speed_levels[i-1] << "\n";
|
||||
output << "speed=" << (int)_s_speed_levels[i-1] << "\n";
|
||||
|
||||
// lightmode
|
||||
output << "lightmode=";
|
||||
if( _lightmodes[i-1] == lightmode_off )
|
||||
if( _s_lightmodes[i-1] == lightmode_off )
|
||||
output << "off\n";
|
||||
else if( _lightmodes[i-1] == lightmode_breathing )
|
||||
else if( _s_lightmodes[i-1] == lightmode_breathing )
|
||||
output << "breathing\n";
|
||||
else if( _lightmodes[i-1] == lightmode_rainbow )
|
||||
else if( _s_lightmodes[i-1] == lightmode_rainbow )
|
||||
output << "rainbow\n";
|
||||
else if( _lightmodes[i-1] == lightmode_static )
|
||||
else if( _s_lightmodes[i-1] == lightmode_static )
|
||||
output << "static\n";
|
||||
else if( _lightmodes[i-1] == lightmode_wave )
|
||||
else if( _s_lightmodes[i-1] == lightmode_wave )
|
||||
output << "wave\n";
|
||||
else if( _lightmodes[i-1] == lightmode_alternating )
|
||||
else if( _s_lightmodes[i-1] == lightmode_alternating )
|
||||
output << "alternating\n";
|
||||
else if( _lightmodes[i-1] == lightmode_reactive )
|
||||
else if( _s_lightmodes[i-1] == lightmode_reactive )
|
||||
output << "reactive\n";
|
||||
else if( _lightmodes[i-1] == lightmode_flashing )
|
||||
else if( _s_lightmodes[i-1] == lightmode_flashing )
|
||||
output << "flashing\n";
|
||||
else{
|
||||
output << "unknown, please report as bug\n";
|
||||
|
@ -266,32 +266,32 @@ int mouse_m908::print_settings( std::ostream& output ){
|
|||
|
||||
// polling rate (report rate)
|
||||
output << "\n";
|
||||
if( _report_rates[i-1] == r_125Hz )
|
||||
if( _s_report_rates[i-1] == r_125Hz )
|
||||
output << "report_rate=125\n";
|
||||
else if( _report_rates[i-1] == r_250Hz )
|
||||
else if( _s_report_rates[i-1] == r_250Hz )
|
||||
output << "report_rate=250\n";
|
||||
else if( _report_rates[i-1] == r_500Hz )
|
||||
else if( _s_report_rates[i-1] == r_500Hz )
|
||||
output << "report_rate=500\n";
|
||||
else if( _report_rates[i-1] == r_1000Hz )
|
||||
else if( _s_report_rates[i-1] == r_1000Hz )
|
||||
output << "report_rate=1000\n";
|
||||
else{
|
||||
output << "# report rate unknown, please report as bug\n";
|
||||
}
|
||||
|
||||
// scrollspeed
|
||||
output << "scrollspeed=" << std::hex << (int)_scrollspeeds[i-1] << std::dec << "\n";
|
||||
output << "scrollspeed=" << std::hex << (int)_s_scrollspeeds[i-1] << std::dec << "\n";
|
||||
|
||||
// dpi
|
||||
output << "\n# DPI settings\n";
|
||||
for( int j = 1; j < 6; j++ ){
|
||||
|
||||
if( _dpi_enabled[i-1][j] )
|
||||
if( _s_dpi_enabled[i-1][j] )
|
||||
output << "dpi" << j << "_enable=1\n";
|
||||
else
|
||||
output << "dpi" << j << "_enable=0\n";
|
||||
|
||||
output << std::setfill('0') << std::setw(2) << std::hex;
|
||||
output << "dpi" << j << "=" << (int)_dpi_levels[i-1][j-1] << "\n";
|
||||
output << "dpi" << j << "=" << (int)_s_dpi_levels[i-1][j-1] << "\n";
|
||||
output << std::setfill(' ') << std::setw(0) << std::dec;
|
||||
}
|
||||
|
||||
|
@ -300,13 +300,13 @@ int mouse_m908::print_settings( std::ostream& output ){
|
|||
|
||||
for( int j = 0; j < 20; j++ ){
|
||||
|
||||
uint8_t b1 = _keymap_data[i-1][j][0];
|
||||
uint8_t b2 = _keymap_data[i-1][j][1];
|
||||
uint8_t b3 = _keymap_data[i-1][j][2];
|
||||
uint8_t b4 = _keymap_data[i-1][j][3];
|
||||
uint8_t b1 = _s_keymap_data[i-1][j][0];
|
||||
uint8_t b2 = _s_keymap_data[i-1][j][1];
|
||||
uint8_t b3 = _s_keymap_data[i-1][j][2];
|
||||
uint8_t b4 = _s_keymap_data[i-1][j][3];
|
||||
bool found_name = false;
|
||||
|
||||
output << _button_names[j] << "=";
|
||||
output << _c_button_names[j] << "=";
|
||||
|
||||
// fire button
|
||||
if( b1 == 0x99 ){
|
||||
|
@ -322,8 +322,8 @@ int mouse_m908::print_settings( std::ostream& output ){
|
|||
output << "mouse_middle:";
|
||||
else{
|
||||
|
||||
// iterate over _keyboard_key_values
|
||||
for( auto keycode : _keyboard_key_values ){
|
||||
// iterate over _c_keyboard_key_values
|
||||
for( auto keycode : _c_keyboard_key_values ){
|
||||
|
||||
if( keycode.second == b2 ){
|
||||
|
||||
|
@ -347,8 +347,8 @@ int mouse_m908::print_settings( std::ostream& output ){
|
|||
// keyboard key
|
||||
} else if( b1 == 0x90 ){
|
||||
|
||||
// iterate over _keyboard_key_values
|
||||
for( auto keycode : _keyboard_key_values ){
|
||||
// iterate over _c_keyboard_key_values
|
||||
for( auto keycode : _c_keyboard_key_values ){
|
||||
|
||||
if( keycode.second == b3 ){
|
||||
|
||||
|
@ -363,8 +363,8 @@ int mouse_m908::print_settings( std::ostream& output ){
|
|||
// modifiers + keyboard key
|
||||
} else if( b1 == 0x8f ){
|
||||
|
||||
// iterate over _keyboard_modifier_values
|
||||
for( auto modifier : _keyboard_modifier_values ){
|
||||
// iterate over _c_keyboard_modifier_values
|
||||
for( auto modifier : _c_keyboard_modifier_values ){
|
||||
|
||||
if( modifier.second & b2 ){
|
||||
output << modifier.first;
|
||||
|
@ -372,8 +372,8 @@ int mouse_m908::print_settings( std::ostream& output ){
|
|||
|
||||
}
|
||||
|
||||
// iterate over _keyboard_key_values
|
||||
for( auto keycode : _keyboard_key_values ){
|
||||
// iterate over _c_keyboard_key_values
|
||||
for( auto keycode : _c_keyboard_key_values ){
|
||||
|
||||
if( keycode.second == b3 ){
|
||||
|
||||
|
@ -387,8 +387,8 @@ int mouse_m908::print_settings( std::ostream& output ){
|
|||
|
||||
} else{ // mousebutton or special function ?
|
||||
|
||||
// iterate over _keycodes
|
||||
for( auto keycode : _keycodes ){
|
||||
// iterate over _c_keycodes
|
||||
for( auto keycode : _c_keycodes ){
|
||||
|
||||
if( keycode.second[0] == b1 &&
|
||||
keycode.second[1] == b2 &&
|
||||
|
@ -421,57 +421,57 @@ int mouse_m908::print_settings( std::ostream& output ){
|
|||
for( int i = 0; i < 15; i++ ){
|
||||
|
||||
// macro undefined?
|
||||
if( _macro_data[i][8] == 0 && _macro_data[i][9] == 0 && _macro_data[i][10] == 0 )
|
||||
if( _s_macro_data[i][8] == 0 && _s_macro_data[i][9] == 0 && _s_macro_data[i][10] == 0 )
|
||||
continue;
|
||||
|
||||
output << "\n;## macro" << i+1 << "\n";
|
||||
|
||||
for( long unsigned int j = 8; j < _macro_data[i].size(); ){
|
||||
for( long unsigned int j = 8; j < _s_macro_data[i].size(); ){
|
||||
|
||||
// failsafe
|
||||
if( j >= _macro_data[i].size() )
|
||||
if( j >= _s_macro_data[i].size() )
|
||||
break;
|
||||
|
||||
if( _macro_data[i][j] == 0x81 ){ // mouse button down
|
||||
if( _s_macro_data[i][j] == 0x81 ){ // mouse button down
|
||||
|
||||
if( _macro_data[i][j] == 0x01 )
|
||||
if( _s_macro_data[i][j] == 0x01 )
|
||||
output << ";# down\tmouse_left\n";
|
||||
else if( _macro_data[i][j] == 0x02 )
|
||||
else if( _s_macro_data[i][j] == 0x02 )
|
||||
output << ";# down\tmouse_right\n";
|
||||
else if( _macro_data[i][j] == 0x04 )
|
||||
else if( _s_macro_data[i][j] == 0x04 )
|
||||
output << ";# down\tmouse_middle\n";
|
||||
else{
|
||||
output << ";# unknown, please report as bug: ";
|
||||
output << std::hex << (int)_macro_data[i][j] << " ";
|
||||
output << std::hex << (int)_macro_data[i][j+1] << " ";
|
||||
output << std::hex << (int)_macro_data[i][j+2];
|
||||
output << std::hex << (int)_s_macro_data[i][j] << " ";
|
||||
output << std::hex << (int)_s_macro_data[i][j+1] << " ";
|
||||
output << std::hex << (int)_s_macro_data[i][j+2];
|
||||
output << std::dec << "\n";
|
||||
}
|
||||
|
||||
} else if( _macro_data[i][j] == 0x01 ){ // mouse button up
|
||||
} else if( _s_macro_data[i][j] == 0x01 ){ // mouse button up
|
||||
|
||||
if( _macro_data[i][j] == 0x01 )
|
||||
if( _s_macro_data[i][j] == 0x01 )
|
||||
output << ";# up\tmouse_left\n";
|
||||
else if( _macro_data[i][j] == 0x02 )
|
||||
else if( _s_macro_data[i][j] == 0x02 )
|
||||
output << ";# up\tmouse_right\n";
|
||||
else if( _macro_data[i][j] == 0x04 )
|
||||
else if( _s_macro_data[i][j] == 0x04 )
|
||||
output << ";# up\tmouse_middle\n";
|
||||
else{
|
||||
output << ";# unknown, please report as bug: ";
|
||||
output << std::hex << (int)_macro_data[i][j] << " ";
|
||||
output << std::hex << (int)_macro_data[i][j+1] << " ";
|
||||
output << std::hex << (int)_macro_data[i][j+2];
|
||||
output << std::hex << (int)_s_macro_data[i][j] << " ";
|
||||
output << std::hex << (int)_s_macro_data[i][j+1] << " ";
|
||||
output << std::hex << (int)_s_macro_data[i][j+2];
|
||||
output << std::dec << "\n";
|
||||
}
|
||||
|
||||
} else if( _macro_data[i][j] == 0x84 ){ // keyboard key down
|
||||
} else if( _s_macro_data[i][j] == 0x84 ){ // keyboard key down
|
||||
|
||||
bool found_name = false;
|
||||
|
||||
// iterate over _keyboard_key_values
|
||||
for( auto keycode : _keyboard_key_values ){
|
||||
// iterate over _c_keyboard_key_values
|
||||
for( auto keycode : _c_keyboard_key_values ){
|
||||
|
||||
if( keycode.second == _macro_data[i][j+1] ){
|
||||
if( keycode.second == _s_macro_data[i][j+1] ){
|
||||
|
||||
output << ";# down\t" << keycode.first << "\n";
|
||||
found_name = true;
|
||||
|
@ -483,20 +483,20 @@ int mouse_m908::print_settings( std::ostream& output ){
|
|||
|
||||
if( !found_name ){
|
||||
output << ";# unknown, please report as bug: ";
|
||||
output << std::hex << (int)_macro_data[i][j] << " ";
|
||||
output << std::hex << (int)_macro_data[i][j+1] << " ";
|
||||
output << std::hex << (int)_macro_data[i][j+2];
|
||||
output << std::hex << (int)_s_macro_data[i][j] << " ";
|
||||
output << std::hex << (int)_s_macro_data[i][j+1] << " ";
|
||||
output << std::hex << (int)_s_macro_data[i][j+2];
|
||||
output << std::dec << "\n";
|
||||
}
|
||||
|
||||
} else if( _macro_data[i][j] == 0x04 ){ // keyboard key up
|
||||
} else if( _s_macro_data[i][j] == 0x04 ){ // keyboard key up
|
||||
|
||||
bool found_name = false;
|
||||
|
||||
// iterate over _keyboard_key_values
|
||||
for( auto keycode : _keyboard_key_values ){
|
||||
// iterate over _c_keyboard_key_values
|
||||
for( auto keycode : _c_keyboard_key_values ){
|
||||
|
||||
if( keycode.second == _macro_data[i][j+1] ){
|
||||
if( keycode.second == _s_macro_data[i][j+1] ){
|
||||
|
||||
output << ";# up\t" << keycode.first << "\n";
|
||||
found_name = true;
|
||||
|
@ -508,25 +508,25 @@ int mouse_m908::print_settings( std::ostream& output ){
|
|||
|
||||
if( !found_name ){
|
||||
output << ";# unknown, please report as bug: ";
|
||||
output << std::hex << (int)_macro_data[i][j] << " ";
|
||||
output << std::hex << (int)_macro_data[i][j+1] << " ";
|
||||
output << std::hex << (int)_macro_data[i][j+2];
|
||||
output << std::hex << (int)_s_macro_data[i][j] << " ";
|
||||
output << std::hex << (int)_s_macro_data[i][j+1] << " ";
|
||||
output << std::hex << (int)_s_macro_data[i][j+2];
|
||||
output << std::dec << "\n";
|
||||
}
|
||||
|
||||
} else if( _macro_data[i][j] == 0x06 ){ // delay
|
||||
} else if( _s_macro_data[i][j] == 0x06 ){ // delay
|
||||
|
||||
output << ";# delay\t" << (int)_macro_data[i][j+1] << "\n";
|
||||
output << ";# delay\t" << (int)_s_macro_data[i][j+1] << "\n";
|
||||
|
||||
} else if( _macro_data[i][j] == 0x00 ){ // padding
|
||||
} else if( _s_macro_data[i][j] == 0x00 ){ // padding
|
||||
|
||||
j++;
|
||||
|
||||
} else{
|
||||
output << ";# unknown, please report as bug: ";
|
||||
output << std::hex << (int)_macro_data[i][j] << " ";
|
||||
output << std::hex << (int)_macro_data[i][j+1] << " ";
|
||||
output << std::hex << (int)_macro_data[i][j+2];
|
||||
output << std::hex << (int)_s_macro_data[i][j] << " ";
|
||||
output << std::hex << (int)_s_macro_data[i][j+1] << " ";
|
||||
output << std::hex << (int)_s_macro_data[i][j+2];
|
||||
output << std::dec << "\n";
|
||||
}
|
||||
|
||||
|
|
|
@ -49,7 +49,10 @@
|
|||
* 3. write_* (this step sends the internal state of the class to the mouse)
|
||||
* 4. close_mouse()
|
||||
*
|
||||
*
|
||||
* Private member variables are named as follows:
|
||||
* - \_i\_* for internal variables that determine how the mouse is opened, etc.
|
||||
* - \_s\_* for variables that describe the settings on the mouse
|
||||
* - \_c\_* for constants like keycodes, USB data, minimum and maximum values, etc. (these are not neccessarily defined as const)
|
||||
*/
|
||||
class mouse_m908{
|
||||
|
||||
|
@ -97,8 +100,8 @@ class mouse_m908{
|
|||
int set_profile( m908_profile profile );
|
||||
|
||||
/** \brief Set the scrollspeed for the specified profile
|
||||
* \see _scrollspeed_min
|
||||
* \see _scrollspeed_max
|
||||
* \see _c_scrollspeed_min
|
||||
* \see _c_scrollspeed_max
|
||||
* \return 0 if successful, 1 if out of bounds
|
||||
*/
|
||||
int set_scrollspeed( m908_profile profile, uint8_t speed );
|
||||
|
@ -116,31 +119,31 @@ class mouse_m908{
|
|||
int set_color( m908_profile profile, std::array<uint8_t, 3> color );
|
||||
|
||||
/** \brief Set the led brightness for the specified profile
|
||||
* \see _brightness_min
|
||||
* \see _brightness_max
|
||||
* \see _c_brightness_min
|
||||
* \see _c_brightness_max
|
||||
* \return 0 if successful, 1 if out of bounds
|
||||
*/
|
||||
int set_brightness( m908_profile profile, uint8_t brightness );
|
||||
|
||||
/** \brief Set the led animation speed for the specified profile
|
||||
* \see _speed_min
|
||||
* \see _speed_max
|
||||
* \see _c_speed_min
|
||||
* \see _c_speed_max
|
||||
* \return 0 if successful, 1 if out of bounds
|
||||
*/
|
||||
int set_speed( m908_profile profile, uint8_t speed );
|
||||
|
||||
/** \brief Enables/Disables a dpi level for the specified profile
|
||||
* \see _level_min
|
||||
* \see _level_max
|
||||
* \see _c_level_min
|
||||
* \see _c_level_max
|
||||
* \return 0 if successful, 1 if out of bounds
|
||||
*/
|
||||
int set_dpi_enable( m908_profile profile, int level, bool enabled );
|
||||
|
||||
/** \brief Set the value of a dpi level for the specified profile
|
||||
* \see _dpi_min
|
||||
* \see _dpi_max
|
||||
* \see _level_min
|
||||
* \see _level_max
|
||||
* \see _c_dpi_min
|
||||
* \see _c_dpi_max
|
||||
* \see _c_level_min
|
||||
* \see _c_level_max
|
||||
* \return 0 if successful, 1 if out of bounds
|
||||
*/
|
||||
int set_dpi( m908_profile profile, int level, uint8_t dpi );
|
||||
|
@ -207,7 +210,7 @@ class mouse_m908{
|
|||
m908_report_rate get_report_rate( m908_profile profile );
|
||||
/// Get macro repeat number of specified profile
|
||||
uint8_t get_macro_repeat( int macro_number );
|
||||
/// Get _detach_kernel_driver
|
||||
/// Get _i_detach_kernel_driver
|
||||
bool get_detach_kernel_driver();
|
||||
/// Get button mapping as a string
|
||||
int get_key_mapping( m908_profile profile, int key, std::string& mapping );
|
||||
|
@ -281,78 +284,78 @@ class mouse_m908{
|
|||
private:
|
||||
|
||||
/// whether to detach kernel driver
|
||||
bool _detach_kernel_driver = true;
|
||||
bool _i_detach_kernel_driver = true;
|
||||
|
||||
//usb device vars
|
||||
/// USB vendor id
|
||||
static const uint16_t _mouse_vid;
|
||||
static const uint16_t _c_mouse_vid;
|
||||
/// USB product id
|
||||
static const uint16_t _mouse_pid;
|
||||
static const uint16_t _c_mouse_pid;
|
||||
/// libusb device handle
|
||||
libusb_device_handle* _handle;
|
||||
libusb_device_handle* _i_handle;
|
||||
/// set by open_mouse for close_mouse
|
||||
bool _detached_driver_0 = false;
|
||||
bool _i_detached_driver_0 = false;
|
||||
/// set by open_mouse for close_mouse
|
||||
bool _detached_driver_1 = false;
|
||||
bool _i_detached_driver_1 = false;
|
||||
/// set by open_mouse for close_mouse
|
||||
bool _detached_driver_2 = false;
|
||||
bool _i_detached_driver_2 = false;
|
||||
|
||||
//setting min and max values
|
||||
static const uint8_t _scrollspeed_min, _scrollspeed_max;
|
||||
static const uint8_t _brightness_min, _brightness_max;
|
||||
static const uint8_t _speed_min, _speed_max;
|
||||
static const uint8_t _level_min, _level_max;
|
||||
static const uint8_t _dpi_min, _dpi_max;
|
||||
static const uint8_t _c_scrollspeed_min, _c_scrollspeed_max;
|
||||
static const uint8_t _c_brightness_min, _c_brightness_max;
|
||||
static const uint8_t _c_speed_min, _c_speed_max;
|
||||
static const uint8_t _c_level_min, _c_level_max;
|
||||
static const uint8_t _c_dpi_min, _c_dpi_max;
|
||||
|
||||
//setting vars
|
||||
m908_profile _profile;
|
||||
std::array<uint8_t, 5> _scrollspeeds;
|
||||
std::array<m908_lightmode, 5> _lightmodes;
|
||||
std::array<std::array<uint8_t, 3>, 5> _colors;
|
||||
std::array<uint8_t, 5> _brightness_levels;
|
||||
std::array<uint8_t, 5> _speed_levels;
|
||||
std::array<std::array<bool, 5>, 5> _dpi_enabled;
|
||||
std::array<std::array<uint8_t, 5>, 5> _dpi_levels;
|
||||
std::array<std::array<std::array<uint8_t, 4>, 20>, 5> _keymap_data;
|
||||
std::array<m908_report_rate, 5> _report_rates;
|
||||
std::array<std::array<uint8_t, 256>, 15> _macro_data;
|
||||
std::array<uint8_t, 15> _macro_repeat;
|
||||
m908_profile _s_profile;
|
||||
std::array<uint8_t, 5> _s_scrollspeeds;
|
||||
std::array<m908_lightmode, 5> _s_lightmodes;
|
||||
std::array<std::array<uint8_t, 3>, 5> _s_colors;
|
||||
std::array<uint8_t, 5> _s_brightness_levels;
|
||||
std::array<uint8_t, 5> _s_speed_levels;
|
||||
std::array<std::array<bool, 5>, 5> _s_dpi_enabled;
|
||||
std::array<std::array<uint8_t, 5>, 5> _s_dpi_levels;
|
||||
std::array<std::array<std::array<uint8_t, 4>, 20>, 5> _s_keymap_data;
|
||||
std::array<m908_report_rate, 5> _s_report_rates;
|
||||
std::array<std::array<uint8_t, 256>, 15> _s_macro_data;
|
||||
std::array<uint8_t, 15> _s_macro_repeat;
|
||||
|
||||
//mapping of button names to values
|
||||
/// Values/keycodes of mouse buttons and special button functions
|
||||
static std::map< std::string, std::array<uint8_t, 3> > _keycodes;
|
||||
static std::map< std::string, std::array<uint8_t, 3> > _c_keycodes;
|
||||
/// Values of keyboard modifiers
|
||||
static const std::map< std::string, uint8_t > _keyboard_modifier_values;
|
||||
static const std::map< std::string, uint8_t > _c_keyboard_modifier_values;
|
||||
/// Values/keycodes of keyboard keys
|
||||
static std::map< std::string, uint8_t > _keyboard_key_values;
|
||||
static std::map< std::string, uint8_t > _c_keyboard_key_values;
|
||||
/// Names of the physical buttons
|
||||
static std::map< int, std::string > _button_names;
|
||||
static std::map< int, std::string > _c_button_names;
|
||||
|
||||
//usb data packets
|
||||
/// Used for changing the active profile
|
||||
static uint8_t _data_profile[6][16];
|
||||
static uint8_t _c_data_s_profile[6][16];
|
||||
/// Used for sending the settings, part 1/3
|
||||
static uint8_t _data_settings_1[15][16];
|
||||
static uint8_t _c_data_settings_1[15][16];
|
||||
/// Used for sending the settings, part 2/3
|
||||
static uint8_t _data_settings_2[64];
|
||||
static uint8_t _c_data_settings_2[64];
|
||||
/// Used for sending the settings, part 3/3
|
||||
static uint8_t _data_settings_3[140][16];
|
||||
static uint8_t _c_data_settings_3[140][16];
|
||||
/// Used for sending a macro, part 1/3
|
||||
static uint8_t _data_macros_1[16];
|
||||
static uint8_t _c_data_macros_1[16];
|
||||
/// Used for sending a macro, part 2/3
|
||||
static uint8_t _data_macros_2[256];
|
||||
static uint8_t _c_data_macros_2[256];
|
||||
/// Used for sending a macro, part 3/3
|
||||
static uint8_t _data_macros_3[16];
|
||||
/// Lookup table for used when specifying which slot to send a macro to
|
||||
static uint8_t _data_macros_codes[15][2];
|
||||
static uint8_t _c_data_macros_3[16];
|
||||
/// Lookup table used when specifying which slot to send a macro to
|
||||
static uint8_t _c_data_macros_codes[15][2];
|
||||
/// Used to send the number repeats for a macro
|
||||
static uint8_t _data_macros_repeat[16];
|
||||
static uint8_t _c_data_macros_repeat[16];
|
||||
/// Used to read the settings, part 1/3
|
||||
static uint8_t _data_read_1[9][16];
|
||||
static uint8_t _c_data_read_1[9][16];
|
||||
/// Used to read the settings, part 2/3
|
||||
static uint8_t _data_read_2[85][64];
|
||||
static uint8_t _c_data_read_2[85][64];
|
||||
/// Used to read the settings, part 3/3
|
||||
static uint8_t _data_read_3[101][16];
|
||||
static uint8_t _c_data_read_3[101][16];
|
||||
};
|
||||
|
||||
/* the files are now compiled individually
|
||||
|
|
|
@ -23,24 +23,24 @@
|
|||
int mouse_m908::dump_settings( std::ostream& output ){
|
||||
|
||||
//prepare data 1
|
||||
int rows1 = sizeof(_data_read_1) / sizeof(_data_read_1[0]);
|
||||
int rows1 = sizeof(_c_data_read_1) / sizeof(_c_data_read_1[0]);
|
||||
uint8_t buffer1[rows1][16];
|
||||
for( int i = 0; i < rows1; i++ ){
|
||||
std::copy(std::begin(_data_read_1[i]), std::end(_data_read_1[i]), std::begin(buffer1[i]));
|
||||
std::copy(std::begin(_c_data_read_1[i]), std::end(_c_data_read_1[i]), std::begin(buffer1[i]));
|
||||
}
|
||||
|
||||
//prepare data 2
|
||||
int rows2 = sizeof(_data_read_2) / sizeof(_data_read_2[0]);
|
||||
int rows2 = sizeof(_c_data_read_2) / sizeof(_c_data_read_2[0]);
|
||||
uint8_t buffer2[rows2][64];
|
||||
for( int i = 0; i < rows2; i++ ){
|
||||
std::copy(std::begin(_data_read_2[i]), std::end(_data_read_2[i]), std::begin(buffer2[i]));
|
||||
std::copy(std::begin(_c_data_read_2[i]), std::end(_c_data_read_2[i]), std::begin(buffer2[i]));
|
||||
}
|
||||
|
||||
//prepare data 3
|
||||
int rows3 = sizeof(_data_read_3) / sizeof(_data_read_3[0]);
|
||||
int rows3 = sizeof(_c_data_read_3) / sizeof(_c_data_read_3[0]);
|
||||
uint8_t buffer3[rows3][16];
|
||||
for( int i = 0; i < rows3; i++ ){
|
||||
std::copy(std::begin(_data_read_3[i]), std::end(_data_read_3[i]), std::begin(buffer3[i]));
|
||||
std::copy(std::begin(_c_data_read_3[i]), std::end(_c_data_read_3[i]), std::begin(buffer3[i]));
|
||||
}
|
||||
|
||||
output << "Part 1:\n\n";
|
||||
|
@ -48,13 +48,13 @@ int mouse_m908::dump_settings( std::ostream& output ){
|
|||
//send data 1
|
||||
uint8_t buffer_in1[16];
|
||||
int num_bytes_in;
|
||||
libusb_control_transfer( _handle, 0x21, 0x09, 0x0302, 0x0002, buffer1[0], 16, 1000 );
|
||||
libusb_control_transfer( _i_handle, 0x21, 0x09, 0x0302, 0x0002, buffer1[0], 16, 1000 );
|
||||
for( int i = 1; i < rows1; i++ ){
|
||||
// control out
|
||||
libusb_control_transfer( _handle, 0x21, 0x09, 0x0302, 0x0002, buffer1[i], 16, 1000 );
|
||||
libusb_control_transfer( _i_handle, 0x21, 0x09, 0x0302, 0x0002, buffer1[i], 16, 1000 );
|
||||
|
||||
// control in
|
||||
num_bytes_in = libusb_control_transfer( _handle, 0xa1, 0x01, 0x0302, 0x0002, buffer_in1, 16, 1000 );
|
||||
num_bytes_in = libusb_control_transfer( _i_handle, 0xa1, 0x01, 0x0302, 0x0002, buffer_in1, 16, 1000 );
|
||||
|
||||
// hexdump
|
||||
if ( num_bytes_in > 0 ){
|
||||
|
@ -72,10 +72,10 @@ int mouse_m908::dump_settings( std::ostream& output ){
|
|||
uint8_t buffer_in2[64];
|
||||
for( int i = 0; i < rows2; i++ ){
|
||||
// control out
|
||||
libusb_control_transfer( _handle, 0x21, 0x09, 0x0303, 0x0002, buffer2[i], 64, 1000 );
|
||||
libusb_control_transfer( _i_handle, 0x21, 0x09, 0x0303, 0x0002, buffer2[i], 64, 1000 );
|
||||
|
||||
// control in
|
||||
num_bytes_in = libusb_control_transfer( _handle, 0xa1, 0x01, 0x0303, 0x0002, buffer_in2, 64, 1000 );
|
||||
num_bytes_in = libusb_control_transfer( _i_handle, 0xa1, 0x01, 0x0303, 0x0002, buffer_in2, 64, 1000 );
|
||||
|
||||
// hexdump
|
||||
if ( num_bytes_in > 0 ){
|
||||
|
@ -93,10 +93,10 @@ int mouse_m908::dump_settings( std::ostream& output ){
|
|||
uint8_t buffer_in3[16];
|
||||
for( int i = 0; i < rows3-1; i++ ){
|
||||
// control out
|
||||
libusb_control_transfer( _handle, 0x21, 0x09, 0x0302, 0x0002, buffer3[i], 16, 1000 );
|
||||
libusb_control_transfer( _i_handle, 0x21, 0x09, 0x0302, 0x0002, buffer3[i], 16, 1000 );
|
||||
|
||||
// control in
|
||||
num_bytes_in = libusb_control_transfer( _handle, 0xa1, 0x01, 0x0302, 0x0002, buffer_in3, 16, 1000 );
|
||||
num_bytes_in = libusb_control_transfer( _i_handle, 0xa1, 0x01, 0x0302, 0x0002, buffer_in3, 16, 1000 );
|
||||
|
||||
// hexdump
|
||||
if ( num_bytes_in > 0 ){
|
||||
|
@ -107,7 +107,7 @@ int mouse_m908::dump_settings( std::ostream& output ){
|
|||
output << "\n\n" << std::dec << std::setw(0) << std::setfill(' ');
|
||||
}
|
||||
}
|
||||
libusb_control_transfer( _handle, 0x21, 0x09, 0x0302, 0x0002, buffer3[100], 16, 1000 );
|
||||
libusb_control_transfer( _i_handle, 0x21, 0x09, 0x0302, 0x0002, buffer3[100], 16, 1000 );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -115,36 +115,36 @@ int mouse_m908::dump_settings( std::ostream& output ){
|
|||
int mouse_m908::read_and_print_settings( std::ostream& output ){
|
||||
|
||||
//prepare data 1
|
||||
int rows1 = sizeof(_data_read_1) / sizeof(_data_read_1[0]);
|
||||
int rows1 = sizeof(_c_data_read_1) / sizeof(_c_data_read_1[0]);
|
||||
uint8_t buffer1[rows1][16];
|
||||
for( int i = 0; i < rows1; i++ ){
|
||||
std::copy(std::begin(_data_read_1[i]), std::end(_data_read_1[i]), std::begin(buffer1[i]));
|
||||
std::copy(std::begin(_c_data_read_1[i]), std::end(_c_data_read_1[i]), std::begin(buffer1[i]));
|
||||
}
|
||||
|
||||
//prepare data 2
|
||||
int rows2 = sizeof(_data_read_2) / sizeof(_data_read_2[0]);
|
||||
int rows2 = sizeof(_c_data_read_2) / sizeof(_c_data_read_2[0]);
|
||||
uint8_t buffer2[rows2][64];
|
||||
for( int i = 0; i < rows2; i++ ){
|
||||
std::copy(std::begin(_data_read_2[i]), std::end(_data_read_2[i]), std::begin(buffer2[i]));
|
||||
std::copy(std::begin(_c_data_read_2[i]), std::end(_c_data_read_2[i]), std::begin(buffer2[i]));
|
||||
}
|
||||
|
||||
//prepare data 3
|
||||
int rows3 = sizeof(_data_read_3) / sizeof(_data_read_3[0]);
|
||||
int rows3 = sizeof(_c_data_read_3) / sizeof(_c_data_read_3[0]);
|
||||
uint8_t buffer3[rows3][16];
|
||||
for( int i = 0; i < rows3; i++ ){
|
||||
std::copy(std::begin(_data_read_3[i]), std::end(_data_read_3[i]), std::begin(buffer3[i]));
|
||||
std::copy(std::begin(_c_data_read_3[i]), std::end(_c_data_read_3[i]), std::begin(buffer3[i]));
|
||||
}
|
||||
|
||||
|
||||
//send data 1
|
||||
uint8_t buffer_in1[8][16] = {0};
|
||||
libusb_control_transfer( _handle, 0x21, 0x09, 0x0302, 0x0002, buffer1[0], 16, 1000 );
|
||||
libusb_control_transfer( _i_handle, 0x21, 0x09, 0x0302, 0x0002, buffer1[0], 16, 1000 );
|
||||
for( int i = 1; i < rows1; i++ ){
|
||||
// control out
|
||||
libusb_control_transfer( _handle, 0x21, 0x09, 0x0302, 0x0002, buffer1[i], 16, 1000 );
|
||||
libusb_control_transfer( _i_handle, 0x21, 0x09, 0x0302, 0x0002, buffer1[i], 16, 1000 );
|
||||
|
||||
// control in
|
||||
libusb_control_transfer( _handle, 0xa1, 0x01, 0x0302, 0x0002, buffer_in1[i-1], 16, 1000 );
|
||||
libusb_control_transfer( _i_handle, 0xa1, 0x01, 0x0302, 0x0002, buffer_in1[i-1], 16, 1000 );
|
||||
|
||||
}
|
||||
|
||||
|
@ -152,10 +152,10 @@ int mouse_m908::read_and_print_settings( std::ostream& output ){
|
|||
uint8_t buffer_in2[85][64] = {0};
|
||||
for( int i = 0; i < rows2; i++ ){
|
||||
// control out
|
||||
libusb_control_transfer( _handle, 0x21, 0x09, 0x0303, 0x0002, buffer2[i], 64, 1000 );
|
||||
libusb_control_transfer( _i_handle, 0x21, 0x09, 0x0303, 0x0002, buffer2[i], 64, 1000 );
|
||||
|
||||
// control in
|
||||
libusb_control_transfer( _handle, 0xa1, 0x01, 0x0303, 0x0002, buffer_in2[i], 64, 1000 );
|
||||
libusb_control_transfer( _i_handle, 0xa1, 0x01, 0x0303, 0x0002, buffer_in2[i], 64, 1000 );
|
||||
|
||||
}
|
||||
|
||||
|
@ -163,19 +163,20 @@ int mouse_m908::read_and_print_settings( std::ostream& output ){
|
|||
uint8_t buffer_in3[100][16] = {0};
|
||||
for( int i = 0; i < rows3-1; i++ ){
|
||||
// control out
|
||||
libusb_control_transfer( _handle, 0x21, 0x09, 0x0302, 0x0002, buffer3[i], 16, 1000 );
|
||||
libusb_control_transfer( _i_handle, 0x21, 0x09, 0x0302, 0x0002, buffer3[i], 16, 1000 );
|
||||
|
||||
// control in
|
||||
libusb_control_transfer( _handle, 0xa1, 0x01, 0x0302, 0x0002, buffer_in3[i], 16, 1000 );
|
||||
libusb_control_transfer( _i_handle, 0xa1, 0x01, 0x0302, 0x0002, buffer_in3[i], 16, 1000 );
|
||||
|
||||
}
|
||||
libusb_control_transfer( _handle, 0x21, 0x09, 0x0302, 0x0002, buffer3[100], 16, 1000 );
|
||||
libusb_control_transfer( _i_handle, 0x21, 0x09, 0x0302, 0x0002, buffer3[100], 16, 1000 );
|
||||
|
||||
|
||||
// print configuration
|
||||
output << "# Configuration created with mouse_m908 -R.\n";
|
||||
output << "# Reading the scrollspeed is not supported.\n";
|
||||
output << "# Currently active profile: " << (int)buffer_in1[0][8]+1 << "\n";
|
||||
output << "# This configuration can be send to the mouse with mouse_m908 -c.\n";
|
||||
output << "# Note: reading the scrollspeed is not supported.\n";
|
||||
output << "\n# Currently active profile: " << (int)buffer_in1[0][8]+1 << "\n";
|
||||
|
||||
for( int i = 1; i < 6; i++ ){
|
||||
|
||||
|
@ -280,7 +281,7 @@ int mouse_m908::read_and_print_settings( std::ostream& output ){
|
|||
uint8_t b4 = buffer_in3[j+(20*(i-1))][11];
|
||||
bool found_name = false;
|
||||
|
||||
output << _button_names[j] << "=";
|
||||
output << _c_button_names[j] << "=";
|
||||
|
||||
// fire button
|
||||
if( b1 == 0x99 ){
|
||||
|
@ -296,8 +297,8 @@ int mouse_m908::read_and_print_settings( std::ostream& output ){
|
|||
output << "mouse_middle:";
|
||||
else{
|
||||
|
||||
// iterate over _keyboard_key_values
|
||||
for( auto keycode : _keyboard_key_values ){
|
||||
// iterate over _c_keyboard_key_values
|
||||
for( auto keycode : _c_keyboard_key_values ){
|
||||
|
||||
if( keycode.second == b2 ){
|
||||
|
||||
|
@ -321,8 +322,8 @@ int mouse_m908::read_and_print_settings( std::ostream& output ){
|
|||
// keyboard key
|
||||
} else if( b1 == 0x90 ){
|
||||
|
||||
// iterate over _keyboard_key_values
|
||||
for( auto keycode : _keyboard_key_values ){
|
||||
// iterate over _c_keyboard_key_values
|
||||
for( auto keycode : _c_keyboard_key_values ){
|
||||
|
||||
if( keycode.second == b3 ){
|
||||
|
||||
|
@ -337,8 +338,8 @@ int mouse_m908::read_and_print_settings( std::ostream& output ){
|
|||
// modifiers + keyboard key
|
||||
} else if( b1 == 0x8f ){
|
||||
|
||||
// iterate over _keyboard_modifier_values
|
||||
for( auto modifier : _keyboard_modifier_values ){
|
||||
// iterate over _c_keyboard_modifier_values
|
||||
for( auto modifier : _c_keyboard_modifier_values ){
|
||||
|
||||
if( modifier.second & b2 ){
|
||||
output << modifier.first;
|
||||
|
@ -346,8 +347,8 @@ int mouse_m908::read_and_print_settings( std::ostream& output ){
|
|||
|
||||
}
|
||||
|
||||
// iterate over _keyboard_key_values
|
||||
for( auto keycode : _keyboard_key_values ){
|
||||
// iterate over _c_keyboard_key_values
|
||||
for( auto keycode : _c_keyboard_key_values ){
|
||||
|
||||
if( keycode.second == b3 ){
|
||||
|
||||
|
@ -361,8 +362,8 @@ int mouse_m908::read_and_print_settings( std::ostream& output ){
|
|||
|
||||
} else{ // mousebutton or special function ?
|
||||
|
||||
// iterate over _keycodes
|
||||
for( auto keycode : _keycodes ){
|
||||
// iterate over _c_keycodes
|
||||
for( auto keycode : _c_keycodes ){
|
||||
|
||||
if( keycode.second[0] == b1 &&
|
||||
keycode.second[1] == b2 &&
|
||||
|
@ -469,8 +470,8 @@ int mouse_m908::read_and_print_settings( std::ostream& output ){
|
|||
|
||||
bool found_name = false;
|
||||
|
||||
// iterate over _keyboard_key_values
|
||||
for( auto keycode : _keyboard_key_values ){
|
||||
// iterate over _c_keyboard_key_values
|
||||
for( auto keycode : _c_keyboard_key_values ){
|
||||
|
||||
if( keycode.second == macro_bytes[i][j+1] ){
|
||||
|
||||
|
@ -494,8 +495,8 @@ int mouse_m908::read_and_print_settings( std::ostream& output ){
|
|||
|
||||
bool found_name = false;
|
||||
|
||||
// iterate over _keyboard_key_values
|
||||
for( auto keycode : _keyboard_key_values ){
|
||||
// iterate over _c_keyboard_key_values
|
||||
for( auto keycode : _c_keyboard_key_values ){
|
||||
|
||||
if( keycode.second == macro_bytes[i][j+1] ){
|
||||
|
||||
|
@ -544,36 +545,36 @@ int mouse_m908::read_and_print_settings( std::ostream& output ){
|
|||
int mouse_m908::read_settings(){
|
||||
|
||||
//prepare data 1
|
||||
int rows1 = sizeof(_data_read_1) / sizeof(_data_read_1[0]);
|
||||
int rows1 = sizeof(_c_data_read_1) / sizeof(_c_data_read_1[0]);
|
||||
uint8_t buffer1[rows1][16];
|
||||
for( int i = 0; i < rows1; i++ ){
|
||||
std::copy(std::begin(_data_read_1[i]), std::end(_data_read_1[i]), std::begin(buffer1[i]));
|
||||
std::copy(std::begin(_c_data_read_1[i]), std::end(_c_data_read_1[i]), std::begin(buffer1[i]));
|
||||
}
|
||||
|
||||
//prepare data 2
|
||||
int rows2 = sizeof(_data_read_2) / sizeof(_data_read_2[0]);
|
||||
int rows2 = sizeof(_c_data_read_2) / sizeof(_c_data_read_2[0]);
|
||||
uint8_t buffer2[rows2][64];
|
||||
for( int i = 0; i < rows2; i++ ){
|
||||
std::copy(std::begin(_data_read_2[i]), std::end(_data_read_2[i]), std::begin(buffer2[i]));
|
||||
std::copy(std::begin(_c_data_read_2[i]), std::end(_c_data_read_2[i]), std::begin(buffer2[i]));
|
||||
}
|
||||
|
||||
//prepare data 3
|
||||
int rows3 = sizeof(_data_read_3) / sizeof(_data_read_3[0]);
|
||||
int rows3 = sizeof(_c_data_read_3) / sizeof(_c_data_read_3[0]);
|
||||
uint8_t buffer3[rows3][16];
|
||||
for( int i = 0; i < rows3; i++ ){
|
||||
std::copy(std::begin(_data_read_3[i]), std::end(_data_read_3[i]), std::begin(buffer3[i]));
|
||||
std::copy(std::begin(_c_data_read_3[i]), std::end(_c_data_read_3[i]), std::begin(buffer3[i]));
|
||||
}
|
||||
|
||||
|
||||
//send data 1
|
||||
uint8_t buffer_in1[8][16] = {0};
|
||||
libusb_control_transfer( _handle, 0x21, 0x09, 0x0302, 0x0002, buffer1[0], 16, 1000 );
|
||||
libusb_control_transfer( _i_handle, 0x21, 0x09, 0x0302, 0x0002, buffer1[0], 16, 1000 );
|
||||
for( int i = 1; i < rows1; i++ ){
|
||||
// control out
|
||||
libusb_control_transfer( _handle, 0x21, 0x09, 0x0302, 0x0002, buffer1[i], 16, 1000 );
|
||||
libusb_control_transfer( _i_handle, 0x21, 0x09, 0x0302, 0x0002, buffer1[i], 16, 1000 );
|
||||
|
||||
// control in
|
||||
libusb_control_transfer( _handle, 0xa1, 0x01, 0x0302, 0x0002, buffer_in1[i-1], 16, 1000 );
|
||||
libusb_control_transfer( _i_handle, 0xa1, 0x01, 0x0302, 0x0002, buffer_in1[i-1], 16, 1000 );
|
||||
|
||||
}
|
||||
|
||||
|
@ -581,10 +582,10 @@ int mouse_m908::read_settings(){
|
|||
uint8_t buffer_in2[85][64] = {0};
|
||||
for( int i = 0; i < rows2; i++ ){
|
||||
// control out
|
||||
libusb_control_transfer( _handle, 0x21, 0x09, 0x0303, 0x0002, buffer2[i], 64, 1000 );
|
||||
libusb_control_transfer( _i_handle, 0x21, 0x09, 0x0303, 0x0002, buffer2[i], 64, 1000 );
|
||||
|
||||
// control in
|
||||
libusb_control_transfer( _handle, 0xa1, 0x01, 0x0303, 0x0002, buffer_in2[i], 64, 1000 );
|
||||
libusb_control_transfer( _i_handle, 0xa1, 0x01, 0x0303, 0x0002, buffer_in2[i], 64, 1000 );
|
||||
|
||||
}
|
||||
|
||||
|
@ -592,80 +593,80 @@ int mouse_m908::read_settings(){
|
|||
uint8_t buffer_in3[100][16] = {0};
|
||||
for( int i = 0; i < rows3-1; i++ ){
|
||||
// control out
|
||||
libusb_control_transfer( _handle, 0x21, 0x09, 0x0302, 0x0002, buffer3[i], 16, 1000 );
|
||||
libusb_control_transfer( _i_handle, 0x21, 0x09, 0x0302, 0x0002, buffer3[i], 16, 1000 );
|
||||
|
||||
// control in
|
||||
libusb_control_transfer( _handle, 0xa1, 0x01, 0x0302, 0x0002, buffer_in3[i], 16, 1000 );
|
||||
libusb_control_transfer( _i_handle, 0xa1, 0x01, 0x0302, 0x0002, buffer_in3[i], 16, 1000 );
|
||||
|
||||
}
|
||||
libusb_control_transfer( _handle, 0x21, 0x09, 0x0302, 0x0002, buffer3[100], 16, 1000 );
|
||||
libusb_control_transfer( _i_handle, 0x21, 0x09, 0x0302, 0x0002, buffer3[100], 16, 1000 );
|
||||
|
||||
// parse received data
|
||||
|
||||
if( buffer_in1[0][8]+1 == 1 )
|
||||
_profile = profile_1;
|
||||
_s_profile = profile_1;
|
||||
if( buffer_in1[0][8]+1 == 2 )
|
||||
_profile = profile_2;
|
||||
_s_profile = profile_2;
|
||||
if( buffer_in1[0][8]+1 == 3 )
|
||||
_profile = profile_3;
|
||||
_s_profile = profile_3;
|
||||
if( buffer_in1[0][8]+1 == 4 )
|
||||
_profile = profile_4;
|
||||
_s_profile = profile_4;
|
||||
if( buffer_in1[0][8]+1 == 5 )
|
||||
_profile = profile_5;
|
||||
_s_profile = profile_5;
|
||||
|
||||
for( int i = 1; i < 6; i++ ){
|
||||
|
||||
// color
|
||||
_colors[i-1][0] = buffer_in1[i][8];
|
||||
_colors[i-1][1] = buffer_in1[i][9];
|
||||
_colors[i-1][2] = buffer_in1[i][10];
|
||||
_s_colors[i-1][0] = buffer_in1[i][8];
|
||||
_s_colors[i-1][1] = buffer_in1[i][9];
|
||||
_s_colors[i-1][2] = buffer_in1[i][10];
|
||||
|
||||
// brightness
|
||||
_brightness_levels[i-1] = buffer_in1[i][14];
|
||||
_s_brightness_levels[i-1] = buffer_in1[i][14];
|
||||
|
||||
// speed
|
||||
_speed_levels[i-1] = buffer_in1[i][13];
|
||||
_s_speed_levels[i-1] = buffer_in1[i][13];
|
||||
|
||||
// lightmode
|
||||
if( buffer_in1[i][11] == 0x00 && buffer_in1[i][13] == 0x00 )
|
||||
_lightmodes[i-1] = lightmode_off;
|
||||
_s_lightmodes[i-1] = lightmode_off;
|
||||
else if( buffer_in1[i][11] == 0x01 && buffer_in1[i][13] == 0x04 )
|
||||
_lightmodes[i-1] = lightmode_breathing;
|
||||
_s_lightmodes[i-1] = lightmode_breathing;
|
||||
else if( buffer_in1[i][11] == 0x01 && buffer_in1[i][13] == 0x08 )
|
||||
_lightmodes[i-1] = lightmode_rainbow;
|
||||
_s_lightmodes[i-1] = lightmode_rainbow;
|
||||
else if( buffer_in1[i][11] == 0x01 && buffer_in1[i][13] == 0x02 )
|
||||
_lightmodes[i-1] = lightmode_static;
|
||||
_s_lightmodes[i-1] = lightmode_static;
|
||||
else if( buffer_in1[i][11] == 0x02 && buffer_in1[i][13] == 0x00 )
|
||||
_lightmodes[i-1] = lightmode_wave;
|
||||
_s_lightmodes[i-1] = lightmode_wave;
|
||||
else if( buffer_in1[i][11] == 0x06 && buffer_in1[i][13] == 0x00 )
|
||||
_lightmodes[i-1] = lightmode_alternating;
|
||||
_s_lightmodes[i-1] = lightmode_alternating;
|
||||
else if( buffer_in1[i][11] == 0x07 && buffer_in1[i][13] == 0x00 )
|
||||
_lightmodes[i-1] = lightmode_reactive;
|
||||
_s_lightmodes[i-1] = lightmode_reactive;
|
||||
else if( buffer_in1[i][11] == 0x01 && buffer_in1[i][13] == 0x10 )
|
||||
_lightmodes[i-1] = lightmode_flashing;
|
||||
_s_lightmodes[i-1] = lightmode_flashing;
|
||||
|
||||
// polling rate (report rate)
|
||||
if( i < 4 ){
|
||||
|
||||
if( buffer_in1[6][6+(2*i)] == 8 )
|
||||
_report_rates[i-1] = r_125Hz;
|
||||
_s_report_rates[i-1] = r_125Hz;
|
||||
else if( buffer_in1[6][6+(2*i)] == 4 )
|
||||
_report_rates[i-1] = r_250Hz;
|
||||
_s_report_rates[i-1] = r_250Hz;
|
||||
else if( buffer_in1[6][6+(2*i)] == 2 )
|
||||
_report_rates[i-1] = r_500Hz;
|
||||
_s_report_rates[i-1] = r_500Hz;
|
||||
else if( buffer_in1[6][6+(2*i)] == 1 )
|
||||
_report_rates[i-1] = r_1000Hz;
|
||||
_s_report_rates[i-1] = r_1000Hz;
|
||||
|
||||
} else{
|
||||
|
||||
if( buffer_in1[7][(2*i)] == 8 )
|
||||
_report_rates[i-1] = r_125Hz;
|
||||
_s_report_rates[i-1] = r_125Hz;
|
||||
else if( buffer_in1[7][(2*i)] == 4 )
|
||||
_report_rates[i-1] = r_250Hz;
|
||||
_s_report_rates[i-1] = r_250Hz;
|
||||
else if( buffer_in1[7][(2*i)] == 2 )
|
||||
_report_rates[i-1] = r_500Hz;
|
||||
_s_report_rates[i-1] = r_500Hz;
|
||||
else if( buffer_in1[7][(2*i)] == 1 )
|
||||
_report_rates[i-1] = r_1000Hz;
|
||||
_s_report_rates[i-1] = r_1000Hz;
|
||||
|
||||
}
|
||||
|
||||
|
@ -674,21 +675,21 @@ int mouse_m908::read_settings(){
|
|||
for( int j = 1; j < 6; j++ ){
|
||||
|
||||
if( buffer_in2[i-1][4+(6*j)] )
|
||||
_dpi_enabled[i-1][j-1] = true;
|
||||
_s_dpi_enabled[i-1][j-1] = true;
|
||||
else
|
||||
_dpi_enabled[i-1][j-1] = false;
|
||||
_s_dpi_enabled[i-1][j-1] = false;
|
||||
|
||||
_dpi_levels[i-1][j-1] = buffer_in2[i-1][5+(6*j)];
|
||||
_s_dpi_levels[i-1][j-1] = buffer_in2[i-1][5+(6*j)];
|
||||
|
||||
}
|
||||
|
||||
// button mapping
|
||||
for( int j = 0; j < 20; j++ ){
|
||||
|
||||
_keymap_data[i-1][j][0] = buffer_in3[j+(20*(i-1))][8];
|
||||
_keymap_data[i-1][j][1] = buffer_in3[j+(20*(i-1))][9];
|
||||
_keymap_data[i-1][j][2] = buffer_in3[j+(20*(i-1))][10];
|
||||
_keymap_data[i-1][j][3] = buffer_in3[j+(20*(i-1))][11];
|
||||
_s_keymap_data[i-1][j][0] = buffer_in3[j+(20*(i-1))][8];
|
||||
_s_keymap_data[i-1][j][1] = buffer_in3[j+(20*(i-1))][9];
|
||||
_s_keymap_data[i-1][j][2] = buffer_in3[j+(20*(i-1))][10];
|
||||
_s_keymap_data[i-1][j][3] = buffer_in3[j+(20*(i-1))][11];
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -725,17 +726,17 @@ int mouse_m908::read_settings(){
|
|||
|
||||
}
|
||||
|
||||
// store extracted bytes in _macro_data
|
||||
// store extracted bytes in _s_macro_data
|
||||
for( int i = 0; i < 15; i++ ){ // for each macro in macro_bytes
|
||||
|
||||
// for each byte in the macro
|
||||
for( unsigned int j = 0; j < macro_bytes[i].size(); j++ ){
|
||||
|
||||
// failsafe
|
||||
if( j >= (_macro_data[i].size()+8) )
|
||||
if( j >= (_s_macro_data[i].size()+8) )
|
||||
break;
|
||||
|
||||
_macro_data[i][j+8] = macro_bytes[i][j];
|
||||
_s_macro_data[i][j+8] = macro_bytes[i][j];
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -21,74 +21,74 @@
|
|||
//setter functions
|
||||
|
||||
int mouse_m908::set_profile( m908_profile profile ){
|
||||
_profile = profile;
|
||||
_s_profile = profile;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int mouse_m908::set_scrollspeed( m908_profile profile, uint8_t speed ){
|
||||
|
||||
//check if bounds exceeded
|
||||
if( speed < _scrollspeed_min || speed > _scrollspeed_max ){
|
||||
if( speed < _c_scrollspeed_min || speed > _c_scrollspeed_max ){
|
||||
return 1;
|
||||
}
|
||||
|
||||
_scrollspeeds[profile] = speed;
|
||||
_s_scrollspeeds[profile] = speed;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int mouse_m908::set_lightmode( m908_profile profile, m908_lightmode lightmode ){
|
||||
_lightmodes[profile] = lightmode;
|
||||
_s_lightmodes[profile] = lightmode;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int mouse_m908::set_color( m908_profile profile, std::array<uint8_t, 3> color ){
|
||||
_colors[profile] = color;
|
||||
_s_colors[profile] = color;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int mouse_m908::set_brightness( m908_profile profile, uint8_t brightness ){
|
||||
|
||||
//check bounds
|
||||
if( brightness < _brightness_min || brightness > _brightness_max ){
|
||||
if( brightness < _c_brightness_min || brightness > _c_brightness_max ){
|
||||
return 1;
|
||||
}
|
||||
|
||||
_brightness_levels[profile] = brightness;
|
||||
_s_brightness_levels[profile] = brightness;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int mouse_m908::set_speed( m908_profile profile, uint8_t speed ){
|
||||
|
||||
//check bounds
|
||||
if( speed < _speed_min || speed > _speed_max ){
|
||||
if( speed < _c_speed_min || speed > _c_speed_max ){
|
||||
return 1;
|
||||
}
|
||||
|
||||
_speed_levels[profile] = speed;
|
||||
_s_speed_levels[profile] = speed;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int mouse_m908::set_dpi_enable( m908_profile profile, int level, bool enabled ){
|
||||
|
||||
//check bounds
|
||||
if( level < _level_min || level > _level_max ){
|
||||
if( level < _c_level_min || level > _c_level_max ){
|
||||
return 1;
|
||||
}
|
||||
|
||||
_dpi_enabled[profile][level] = enabled;
|
||||
_s_dpi_enabled[profile][level] = enabled;
|
||||
|
||||
// check if at least one level enabled
|
||||
int sum = 0;
|
||||
for( int i = _level_min; i <= _level_max; i++ ){
|
||||
if( _dpi_enabled[profile][i] ){
|
||||
for( int i = _c_level_min; i <= _c_level_max; i++ ){
|
||||
if( _s_dpi_enabled[profile][i] ){
|
||||
sum++;
|
||||
}
|
||||
}
|
||||
|
||||
// if no level enabled: reenable specified level
|
||||
if( sum == 0 ){
|
||||
_dpi_enabled[profile][level] = true;
|
||||
_s_dpi_enabled[profile][level] = true;
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -98,30 +98,30 @@ int mouse_m908::set_dpi_enable( m908_profile profile, int level, bool enabled ){
|
|||
int mouse_m908::set_dpi( m908_profile profile, int level, uint8_t dpi ){
|
||||
|
||||
//check bounds
|
||||
if( dpi < _dpi_min || dpi > _dpi_max ){
|
||||
if( dpi < _c_dpi_min || dpi > _c_dpi_max ){
|
||||
return 1;
|
||||
}
|
||||
|
||||
_dpi_levels[profile][level] = dpi;
|
||||
_s_dpi_levels[profile][level] = dpi;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int mouse_m908::set_key_mapping( m908_profile profile, int key, std::array<uint8_t, 4> mapping ){
|
||||
_keymap_data[profile][key][0] = mapping[0];
|
||||
_keymap_data[profile][key][1] = mapping[1];
|
||||
_keymap_data[profile][key][2] = mapping[2];
|
||||
_keymap_data[profile][key][3] = mapping[3];
|
||||
_s_keymap_data[profile][key][0] = mapping[0];
|
||||
_s_keymap_data[profile][key][1] = mapping[1];
|
||||
_s_keymap_data[profile][key][2] = mapping[2];
|
||||
_s_keymap_data[profile][key][3] = mapping[3];
|
||||
return 0;
|
||||
}
|
||||
|
||||
int mouse_m908::set_key_mapping( m908_profile profile, int key, std::string mapping ){
|
||||
|
||||
// is string in _keycodes? mousebuttons/special functions and media controls
|
||||
if( _keycodes.find(mapping) != _keycodes.end() ){
|
||||
_keymap_data[profile][key][0] = _keycodes[mapping][0];
|
||||
_keymap_data[profile][key][1] = _keycodes[mapping][1];
|
||||
_keymap_data[profile][key][2] = _keycodes[mapping][2];
|
||||
_keymap_data[profile][key][3] = 0x00;
|
||||
// is string in _c_keycodes? mousebuttons/special functions and media controls
|
||||
if( _c_keycodes.find(mapping) != _c_keycodes.end() ){
|
||||
_s_keymap_data[profile][key][0] = _c_keycodes[mapping][0];
|
||||
_s_keymap_data[profile][key][1] = _c_keycodes[mapping][1];
|
||||
_s_keymap_data[profile][key][2] = _c_keycodes[mapping][2];
|
||||
_s_keymap_data[profile][key][3] = 0x00;
|
||||
} else if( mapping.find("fire") == 0 ){
|
||||
// fire button (multiple keypresses)
|
||||
|
||||
|
@ -141,8 +141,8 @@ int mouse_m908::set_key_mapping( m908_profile profile, int key, std::string mapp
|
|||
keycode = 0x82;
|
||||
} else if( value1 == "mouse_middle" ){
|
||||
keycode = 0x84;
|
||||
} else if( _keyboard_key_values.find(value1) != _keyboard_key_values.end() ){
|
||||
keycode = _keyboard_key_values[value1];
|
||||
} else if( _c_keyboard_key_values.find(value1) != _c_keyboard_key_values.end() ){
|
||||
keycode = _c_keyboard_key_values[value1];
|
||||
} else{
|
||||
return 1;
|
||||
}
|
||||
|
@ -151,18 +151,18 @@ int mouse_m908::set_key_mapping( m908_profile profile, int key, std::string mapp
|
|||
delay = (uint8_t)stoi(value3);
|
||||
|
||||
// store values
|
||||
_keymap_data[profile][key][0] = 0x99;
|
||||
_keymap_data[profile][key][1] = keycode;
|
||||
_keymap_data[profile][key][2] = repeats;
|
||||
_keymap_data[profile][key][3] = delay;
|
||||
_s_keymap_data[profile][key][0] = 0x99;
|
||||
_s_keymap_data[profile][key][1] = keycode;
|
||||
_s_keymap_data[profile][key][2] = repeats;
|
||||
_s_keymap_data[profile][key][3] = delay;
|
||||
|
||||
} else{
|
||||
// string is not a key in _keycodes: keyboard key?
|
||||
// string is not a key in _c_keycodes: keyboard key?
|
||||
|
||||
// search for modifiers and change values accordingly: ctrl, shift ...
|
||||
uint8_t first_value = 0x90;
|
||||
uint8_t modifier_value = 0x00;
|
||||
for( auto i : _keyboard_modifier_values ){
|
||||
for( auto i : _c_keyboard_modifier_values ){
|
||||
if( mapping.find( i.first ) != std::string::npos ){
|
||||
modifier_value += i.second;
|
||||
first_value = 0x8f;
|
||||
|
@ -173,10 +173,10 @@ int mouse_m908::set_key_mapping( m908_profile profile, int key, std::string mapp
|
|||
try{
|
||||
std::regex modifier_regex ("[a-z_]*\\+");
|
||||
// store values
|
||||
_keymap_data[profile][key][0] = first_value;
|
||||
_keymap_data[profile][key][1] = modifier_value;
|
||||
_keymap_data[profile][key][2] = _keyboard_key_values[std::regex_replace( mapping, modifier_regex, "" )];
|
||||
_keymap_data[profile][key][3] = 0x00;
|
||||
_s_keymap_data[profile][key][0] = first_value;
|
||||
_s_keymap_data[profile][key][1] = modifier_value;
|
||||
_s_keymap_data[profile][key][2] = _c_keyboard_key_values[std::regex_replace( mapping, modifier_regex, "" )];
|
||||
_s_keymap_data[profile][key][3] = 0x00;
|
||||
//std::cout << std::regex_replace( mapping, modifier_regex, "" ) << "\n";
|
||||
} catch( std::exception& f ){
|
||||
return 1;
|
||||
|
@ -187,7 +187,7 @@ int mouse_m908::set_key_mapping( m908_profile profile, int key, std::string mapp
|
|||
}
|
||||
|
||||
int mouse_m908::set_report_rate( m908_profile profile, m908_report_rate report_rate ){
|
||||
_report_rates[profile] = report_rate;
|
||||
_s_report_rates[profile] = report_rate;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -220,48 +220,48 @@ int mouse_m908::set_macro( int macro_number, std::string file ){
|
|||
value1 = line.substr(0, position);
|
||||
value2 = line.substr(position+1);
|
||||
|
||||
if( value1 == "down" && _keyboard_key_values.find(value2) != _keyboard_key_values.end() ){
|
||||
if( value1 == "down" && _c_keyboard_key_values.find(value2) != _c_keyboard_key_values.end() ){
|
||||
// keyboard key down
|
||||
//std::cout << "down\n";
|
||||
_macro_data[macro_number-1][data_offset] = 0x84;
|
||||
_macro_data[macro_number-1][data_offset+1] = _keyboard_key_values[value2];
|
||||
_s_macro_data[macro_number-1][data_offset] = 0x84;
|
||||
_s_macro_data[macro_number-1][data_offset+1] = _c_keyboard_key_values[value2];
|
||||
data_offset += 3;
|
||||
} else if( value1 == "up" && _keyboard_key_values.find(value2) != _keyboard_key_values.end() ){
|
||||
} else if( value1 == "up" && _c_keyboard_key_values.find(value2) != _c_keyboard_key_values.end() ){
|
||||
// keyboard key up
|
||||
//std::cout << "up\n";
|
||||
_macro_data[macro_number-1][data_offset] = 0x04;
|
||||
_macro_data[macro_number-1][data_offset+1] = _keyboard_key_values[value2];
|
||||
_s_macro_data[macro_number-1][data_offset] = 0x04;
|
||||
_s_macro_data[macro_number-1][data_offset+1] = _c_keyboard_key_values[value2];
|
||||
data_offset += 3;
|
||||
} else if( value1 == "down" && _keyboard_key_values.find(value2) == _keyboard_key_values.end() ){
|
||||
} else if( value1 == "down" && _c_keyboard_key_values.find(value2) == _c_keyboard_key_values.end() ){
|
||||
// mouse button down
|
||||
//std::cout << "mouse down\n";
|
||||
if( value2 == "mouse_left" ){
|
||||
_macro_data[macro_number-1][data_offset] = 0x81;
|
||||
_macro_data[macro_number-1][data_offset+1] = 0x01;
|
||||
_s_macro_data[macro_number-1][data_offset] = 0x81;
|
||||
_s_macro_data[macro_number-1][data_offset+1] = 0x01;
|
||||
data_offset += 3;
|
||||
} else if( value2 == "mouse_right" ){
|
||||
_macro_data[macro_number-1][data_offset] = 0x81;
|
||||
_macro_data[macro_number-1][data_offset+1] = 0x02;
|
||||
_s_macro_data[macro_number-1][data_offset] = 0x81;
|
||||
_s_macro_data[macro_number-1][data_offset+1] = 0x02;
|
||||
data_offset += 3;
|
||||
} else if( value2 == "mouse_middle" ){
|
||||
_macro_data[macro_number-1][data_offset] = 0x81;
|
||||
_macro_data[macro_number-1][data_offset+1] = 0x04;
|
||||
_s_macro_data[macro_number-1][data_offset] = 0x81;
|
||||
_s_macro_data[macro_number-1][data_offset+1] = 0x04;
|
||||
data_offset += 3;
|
||||
}
|
||||
} else if( value1 == "up" && _keyboard_key_values.find(value2) == _keyboard_key_values.end() ){
|
||||
} else if( value1 == "up" && _c_keyboard_key_values.find(value2) == _c_keyboard_key_values.end() ){
|
||||
// mouse button up
|
||||
//std::cout << "mouse up\n";
|
||||
if( value2 == "mouse_left" ){
|
||||
_macro_data[macro_number-1][data_offset] = 0x01;
|
||||
_macro_data[macro_number-1][data_offset+1] = 0x01;
|
||||
_s_macro_data[macro_number-1][data_offset] = 0x01;
|
||||
_s_macro_data[macro_number-1][data_offset+1] = 0x01;
|
||||
data_offset += 3;
|
||||
} else if( value2 == "mouse_right" ){
|
||||
_macro_data[macro_number-1][data_offset] = 0x01;
|
||||
_macro_data[macro_number-1][data_offset+1] = 0x02;
|
||||
_s_macro_data[macro_number-1][data_offset] = 0x01;
|
||||
_s_macro_data[macro_number-1][data_offset+1] = 0x02;
|
||||
data_offset += 3;
|
||||
} else if( value2 == "mouse_middle" ){
|
||||
_macro_data[macro_number-1][data_offset] = 0x01;
|
||||
_macro_data[macro_number-1][data_offset+1] = 0x04;
|
||||
_s_macro_data[macro_number-1][data_offset] = 0x01;
|
||||
_s_macro_data[macro_number-1][data_offset+1] = 0x04;
|
||||
data_offset += 3;
|
||||
}
|
||||
} else if( value1 == "delay" ){
|
||||
|
@ -269,8 +269,8 @@ int mouse_m908::set_macro( int macro_number, std::string file ){
|
|||
//std::cout << "delay\n";
|
||||
int duration = (uint8_t)stoi( value2, 0, 10);
|
||||
if( duration >= 1 && duration <= 255 ){
|
||||
_macro_data[macro_number-1][data_offset] = 0x06;
|
||||
_macro_data[macro_number-1][data_offset+1] = duration;
|
||||
_s_macro_data[macro_number-1][data_offset] = 0x06;
|
||||
_s_macro_data[macro_number-1][data_offset+1] = duration;
|
||||
data_offset += 3;
|
||||
}
|
||||
}
|
||||
|
@ -292,13 +292,13 @@ int mouse_m908::set_macro_repeat( int macro_number, uint8_t repeat ){
|
|||
return 1;
|
||||
}
|
||||
|
||||
_macro_repeat[macro_number] = repeat;
|
||||
_s_macro_repeat[macro_number] = repeat;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int mouse_m908::set_detach_kernel_driver( bool detach_kernel_driver ){
|
||||
|
||||
_detach_kernel_driver = detach_kernel_driver;
|
||||
_i_detach_kernel_driver = detach_kernel_driver;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -351,48 +351,48 @@ int mouse_m908::set_all_macros( std::string file ){
|
|||
value2 = action.substr(position+1);
|
||||
|
||||
// encode values
|
||||
if( value1 == "down" && _keyboard_key_values.find(value2) != _keyboard_key_values.end() ){
|
||||
if( value1 == "down" && _c_keyboard_key_values.find(value2) != _c_keyboard_key_values.end() ){
|
||||
// keyboard key down
|
||||
//std::cout << "down\n";
|
||||
_macro_data[macro_number-1][data_offset] = 0x84;
|
||||
_macro_data[macro_number-1][data_offset+1] = _keyboard_key_values[value2];
|
||||
_s_macro_data[macro_number-1][data_offset] = 0x84;
|
||||
_s_macro_data[macro_number-1][data_offset+1] = _c_keyboard_key_values[value2];
|
||||
data_offset += 3;
|
||||
} else if( value1 == "up" && _keyboard_key_values.find(value2) != _keyboard_key_values.end() ){
|
||||
} else if( value1 == "up" && _c_keyboard_key_values.find(value2) != _c_keyboard_key_values.end() ){
|
||||
// keyboard key up
|
||||
//std::cout << "up\n";
|
||||
_macro_data[macro_number-1][data_offset] = 0x04;
|
||||
_macro_data[macro_number-1][data_offset+1] = _keyboard_key_values[value2];
|
||||
_s_macro_data[macro_number-1][data_offset] = 0x04;
|
||||
_s_macro_data[macro_number-1][data_offset+1] = _c_keyboard_key_values[value2];
|
||||
data_offset += 3;
|
||||
} else if( value1 == "down" && _keyboard_key_values.find(value2) == _keyboard_key_values.end() ){
|
||||
} else if( value1 == "down" && _c_keyboard_key_values.find(value2) == _c_keyboard_key_values.end() ){
|
||||
// mouse button down
|
||||
//std::cout << "mouse down\n";
|
||||
if( value2 == "mouse_left" ){
|
||||
_macro_data[macro_number-1][data_offset] = 0x81;
|
||||
_macro_data[macro_number-1][data_offset+1] = 0x01;
|
||||
_s_macro_data[macro_number-1][data_offset] = 0x81;
|
||||
_s_macro_data[macro_number-1][data_offset+1] = 0x01;
|
||||
data_offset += 3;
|
||||
} else if( value2 == "mouse_right" ){
|
||||
_macro_data[macro_number-1][data_offset] = 0x81;
|
||||
_macro_data[macro_number-1][data_offset+1] = 0x02;
|
||||
_s_macro_data[macro_number-1][data_offset] = 0x81;
|
||||
_s_macro_data[macro_number-1][data_offset+1] = 0x02;
|
||||
data_offset += 3;
|
||||
} else if( value2 == "mouse_middle" ){
|
||||
_macro_data[macro_number-1][data_offset] = 0x81;
|
||||
_macro_data[macro_number-1][data_offset+1] = 0x04;
|
||||
_s_macro_data[macro_number-1][data_offset] = 0x81;
|
||||
_s_macro_data[macro_number-1][data_offset+1] = 0x04;
|
||||
data_offset += 3;
|
||||
}
|
||||
} else if( value1 == "up" && _keyboard_key_values.find(value2) == _keyboard_key_values.end() ){
|
||||
} else if( value1 == "up" && _c_keyboard_key_values.find(value2) == _c_keyboard_key_values.end() ){
|
||||
// mouse button up
|
||||
//std::cout << "mouse up\n";
|
||||
if( value2 == "mouse_left" ){
|
||||
_macro_data[macro_number-1][data_offset] = 0x01;
|
||||
_macro_data[macro_number-1][data_offset+1] = 0x01;
|
||||
_s_macro_data[macro_number-1][data_offset] = 0x01;
|
||||
_s_macro_data[macro_number-1][data_offset+1] = 0x01;
|
||||
data_offset += 3;
|
||||
} else if( value2 == "mouse_right" ){
|
||||
_macro_data[macro_number-1][data_offset] = 0x01;
|
||||
_macro_data[macro_number-1][data_offset+1] = 0x02;
|
||||
_s_macro_data[macro_number-1][data_offset] = 0x01;
|
||||
_s_macro_data[macro_number-1][data_offset+1] = 0x02;
|
||||
data_offset += 3;
|
||||
} else if( value2 == "mouse_middle" ){
|
||||
_macro_data[macro_number-1][data_offset] = 0x01;
|
||||
_macro_data[macro_number-1][data_offset+1] = 0x04;
|
||||
_s_macro_data[macro_number-1][data_offset] = 0x01;
|
||||
_s_macro_data[macro_number-1][data_offset+1] = 0x04;
|
||||
data_offset += 3;
|
||||
}
|
||||
} else if( value1 == "delay" ){
|
||||
|
@ -400,82 +400,14 @@ int mouse_m908::set_all_macros( std::string file ){
|
|||
//std::cout << "delay\n";
|
||||
int duration = (uint8_t)stoi( value2, 0, 10);
|
||||
if( duration >= 1 && duration <= 255 ){
|
||||
_macro_data[macro_number-1][data_offset] = 0x06;
|
||||
_macro_data[macro_number-1][data_offset+1] = duration;
|
||||
_s_macro_data[macro_number-1][data_offset] = 0x06;
|
||||
_s_macro_data[macro_number-1][data_offset+1] = duration;
|
||||
data_offset += 3;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//process individual line
|
||||
/*if( line.length() != 0 ){
|
||||
|
||||
position = 0;
|
||||
position = line.find("\t", position);
|
||||
value1 = line.substr(0, position);
|
||||
value2 = line.substr(position+1);
|
||||
|
||||
if( value1 == "down" && _keyboard_key_values.find(value2) != _keyboard_key_values.end() ){
|
||||
// keyboard key down
|
||||
//std::cout << "down\n";
|
||||
_macro_data[macro_number-1][data_offset] = 0x84;
|
||||
_macro_data[macro_number-1][data_offset+1] = _keyboard_key_values[value2];
|
||||
data_offset += 3;
|
||||
} else if( value1 == "up" && _keyboard_key_values.find(value2) != _keyboard_key_values.end() ){
|
||||
// keyboard key up
|
||||
//std::cout << "up\n";
|
||||
_macro_data[macro_number-1][data_offset] = 0x04;
|
||||
_macro_data[macro_number-1][data_offset+1] = _keyboard_key_values[value2];
|
||||
data_offset += 3;
|
||||
} else if( value1 == "down" && _keyboard_key_values.find(value2) == _keyboard_key_values.end() ){
|
||||
// mouse button down
|
||||
//std::cout << "mouse down\n";
|
||||
if( value2 == "mouse_left" ){
|
||||
_macro_data[macro_number-1][data_offset] = 0x81;
|
||||
_macro_data[macro_number-1][data_offset+1] = 0x01;
|
||||
data_offset += 3;
|
||||
} else if( value2 == "mouse_right" ){
|
||||
_macro_data[macro_number-1][data_offset] = 0x81;
|
||||
_macro_data[macro_number-1][data_offset+1] = 0x02;
|
||||
data_offset += 3;
|
||||
} else if( value2 == "mouse_middle" ){
|
||||
_macro_data[macro_number-1][data_offset] = 0x81;
|
||||
_macro_data[macro_number-1][data_offset+1] = 0x04;
|
||||
data_offset += 3;
|
||||
}
|
||||
} else if( value1 == "up" && _keyboard_key_values.find(value2) == _keyboard_key_values.end() ){
|
||||
// mouse button up
|
||||
//std::cout << "mouse up\n";
|
||||
if( value2 == "mouse_left" ){
|
||||
_macro_data[macro_number-1][data_offset] = 0x01;
|
||||
_macro_data[macro_number-1][data_offset+1] = 0x01;
|
||||
data_offset += 3;
|
||||
} else if( value2 == "mouse_right" ){
|
||||
_macro_data[macro_number-1][data_offset] = 0x01;
|
||||
_macro_data[macro_number-1][data_offset+1] = 0x02;
|
||||
data_offset += 3;
|
||||
} else if( value2 == "mouse_middle" ){
|
||||
_macro_data[macro_number-1][data_offset] = 0x01;
|
||||
_macro_data[macro_number-1][data_offset+1] = 0x04;
|
||||
data_offset += 3;
|
||||
}
|
||||
} else if( value1 == "delay" ){
|
||||
// delay
|
||||
//std::cout << "delay\n";
|
||||
int duration = (uint8_t)stoi( value2, 0, 10);
|
||||
if( duration >= 1 && duration <= 255 ){
|
||||
_macro_data[macro_number-1][data_offset] = 0x06;
|
||||
_macro_data[macro_number-1][data_offset+1] = duration;
|
||||
data_offset += 3;
|
||||
}
|
||||
}
|
||||
|
||||
if(data_offset > 212){
|
||||
return 0;
|
||||
}
|
||||
*/
|
||||
//}
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
|
|
@ -25,15 +25,15 @@ int mouse_m908::write_profile(){
|
|||
//prepare data
|
||||
uint8_t buffer[6][16];
|
||||
for( int i = 0; i < 6; i++ ){
|
||||
std::copy(std::begin(_data_profile[i]), std::end(_data_profile[i]), std::begin(buffer[i]));
|
||||
std::copy(std::begin(_c_data_s_profile[i]), std::end(_c_data_s_profile[i]), std::begin(buffer[i]));
|
||||
}
|
||||
|
||||
//modify buffer from default to include specified profile
|
||||
buffer[0][8] = _profile;
|
||||
buffer[0][8] = _s_profile;
|
||||
|
||||
//send data
|
||||
for( int i = 0; i < 6; i++ ){
|
||||
libusb_control_transfer( _handle, 0x21, 0x09, 0x0302, 0x0002, buffer[i], 16, 1000 );
|
||||
libusb_control_transfer( _i_handle, 0x21, 0x09, 0x0302, 0x0002, buffer[i], 16, 1000 );
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -42,31 +42,31 @@ int mouse_m908::write_profile(){
|
|||
int mouse_m908::write_settings(){
|
||||
|
||||
//prepare data 1
|
||||
int rows1 = sizeof(_data_settings_1) / sizeof(_data_settings_1[0]);
|
||||
int rows1 = sizeof(_c_data_settings_1) / sizeof(_c_data_settings_1[0]);
|
||||
uint8_t buffer1[rows1][16];
|
||||
for( int i = 0; i < rows1; i++ ){
|
||||
std::copy(std::begin(_data_settings_1[i]), std::end(_data_settings_1[i]), std::begin(buffer1[i]));
|
||||
std::copy(std::begin(_c_data_settings_1[i]), std::end(_c_data_settings_1[i]), std::begin(buffer1[i]));
|
||||
}
|
||||
|
||||
//prepare data 2
|
||||
uint8_t buffer2[64];
|
||||
std::copy(std::begin(_data_settings_2), std::end(_data_settings_2), std::begin(buffer2));
|
||||
std::copy(std::begin(_c_data_settings_2), std::end(_c_data_settings_2), std::begin(buffer2));
|
||||
|
||||
//prepare data 3
|
||||
int rows3 = sizeof(_data_settings_3) / sizeof(_data_settings_3[0]);
|
||||
int rows3 = sizeof(_c_data_settings_3) / sizeof(_c_data_settings_3[0]);
|
||||
uint8_t buffer3[rows3][16];
|
||||
for( int i = 0; i < rows3; i++ ){
|
||||
std::copy(std::begin(_data_settings_3[i]), std::end(_data_settings_3[i]), std::begin(buffer3[i]));
|
||||
std::copy(std::begin(_c_data_settings_3[i]), std::end(_c_data_settings_3[i]), std::begin(buffer3[i]));
|
||||
}
|
||||
|
||||
//modify buffers to include settings
|
||||
//scrollspeed
|
||||
for( int i = 0; i < 5; i++ ){
|
||||
buffer2[8+(2*i)] = _scrollspeeds[i];
|
||||
buffer2[8+(2*i)] = _s_scrollspeeds[i];
|
||||
}
|
||||
//lightmode
|
||||
for( int i = 0; i < 5; i++ ){
|
||||
switch( _lightmodes[i] ){
|
||||
switch( _s_lightmodes[i] ){
|
||||
case lightmode_breathing:
|
||||
buffer1[3+(2*i)][11] = 0x01;
|
||||
buffer1[3+(2*i)][13] = 0x04;
|
||||
|
@ -104,38 +104,38 @@ int mouse_m908::write_settings(){
|
|||
}
|
||||
//color
|
||||
for( int i = 0; i < 5; i++ ){
|
||||
buffer1[3+(2*i)][8] = _colors[i].at(0);
|
||||
buffer1[3+(2*i)][9] = _colors[i].at(1);
|
||||
buffer1[3+(2*i)][10] = _colors[i].at(2);
|
||||
buffer1[3+(2*i)][8] = _s_colors[i].at(0);
|
||||
buffer1[3+(2*i)][9] = _s_colors[i].at(1);
|
||||
buffer1[3+(2*i)][10] = _s_colors[i].at(2);
|
||||
}
|
||||
//brightness
|
||||
for( int i = 0; i < 5; i++ ){
|
||||
buffer1[4+(2*i)][8] = _brightness_levels[i];
|
||||
buffer1[4+(2*i)][8] = _s_brightness_levels[i];
|
||||
}
|
||||
//speed
|
||||
for( int i = 0; i < 5; i++ ){
|
||||
buffer1[3+(2*i)][12] = _speed_levels[i];
|
||||
buffer1[3+(2*i)][12] = _s_speed_levels[i];
|
||||
}
|
||||
//dpi
|
||||
for( int i = 0; i < 5; i++ ){
|
||||
for( int j = 0; j < 5; j++ ){
|
||||
buffer3[7+(5*i)+j][8] = _dpi_enabled[j][i];
|
||||
buffer3[7+(5*i)+j][9] = _dpi_levels[j][i];
|
||||
buffer3[7+(5*i)+j][8] = _s_dpi_enabled[j][i];
|
||||
buffer3[7+(5*i)+j][9] = _s_dpi_levels[j][i];
|
||||
}
|
||||
}
|
||||
//key mapping
|
||||
for( int i = 0; i < 5; i++ ){
|
||||
for( int j = 0; j < 20; j++ ){
|
||||
buffer3[35+(20*i)+j][8] = _keymap_data[i][j][0];
|
||||
buffer3[35+(20*i)+j][9] = _keymap_data[i][j][1];
|
||||
buffer3[35+(20*i)+j][10] = _keymap_data[i][j][2];
|
||||
buffer3[35+(20*i)+j][11] = _keymap_data[i][j][3];
|
||||
//std::cout << (int)_keymap_data[i][j][0] << " " << (int)_keymap_data[i][j][1] << " " << (int)_keymap_data[i][j][2] << " " << (int)_keymap_data[i][j][3] << "\n";
|
||||
buffer3[35+(20*i)+j][8] = _s_keymap_data[i][j][0];
|
||||
buffer3[35+(20*i)+j][9] = _s_keymap_data[i][j][1];
|
||||
buffer3[35+(20*i)+j][10] = _s_keymap_data[i][j][2];
|
||||
buffer3[35+(20*i)+j][11] = _s_keymap_data[i][j][3];
|
||||
//std::cout << (int)_s_keymap_data[i][j][0] << " " << (int)_s_keymap_data[i][j][1] << " " << (int)_s_keymap_data[i][j][2] << " " << (int)_s_keymap_data[i][j][3] << "\n";
|
||||
}
|
||||
}
|
||||
//usb report rate
|
||||
for( int i = 0; i < 3; i++ ){
|
||||
switch( _report_rates[i] ){
|
||||
switch( _s_report_rates[i] ){
|
||||
default:
|
||||
case r_125Hz:
|
||||
buffer1[13][8+(2*i)] = 0x08; break;
|
||||
|
@ -148,7 +148,7 @@ int mouse_m908::write_settings(){
|
|||
}
|
||||
}
|
||||
for( int i = 3; i < 5; i++ ){
|
||||
switch( _report_rates[i] ){
|
||||
switch( _s_report_rates[i] ){
|
||||
default:
|
||||
case r_125Hz:
|
||||
buffer1[14][2+(2*i)] = 0x08; break;
|
||||
|
@ -164,15 +164,15 @@ int mouse_m908::write_settings(){
|
|||
|
||||
//send data 1
|
||||
for( int i = 0; i < rows1; i++ ){
|
||||
libusb_control_transfer( _handle, 0x21, 0x09, 0x0302, 0x0002, buffer1[i], 16, 1000 );
|
||||
libusb_control_transfer( _i_handle, 0x21, 0x09, 0x0302, 0x0002, buffer1[i], 16, 1000 );
|
||||
}
|
||||
|
||||
//send data 2
|
||||
libusb_control_transfer( _handle, 0x21, 0x09, 0x0302, 0x0002, buffer2, 64, 1000 );
|
||||
libusb_control_transfer( _i_handle, 0x21, 0x09, 0x0302, 0x0002, buffer2, 64, 1000 );
|
||||
|
||||
//send data 3
|
||||
for( int i = 0; i < rows3; i++ ){
|
||||
libusb_control_transfer( _handle, 0x21, 0x09, 0x0302, 0x0002, buffer3[i], 16, 1000 );
|
||||
libusb_control_transfer( _i_handle, 0x21, 0x09, 0x0302, 0x0002, buffer3[i], 16, 1000 );
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -187,24 +187,24 @@ int mouse_m908::write_macro( int macro_number ){
|
|||
|
||||
//prepare data 1
|
||||
uint8_t buffer1[16];
|
||||
std::copy(std::begin(_data_macros_1), std::end(_data_macros_1), std::begin(buffer1));
|
||||
std::copy(std::begin(_c_data_macros_1), std::end(_c_data_macros_1), std::begin(buffer1));
|
||||
|
||||
//prepare data 2
|
||||
uint8_t buffer2[265];
|
||||
std::copy(std::begin(_macro_data[macro_number-1]), std::end(_macro_data[macro_number-1]), std::begin(buffer2));
|
||||
std::copy(std::begin(_s_macro_data[macro_number-1]), std::end(_s_macro_data[macro_number-1]), std::begin(buffer2));
|
||||
|
||||
//prepare data 3
|
||||
uint8_t buffer3[16];
|
||||
std::copy(std::begin(_data_macros_3), std::end(_data_macros_3), std::begin(buffer3));
|
||||
std::copy(std::begin(_c_data_macros_3), std::end(_c_data_macros_3), std::begin(buffer3));
|
||||
|
||||
//send data 1
|
||||
libusb_control_transfer( _handle, 0x21, 0x09, 0x0302, 0x0002, buffer1, 16, 1000 );
|
||||
libusb_control_transfer( _i_handle, 0x21, 0x09, 0x0302, 0x0002, buffer1, 16, 1000 );
|
||||
|
||||
//send data 2
|
||||
libusb_control_transfer( _handle, 0x21, 0x09, 0x0302, 0x0002, buffer2, 256, 1000 );
|
||||
libusb_control_transfer( _i_handle, 0x21, 0x09, 0x0302, 0x0002, buffer2, 256, 1000 );
|
||||
|
||||
//send data 3
|
||||
libusb_control_transfer( _handle, 0x21, 0x09, 0x0302, 0x0002, buffer3, 16, 1000 );
|
||||
libusb_control_transfer( _i_handle, 0x21, 0x09, 0x0302, 0x0002, buffer3, 16, 1000 );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -218,12 +218,12 @@ int mouse_m908::write_macro_repeat( int macro_number ){
|
|||
|
||||
//prepare data
|
||||
uint8_t buffer[16];
|
||||
std::copy(std::begin(_data_macros_repeat), std::end(_data_macros_repeat), std::begin(buffer));
|
||||
std::copy(std::begin(_c_data_macros_repeat), std::end(_c_data_macros_repeat), std::begin(buffer));
|
||||
|
||||
buffer[10] = _macro_repeat[macro_number];
|
||||
buffer[10] = _s_macro_repeat[macro_number];
|
||||
|
||||
//send data
|
||||
libusb_control_transfer( _handle, 0x21, 0x09, 0x0302, 0x0002, buffer, 16, 1000 );
|
||||
libusb_control_transfer( _i_handle, 0x21, 0x09, 0x0302, 0x0002, buffer, 16, 1000 );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue