From f1c5905cbae91195036fe6566a3a98e1e1c5142d Mon Sep 17 00:00:00 2001 From: Adam Honse Date: Sun, 13 Feb 2022 00:48:55 -0600 Subject: [PATCH] Move definitions of key name memory constants to a separate .cpp file, hopefully to cut down on file size --- OpenRGB.pro | 3 +- RGBController/RGBControllerKeyNames.cpp | 138 ++++++++++++++ RGBController/RGBControllerKeyNames.h | 234 ++++++++++++------------ 3 files changed, 257 insertions(+), 118 deletions(-) create mode 100644 RGBController/RGBControllerKeyNames.cpp diff --git a/OpenRGB.pro b/OpenRGB.pro index 4a80d31e..3d382701 100644 --- a/OpenRGB.pro +++ b/OpenRGB.pro @@ -507,8 +507,8 @@ HEADERS += Controllers/ZETKeyboardController/RGBController_ZETBladeOptical.h \ RGBController/RGBController.h \ RGBController/RGBController_Dummy.h \ - RGBController/RGBController_Network.h \ RGBController/RGBControllerKeyNames.h \ + RGBController/RGBController_Network.h \ SOURCES += \ dependencies/Swatches/swatches.cpp \ @@ -964,6 +964,7 @@ SOURCES += Controllers/ZETKeyboardController/RGBController_ZETBladeOptical.cpp \ RGBController/RGBController.cpp \ RGBController/RGBController_Dummy.cpp \ + RGBController/RGBControllerKeyNames.cpp \ RGBController/RGBController_Network.cpp \ RESOURCES += \ diff --git a/RGBController/RGBControllerKeyNames.cpp b/RGBController/RGBControllerKeyNames.cpp new file mode 100644 index 00000000..1e19cd95 --- /dev/null +++ b/RGBController/RGBControllerKeyNames.cpp @@ -0,0 +1,138 @@ +/*-------------------------------------------------------------------*\ +| RGBControllerKeyNames.cpp | +| | +| This is the canonical list of Key Names to be used in | +| keyboard and other device initialisations to avoid redundant | +| string literal declarations | +| | +| Chris M (Dr_No) 25 Jan 2022 | +| | +\*-------------------------------------------------------------------*/ + +#include "RGBControllerKeyNames.h" + +const char* KEY_EN_UNUSED = ""; + +const char* KEY_EN_ESCAPE = "Key: Escape"; +const char* KEY_EN_F1 = "Key: F1"; +const char* KEY_EN_F2 = "Key: F2"; +const char* KEY_EN_F3 = "Key: F3"; +const char* KEY_EN_F4 = "Key: F4"; +const char* KEY_EN_F5 = "Key: F5"; +const char* KEY_EN_F6 = "Key: F6"; +const char* KEY_EN_F7 = "Key: F7"; +const char* KEY_EN_F8 = "Key: F8"; +const char* KEY_EN_F9 = "Key: F9"; +const char* KEY_EN_F10 = "Key: F10"; +const char* KEY_EN_F11 = "Key: F11"; +const char* KEY_EN_F12 = "Key: F12"; +const char* KEY_EN_PRINT_SCREEN = "Key: Print Screen"; +const char* KEY_EN_SCROLL_LOCK = "Key: Scroll Lock"; +const char* KEY_EN_PAUSE_BREAK = "Key: Pause/Break"; + +const char* KEY_EN_BACK_TICK = "Key: `"; +const char* KEY_EN_1 = "Key: 1"; +const char* KEY_EN_2 = "Key: 2"; +const char* KEY_EN_3 = "Key: 3"; +const char* KEY_EN_4 = "Key: 4"; +const char* KEY_EN_5 = "Key: 5"; +const char* KEY_EN_6 = "Key: 6"; +const char* KEY_EN_7 = "Key: 7"; +const char* KEY_EN_8 = "Key: 8"; +const char* KEY_EN_9 = "Key: 9"; +const char* KEY_EN_0 = "Key: 0"; +const char* KEY_EN_MINUS = "Key: -"; +const char* KEY_EN_EQUALS = "Key: ="; +const char* KEY_EN_BACKSPACE = "Key: Backspace"; +const char* KEY_EN_INSERT = "Key: Insert"; +const char* KEY_EN_HOME = "Key: Home"; +const char* KEY_EN_PAGE_UP = "Key: Page Up"; + +const char* KEY_EN_TAB = "Key: TAB"; +const char* KEY_EN_Q = "Key: Q"; +const char* KEY_EN_W = "Key: W"; +const char* KEY_EN_E = "Key: E"; +const char* KEY_EN_R = "Key: R"; +const char* KEY_EN_T = "Key: T"; +const char* KEY_EN_Y = "Key: Y"; +const char* KEY_EN_U = "Key: U"; +const char* KEY_EN_I = "Key: I"; +const char* KEY_EN_O = "Key: O"; +const char* KEY_EN_P = "Key: P"; +const char* KEY_EN_LEFT_BRACKET = "Key: ["; +const char* KEY_EN_RIGHT_BRACKET = "Key: ]"; +const char* KEY_EN_ANSI_BACK_SLASH = "Key: \\ (ANSI)"; +const char* KEY_EN_DELETE = "Key: Delete"; +const char* KEY_EN_END = "Key: End"; +const char* KEY_EN_PAGE_DOWN = "Key: Page Down"; + +const char* KEY_EN_CAPS_LOCK = "Key: Caps Lock"; +const char* KEY_EN_A = "Key: A"; +const char* KEY_EN_S = "Key: S"; +const char* KEY_EN_D = "Key: D"; +const char* KEY_EN_F = "Key: F"; +const char* KEY_EN_G = "Key: G"; +const char* KEY_EN_H = "Key: H"; +const char* KEY_EN_J = "Key: J"; +const char* KEY_EN_K = "Key: K"; +const char* KEY_EN_L = "Key: L"; +const char* KEY_EN_SEMICOLON = "Key: ;"; +const char* KEY_EN_QUOTE = "Key: '"; +const char* KEY_EN_POUND = "Key: #"; +const char* KEY_EN_ANSI_ENTER = "Key: Enter"; +const char* KEY_EN_ISO_ENTER = "Key: Enter (ISO)"; + +const char* KEY_EN_LEFT_SHIFT = "Key: Left Shift"; +const char* KEY_EN_ISO_BACK_SLASH = "Key: \\ (ISO)"; +const char* KEY_EN_Z = "Key: Z"; +const char* KEY_EN_X = "Key: X"; +const char* KEY_EN_C = "Key: C"; +const char* KEY_EN_V = "Key: V"; +const char* KEY_EN_B = "Key: B"; +const char* KEY_EN_N = "Key: N"; +const char* KEY_EN_M = "Key: M"; +const char* KEY_EN_COMMA = "Key: ,"; +const char* KEY_EN_PERIOD = "Key: ."; +const char* KEY_EN_FORWARD_SLASH = "Key: /"; +const char* KEY_EN_RIGHT_SHIFT = "Key: Right Shift"; +const char* KEY_EN_UP_ARROW = "Key: Up Arrow"; + +const char* KEY_EN_LEFT_CONTROL = "Key: Left Control"; +const char* KEY_EN_LEFT_WINDOWS = "Key: Left Windows"; +const char* KEY_EN_LEFT_FUNCTION = "Key: Left Fn"; +const char* KEY_EN_LEFT_ALT = "Key: Left Alt"; +const char* KEY_EN_SPACE = "Key: Space"; +const char* KEY_EN_RIGHT_ALT = "Key: Right Alt"; +const char* KEY_EN_RIGHT_FUNCTION = "Key: Right Fn"; +const char* KEY_EN_RIGHT_WINDOWS = "Key: Right Windows"; +const char* KEY_EN_MENU = "Key: Menu"; +const char* KEY_EN_RIGHT_CONTROL = "Key: Right Control"; +const char* KEY_EN_LEFT_ARROW = "Key: Left Arrow"; +const char* KEY_EN_DOWN_ARROW = "Key: Down Arrow"; +const char* KEY_EN_RIGHT_ARROW = "Key: Right Arrow"; + +const char* KEY_EN_NUMPAD_LOCK = "Key: Num Lock"; +const char* KEY_EN_NUMPAD_DIVIDE = "Key: Number Pad /"; +const char* KEY_EN_NUMPAD_TIMES = "Key: Number Pad *"; +const char* KEY_EN_NUMPAD_MINUS = "Key: Number Pad -"; +const char* KEY_EN_NUMPAD_PLUS = "Key: Number Pad +"; +const char* KEY_EN_NUMPAD_PERIOD = "Key: Number Pad ."; +const char* KEY_EN_NUMPAD_ENTER = "Key: Number Pad Enter"; +const char* KEY_EN_NUMPAD_0 = "Key: Number Pad 0"; +const char* KEY_EN_NUMPAD_1 = "Key: Number Pad 1"; +const char* KEY_EN_NUMPAD_2 = "Key: Number Pad 2"; +const char* KEY_EN_NUMPAD_3 = "Key: Number Pad 3"; +const char* KEY_EN_NUMPAD_4 = "Key: Number Pad 4"; +const char* KEY_EN_NUMPAD_5 = "Key: Number Pad 5"; +const char* KEY_EN_NUMPAD_6 = "Key: Number Pad 6"; +const char* KEY_EN_NUMPAD_7 = "Key: Number Pad 7"; +const char* KEY_EN_NUMPAD_8 = "Key: Number Pad 8"; +const char* KEY_EN_NUMPAD_9 = "Key: Number Pad 9"; + +const char* KEY_EN_MEDIA_PLAY_PAUSE = "Key: Media Play/Pause"; +const char* KEY_EN_MEDIA_PREVIOUS = "Key: Media Previous"; +const char* KEY_EN_MEDIA_NEXT = "Key: Media Next"; +const char* KEY_EN_MEDIA_STOP = "Key: Media Stop"; +const char* KEY_EN_MEDIA_MUTE = "Key: Media Mute"; +const char* KEY_EN_MEDIA_VOLUME_DOWN = "Key: Media Volume -"; +const char* KEY_EN_MEDIA_VOLUME_UP = "Key: Media Volume +"; \ No newline at end of file diff --git a/RGBController/RGBControllerKeyNames.h b/RGBController/RGBControllerKeyNames.h index 5614de6c..31fb1cb7 100644 --- a/RGBController/RGBControllerKeyNames.h +++ b/RGBController/RGBControllerKeyNames.h @@ -11,128 +11,128 @@ #pragma once -static const char *KEY_EN_UNUSED = ""; +extern const char* KEY_EN_UNUSED; -static const char *KEY_EN_ESCAPE = "Key: Escape"; -static const char *KEY_EN_F1 = "Key: F1"; -static const char *KEY_EN_F2 = "Key: F2"; -static const char *KEY_EN_F3 = "Key: F3"; -static const char *KEY_EN_F4 = "Key: F4"; -static const char *KEY_EN_F5 = "Key: F5"; -static const char *KEY_EN_F6 = "Key: F6"; -static const char *KEY_EN_F7 = "Key: F7"; -static const char *KEY_EN_F8 = "Key: F8"; -static const char *KEY_EN_F9 = "Key: F9"; -static const char *KEY_EN_F10 = "Key: F10"; -static const char *KEY_EN_F11 = "Key: F11"; -static const char *KEY_EN_F12 = "Key: F12"; -static const char *KEY_EN_PRINT_SCREEN = "Key: Print Screen"; -static const char *KEY_EN_SCROLL_LOCK = "Key: Scroll Lock"; -static const char *KEY_EN_PAUSE_BREAK = "Key: Pause/Break"; +extern const char* KEY_EN_ESCAPE; +extern const char* KEY_EN_F1; +extern const char* KEY_EN_F2; +extern const char* KEY_EN_F3; +extern const char* KEY_EN_F4; +extern const char* KEY_EN_F5; +extern const char* KEY_EN_F6; +extern const char* KEY_EN_F7; +extern const char* KEY_EN_F8; +extern const char* KEY_EN_F9; +extern const char* KEY_EN_F10; +extern const char* KEY_EN_F11; +extern const char* KEY_EN_F12; +extern const char* KEY_EN_PRINT_SCREEN; +extern const char* KEY_EN_SCROLL_LOCK; +extern const char* KEY_EN_PAUSE_BREAK; -static const char *KEY_EN_BACK_TICK = "Key: `"; -static const char *KEY_EN_1 = "Key: 1"; -static const char *KEY_EN_2 = "Key: 2"; -static const char *KEY_EN_3 = "Key: 3"; -static const char *KEY_EN_4 = "Key: 4"; -static const char *KEY_EN_5 = "Key: 5"; -static const char *KEY_EN_6 = "Key: 6"; -static const char *KEY_EN_7 = "Key: 7"; -static const char *KEY_EN_8 = "Key: 8"; -static const char *KEY_EN_9 = "Key: 9"; -static const char *KEY_EN_0 = "Key: 0"; -static const char *KEY_EN_MINUS = "Key: -"; -static const char *KEY_EN_EQUALS = "Key: ="; -static const char *KEY_EN_BACKSPACE = "Key: Backspace"; -static const char *KEY_EN_INSERT = "Key: Insert"; -static const char *KEY_EN_HOME = "Key: Home"; -static const char *KEY_EN_PAGE_UP = "Key: Page Up"; +extern const char* KEY_EN_BACK_TICK; +extern const char* KEY_EN_1; +extern const char* KEY_EN_2; +extern const char* KEY_EN_3; +extern const char* KEY_EN_4; +extern const char* KEY_EN_5; +extern const char* KEY_EN_6; +extern const char* KEY_EN_7; +extern const char* KEY_EN_8; +extern const char* KEY_EN_9; +extern const char* KEY_EN_0; +extern const char* KEY_EN_MINUS; +extern const char* KEY_EN_EQUALS; +extern const char* KEY_EN_BACKSPACE; +extern const char* KEY_EN_INSERT; +extern const char* KEY_EN_HOME; +extern const char* KEY_EN_PAGE_UP; -static const char *KEY_EN_TAB = "Key: TAB"; -static const char *KEY_EN_Q = "Key: Q"; -static const char *KEY_EN_W = "Key: W"; -static const char *KEY_EN_E = "Key: E"; -static const char *KEY_EN_R = "Key: R"; -static const char *KEY_EN_T = "Key: T"; -static const char *KEY_EN_Y = "Key: Y"; -static const char *KEY_EN_U = "Key: U"; -static const char *KEY_EN_I = "Key: I"; -static const char *KEY_EN_O = "Key: O"; -static const char *KEY_EN_P = "Key: P"; -static const char *KEY_EN_LEFT_BRACKET = "Key: ["; -static const char *KEY_EN_RIGHT_BRACKET = "Key: ]"; -static const char *KEY_EN_ANSI_BACK_SLASH = "Key: \\ (ANSI)"; -static const char *KEY_EN_DELETE = "Key: Delete"; -static const char *KEY_EN_END = "Key: End"; -static const char *KEY_EN_PAGE_DOWN = "Key: Page Down"; +extern const char* KEY_EN_TAB; +extern const char* KEY_EN_Q; +extern const char* KEY_EN_W; +extern const char* KEY_EN_E; +extern const char* KEY_EN_R; +extern const char* KEY_EN_T; +extern const char* KEY_EN_Y; +extern const char* KEY_EN_U; +extern const char* KEY_EN_I; +extern const char* KEY_EN_O; +extern const char* KEY_EN_P; +extern const char* KEY_EN_LEFT_BRACKET; +extern const char* KEY_EN_RIGHT_BRACKET; +extern const char* KEY_EN_ANSI_BACK_SLASH; +extern const char* KEY_EN_DELETE; +extern const char* KEY_EN_END; +extern const char* KEY_EN_PAGE_DOWN; -static const char *KEY_EN_CAPS_LOCK = "Key: Caps Lock"; -static const char *KEY_EN_A = "Key: A"; -static const char *KEY_EN_S = "Key: S"; -static const char *KEY_EN_D = "Key: D"; -static const char *KEY_EN_F = "Key: F"; -static const char *KEY_EN_G = "Key: G"; -static const char *KEY_EN_H = "Key: H"; -static const char *KEY_EN_J = "Key: J"; -static const char *KEY_EN_K = "Key: K"; -static const char *KEY_EN_L = "Key: L"; -static const char *KEY_EN_SEMICOLON = "Key: ;"; -static const char *KEY_EN_QUOTE = "Key: '"; -static const char *KEY_EN_POUND = "Key: #"; -static const char *KEY_EN_ANSI_ENTER = "Key: Enter"; -static const char *KEY_EN_ISO_ENTER = "Key: Enter (ISO)"; +extern const char* KEY_EN_CAPS_LOCK; +extern const char* KEY_EN_A; +extern const char* KEY_EN_S; +extern const char* KEY_EN_D; +extern const char* KEY_EN_F; +extern const char* KEY_EN_G; +extern const char* KEY_EN_H; +extern const char* KEY_EN_J; +extern const char* KEY_EN_K; +extern const char* KEY_EN_L; +extern const char* KEY_EN_SEMICOLON; +extern const char* KEY_EN_QUOTE; +extern const char* KEY_EN_POUND; +extern const char* KEY_EN_ANSI_ENTER; +extern const char* KEY_EN_ISO_ENTER; -static const char *KEY_EN_LEFT_SHIFT = "Key: Left Shift"; -static const char *KEY_EN_ISO_BACK_SLASH = "Key: \\ (ISO)"; -static const char *KEY_EN_Z = "Key: Z"; -static const char *KEY_EN_X = "Key: X"; -static const char *KEY_EN_C = "Key: C"; -static const char *KEY_EN_V = "Key: V"; -static const char *KEY_EN_B = "Key: B"; -static const char *KEY_EN_N = "Key: N"; -static const char *KEY_EN_M = "Key: M"; -static const char *KEY_EN_COMMA = "Key: ,"; -static const char *KEY_EN_PERIOD = "Key: ."; -static const char *KEY_EN_FORWARD_SLASH = "Key: /"; -static const char *KEY_EN_RIGHT_SHIFT = "Key: Right Shift"; -static const char *KEY_EN_UP_ARROW = "Key: Up Arrow"; +extern const char* KEY_EN_LEFT_SHIFT; +extern const char* KEY_EN_ISO_BACK_SLASH; +extern const char* KEY_EN_Z; +extern const char* KEY_EN_X; +extern const char* KEY_EN_C; +extern const char* KEY_EN_V; +extern const char* KEY_EN_B; +extern const char* KEY_EN_N; +extern const char* KEY_EN_M; +extern const char* KEY_EN_COMMA; +extern const char* KEY_EN_PERIOD; +extern const char* KEY_EN_FORWARD_SLASH; +extern const char* KEY_EN_RIGHT_SHIFT; +extern const char* KEY_EN_UP_ARROW; -static const char *KEY_EN_LEFT_CONTROL = "Key: Left Control"; -static const char *KEY_EN_LEFT_WINDOWS = "Key: Left Windows"; -static const char *KEY_EN_LEFT_FUNCTION = "Key: Left Fn"; -static const char *KEY_EN_LEFT_ALT = "Key: Left Alt"; -static const char *KEY_EN_SPACE = "Key: Space"; -static const char *KEY_EN_RIGHT_ALT = "Key: Right Alt"; -static const char *KEY_EN_RIGHT_FUNCTION = "Key: Right Fn"; -static const char *KEY_EN_RIGHT_WINDOWS = "Key: Right Windows"; -static const char *KEY_EN_MENU = "Key: Menu"; -static const char *KEY_EN_RIGHT_CONTROL = "Key: Right Control"; -static const char *KEY_EN_LEFT_ARROW = "Key: Left Arrow"; -static const char *KEY_EN_DOWN_ARROW = "Key: Down Arrow"; -static const char *KEY_EN_RIGHT_ARROW = "Key: Right Arrow"; +extern const char* KEY_EN_LEFT_CONTROL; +extern const char* KEY_EN_LEFT_WINDOWS; +extern const char* KEY_EN_LEFT_FUNCTION; +extern const char* KEY_EN_LEFT_ALT; +extern const char* KEY_EN_SPACE; +extern const char* KEY_EN_RIGHT_ALT; +extern const char* KEY_EN_RIGHT_FUNCTION; +extern const char* KEY_EN_RIGHT_WINDOWS; +extern const char* KEY_EN_MENU; +extern const char* KEY_EN_RIGHT_CONTROL; +extern const char* KEY_EN_LEFT_ARROW; +extern const char* KEY_EN_DOWN_ARROW; +extern const char* KEY_EN_RIGHT_ARROW; -static const char *KEY_EN_NUMPAD_LOCK = "Key: Num Lock"; -static const char *KEY_EN_NUMPAD_DIVIDE = "Key: Number Pad /"; -static const char *KEY_EN_NUMPAD_TIMES = "Key: Number Pad *"; -static const char *KEY_EN_NUMPAD_MINUS = "Key: Number Pad -"; -static const char *KEY_EN_NUMPAD_PLUS = "Key: Number Pad +"; -static const char *KEY_EN_NUMPAD_PERIOD = "Key: Number Pad ."; -static const char *KEY_EN_NUMPAD_ENTER = "Key: Number Pad Enter"; -static const char *KEY_EN_NUMPAD_0 = "Key: Number Pad 0"; -static const char *KEY_EN_NUMPAD_1 = "Key: Number Pad 1"; -static const char *KEY_EN_NUMPAD_2 = "Key: Number Pad 2"; -static const char *KEY_EN_NUMPAD_3 = "Key: Number Pad 3"; -static const char *KEY_EN_NUMPAD_4 = "Key: Number Pad 4"; -static const char *KEY_EN_NUMPAD_5 = "Key: Number Pad 5"; -static const char *KEY_EN_NUMPAD_6 = "Key: Number Pad 6"; -static const char *KEY_EN_NUMPAD_7 = "Key: Number Pad 7"; -static const char *KEY_EN_NUMPAD_8 = "Key: Number Pad 8"; -static const char *KEY_EN_NUMPAD_9 = "Key: Number Pad 9"; +extern const char* KEY_EN_NUMPAD_LOCK; +extern const char* KEY_EN_NUMPAD_DIVIDE; +extern const char* KEY_EN_NUMPAD_TIMES; +extern const char* KEY_EN_NUMPAD_MINUS; +extern const char* KEY_EN_NUMPAD_PLUS; +extern const char* KEY_EN_NUMPAD_PERIOD; +extern const char* KEY_EN_NUMPAD_ENTER; +extern const char* KEY_EN_NUMPAD_0; +extern const char* KEY_EN_NUMPAD_1; +extern const char* KEY_EN_NUMPAD_2; +extern const char* KEY_EN_NUMPAD_3; +extern const char* KEY_EN_NUMPAD_4; +extern const char* KEY_EN_NUMPAD_5; +extern const char* KEY_EN_NUMPAD_6; +extern const char* KEY_EN_NUMPAD_7; +extern const char* KEY_EN_NUMPAD_8; +extern const char* KEY_EN_NUMPAD_9; -static const char *KEY_EN_MEDIA_PLAY_PAUSE = "Key: Media Play/Pause"; -static const char *KEY_EN_MEDIA_PREVIOUS = "Key: Media Previous"; -static const char *KEY_EN_MEDIA_NEXT = "Key: Media Next"; -static const char *KEY_EN_MEDIA_STOP = "Key: Media Stop"; -static const char *KEY_EN_MEDIA_MUTE = "Key: Media Mute"; -static const char *KEY_EN_MEDIA_VOLUME_DOWN = "Key: Media Volume -"; -static const char *KEY_EN_MEDIA_VOLUME_UP = "Key: Media Volume +"; +extern const char* KEY_EN_MEDIA_PLAY_PAUSE; +extern const char* KEY_EN_MEDIA_PREVIOUS; +extern const char* KEY_EN_MEDIA_NEXT; +extern const char* KEY_EN_MEDIA_STOP; +extern const char* KEY_EN_MEDIA_MUTE; +extern const char* KEY_EN_MEDIA_VOLUME_DOWN; +extern const char* KEY_EN_MEDIA_VOLUME_UP;