diff --git a/Source/DiabloUI/settingsmenu.cpp b/Source/DiabloUI/settingsmenu.cpp index 8fe7bd129..268b9f42c 100644 --- a/Source/DiabloUI/settingsmenu.cpp +++ b/Source/DiabloUI/settingsmenu.cpp @@ -447,6 +447,19 @@ void UiSettingsMenu() break; } break; +#if SDL_VERSION_ATLEAST(2, 0, 0) + case SDL_MOUSEWHEEL: + if (event.wheel.y > 0) { + key = MouseScrollUpButton; + } else if (event.wheel.y < 0) { + key = MouseScrollDownButton; + } else if (event.wheel.x > 0) { + key = MouseScrollLeftButton; + } else if (event.wheel.x < 0) { + key = MouseScrollRightButton; + } + break; +#endif } // Ignore unknown keys if (key == SDLK_UNKNOWN) diff --git a/Source/diablo.cpp b/Source/diablo.cpp index 5181b565f..77034df37 100644 --- a/Source/diablo.cpp +++ b/Source/diablo.cpp @@ -776,6 +776,8 @@ void GameEventHandler(const SDL_Event &event, uint16_t modState) ChatLogScrollUp(); } else if (IsStashOpen) { Stash.PreviousPage(); + } else { + sgOptions.Keymapper.KeyPressed(MouseScrollUpButton); } } else if (event.wheel.y < 0) { // down if (stextflag != TalkID::None) { @@ -788,7 +790,13 @@ void GameEventHandler(const SDL_Event &event, uint16_t modState) ChatLogScrollDown(); } else if (IsStashOpen) { Stash.NextPage(); + } else { + sgOptions.Keymapper.KeyPressed(MouseScrollDownButton); } + } else if (event.wheel.x > 0) { // left + sgOptions.Keymapper.KeyPressed(MouseScrollLeftButton); + } else if (event.wheel.x < 0) { // right + sgOptions.Keymapper.KeyPressed(MouseScrollRightButton); } break; #endif diff --git a/Source/options.cpp b/Source/options.cpp index 46f398622..607e6ae76 100644 --- a/Source/options.cpp +++ b/Source/options.cpp @@ -1333,6 +1333,10 @@ KeymapperOptions::KeymapperOptions() keyIDToKeyName.emplace(SDL_BUTTON_MIDDLE | KeymapperMouseButtonMask, "MMOUSE"); keyIDToKeyName.emplace(SDL_BUTTON_X1 | KeymapperMouseButtonMask, "X1MOUSE"); keyIDToKeyName.emplace(SDL_BUTTON_X2 | KeymapperMouseButtonMask, "X2MOUSE"); + keyIDToKeyName.emplace(MouseScrollUpButton, "SCROLlUPMOUSE"); + keyIDToKeyName.emplace(MouseScrollDownButton, "SCROLLDOWNMOUSE"); + keyIDToKeyName.emplace(MouseScrollLeftButton, "SCROLlLEFTMOUSE"); + keyIDToKeyName.emplace(MouseScrollRightButton, "SCROLLRIGHTMOUSE"); keyIDToKeyName.emplace(SDLK_BACKQUOTE, "`"); keyIDToKeyName.emplace(SDLK_LEFTBRACKET, "["); diff --git a/Source/options.h b/Source/options.h index 7d9aa87e1..1ba00e220 100644 --- a/Source/options.h +++ b/Source/options.h @@ -654,6 +654,10 @@ struct LanguageOptions : OptionCategoryBase { }; constexpr uint32_t KeymapperMouseButtonMask = 1 << 31; +constexpr uint32_t MouseScrollUpButton = 65536 | KeymapperMouseButtonMask; +constexpr uint32_t MouseScrollDownButton = 65537 | KeymapperMouseButtonMask; +constexpr uint32_t MouseScrollLeftButton = 65538 | KeymapperMouseButtonMask; +constexpr uint32_t MouseScrollRightButton = 65539 | KeymapperMouseButtonMask; /** The Keymapper maps keys to actions. */ struct KeymapperOptions : OptionCategoryBase {