diff options
author | Clément Gallet <clement.gallet@ens-lyon.org> | 2024-02-15 19:04:02 +0100 |
---|---|---|
committer | Clément Gallet <clement.gallet@ens-lyon.org> | 2024-02-15 19:04:02 +0100 |
commit | 286306e9355d4750a5f6af931c7909961cc21e3e (patch) | |
tree | e234612f4b3e3097f4ebcbb4ef5ceacf3eba4bbd | |
parent | b633f9923deb77f30895d80a81c097624a68011a (diff) |
Implement mouse wheel input
-rw-r--r-- | CHANGELOG.md | 1 | ||||
-rw-r--r-- | configure.ac | 1 | ||||
-rw-r--r-- | debian/control | 4 | ||||
-rw-r--r-- | src/library/inputs/inputevents.cpp | 17 | ||||
-rw-r--r-- | src/library/inputs/inputs.cpp | 1 | ||||
-rw-r--r-- | src/library/renderhud/InputsWindow.cpp | 4 | ||||
-rw-r--r-- | src/program/Context.h | 3 | ||||
-rw-r--r-- | src/program/GameEvents.cpp | 48 | ||||
-rw-r--r-- | src/program/GameEvents.h | 8 | ||||
-rw-r--r-- | src/program/GameEventsXcb.cpp | 23 | ||||
-rw-r--r-- | src/program/GameLoop.cpp | 7 | ||||
-rw-r--r-- | src/program/KeyMapping.cpp | 1 | ||||
-rw-r--r-- | src/program/KeyMapping.h | 2 | ||||
-rw-r--r-- | src/program/KeyMappingQuartz.h | 2 | ||||
-rw-r--r-- | src/program/KeyMappingQuartz.mm | 4 | ||||
-rw-r--r-- | src/program/KeyMappingXcb.cpp | 4 | ||||
-rw-r--r-- | src/program/KeyMappingXcb.h | 2 | ||||
-rw-r--r-- | src/program/movie/MovieFileInputs.cpp | 6 | ||||
-rw-r--r-- | src/shared/inputs/AllInputs.cpp | 2 | ||||
-rw-r--r-- | src/shared/inputs/MouseInputs.cpp | 12 | ||||
-rw-r--r-- | src/shared/inputs/MouseInputs.h | 5 | ||||
-rw-r--r-- | src/shared/inputs/SingleInput.cpp | 2 | ||||
-rw-r--r-- | src/shared/inputs/SingleInput.h | 13 |
23 files changed, 129 insertions, 43 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 268667d8..90ef38a5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,7 @@ * [ImGui] When detached, game window can be resized * Disable a dotnet speed check (#590) * Hook getrandom() +* Implement mouse wheel input ### Changed diff --git a/configure.ac b/configure.ac index 8d43b6e1..a25d2fcf 100644 --- a/configure.ac +++ b/configure.ac @@ -69,6 +69,7 @@ AS_IF([test "x$enable_i386_lib" != "xyes"], [ AC_SEARCH_LIBS([xcb_connect], [xcb], [], [AC_MSG_ERROR(The xcb library is required!)]) AC_SEARCH_LIBS([xcb_xkb_use_extension], [xcb-xkb], [], [AC_MSG_ERROR(The xcb-xkb library is required!)]) AC_SEARCH_LIBS([xcb_key_symbols_alloc], [xcb-keysyms], [], [AC_MSG_ERROR(The xcb-keysyms library is required!)]) + AC_SEARCH_LIBS([xcb_input_xi_select_events], [xcb-xinput], [], [AC_MSG_ERROR(The xcb-xinput library is required!)]) AC_SEARCH_LIBS([pthread_create], [pthread], [], [AC_MSG_ERROR(The pthread library is required!)]) diff --git a/debian/control b/debian/control index def8c4cb..f37497af 100644 --- a/debian/control +++ b/debian/control @@ -2,11 +2,11 @@ Source: libtas Section: unknown Priority: optional Maintainer: Clement Gallet <clement.gallet@ens-lyon.org> -Build-Depends: debhelper-compat (= 10), libx11-dev, qtbase5-dev (>= 5.6.0), libsdl2-dev, libxcb1-dev, libxcb-keysyms1-dev, libxcb-xkb-dev, libx11-xcb-dev, libasound2-dev, libavutil-dev, liblua5.3-dev | liblua5.4-dev, libswresample-dev +Build-Depends: debhelper-compat (= 10), libx11-dev, qtbase5-dev (>= 5.6.0), libsdl2-dev, libxcb1-dev, libxcb-keysyms1-dev, libxcb-xinput-dev, libxcb-xkb-dev, libx11-xcb-dev, libasound2-dev, libavutil-dev, liblua5.3-dev | liblua5.4-dev, libswresample-dev Standards-Version: 3.9.8 Homepage: https://github.com/clementgallet/libTAS Package: libtas Architecture: any -Depends: libasound2 (>= 1.0.16), libc6 (>= 2.15), libgcc1 (>= 1:3.0), libqt5core5a (>= 5.7.0), libqt5gui5 (>= 5.6.0), libqt5widgets5 (>= 5.6.0), libstdc++6 (>= 6), libswresample2 (>= 7:3.2.0) | libswresample3 | libswresample4, libx11-6, libxcb-keysyms1 (>= 0.4.0), libxcb-xkb1, libxcb1, libx11-xcb1, liblua5.3-0 | liblua5.4-0, ffmpeg +Depends: libasound2 (>= 1.0.16), libc6 (>= 2.15), libgcc1 (>= 1:3.0), libqt5core5a (>= 5.7.0), libqt5gui5 (>= 5.6.0), libqt5widgets5 (>= 5.6.0), libstdc++6 (>= 6), libswresample2 (>= 7:3.2.0) | libswresample3 | libswresample4, libx11-6, libxcb-keysyms1 (>= 0.4.0), libxcb-xinput0, libxcb-xkb1, libxcb1, libx11-xcb1, liblua5.3-0 | liblua5.4-0, ffmpeg Description: A program to provide tool-assisted speedrun tools to Linux games diff --git a/src/library/inputs/inputevents.cpp b/src/library/inputs/inputevents.cpp index 0f275724..33a7965b 100644 --- a/src/library/inputs/inputevents.cpp +++ b/src/library/inputs/inputevents.cpp @@ -1061,6 +1061,23 @@ void generateMouseButtonEvents(void) #endif } } + + /* Check if we got a change in mouse wheel */ + if (!game_ai.pointer->wheel) + return; + + if (Global::game_info.mouse & GameInfo::SDL2) { + SDL_Event event2; + event2.type = SDL_MOUSEWHEEL; + event2.wheel.timestamp = timestamp; + event2.wheel.windowID = 1; + event2.wheel.which = 0; // TODO: Mouse instance id. No idea what to put here... + event2.wheel.x = 0; // Only vertical wheel is supported + event2.wheel.y = game_ai.pointer->wheel; + event2.wheel.direction = SDL_MOUSEWHEEL_FLIPPED; + sdlEventQueue.insert(&event2); + debuglogstdio(LCF_SDL | LCF_EVENTS | LCF_MOUSE, "Generate SDL event MOUSEWHEEL with new value (%d)", game_ai.pointer->wheel); + } } /* Generate focus/unfocus event */ diff --git a/src/library/inputs/inputs.cpp b/src/library/inputs/inputs.cpp index 852eb49f..23f67427 100644 --- a/src/library/inputs/inputs.cpp +++ b/src/library/inputs/inputs.cpp @@ -66,6 +66,7 @@ void updateGameInputs() } } + game_ai.pointer->wheel = ai.pointer->wheel; game_ai.pointer->mask = ai.pointer->mask; for (int ji=0; ji<Global::shared_config.nb_controllers; ji++) { diff --git a/src/library/renderhud/InputsWindow.cpp b/src/library/renderhud/InputsWindow.cpp index 92424939..8db73a1c 100644 --- a/src/library/renderhud/InputsWindow.cpp +++ b/src/library/renderhud/InputsWindow.cpp @@ -84,8 +84,8 @@ std::string InputsWindow::formatInputs(const AllInputs& ai) /* Mouse */ if (Global::shared_config.mouse_support) { - if (ai.pointer->x != -1) { - oss << "[M " << ai.pointer->x << ":" << ai.pointer->y << ":"; + if (ai.pointer->x != 0 || ai.pointer->y != 0 || ai.pointer->wheel != 0) { + oss << "[M " << ai.pointer->x << ":" << ai.pointer->y << ":" << ai.pointer->wheel << ":"; oss << ((ai.pointer->mode==SingleInput::POINTER_MODE_RELATIVE)?"R":"A"); oss << "] "; } diff --git a/src/program/Context.h b/src/program/Context.h index f00fdd38..926f2e90 100644 --- a/src/program/Context.h +++ b/src/program/Context.h @@ -82,6 +82,9 @@ struct Context { int64_t new_realtime_sec; int64_t new_realtime_nsec; + /* accumulated values of the mouse wheel, to be able to send wheel inputs */ + int mouse_wheel; + /* config */ Config config; diff --git a/src/program/GameEvents.cpp b/src/program/GameEvents.cpp index 6c338a4e..4a58921c 100644 --- a/src/program/GameEvents.cpp +++ b/src/program/GameEvents.cpp @@ -38,11 +38,11 @@ GameEvents::GameEvents(Context* c, MovieFile* m) : context(c), movie(m) {} void GameEvents::init() { ar_ticks = -1; - ar_delay = 50; + ar_delay = 25; ar_freq = 2; } -bool GameEvents::processEvent(GameEvents::EventType type, struct HotKey &hk) +bool GameEvents::processEvent(GameEvents::EventType type, const HotKey &hk) { switch (type) { @@ -56,6 +56,14 @@ bool GameEvents::processEvent(GameEvents::EventType type, struct HotKey &hk) sendMessage(MSGN_EXPOSE); return false; + case EVENT_TYPE_WHEEL_UP: + context->mouse_wheel -= 1; + return false; + + case EVENT_TYPE_WHEEL_DOWN: + context->mouse_wheel += 1; + return false; + case EVENT_TYPE_PRESS: switch(hk.type) { @@ -95,7 +103,7 @@ bool GameEvents::processEvent(GameEvents::EventType type, struct HotKey &hk) context->config.sc_modified = true; /* Make frame advance auto-repeat faster */ - ar_freq = 1; + ar_freq = 2 - context->config.sc.fastforward; return false; @@ -370,22 +378,26 @@ int GameEvents::handleEvent() } struct HotKey hk; - EventType eventType = nextEvent(hk); - + EventType eventType = EVENT_TYPE_NONE; int flags = ar_advance?RETURN_FLAG_ADVANCE:0; - - if (eventType) { - flags |= RETURN_FLAG_EVENT; - flags |= RETURN_FLAG_UPDATE; // For now, mark all events for update - if (processEvent(eventType, hk)) - flags |= RETURN_FLAG_ADVANCE; - } - else { - uint64_t input_framecount = movie->inputs->processEvent(); - while (input_framecount != UINT64_MAX) { - emit inputsEdited(input_framecount); - input_framecount = movie->inputs->processEvent(); + + do { + eventType = nextEvent(hk); + + if (eventType != EVENT_TYPE_NONE) { + flags |= RETURN_FLAG_EVENT; + flags |= RETURN_FLAG_UPDATE; // For now, mark all events for update + if (processEvent(eventType, hk)) + flags |= RETURN_FLAG_ADVANCE; } - } + else { + uint64_t input_framecount = movie->inputs->processEvent(); + while (input_framecount != UINT64_MAX) { + emit inputsEdited(input_framecount); + input_framecount = movie->inputs->processEvent(); + } + } + } while (eventType != EVENT_TYPE_NONE); + return flags; } diff --git a/src/program/GameEvents.h b/src/program/GameEvents.h index e1b63938..f9bbc4c8 100644 --- a/src/program/GameEvents.h +++ b/src/program/GameEvents.h @@ -75,13 +75,13 @@ protected: EVENT_TYPE_RELEASE, EVENT_TYPE_FOCUS_OUT, EVENT_TYPE_EXPOSE, - EVENT_TYPE_INPUT_SET, - EVENT_TYPE_INPUT_TOGGLE, + EVENT_TYPE_WHEEL_UP, + EVENT_TYPE_WHEEL_DOWN, }; - virtual EventType nextEvent(struct HotKey &hk) = 0; + virtual EventType nextEvent(HotKey &hk) = 0; - bool processEvent(EventType type, struct HotKey &hk); + bool processEvent(EventType type, const HotKey &hk); signals: void alertToShow(QString str); diff --git a/src/program/GameEventsXcb.cpp b/src/program/GameEventsXcb.cpp index 9f8031ea..37541d77 100644 --- a/src/program/GameEventsXcb.cpp +++ b/src/program/GameEventsXcb.cpp @@ -27,6 +27,7 @@ #include <xcb/xcb.h> #include <xcb/xcb_keysyms.h> +#include <xcb/xinput.h> #include <string> #include <iostream> @@ -62,6 +63,16 @@ void GameEventsXcb::registerGameWindow(uint32_t gameWindow) std::cerr << "error in xcb_change_window_attributes: " << error->error_code << std::endl; } + struct { + xcb_input_event_mask_t iem; + int xiem; + } se_mask; + se_mask.iem.deviceid = XCB_INPUT_DEVICE_ALL_MASTER; + se_mask.iem.mask_len = 1; + + se_mask.xiem = XCB_INPUT_XI_EVENT_MASK_BUTTON_PRESS; + xcb_input_xi_select_events(context->conn, context->game_window, 1, &se_mask.iem); + /* Also get parent window of game window for focus */ xcb_query_tree_cookie_t qt_cookie = xcb_query_tree(context->conn, context->game_window); xcb_query_tree_reply_t *reply = xcb_query_tree_reply(context->conn, qt_cookie, &error); @@ -196,8 +207,16 @@ GameEventsXcb::EventType GameEventsXcb::nextEvent(struct HotKey &hk) return EVENT_TYPE_FOCUS_OUT; case XCB_EXPOSE: return EVENT_TYPE_EXPOSE; - default: - return EVENT_TYPE_NONE; + case XCB_GE_GENERIC: { + xcb_ge_generic_event_t *gev = reinterpret_cast<xcb_ge_generic_event_t *>(event.get()); + if (gev->event_type == XCB_INPUT_BUTTON_PRESS) { + xcb_input_button_press_event_t *mev = reinterpret_cast<xcb_input_button_press_event_t*>(gev); + if (mev->detail == XCB_BUTTON_INDEX_4) + return EVENT_TYPE_WHEEL_UP; + if (mev->detail == XCB_BUTTON_INDEX_5) + return EVENT_TYPE_WHEEL_DOWN; + } + } } } } diff --git a/src/program/GameLoop.cpp b/src/program/GameLoop.cpp index 825dab26..0af26cf3 100644 --- a/src/program/GameLoop.cpp +++ b/src/program/GameLoop.cpp @@ -624,7 +624,7 @@ void GameLoop::sleepSendPreview() static AllInputs preview_ai, last_preview_ai; if (gameEvents->haveFocus()) { /* Format the keyboard and mouse state and save it in the AllInputs struct */ - context->config.km->buildAllInputs(preview_ai, context->game_window, context->config.sc, false); + context->config.km->buildAllInputs(preview_ai, context->game_window, context->config.sc, false, context->mouse_wheel); } /* Fill controller inputs from the controller input window. */ @@ -660,7 +660,10 @@ void GameLoop::processInputs(AllInputs &ai) /* Get inputs if we have input focus */ if (gameEvents->haveFocus()) { /* Format the keyboard and mouse state and save it in the AllInputs struct */ - context->config.km->buildAllInputs(ai, context->game_window, context->config.sc, context->config.mouse_warp); + context->config.km->buildAllInputs(ai, context->game_window, context->config.sc, context->config.mouse_warp, context->mouse_wheel); + + /* Reset mouse wheel */ + context->mouse_wheel = 0; } /* Fill controller inputs from the controller input window. */ diff --git a/src/program/KeyMapping.cpp b/src/program/KeyMapping.cpp index 9ea9a60a..0776de73 100644 --- a/src/program/KeyMapping.cpp +++ b/src/program/KeyMapping.cpp @@ -172,6 +172,7 @@ KeyMapping::KeyMapping(void* c) /* Mouse mapping */ input_list[INPUTLIST_HIDDEN].push_back({SingleInput::IT_POINTER_X, 1, "Mouse X coord"}); input_list[INPUTLIST_HIDDEN].push_back({SingleInput::IT_POINTER_Y, 1, "Mouse Y coord"}); + input_list[INPUTLIST_HIDDEN].push_back({SingleInput::IT_POINTER_WHEEL, 1, "Mouse wheel"}); input_list[INPUTLIST_HIDDEN].push_back({SingleInput::IT_POINTER_MODE, 1, "Mouse rel"}); /* Framerate mapping */ diff --git a/src/program/KeyMapping.h b/src/program/KeyMapping.h index 495b99a2..925aa779 100644 --- a/src/program/KeyMapping.h +++ b/src/program/KeyMapping.h @@ -194,7 +194,7 @@ class KeyMapping { * - Get the mouse state * - Warp mouse pointer if needed */ - virtual void buildAllInputs(AllInputs& ai, uint32_t window, SharedConfig& sc, bool mouse_warp) = 0; + virtual void buildAllInputs(AllInputs& ai, uint32_t window, SharedConfig& sc, bool mouse_warp, int mouse_wheel) = 0; }; #endif // LIBTAS_KEYMAPPING_H_INCLUDED diff --git a/src/program/KeyMappingQuartz.h b/src/program/KeyMappingQuartz.h index a310c891..5fbe7f98 100644 --- a/src/program/KeyMappingQuartz.h +++ b/src/program/KeyMappingQuartz.h @@ -67,7 +67,7 @@ class KeyMappingQuartz : public KeyMapping { * - Get the mouse state * - Warp mouse pointer if needed */ - void buildAllInputs(AllInputs& ai, uint32_t window, SharedConfig& sc, bool mouse_warp); + void buildAllInputs(AllInputs& ai, uint32_t window, SharedConfig& sc, bool mouse_warp, int mouse_wheel); private: /* Up-to-date keyboard state */ diff --git a/src/program/KeyMappingQuartz.mm b/src/program/KeyMappingQuartz.mm index f42ca85d..cce2b3af 100644 --- a/src/program/KeyMappingQuartz.mm +++ b/src/program/KeyMappingQuartz.mm @@ -176,7 +176,7 @@ void KeyMappingQuartz::default_input(int tab, int input_index) } } -void KeyMappingQuartz::buildAllInputs(AllInputs& ai, uint32_t window, SharedConfig& sc, bool mouse_warp){ +void KeyMappingQuartz::buildAllInputs(AllInputs& ai, uint32_t window, SharedConfig& sc, bool mouse_warp, int mouse_wheel){ int i,j; int keysym_i = 0; @@ -325,6 +325,8 @@ void KeyMappingQuartz::buildAllInputs(AllInputs& ai, uint32_t window, SharedConf ai.pointer->y = static_cast<int>(cocoaLocation.y - bounds.size.height/2); } + ai.pointer->wheel = mouse_wheel; + /* We only care about the five mouse buttons */ if (cocoaButtons & (1 << 0)) ai.pointer->mask |= (0x1u << SingleInput::POINTER_B1); diff --git a/src/program/KeyMappingXcb.cpp b/src/program/KeyMappingXcb.cpp index 272459f1..4026d875 100644 --- a/src/program/KeyMappingXcb.cpp +++ b/src/program/KeyMappingXcb.cpp @@ -264,7 +264,7 @@ void KeyMappingXcb::default_input(int tab, int input_index) } } -void KeyMappingXcb::buildAllInputs(AllInputs& ai, uint32_t window, SharedConfig& sc, bool mouse_warp){ +void KeyMappingXcb::buildAllInputs(AllInputs& ai, uint32_t window, SharedConfig& sc, bool mouse_warp, int mouse_wheel){ int i,j; int keysym_i = 0; @@ -440,6 +440,8 @@ void KeyMappingXcb::buildAllInputs(AllInputs& ai, uint32_t window, SharedConfig& ai.pointer->y = pointer_reply->win_y; } + ai.pointer->wheel = mouse_wheel; + /* We only care about the five mouse buttons */ if (pointer_reply->mask & XCB_BUTTON_MASK_1) ai.pointer->mask |= (0x1u << SingleInput::POINTER_B1); diff --git a/src/program/KeyMappingXcb.h b/src/program/KeyMappingXcb.h index feabf9b9..bd22131c 100644 --- a/src/program/KeyMappingXcb.h +++ b/src/program/KeyMappingXcb.h @@ -66,7 +66,7 @@ class KeyMappingXcb : public KeyMapping { * - Get the mouse state * - Warp mouse pointer if needed */ - void buildAllInputs(AllInputs& ai, uint32_t window, SharedConfig& sc, bool mouse_warp); + void buildAllInputs(AllInputs& ai, uint32_t window, SharedConfig& sc, bool mouse_warp, int mouse_wheel); private: /* Connection to the X11 server */ diff --git a/src/program/movie/MovieFileInputs.cpp b/src/program/movie/MovieFileInputs.cpp index 994dd5a2..6ecf2fa1 100644 --- a/src/program/movie/MovieFileInputs.cpp +++ b/src/program/movie/MovieFileInputs.cpp @@ -104,6 +104,7 @@ int MovieFileInputs::writeFrame(std::ostream& input_stream, const AllInputs& inp input_stream.put((inputs.pointer->mask&(1<<SingleInput::POINTER_B3))?'3':'.'); input_stream.put((inputs.pointer->mask&(1<<SingleInput::POINTER_B4))?'4':'.'); input_stream.put((inputs.pointer->mask&(1<<SingleInput::POINTER_B5))?'5':'.'); + input_stream << ":" << inputs.pointer->wheel; } /* Write controller inputs */ @@ -306,7 +307,12 @@ int MovieFileInputs::readMouseFrame(std::istringstream& input_string, AllInputs& if (d != '.') inputs.pointer->mask |= (1 << SingleInput::POINTER_B4); input_string >> d; if (d != '.') inputs.pointer->mask |= (1 << SingleInput::POINTER_B5); + input_string >> d; + + /* Check for optional wheel value */ + if (d == ':') + input_string >> inputs.pointer->wheel >> d; return 0; } diff --git a/src/shared/inputs/AllInputs.cpp b/src/shared/inputs/AllInputs.cpp index cd7826d4..6fe284ce 100644 --- a/src/shared/inputs/AllInputs.cpp +++ b/src/shared/inputs/AllInputs.cpp @@ -194,6 +194,7 @@ int AllInputs::getInput(const SingleInput &si) const /* Mouse inputs */ case SingleInput::IT_POINTER_X: case SingleInput::IT_POINTER_Y: + case SingleInput::IT_POINTER_WHEEL: case SingleInput::IT_POINTER_MODE: case SingleInput::IT_POINTER_B1: case SingleInput::IT_POINTER_B2: @@ -265,6 +266,7 @@ void AllInputs::setInput(const SingleInput &si, int value) /* Mouse inputs */ case SingleInput::IT_POINTER_X: case SingleInput::IT_POINTER_Y: + case SingleInput::IT_POINTER_WHEEL: case SingleInput::IT_POINTER_MODE: case SingleInput::IT_POINTER_B1: case SingleInput::IT_POINTER_B2: diff --git a/src/shared/inputs/MouseInputs.cpp b/src/shared/inputs/MouseInputs.cpp index 60b6a913..88ea5a2d 100644 --- a/src/shared/inputs/MouseInputs.cpp +++ b/src/shared/inputs/MouseInputs.cpp @@ -25,6 +25,7 @@ MouseInputs& MouseInputs::operator|=(const MouseInputs& mi) { x |= mi.x; y |= mi.y; + wheel |= mi.wheel; mode |= mi.mode; mask |= mi.mask; return *this; @@ -34,6 +35,7 @@ MouseInputs& MouseInputs::operator=(const MouseInputs& mi) { x = mi.x; y = mi.y; + wheel = mi.wheel; mode = mi.mode; mask = mi.mask; return *this; @@ -42,6 +44,7 @@ MouseInputs& MouseInputs::operator=(const MouseInputs& mi) void MouseInputs::clear() { x = 0; y = 0; + wheel = 0; mode = SingleInput::POINTER_MODE_ABSOLUTE; mask = 0; } @@ -54,6 +57,8 @@ int MouseInputs::getInput(const SingleInput &si) const return x; case SingleInput::IT_POINTER_Y: return y; + case SingleInput::IT_POINTER_WHEEL: + return wheel; case SingleInput::IT_POINTER_MODE: return mode; case SingleInput::IT_POINTER_B1: @@ -75,6 +80,9 @@ void MouseInputs::setInput(const SingleInput &si, int value) case SingleInput::IT_POINTER_Y: y = value; break; + case SingleInput::IT_POINTER_WHEEL: + wheel = value; + break; case SingleInput::IT_POINTER_MODE: mode = value; break; @@ -103,6 +111,10 @@ void MouseInputs::extractInputs(std::set<SingleInput> &input_set) const si = {SingleInput::IT_POINTER_Y, 1, ""}; input_set.insert(si); } + if (wheel) { + si = {SingleInput::IT_POINTER_WHEEL, 1, ""}; + input_set.insert(si); + } if (mode) { si = {SingleInput::IT_POINTER_MODE, 1, ""}; input_set.insert(si); diff --git a/src/shared/inputs/MouseInputs.h b/src/shared/inputs/MouseInputs.h index 8272c652..a706689c 100644 --- a/src/shared/inputs/MouseInputs.h +++ b/src/shared/inputs/MouseInputs.h @@ -32,6 +32,9 @@ class MouseInputs { int x; int y; + /* Pointer vertical wheel */ + int wheel; + /* Absolute or relative mode */ unsigned int mode; @@ -42,7 +45,7 @@ class MouseInputs { inline bool operator==(const MouseInputs& other) const { return ((x == other.x) && (y == other.y) && - (mode == other.mode) && (mask == other.mask)); + (mode == other.mode) && (mask == other.mask) && (wheel == other.wheel)); } /* OR all elements of the struct, so that unique inputs can be queried */ diff --git a/src/shared/inputs/SingleInput.cpp b/src/shared/inputs/SingleInput.cpp index e826ec26..a3869040 100644 --- a/src/shared/inputs/SingleInput.cpp +++ b/src/shared/inputs/SingleInput.cpp @@ -31,7 +31,7 @@ bool SingleInput::isAnalog() const { - if ((type == IT_POINTER_X) || (type == IT_POINTER_Y)) + if ((type == IT_POINTER_X) || (type == IT_POINTER_Y) || (type == IT_POINTER_WHEEL)) return true; if ((type == IT_FRAMERATE_NUM) || (type == IT_FRAMERATE_DEN)) return true; diff --git a/src/shared/inputs/SingleInput.h b/src/shared/inputs/SingleInput.h index 629a1258..288593bc 100644 --- a/src/shared/inputs/SingleInput.h +++ b/src/shared/inputs/SingleInput.h @@ -92,12 +92,13 @@ public: /* Mouse */ IT_POINTER_X = 1, IT_POINTER_Y = 2, - IT_POINTER_MODE = 3, - IT_POINTER_B1 = 4 + POINTER_B1, - IT_POINTER_B2 = 4 + POINTER_B2, - IT_POINTER_B3 = 4 + POINTER_B3, - IT_POINTER_B4 = 4 + POINTER_B4, - IT_POINTER_B5 = 4 + POINTER_B5, + IT_POINTER_WHEEL = 3, + IT_POINTER_MODE = 4, + IT_POINTER_B1 = 5 + POINTER_B1, + IT_POINTER_B2 = 5 + POINTER_B2, + IT_POINTER_B3 = 5 + POINTER_B3, + IT_POINTER_B4 = 5 + POINTER_B4, + IT_POINTER_B5 = 5 + POINTER_B5, /* Single flag */ IT_FLAG = 10, |