Skip to content

Commit

Permalink
Add option to reverse mouse scroll direction
Browse files Browse the repository at this point in the history
This change adds a ReverseScroll parameter to the configuration, which
if set, will change the direction of the scroll wheel of the virtual
mouse.

Github-Issue: #45
  • Loading branch information
nirenjan committed Jun 14, 2022
1 parent d0f0232 commit 95a10b5
Show file tree
Hide file tree
Showing 8 changed files with 52 additions and 16 deletions.
3 changes: 3 additions & 0 deletions daemon/x52d.conf
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@ Enabled=yes
# Speed is proportional to the speed of updates to the virtual mouse
Speed=0

# ReverseScroll reverses the direction of the virtual scroll wheel
ReverseScroll=no

######################################################################
# Profiles - only valid on Linux
######################################################################
Expand Down
3 changes: 3 additions & 0 deletions daemon/x52d_config.def
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ CFG(Mouse, Enabled, mouse_enabled, bool, true)
// virtual mouse
CFG(Mouse, Speed, mouse_speed, int, 0)

// ReverseScroll controls the scrolling direction
CFG(Mouse, ReverseScroll, mouse_reverse_scroll, bool, false)

/**********************************************************************
* Profiles - only valid on Linux
*********************************************************************/
Expand Down
2 changes: 2 additions & 0 deletions daemon/x52d_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ struct x52d_config {

bool mouse_enabled;
int mouse_speed;
bool mouse_reverse_scroll;

bool clutch_enabled;
bool clutch_latched;
Expand Down Expand Up @@ -71,6 +72,7 @@ void x52d_cfg_set_Brightness_MFD(uint16_t param);
void x52d_cfg_set_Brightness_LED(uint16_t param);
void x52d_cfg_set_Mouse_Enabled(bool param);
void x52d_cfg_set_Mouse_Speed(int param);
void x52d_cfg_set_Mouse_ReverseScroll(bool param);
void x52d_cfg_set_Profiles_Directory(char* param);
void x52d_cfg_set_Profiles_ClutchEnabled(bool param);
void x52d_cfg_set_Profiles_ClutchLatched(bool param);
Expand Down
13 changes: 13 additions & 0 deletions daemon/x52d_mouse.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

volatile int mouse_delay = DEFAULT_MOUSE_DELAY;
volatile int mouse_mult = MOUSE_MULT_FACTOR;
volatile int mouse_scroll_dir = 1;

void x52d_cfg_set_Mouse_Enabled(bool enabled)
{
Expand Down Expand Up @@ -60,3 +61,15 @@ void x52d_cfg_set_Mouse_Speed(int speed)
mouse_delay = new_delay;
mouse_mult = new_mult;
}

void x52d_cfg_set_Mouse_ReverseScroll(bool enabled)
{
PINELOG_DEBUG(_("Setting mouse reverse scroll to %s"),
enabled ? _("on") : _("off"));

if (enabled) {
mouse_scroll_dir = -1;
} else {
mouse_scroll_dir = 1;
}
}
1 change: 1 addition & 0 deletions daemon/x52d_mouse.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

extern volatile int mouse_delay;
extern volatile int mouse_mult;
extern volatile int mouse_scroll_dir;

#define MOUSE_MULT_FACTOR 4

Expand Down
4 changes: 2 additions & 2 deletions daemon/x52d_mouse_evdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,10 @@ static int report_wheel(void)

if (scroll_up) {
// Scroll up event
wheel = 1;
wheel = 1 * mouse_scroll_dir;
} else if (scroll_dn) {
// Scroll down event
wheel = -1;
wheel = -1 * mouse_scroll_dir;
}

if (wheel != 0) {
Expand Down
19 changes: 13 additions & 6 deletions po/libx52.pot
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: libx52 0.2.3\n"
"Report-Msgid-Bugs-To: https://github.com/nirenjan/libx52/issues\n"
"POT-Creation-Date: 2022-05-16 10:47-0700\n"
"POT-Creation-Date: 2022-06-05 08:22-0700\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
Expand Down Expand Up @@ -142,11 +142,13 @@ msgstr ""
msgid "Unknown LED state %d"
msgstr ""

#: libx52/x52_stringify.c:47 daemon/x52d_clock.c:29 daemon/x52d_mouse.c:31
#: libx52/x52_stringify.c:47 daemon/x52d_clock.c:29 daemon/x52d_mouse.c:32
#: daemon/x52d_mouse.c:68
msgid "off"
msgstr ""

#: libx52/x52_stringify.c:48 daemon/x52d_clock.c:29 daemon/x52d_mouse.c:31
#: libx52/x52_stringify.c:48 daemon/x52d_clock.c:29 daemon/x52d_mouse.c:32
#: daemon/x52d_mouse.c:68
msgid "on"
msgstr ""

Expand Down Expand Up @@ -810,21 +812,26 @@ msgstr ""
msgid "Shutting down X52 I/O driver thread"
msgstr ""

#: daemon/x52d_mouse.c:30
#: daemon/x52d_mouse.c:31
#, c-format
msgid "Setting mouse enable to %s"
msgstr ""

#: daemon/x52d_mouse.c:46
#: daemon/x52d_mouse.c:47
#, c-format
msgid "Ignoring mouse speed %d outside supported range (0-%d)"
msgstr ""

#: daemon/x52d_mouse.c:58
#: daemon/x52d_mouse.c:59
#, c-format
msgid "Setting mouse speed to %d (delay %d ms, multiplier %f)"
msgstr ""

#: daemon/x52d_mouse.c:67
#, c-format
msgid "Setting mouse reverse scroll to %s"
msgstr ""

#: daemon/x52d_mouse_evdev.c:43
#, c-format
msgid "Error writing mouse button event (button %d, state %d)"
Expand Down
23 changes: 15 additions & 8 deletions po/xx_PL.po
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ msgid ""
msgstr ""
"Project-Id-Version: libx52 0.2.3\n"
"Report-Msgid-Bugs-To: https://github.com/nirenjan/libx52/issues\n"
"POT-Creation-Date: 2022-05-16 10:47-0700\n"
"PO-Revision-Date: 2021-11-04 15:35-0700\n"
"POT-Creation-Date: 2022-06-05 08:22-0700\n"
"PO-Revision-Date: 2022-06-05 08:51-0700\n"
"Last-Translator: Nirenjan Krishnan <nirenjan@gmail.com>\n"
"Language-Team: Dummy Language for testing i18n\n"
"Language: xx_PL\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Generator: Poedit 3.0\n"
"X-Generator: Poedit 3.0.1\n"

#: libx52/x52_strerror.c:23 libx52io/io_strings.c:101
msgid "Success"
Expand Down Expand Up @@ -142,11 +142,13 @@ msgstr "YYay-MMay-DDay"
msgid "Unknown LED state %d"
msgstr "Unknownay EDLay atestay %d"

#: libx52/x52_stringify.c:47 daemon/x52d_clock.c:29 daemon/x52d_mouse.c:31
#: libx52/x52_stringify.c:47 daemon/x52d_clock.c:29 daemon/x52d_mouse.c:32
#: daemon/x52d_mouse.c:68
msgid "off"
msgstr "offay"

#: libx52/x52_stringify.c:48 daemon/x52d_clock.c:29 daemon/x52d_mouse.c:31
#: libx52/x52_stringify.c:48 daemon/x52d_clock.c:29 daemon/x52d_mouse.c:32
#: daemon/x52d_mouse.c:68
msgid "on"
msgstr "onay"

Expand Down Expand Up @@ -862,21 +864,26 @@ msgstr "Erroray %d initializingay I/O iverdray eadthray: %s"
msgid "Shutting down X52 I/O driver thread"
msgstr "Uttingshay ownday X52 I/O iverdray eadthray"

#: daemon/x52d_mouse.c:30
#: daemon/x52d_mouse.c:31
#, c-format
msgid "Setting mouse enable to %s"
msgstr "Ettingsay ousemay enableay otay %s"

#: daemon/x52d_mouse.c:46
#: daemon/x52d_mouse.c:47
#, c-format
msgid "Ignoring mouse speed %d outside supported range (0-%d)"
msgstr "Ignoringay ousemay eedspay %d outsideay upportedsay angeray (0-%d)"

#: daemon/x52d_mouse.c:58
#: daemon/x52d_mouse.c:59
#, c-format
msgid "Setting mouse speed to %d (delay %d ms, multiplier %f)"
msgstr "Ettingsay ousemay eedspay otay %d (elayday %d ms, ultipliermay %f)"

#: daemon/x52d_mouse.c:67
#, c-format
msgid "Setting mouse reverse scroll to %s"
msgstr "Ettingsay ousemay everseray ollscray otay %s"

#: daemon/x52d_mouse_evdev.c:43
#, c-format
msgid "Error writing mouse button event (button %d, state %d)"
Expand Down

0 comments on commit 95a10b5

Please sign in to comment.