diff --git a/TODO.md b/TODO.md index f52c63c..519a57b 100644 --- a/TODO.md +++ b/TODO.md @@ -1 +1,6 @@ -Nothing for now +- Prepare for different models/devices + - Add M709 + - Move members from mouse_m908 → rd_mouse +- Update main program + - Rename, make symlinks? + - Add --model option diff --git a/include/data.cpp b/include/data.cpp index 7e562b6..b6a2ae8 100644 --- a/include/data.cpp +++ b/include/data.cpp @@ -17,7 +17,8 @@ */ /* - * This file contains internal constants and lookup tables + * This file contains internal constants and lookup tables that are + * universal to all mice */ #include "rd_mouse.h" diff --git a/include/m908/data.cpp b/include/m908/data.cpp index 4d948f4..e912814 100644 --- a/include/m908/data.cpp +++ b/include/m908/data.cpp @@ -25,253 +25,7 @@ // usb device vars const uint16_t mouse_m908::_c_mouse_vid = 0x04d9; const uint16_t mouse_m908::_c_mouse_pid = 0xfc4d; -// const uint16_t mouse_m908::_c_mouse_pid = 0xfc2a; // M709! -/* TODO! remove -//setting min and max values -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 > mouse_m908::_c_keycodes = { - { "forward", { 0x85, 0x00, 0x00 } }, - { "backward", { 0x84, 0x00, 0x00 } }, - { "dpi+", { 0x8a, 0x00, 0x00 } }, - { "dpi-", { 0x89, 0x00, 0x00 } }, - { "dpi-cycle", { 0x88, 0x00, 0x00 } }, - { "report_rate+", { 0x97, 0x00, 0x00 } }, - { "report_rate-", { 0x98, 0x00, 0x00 } }, - { "scroll_up", { 0x8b, 0x00, 0x00 } }, - { "scroll_down", { 0x8c, 0x00, 0x00 } }, - { "left", { 0x81, 0x00, 0x00 } }, - { "right", { 0x82, 0x00, 0x00 } }, - { "middle", { 0x83, 0x00, 0x00 } }, - { "profile_switch", { 0x8d, 0x00, 0x00 } }, - { "led_mode_switch", { 0x9b, 0x04, 0x00 } }, - { "macro1", { 0x91, 0x00, 0x01 } }, - { "macro2", { 0x91, 0x01, 0x01 } }, - { "macro3", { 0x91, 0x02, 0x01 } }, - { "macro4", { 0x91, 0x03, 0x01 } }, - { "macro5", { 0x91, 0x04, 0x01 } }, - { "macro6", { 0x91, 0x05, 0x01 } }, - { "macro7", { 0x91, 0x06, 0x01 } }, - { "macro8", { 0x91, 0x07, 0x01 } }, - { "macro9", { 0x91, 0x08, 0x01 } }, - { "macro10", { 0x91, 0x09, 0x01 } }, - { "macro11", { 0x91, 0x0a, 0x01 } }, - { "macro12", { 0x91, 0x0b, 0x01 } }, - { "macro13", { 0x91, 0x0c, 0x01 } }, - { "macro14", { 0x91, 0x0d, 0x01 } }, - { "macro15", { 0x91, 0x0e, 0x01 } }, - { "none", { 0x00, 0x00, 0x00 } }, - { "media_play", { 0x8e, 0x01, 0xcd } }, - { "media_stop", { 0x8e, 0x01, 0xb7 } }, - { "media_previous", { 0x8e, 0x01, 0xb6 } }, - { "media_next", { 0x8e, 0x01, 0xb5 } }, - { "media_volume_up", { 0x8e, 0x01, 0xe9 } }, - { "media_volume_down", { 0x8e, 0x01, 0xea } }, - { "media_mute", { 0x8e, 0x01, 0xe2 } } }; - -//modifier name → value -const std::map< std::string, uint8_t > mouse_m908::_c_keyboard_modifier_values = { - { "ctrl_l+", 1 }, - { "shift_l+", 2 }, - { "alt_l+", 4 }, - { "super_l+", 8 }, - { "ctrl_r+", 16 }, - { "shift_r+", 32 }, - { "alt_r+", 64 }, - { "super_r+", 128 } }; - -//keyboard key name → value -std::map< std::string, uint8_t > mouse_m908::_c_keyboard_key_values = { - //top row - { "Esc", 0x29 }, - { "F1", 0x3a }, - { "F2", 0x3b }, - { "F3", 0x3c }, - { "F4", 0x3d }, - { "F5", 0x3e }, - { "F6", 0x3f }, - { "F7", 0x40 }, - { "F8", 0x41 }, - { "F9", 0x42 }, - { "F10", 0x43 }, - { "F11", 0x44 }, - { "F12", 0x45 }, - { "PrtSc", 0x46 }, - { "ScrLk", 0x47 }, - { "Pause", 0x48 }, - //alphanumeric - { "a", 0x04 }, - { "b", 0x05 }, - { "c", 0x06 }, - { "d", 0x07 }, - { "e", 0x08 }, - { "f", 0x09 }, - { "g", 0x0a }, - { "h", 0x0b }, - { "i", 0x0c }, - { "j", 0x0d }, - { "k", 0x0e }, - { "l", 0x0f }, - { "m", 0x10 }, - { "n", 0x11 }, - { "o", 0x12 }, - { "p", 0x13 }, - { "q", 0x14 }, - { "r", 0x15 }, - { "s", 0x16 }, - { "t", 0x17 }, - { "u", 0x18 }, - { "v", 0x19 }, - { "w", 0x1a }, - { "x", 0x1b }, - { "y", 0x1c }, - { "z", 0x1d }, - { "1", 0x1e }, - { "2", 0x1f }, - { "3", 0x20 }, - { "4", 0x21 }, - { "5", 0x22 }, - { "6", 0x23 }, - { "7", 0x24 }, - { "8", 0x25 }, - { "9", 0x26 }, - { "0", 0x27 }, - //modifiers - { "Tab", 0x2b }, - { "Caps_Lock", 0x39 }, - { "Shift_l", 0xe1 }, - { "Ctrl_l", 0xe0 }, - { "Alt_l", 0xe2 }, - { "Super_l", 0xe3 }, - { "Super_r", 0xe7 }, - { "Alt_r", 0xe6 }, - { "Menu", 0x65 }, - { "Ctrl_r", 0xe4 }, - { "Shift_r", 0xe5 }, - { "Return", 0x28 }, - { "Backspace", 0x2a }, - { "Caps_Lock", 0x39 }, - //special characters - { "Space", 0x2c }, - { "Tilde", 0x35 }, - { "Minus", 0x2d }, - { "Equals", 0x2e }, - { "Bracket_l", 0x2f }, - { "Bracket_r", 0x30 }, - { "Backslash", 0x31 }, - { "Hash", 0x32 }, - { "Semicolon", 0x33 }, - { "Apostrophe", 0x34 }, - { "Comma", 0x36 }, - { "Period", 0x37 }, - { "Slash", 0x38 }, - { "Int_Key", 0x64 }, - //navigation - { "Right", 0x4f }, - { "Left", 0x50 }, - { "Down", 0x51 }, - { "Up", 0x52 }, - { "Insert", 0x49 }, - { "Home", 0x4a }, - { "PgUp", 0x4b }, - { "Delete", 0x4c }, - { "End", 0x4d }, - { "PgDown", 0x4e }, - //numpad - { "Num_Slash", 0x54 }, - { "Num_Asterisk", 0x55 }, - { "Num_Minus", 0x56 }, - { "Num_Plus", 0x57 }, - { "Num_Return", 0x58 }, - { "Num_1", 0x59 }, - { "Num_2", 0x5a }, - { "Num_3", 0x5b }, - { "Num_4", 0x5c }, - { "Num_5", 0x5d }, - { "Num_6", 0x5e }, - { "Num_7", 0x5f }, - { "Num_8", 0x60 }, - { "Num_9", 0x61 }, - { "Num_0", 0x62 }, - { "Num_Period", 0x63 }, - { "Num_Lock", 0x53 }, - { "Num_Equals", 0x67 }, - { "Num_Comma", 0x85 }, - { "Num_Paren_l", 0xb6 }, - { "Num_Paren_r", 0xb7 }, - //special keys - { "Power", 0x66 }, - { "Lang1", 0x90 }, - { "Lang2", 0x91 }, - { "Lang3", 0x92 }, - { "Lang4", 0x93 }, - { "Lang5", 0x94 }, - { "Lang6", 0x95 }, - { "Lang7", 0x96 }, - { "Lang8", 0x97 }, - { "Lang9", 0x98 }, - { "F13", 0x68 }, - { "F14", 0x69 }, - { "F15", 0x6a }, - { "F16", 0x6b }, - { "F17", 0x6c }, - { "F18", 0x6d }, - { "F19", 0x6e }, - { "F20", 0x6f }, - { "F21", 0x70 }, - { "F22", 0x71 }, - { "F23", 0x72 }, - { "F24", 0x73 }, - { "Execute", 0x74 }, - { "Help", 0x75 }, - { "Props", 0x76 }, - { "Select", 0x77 }, - { "Stop", 0x78 }, - { "Again", 0x79 }, - { "Undo", 0x7a }, - { "Cut", 0x7b }, - { "Copy", 0x7c }, - { "Paste", 0x7d }, - { "Find", 0x7e }, - { "Mute", 0x7f }, - { "Volume_Up", 0x80 }, - { "Volume_Down", 0x81 }, - { "International1", 0x87 }, - { "International2", 0x88 }, - { "International3", 0x89 }, - { "International4", 0x8a }, - { "International5", 0x8b }, - { "International6", 0x8c }, - { "International7", 0x8d }, - { "International8", 0x8e }, - { "International9", 0x8f }, - // media keys - { "Media_Play_Pause", 0xe8 }, - { "Media_Stop_CD", 0xe9 }, - { "Media_Previous", 0xea }, - { "Media_Next", 0xeb }, - { "Media_Eject_CD", 0xec }, - { "Media_Volume_Up", 0xed }, - { "Media_Volume_Down", 0xee }, - { "Media_Mute", 0xef }, - { "Media_WWW", 0xf0 }, - { "Media_Back", 0xf1 }, - { "Media_Forward", 0xf2 }, - { "Media_Stop", 0xf3 }, - { "Media_Find", 0xf4 }, - { "Media_Scroll_Up", 0xf5 }, - { "Media_Scroll_Down", 0xf6 }, - { "Media_Edit", 0xf7 }, - { "Media_Sleep", 0xf8 }, - { "Media_Screenlock", 0xf9 }, - { "Media_Refresh", 0xfa }, - { "Media_Calc", 0xfb } }; -*/ // Names of the physical buttons std::map< int, std::string > mouse_m908::_c_button_names = { { 0, "button_left" }, diff --git a/include/m908/mouse_m908.h b/include/m908/mouse_m908.h index 49afb0a..48381e1 100644 --- a/include/m908/mouse_m908.h +++ b/include/m908/mouse_m908.h @@ -63,40 +63,6 @@ class mouse_m908 : public rd_mouse{ /// The default constructor. Sets the default settings. mouse_m908(); - - /* - // enums - /// The available profiles - enum m908_profile{ - profile_1 = 0, - profile_2 = 1, - profile_3 = 2, - profile_4 = 3, - profile_5 = 4, - }; - - /// The available led modes - enum m908_lightmode{ - lightmode_breathing, - lightmode_rainbow, - lightmode_static, - lightmode_wave, - lightmode_alternating, - lightmode_reactive, - lightmode_flashing, - lightmode_off, - }; - - /// The available USB report rates (polling rates) - enum m908_report_rate{ - r_125Hz, - r_250Hz, - r_500Hz, - r_1000Hz - };*/ - - - //setter functions /// Set the currently active profile int set_profile( rd_profile profile ); @@ -302,15 +268,6 @@ class mouse_m908 : public rd_mouse{ /// set by open_mouse for close_mouse bool _i_detached_driver_2 = false; - /* TODO! remove - //setting min and max values - 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 rd_profile _s_profile; std::array _s_scrollspeeds; @@ -325,15 +282,6 @@ class mouse_m908 : public rd_mouse{ std::array, 15> _s_macro_data; std::array _s_macro_repeat; - //mapping of button names to values - /* TODO! remove - /// Values/keycodes of mouse buttons and special button functions - static std::map< std::string, std::array > _c_keycodes; - /// Values of keyboard modifiers - static const std::map< std::string, uint8_t > _c_keyboard_modifier_values; - /// Values/keycodes of keyboard keys - static std::map< std::string, uint8_t > _c_keyboard_key_values; - */ /// Names of the physical buttons static std::map< int, std::string > _c_button_names; diff --git a/include/rd_mouse.h b/include/rd_mouse.h index c882c56..90c5541 100644 --- a/include/rd_mouse.h +++ b/include/rd_mouse.h @@ -35,6 +35,10 @@ /** * This class is used as a base for the different models + * + * Global constants (e.g. keyboard keycodes) and universal functions + * should be placed in this class. + * */ class rd_mouse{ diff --git a/makefile b/makefile index d4b4e1b..e964e02 100644 --- a/makefile +++ b/makefile @@ -12,7 +12,7 @@ LIBS != pkg-config --libs libusb-1.0 # version string VERSION_STRING = "\"2.1\"" -# compile TODO! split target int m908, m709 ... +# compile TODO! split target into m908, m709 ... build: constructor_m908.o data_m908.o getters_m908.o helpers_m908.o setters_m908.o writers_m908.o readers_m908.o data_rd.o load_config.o mouse_m908.o $(CC) *.o -o mouse_m908 $(LIBS) $(CC_OPTIONS)