Add keymap support to OpenRazer code and add a keymap for the Huntsman Elite

This commit is contained in:
Adam Honse
2020-07-23 14:42:34 -05:00
parent 030c0c60f3
commit 9a33a78574
3 changed files with 365 additions and 69 deletions

View File

@@ -8,6 +8,14 @@ typedef struct
unsigned int cols;
} razer_zone;
typedef struct
{
unsigned int zone;
unsigned int row;
unsigned int col;
const char* name;
}razer_key;
typedef struct
{
std::string name;
@@ -16,8 +24,130 @@ typedef struct
unsigned int rows;
unsigned int cols;
const razer_zone* zones[RAZER_MAX_ZONES];
const razer_key* keymap;
unsigned int keymap_size;
} razer_device;
/*-------------------------------------------------------------------------*\
| KEYMAPS |
\*-------------------------------------------------------------------------*/
#define HUNTSMAN_ELITE_KEYMAP_SIZE (sizeof(huntsman_elite_keymap) / sizeof(huntsman_elite_keymap[0]))
static const razer_key huntsman_elite_keymap[] =
{
/*---------------------------------------------------------------------*\
| Zone, Row, Column, Key |
\*---------------------------------------------------------------------*/
{ 0, 0, 1, "Key: Escape" },
{ 0, 0, 3, "Key: F1" },
{ 0, 0, 4, "Key: F2" },
{ 0, 0, 5, "Key: F3" },
{ 0, 0, 6, "Key: F4" },
{ 0, 0, 7, "Key: F5" },
{ 0, 0, 8, "Key: F6" },
{ 0, 0, 9, "Key: F7" },
{ 0, 0, 10, "Key: F8" },
{ 0, 0, 11, "Key: F9" },
{ 0, 0, 12, "Key: F10" },
{ 0, 0, 13, "Key: F11" },
{ 0, 0, 14, "Key: F12" },
{ 0, 0, 15, "Key: Print Screen" },
{ 0, 0, 16, "Key: Scroll Lock" },
{ 0, 0, 17, "Key: Pause/Break" },
{ 0, 0, 18, "Key: Media Previous" },
{ 0, 0, 19, "Key: Media Play/Pause" },
{ 0, 0, 20, "Key: Media Next" },
{ 0, 0, 21, "Key: Media Mute" },
{ 0, 1, 1, "Key: `" },
{ 0, 1, 2, "Key: 1" },
{ 0, 1, 3, "Key: 2" },
{ 0, 1, 4, "Key: 3" },
{ 0, 1, 5, "Key: 4" },
{ 0, 1, 6, "Key: 5" },
{ 0, 1, 7, "Key: 6" },
{ 0, 1, 8, "Key: 7" },
{ 0, 1, 9, "Key: 8" },
{ 0, 1, 10, "Key: 9" },
{ 0, 1, 11, "Key: 0" },
{ 0, 1, 12, "Key: -" },
{ 0, 1, 13, "Key: =" },
{ 0, 1, 14, "Key: Backspace" },
{ 0, 1, 15, "Key: Insert" },
{ 0, 1, 16, "Key: Home" },
{ 0, 1, 17, "Key: Page Up" },
{ 0, 1, 18, "Key: Num Lock" },
{ 0, 1, 19, "Key: Number Pad /" },
{ 0, 1, 20, "Key: Number Pad *" },
{ 0, 1, 21, "Key: Number Pad -" },
{ 0, 2, 1, "Key: Tab" },
{ 0, 2, 2, "Key: Q" },
{ 0, 2, 3, "Key: W" },
{ 0, 2, 4, "Key: E" },
{ 0, 2, 5, "Key: R" },
{ 0, 2, 6, "Key: T" },
{ 0, 2, 7, "Key: Y" },
{ 0, 2, 8, "Key: U" },
{ 0, 2, 9, "Key: I" },
{ 0, 2, 10, "Key: O" },
{ 0, 2, 11, "Key: P" },
{ 0, 2, 12, "Key: [" },
{ 0, 2, 13, "Key: ]" },
{ 0, 2, 14, "Key: \\ (ANSI)" },
{ 0, 2, 15, "Key: Delete" },
{ 0, 2, 16, "Key: End" },
{ 0, 2, 17, "Key: Page Down" },
{ 0, 2, 18, "Key: Number Pad 7" },
{ 0, 2, 19, "Key: Number Pad 8" },
{ 0, 2, 20, "Key: Number Pad 9" },
{ 0, 2, 21, "Key: Number Pad +" },
{ 0, 3, 1, "Key: Caps Lock" },
{ 0, 3, 2, "Key: A" },
{ 0, 3, 3, "Key: S" },
{ 0, 3, 4, "Key: D" },
{ 0, 3, 5, "Key: F" },
{ 0, 3, 6, "Key: G" },
{ 0, 3, 7, "Key: H" },
{ 0, 3, 8, "Key: J" },
{ 0, 3, 9, "Key: K" },
{ 0, 3, 10, "Key: L" },
{ 0, 3, 11, "Key: ;" },
{ 0, 3, 12, "Key: '" },
{ 0, 3, 14, "Key: Enter" },
{ 0, 3, 18, "Key: Number Pad 4" },
{ 0, 3, 19, "Key: Number Pad 5" },
{ 0, 3, 20, "Key: Number Pad 6" },
{ 0, 4, 1, "Key: Left Shift" },
{ 0, 4, 3, "Key: Z" },
{ 0, 4, 4, "Key: X" },
{ 0, 4, 5, "Key: C" },
{ 0, 4, 6, "Key: V" },
{ 0, 4, 7, "Key: B" },
{ 0, 4, 8, "Key: N" },
{ 0, 4, 9, "Key: M" },
{ 0, 4, 10, "Key: ," },
{ 0, 4, 11, "Key: ." },
{ 0, 4, 12, "Key: /" },
{ 0, 4, 14, "Key: Right Shift" },
{ 0, 4, 16, "Key: Up Arrow" },
{ 0, 4, 18, "Key: Number Pad 1" },
{ 0, 4, 19, "Key: Number Pad 2" },
{ 0, 4, 20, "Key: Number Pad 3" },
{ 0, 4, 21, "Key: Number Pad Enter" },
{ 0, 5, 1, "Key: Left Control" },
{ 0, 5, 2, "Key: Left Windows" },
{ 0, 5, 3, "Key: Left Alt" },
{ 0, 5, 7, "Key: Space" },
{ 0, 5, 11, "Key: Right Alt" },
{ 0, 5, 12, "Key: Right Fn" },
{ 0, 5, 13, "Key: Context" },
{ 0, 5, 14, "Key: Right Control" },
{ 0, 5, 15, "Key: Left Arrow" },
{ 0, 5, 16, "Key: Down Arrow" },
{ 0, 5, 17, "Key: Right Arrow" },
{ 0, 5, 19, "Key: Number Pad 0" },
{ 0, 5, 20, "Key: Number Pad ." },
};
/*-------------------------------------------------------------------------*\
| KEYBOARDS |
\*-------------------------------------------------------------------------*/
@@ -51,7 +181,9 @@ static const razer_device blackwidow_2019_device =
NULL,
NULL,
NULL
}
},
NULL,
0
};
/*-------------------------------------------------------------*\
@@ -83,7 +215,9 @@ static const razer_device blackwidow_chroma_device =
NULL,
NULL,
NULL
}
},
NULL,
0
};
/*-------------------------------------------------------------*\
@@ -115,7 +249,9 @@ static const razer_device blackwidow_chroma_overwatch_device =
NULL,
NULL,
NULL
}
},
NULL,
0
};
/*-------------------------------------------------------------*\
@@ -147,7 +283,9 @@ static const razer_device blackwidow_chroma_te_device =
NULL,
NULL,
NULL
}
},
NULL,
0
};
/*-------------------------------------------------------------*\
@@ -179,7 +317,9 @@ static const razer_device blackwidow_elite_device =
NULL,
NULL,
NULL
}
},
NULL,
0
};
/*-------------------------------------------------------------*\
@@ -211,7 +351,9 @@ static const razer_device blackwidow_chroma_v2_device =
NULL,
NULL,
NULL
}
},
NULL,
0
};
/*-------------------------------------------------------------*\
@@ -243,7 +385,9 @@ static const razer_device blackwidow_x_chroma_device =
NULL,
NULL,
NULL
}
},
NULL,
0
};
/*-------------------------------------------------------------*\
@@ -275,7 +419,9 @@ static const razer_device blackwidow_x_chroma_te_device =
NULL,
NULL,
NULL
}
},
NULL,
0
};
/*-------------------------------------------------------------*\
@@ -307,7 +453,9 @@ static const razer_device cynosa_chroma_device =
NULL,
NULL,
NULL
}
},
NULL,
0
};
/*-------------------------------------------------------------*\
@@ -339,7 +487,9 @@ static const razer_device ornata_chroma_device =
NULL,
NULL,
NULL
}
},
NULL,
0
};
/*-------------------------------------------------------------*\
@@ -371,7 +521,9 @@ static const razer_device deathstalker_chroma_device =
NULL,
NULL,
NULL
}
},
NULL,
0
};
/*-------------------------------------------------------------*\
@@ -403,7 +555,9 @@ static const razer_device huntsman_device =
NULL,
NULL,
NULL
}
},
NULL,
0
};
/*-------------------------------------------------------------*\
@@ -447,7 +601,9 @@ static const razer_device huntsman_elite_device =
NULL,
NULL,
NULL
}
},
huntsman_elite_keymap,
HUNTSMAN_ELITE_KEYMAP_SIZE
};
/*-------------------------------------------------------------*\
@@ -479,7 +635,9 @@ static const razer_device huntsman_te_device =
NULL,
NULL,
NULL
}
},
NULL,
0
};
/*-------------------------------------------------------------------------*\
@@ -515,7 +673,9 @@ static const razer_device blade_stealth_device =
NULL,
NULL,
NULL
}
},
NULL,
0
};
/*-------------------------------------------------------------*\
@@ -547,7 +707,9 @@ static const razer_device blade_stealth_late_2016_device =
NULL,
NULL,
NULL
}
},
NULL,
0
};
/*-------------------------------------------------------------*\
@@ -579,7 +741,9 @@ static const razer_device blade_stealth_mid_2017_device =
NULL,
NULL,
NULL
}
},
NULL,
0
};
/*-------------------------------------------------------------*\
@@ -611,7 +775,9 @@ static const razer_device blade_stealth_late_2017_device =
NULL,
NULL,
NULL
}
},
NULL,
0
};
/*-------------------------------------------------------------*\
@@ -643,7 +809,9 @@ static const razer_device blade_stealth_2019_device =
NULL,
NULL,
NULL
}
},
NULL,
0
};
/*-------------------------------------------------------------*\
@@ -675,7 +843,9 @@ static const razer_device blade_stealth_late_2019_device =
NULL,
NULL,
NULL
}
},
NULL,
0
};
/*-------------------------------------------------------------*\
@@ -707,7 +877,9 @@ static const razer_device blade_late_2016_device =
NULL,
NULL,
NULL
}
},
NULL,
0
};
/*-------------------------------------------------------------*\
@@ -740,7 +912,9 @@ static const razer_device blade_qhd_device =
NULL,
NULL,
NULL
}
},
NULL,
0
};
/*-------------------------------------------------------------*\
@@ -772,7 +946,9 @@ static const razer_device blade_15_2018_device =
NULL,
NULL,
NULL
}
},
NULL,
0
};
/*-------------------------------------------------------------*\
@@ -804,7 +980,9 @@ static const razer_device blade_15_2018_mercury_device =
NULL,
NULL,
NULL
}
},
NULL,
0
};
/*-------------------------------------------------------------*\
@@ -836,7 +1014,9 @@ static const razer_device blade_15_2018_base_device =
NULL,
NULL,
NULL
}
},
NULL,
0
};
/*-------------------------------------------------------------*\
@@ -868,7 +1048,9 @@ static const razer_device blade_15_2019_advanced_device =
NULL,
NULL,
NULL
}
},
NULL,
0
};
/*-------------------------------------------------------------*\
@@ -900,7 +1082,9 @@ static const razer_device blade_15_mid_2019_mercury_device =
NULL,
NULL,
NULL
}
},
NULL,
0
};
/*-------------------------------------------------------------*\
@@ -932,7 +1116,9 @@ static const razer_device blade_15_mid_2019_base_device =
NULL,
NULL,
NULL
}
},
NULL,
0
};
/*-------------------------------------------------------------*\
@@ -964,7 +1150,9 @@ static const razer_device blade_15_studio_2019_device =
NULL,
NULL,
NULL
}
},
NULL,
0
};
/*-------------------------------------------------------------*\
@@ -996,7 +1184,9 @@ static const razer_device blade_pro_late_2016_device =
NULL,
NULL,
NULL
}
},
NULL,
0
};
/*-------------------------------------------------------------*\
@@ -1028,7 +1218,9 @@ static const razer_device blade_pro_2017_device =
NULL,
NULL,
NULL
}
},
NULL,
0
};
/*-------------------------------------------------------------*\
@@ -1060,7 +1252,9 @@ static const razer_device blade_pro_2017_fullhd_device =
NULL,
NULL,
NULL
}
},
NULL,
0
};
/*-------------------------------------------------------------*\
@@ -1091,7 +1285,9 @@ static const razer_device blade_pro_17_2019_device =
NULL,
NULL,
NULL
}
},
NULL,
0
};
/*-------------------------------------------------------------*\
@@ -1123,7 +1319,9 @@ static const razer_device blade_pro_late_2019_device =
NULL,
NULL,
NULL
}
},
NULL,
0
};
/*-------------------------------------------------------------------------*\
@@ -1159,7 +1357,9 @@ static const razer_device abyssus_elite_dva_edition_device =
NULL,
NULL,
NULL
}
},
NULL,
0
};
/*-------------------------------------------------------------*\
@@ -1191,7 +1391,9 @@ static const razer_device abyssus_essential_device =
NULL,
NULL,
NULL
}
},
NULL,
0
};
/*-------------------------------------------------------------*\
@@ -1235,7 +1437,9 @@ static const razer_device basilisk_device =
NULL,
NULL,
NULL
}
},
NULL,
0
};
/*-------------------------------------------------------------*\
@@ -1279,7 +1483,9 @@ static const razer_device deathadder_chroma_device =
NULL,
NULL,
NULL
}
},
NULL,
0
};
/*-------------------------------------------------------------*\
@@ -1323,7 +1529,9 @@ static const razer_device deathadder_elite_device =
NULL,
NULL,
NULL
}
},
NULL,
0
};
/*-------------------------------------------------------------*\
@@ -1379,7 +1587,9 @@ static const razer_device diamondback_chroma_device =
NULL,
NULL,
NULL
}
},
NULL,
0
};
/*-------------------------------------------------------------*\
@@ -1447,7 +1657,9 @@ static const razer_device lancehead_te_device =
&lancehead_te_scroll_wheel_zone,
NULL,
NULL
}
},
NULL,
0
};
/*-------------------------------------------------------------*\
@@ -1479,7 +1691,9 @@ static const razer_device mamba_2012_wired_device =
NULL,
NULL,
NULL
}
},
NULL,
0
};
/*-------------------------------------------------------------*\
@@ -1511,7 +1725,9 @@ static const razer_device mamba_2012_wireless_device =
NULL,
NULL,
NULL
}
},
NULL,
0
};
/*-------------------------------------------------------------*\
@@ -1543,7 +1759,9 @@ static const razer_device mamba_wired_device =
NULL,
NULL,
NULL
}
},
NULL,
0
};
/*-------------------------------------------------------------*\
@@ -1575,7 +1793,9 @@ static const razer_device mamba_wireless_device =
NULL,
NULL,
NULL
}
},
NULL,
0
};
/*-------------------------------------------------------------*\
@@ -1644,7 +1864,9 @@ static const razer_device mamba_elite_device =
&mamba_elite_right_zone,
NULL,
NULL
}
},
NULL,
0
};
/*-------------------------------------------------------------*\
@@ -1712,7 +1934,9 @@ static const razer_device mamba_te_device =
&mamba_te_scroll_wheel_zone,
NULL,
NULL
}
},
NULL,
0
};
/*-------------------------------------------------------------*\
@@ -1756,7 +1980,9 @@ static const razer_device mamba_wireless_2018_wired_device =
NULL,
NULL,
NULL
}
},
NULL,
0
};
/*-------------------------------------------------------------*\
@@ -1801,7 +2027,9 @@ static const razer_device mamba_wireless_2018_wireless_device =
NULL,
NULL,
NULL
}
},
NULL,
0
};
/*-------------------------------------------------------------*\
@@ -1857,7 +2085,9 @@ static const razer_device naga_chroma_device =
NULL,
NULL,
NULL
}
},
NULL,
0
};
/*-------------------------------------------------------------*\
@@ -1913,7 +2143,9 @@ static const razer_device naga_hex_v2_device =
NULL,
NULL,
NULL
}
},
NULL,
0
};
/*-------------------------------------------------------------*\
@@ -1969,7 +2201,9 @@ static const razer_device naga_trintiy_device =
NULL,
NULL,
NULL
}
},
NULL,
0
};
/*-------------------------------------------------------------*\
@@ -2001,7 +2235,9 @@ static const razer_device viper_ultimate_device =
NULL,
NULL,
NULL
}
},
NULL,
0
};
/*-------------------------------------------------------------*\
@@ -2045,7 +2281,9 @@ static const razer_device naga_epic_chroma_device =
NULL,
NULL,
NULL
}
},
NULL,
0
};
/*-------------------------------------------------------------------------*\
@@ -2081,7 +2319,9 @@ static const razer_device orbweaver_chroma_device =
NULL,
NULL,
NULL
}
},
NULL,
0
};
/*-------------------------------------------------------------*\
@@ -2113,7 +2353,9 @@ static const razer_device tartarus_chroma_device =
NULL,
NULL,
NULL
}
},
NULL,
0
};
/*-------------------------------------------------------------------------*\
@@ -2149,7 +2391,9 @@ static const razer_device firefly_device =
NULL,
NULL,
NULL
}
},
NULL,
0
};
/*-------------------------------------------------------------*\
@@ -2181,7 +2425,9 @@ static const razer_device firefly_hyperflux_device =
NULL,
NULL,
NULL
}
},
NULL,
0
};
/*-------------------------------------------------------------*\
@@ -2213,7 +2459,9 @@ static const razer_device goliathus_device =
NULL,
NULL,
NULL
}
},
NULL,
0
};
/*-------------------------------------------------------------*\
@@ -2245,7 +2493,9 @@ static const razer_device goliathus_extended_device =
NULL,
NULL,
NULL
}
},
NULL,
0
};
/*-------------------------------------------------------------------------*\
@@ -2281,7 +2531,9 @@ static const razer_device kraken_chroma_device =
NULL,
NULL,
NULL
}
},
NULL,
0
};
/*-------------------------------------------------------------*\
@@ -2313,7 +2565,9 @@ static const razer_device kraken_v2_device =
NULL,
NULL,
NULL
}
},
NULL,
0
};
/*-------------------------------------------------------------*\
@@ -2369,7 +2623,9 @@ static const razer_device tiamat_71_v2_device =
NULL,
NULL,
NULL
}
},
NULL,
0
};
/*-------------------------------------------------------------------------*\
@@ -2417,7 +2673,9 @@ static const razer_device core_device =
NULL,
NULL,
NULL
}
},
NULL,
0
};
/*-------------------------------------------------------------*\
@@ -2449,7 +2707,9 @@ static const razer_device mug_holder_device =
NULL,
NULL,
NULL
}
},
NULL,
0
};
/*-------------------------------------------------------------*\
@@ -2517,7 +2777,9 @@ static const razer_device chromahdk_device =
&chromahdk_zone_4,
NULL,
NULL
}
},
NULL,
0
};
/*-------------------------------------------------------------*\
@@ -2549,7 +2811,9 @@ static const razer_device base_station_device =
NULL,
NULL,
NULL
}
},
NULL,
0
};
/*-------------------------------------------------------------*\
@@ -2594,7 +2858,9 @@ static const razer_device nommo_pro_device =
NULL,
NULL,
NULL
}
},
NULL,
0
};
/*-------------------------------------------------------------*\
@@ -2639,7 +2905,9 @@ static const razer_device nommo_chroma_device =
NULL,
NULL,
NULL
}
},
NULL,
0
};
/*-------------------------------------------------------------------------*\

View File

@@ -425,6 +425,20 @@ void RGBController_OpenRazer::SetupZones()
new_led->name = device_list[device_index]->zones[zone_id]->name + " LED ";
new_led->name.append(std::to_string(col_id + 1));
if(device_list[device_index]->keymap != NULL)
{
for(int i = 0; i < device_list[device_index]->keymap_size; i++)
{
if(zone_id == device_list[device_index]->keymap[i].zone &&
row_id == device_list[device_index]->keymap[i].row &&
col_id == device_list[device_index]->keymap[i].col)
{
new_led->name = device_list[device_index]->keymap[i].name;
}
}
}
leds.push_back(*new_led);
}
}

View File

@@ -373,6 +373,20 @@ void RGBController_OpenRazer::SetupZones()
new_led->name = device_list[device_index]->zones[zone_id]->name + " LED ";
new_led->name.append(std::to_string(col_id + 1));
if(device_list[device_index]->keymap != NULL)
{
for(int i = 0; i < device_list[device_index]->keymap_size; i++)
{
if(zone_id == device_list[device_index]->keymap[i].zone &&
row_id == device_list[device_index]->keymap[i].row &&
col_id == device_list[device_index]->keymap[i].col)
{
new_led->name = device_list[device_index]->keymap[i].name;
}
}
}
leds.push_back(*new_led);
}
}