mirror of
https://github.com/spice2x/spice2x.github.io.git
synced 2026-08-01 22:30:42 -07:00
cfg: fix mouse names out of bounds (#535)
## Link to GitHub Issue, if one exists n/a ## Description of change Improper bounds check resulting in crash when binding mouse buttons beyond Mouse 5. ## Testing Tested with `Edit` function.
This commit is contained in:
@@ -301,7 +301,7 @@ std::string Button::getDisplayString(rawinput::RawInputManager* manager) {
|
|||||||
switch (device->type) {
|
switch (device->type) {
|
||||||
case rawinput::MOUSE: {
|
case rawinput::MOUSE: {
|
||||||
const char *btn = "Unknown";
|
const char *btn = "Unknown";
|
||||||
static const char *MOUSE_NAMES[] = {
|
static const std::array<const char *, 8>MOUSE_NAMES = {
|
||||||
"Left Mouse",
|
"Left Mouse",
|
||||||
"Right Mouse",
|
"Right Mouse",
|
||||||
"Middle Mouse",
|
"Middle Mouse",
|
||||||
@@ -311,7 +311,7 @@ std::string Button::getDisplayString(rawinput::RawInputManager* manager) {
|
|||||||
"Mouse 4",
|
"Mouse 4",
|
||||||
"Mouse 5",
|
"Mouse 5",
|
||||||
};
|
};
|
||||||
if (vKey < sizeof(MOUSE_NAMES)) {
|
if (vKey < MOUSE_NAMES.size()) {
|
||||||
btn = MOUSE_NAMES[vKey];
|
btn = MOUSE_NAMES[vKey];
|
||||||
}
|
}
|
||||||
return fmt::format("{} ({})", btn, device->desc);
|
return fmt::format("{} ({})", btn, device->desc);
|
||||||
|
|||||||
Reference in New Issue
Block a user