mirror of https://github.com/nirenjan/libx52.git
Add support for building on macOS
Prior to this change, the build would fail on macOS systems because the evdev sources were only included on Linux systems, and macOS does not have evdev/libevdev. By separating out the configuration and update threads, this should build on macOS, but the configuration would be ignored.reverse-scroll
parent
016851478a
commit
b9e5f34aa4
|
@ -13,6 +13,7 @@ x52d_SOURCES = \
|
|||
daemon/x52d_config.c \
|
||||
daemon/x52d_device.c \
|
||||
daemon/x52d_clock.c \
|
||||
daemon/x52d_mouse.c \
|
||||
daemon/x52d_led.c
|
||||
|
||||
x52d_CFLAGS = \
|
||||
|
@ -59,6 +60,7 @@ EXTRA_DIST += \
|
|||
daemon/x52d_config.h \
|
||||
daemon/x52d_const.h \
|
||||
daemon/x52d_device.h \
|
||||
daemon/x52d_mouse.h \
|
||||
daemon/x52d.conf
|
||||
|
||||
if HAVE_SYSTEMD
|
||||
|
|
|
@ -0,0 +1,54 @@
|
|||
/*
|
||||
* Saitek X52 Pro MFD & LED driver - Mouse driver
|
||||
*
|
||||
* Copyright (C) 2021 Nirenjan Krishnan (nirenjan@nirenjan.org)
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-2.0-only WITH Classpath-exception-2.0
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include <stdio.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "pinelog.h"
|
||||
#include "x52d_config.h"
|
||||
#include "x52d_const.h"
|
||||
#include "x52d_mouse.h"
|
||||
|
||||
// Mouse speed is the delay between subsequent mouse reports
|
||||
#define DEFAULT_MOUSE_SPEED 250000
|
||||
|
||||
volatile bool mouse_enabled = false;
|
||||
volatile int mouse_delay = DEFAULT_MOUSE_SPEED;
|
||||
|
||||
#define MAX_MOUSE_SPEED 5
|
||||
static const int mouse_speed_map[MAX_MOUSE_SPEED] = {
|
||||
250000,
|
||||
200000,
|
||||
150000,
|
||||
100000,
|
||||
50000,
|
||||
};
|
||||
|
||||
void x52d_cfg_set_Mouse_Enabled(bool enabled)
|
||||
{
|
||||
PINELOG_DEBUG(_("Setting mouse enable to %s"),
|
||||
enabled ? _("on") : _("off"));
|
||||
#if defined HAVE_EVDEV
|
||||
x52d_mouse_evdev_thread_control(enabled);
|
||||
#endif
|
||||
}
|
||||
|
||||
void x52d_cfg_set_Mouse_Speed(int speed)
|
||||
{
|
||||
int new_speed;
|
||||
if (speed >= 0 && speed < MAX_MOUSE_SPEED) {
|
||||
new_speed = mouse_speed_map[speed];
|
||||
PINELOG_DEBUG(_("Setting mouse speed to %d (delay %d ms)"),
|
||||
speed, new_speed);
|
||||
mouse_delay = new_speed;
|
||||
} else {
|
||||
PINELOG_INFO(_("Ignoring mouse speed %d outside supported range (0-%d)"),
|
||||
speed, MAX_MOUSE_SPEED);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
/*
|
||||
* Saitek X52 Pro MFD & LED driver - Mouse driver
|
||||
*
|
||||
* Copyright (C) 2021 Nirenjan Krishnan (nirenjan@nirenjan.org)
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-2.0-only WITH Classpath-exception-2.0
|
||||
*/
|
||||
|
||||
#ifndef X52D_MOUSE_H
|
||||
#define X52D_MOUSE_H
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
extern volatile bool mouse_enabled;
|
||||
extern volatile int mouse_delay;
|
||||
|
||||
void x52d_mouse_evdev_thread_control(bool enabled);
|
||||
|
||||
#endif // !defined X52D_MOUSE_H
|
|
@ -9,43 +9,65 @@
|
|||
#include "config.h"
|
||||
#include <stdio.h>
|
||||
#include <stdbool.h>
|
||||
#include <pthread.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "pinelog.h"
|
||||
#include "x52d_config.h"
|
||||
#include "x52d_const.h"
|
||||
#include "x52d_mouse.h"
|
||||
|
||||
// Mouse speed is the delay between subsequent mouse reports
|
||||
#define DEFAULT_MOUSE_SPEED 250000
|
||||
static pthread_t mouse_thr;
|
||||
static bool mouse_thr_enabled = false;
|
||||
|
||||
static bool mouse_enabled = false;
|
||||
static int mouse_speed = DEFAULT_MOUSE_SPEED;
|
||||
|
||||
#define MAX_MOUSE_SPEED 5
|
||||
static const int mouse_speed_map[MAX_MOUSE_SPEED] = {
|
||||
250000,
|
||||
200000,
|
||||
150000,
|
||||
100000,
|
||||
50000,
|
||||
};
|
||||
|
||||
void x52d_cfg_set_Mouse_Enabled(bool enabled)
|
||||
static void * x52_mouse_thr(void *param)
|
||||
{
|
||||
PINELOG_DEBUG(_("Setting mouse enable to %s"),
|
||||
enabled ? _("on") : _("off"));
|
||||
mouse_enabled = enabled;
|
||||
PINELOG_INFO(_("Starting X52 virtual mouse driver thread"));
|
||||
for (;;) {
|
||||
usleep(mouse_delay);
|
||||
if (!mouse_enabled) {
|
||||
/* Mouse thread is disabled, check again next time */
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
void x52d_cfg_set_Mouse_Speed(int speed)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void x52d_mouse_thr_init(void)
|
||||
{
|
||||
int new_speed;
|
||||
if (speed >= 0 && speed < MAX_MOUSE_SPEED) {
|
||||
new_speed = mouse_speed_map[speed];
|
||||
PINELOG_DEBUG(_("Setting mouse speed to %d (delay %d ms)"),
|
||||
speed, new_speed);
|
||||
mouse_speed = new_speed;
|
||||
int rc;
|
||||
|
||||
PINELOG_TRACE("Initializing virtual mouse driver");
|
||||
rc = pthread_create(&mouse_thr, NULL, x52_mouse_thr, NULL);
|
||||
if (rc != 0) {
|
||||
PINELOG_FATAL(_("Error %d initializing mouse thread: %s"),
|
||||
rc, strerror(rc));
|
||||
}
|
||||
}
|
||||
|
||||
static void x52d_mouse_thr_exit(void)
|
||||
{
|
||||
PINELOG_INFO(_("Shutting down X52 virtual mouse driver thread"));
|
||||
pthread_cancel(mouse_thr);
|
||||
}
|
||||
|
||||
void x52d_mouse_evdev_thread_control(bool enabled)
|
||||
{
|
||||
if (enabled) {
|
||||
if (mouse_thr_enabled) {
|
||||
PINELOG_TRACE("Ignoring re-enable mouse thread");
|
||||
return;
|
||||
} else {
|
||||
PINELOG_INFO(_("Ignoring mouse speed %d outside supported range (0-%d)"),
|
||||
speed, MAX_MOUSE_SPEED);
|
||||
x52d_mouse_thr_init();
|
||||
}
|
||||
} else {
|
||||
if (!mouse_thr_enabled) {
|
||||
PINELOG_TRACE("Ignoring re-disable mouse thread");
|
||||
return;
|
||||
} else {
|
||||
x52d_mouse_thr_exit();
|
||||
}
|
||||
}
|
||||
mouse_thr_enabled = enabled;
|
||||
}
|
||||
|
|
|
@ -17,4 +17,5 @@ daemon/x52d_clock.c
|
|||
daemon/x52d_config.c
|
||||
daemon/x52d_config_parser.c
|
||||
daemon/x52d_device.c
|
||||
daemon/x52d_mouse.c
|
||||
daemon/x52d_mouse_evdev.c
|
||||
|
|
|
@ -8,7 +8,7 @@ msgid ""
|
|||
msgstr ""
|
||||
"Project-Id-Version: x52pro-linux 0.2.2\n"
|
||||
"Report-Msgid-Bugs-To: https://github.com/nirenjan/x52pro-linux/issues\n"
|
||||
"POT-Creation-Date: 2021-09-14 09:52-0700\n"
|
||||
"POT-Creation-Date: 2021-09-14 10:32-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"
|
||||
|
@ -142,13 +142,11 @@ msgstr ""
|
|||
msgid "Unknown LED state %d"
|
||||
msgstr ""
|
||||
|
||||
#: libx52/x52_stringify.c:47 daemon/x52d_clock.c:28
|
||||
#: daemon/x52d_mouse_evdev.c:35
|
||||
#: libx52/x52_stringify.c:47 daemon/x52d_clock.c:28 daemon/x52d_mouse.c:36
|
||||
msgid "off"
|
||||
msgstr ""
|
||||
|
||||
#: libx52/x52_stringify.c:48 daemon/x52d_clock.c:28
|
||||
#: daemon/x52d_mouse_evdev.c:35
|
||||
#: libx52/x52_stringify.c:48 daemon/x52d_clock.c:28 daemon/x52d_mouse.c:36
|
||||
msgid "on"
|
||||
msgstr ""
|
||||
|
||||
|
@ -717,17 +715,30 @@ msgstr ""
|
|||
msgid "Error %d when updating X52 device: %s"
|
||||
msgstr ""
|
||||
|
||||
#: daemon/x52d_mouse_evdev.c:34
|
||||
#: daemon/x52d_mouse.c:35
|
||||
#, c-format
|
||||
msgid "Setting mouse enable to %s"
|
||||
msgstr ""
|
||||
|
||||
#: daemon/x52d_mouse_evdev.c:44
|
||||
#: daemon/x52d_mouse.c:47
|
||||
#, c-format
|
||||
msgid "Setting mouse speed to %d (delay %d ms)"
|
||||
msgstr ""
|
||||
|
||||
#: daemon/x52d_mouse_evdev.c:48
|
||||
#: daemon/x52d_mouse.c:51
|
||||
#, c-format
|
||||
msgid "Ignoring mouse speed %d outside supported range (0-%d)"
|
||||
msgstr ""
|
||||
|
||||
#: daemon/x52d_mouse_evdev.c:25
|
||||
msgid "Starting X52 virtual mouse driver thread"
|
||||
msgstr ""
|
||||
|
||||
#: daemon/x52d_mouse_evdev.c:44
|
||||
#, c-format
|
||||
msgid "Error %d initializing mouse thread: %s"
|
||||
msgstr ""
|
||||
|
||||
#: daemon/x52d_mouse_evdev.c:51
|
||||
msgid "Shutting down X52 virtual mouse driver thread"
|
||||
msgstr ""
|
||||
|
|
33
po/xx_PL.po
33
po/xx_PL.po
|
@ -7,8 +7,8 @@ msgid ""
|
|||
msgstr ""
|
||||
"Project-Id-Version: x52pro-linux 0.2.1\n"
|
||||
"Report-Msgid-Bugs-To: https://github.com/nirenjan/x52pro-linux/issues\n"
|
||||
"POT-Creation-Date: 2021-09-14 09:52-0700\n"
|
||||
"PO-Revision-Date: 2021-09-14 09:54-0700\n"
|
||||
"POT-Creation-Date: 2021-09-14 10:32-0700\n"
|
||||
"PO-Revision-Date: 2021-09-14 10:34-0700\n"
|
||||
"Last-Translator: Nirenjan Krishnan <nirenjan@gmail.com>\n"
|
||||
"Language-Team: Dummy Language for testing i18n\n"
|
||||
"Language: xx_PL\n"
|
||||
|
@ -142,13 +142,11 @@ msgstr "YYay-MMay-DDay"
|
|||
msgid "Unknown LED state %d"
|
||||
msgstr "Unknownay EDLay atestay %d"
|
||||
|
||||
#: libx52/x52_stringify.c:47 daemon/x52d_clock.c:28
|
||||
#: daemon/x52d_mouse_evdev.c:35
|
||||
#: libx52/x52_stringify.c:47 daemon/x52d_clock.c:28 daemon/x52d_mouse.c:36
|
||||
msgid "off"
|
||||
msgstr "offay"
|
||||
|
||||
#: libx52/x52_stringify.c:48 daemon/x52d_clock.c:28
|
||||
#: daemon/x52d_mouse_evdev.c:35
|
||||
#: libx52/x52_stringify.c:48 daemon/x52d_clock.c:28 daemon/x52d_mouse.c:36
|
||||
msgid "on"
|
||||
msgstr "onay"
|
||||
|
||||
|
@ -766,17 +764,34 @@ msgstr "Erroray %d enwhay updatingay X52 arameterpay: %s"
|
|||
msgid "Error %d when updating X52 device: %s"
|
||||
msgstr "Erroray %d enwhay updatingay X52 eviceday: %s"
|
||||
|
||||
#: daemon/x52d_mouse_evdev.c:34
|
||||
#: daemon/x52d_mouse.c:35
|
||||
#, c-format
|
||||
msgid "Setting mouse enable to %s"
|
||||
msgstr "Ettingsay ousemay enableay otay %s"
|
||||
|
||||
#: daemon/x52d_mouse_evdev.c:44
|
||||
#: daemon/x52d_mouse.c:47
|
||||
#, c-format
|
||||
msgid "Setting mouse speed to %d (delay %d ms)"
|
||||
msgstr "Ettingsay ousemay eedspay otay %d (elayday %d ms)"
|
||||
|
||||
#: daemon/x52d_mouse_evdev.c:48
|
||||
#: daemon/x52d_mouse.c:51
|
||||
#, 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_evdev.c:25
|
||||
msgid "Starting X52 virtual mouse driver thread"
|
||||
msgstr "Artingstay X52 irtualvay ousemay iverdray eadthray"
|
||||
|
||||
#: daemon/x52d_mouse_evdev.c:44
|
||||
#, c-format
|
||||
msgid "Error %d initializing mouse thread: %s"
|
||||
msgstr "Erroray %d initializingay ousemay eadthray: %s"
|
||||
|
||||
#: daemon/x52d_mouse_evdev.c:51
|
||||
msgid "Shutting down X52 virtual mouse driver thread"
|
||||
msgstr "Uttingshay ownday X52 irtualvay ousemay iverdray eadthray"
|
||||
|
||||
#, fuzzy
|
||||
#~ msgid "Starting X52 mouse manager thread"
|
||||
#~ msgstr "Artingstay X52 ockclay anagermay eadthray"
|
||||
|
|
Loading…
Reference in New Issue