Commit Graph

145 Commits (84e151389a75f592097516f6dad5d356477a9ca0)

Author SHA1 Message Date
nirenjan 75f0125f54 feat: Add layout file parsing to x52d
This change is an initial step to adding support for profiles in x52d.
This will allow the user to create a keyboard layout in an easy to
read/write text based format, and have it compiled into a flat layout
that's easy for the daemon to parse and load into memory. This layout
can then be used to map a user's action key to the actual input usage
needed. This is necessary, because keyboards don't actually send the
character that is typed, but just the position on the keyboard. For
example, on a French AZERTY keyboard, the A key would actually send the
usage for `Keyboard_q_and_Q`. The OS would translate that into the
letter 'a' (or 'A' if Shift key is held) and pass that to the active
window.

This commit adds the full logic necessary for the layout loading,
validation and compiling, as well as tests for the compiler and loader.
2026-04-04 23:16:51 -07:00
nirenjan de465fbf6a refactor: Rename daemon sources to remove x52d_ prefix 2026-04-03 23:50:18 -07:00
nirenjan 9c1eaaa4b2 build: Migrate includes to use libx52/ prefix
As part of the refactor, have the sources include the public headers via
the libx52 prefix, instead of relying on the include directories
approach in meson.build
2026-04-03 22:54:48 -07:00
nirenjan 9c47e78fc5 fix: Make pc files not include -Ilibx52/ in CFLAGS
Modern libraries do not handhold the user into just calling the header,
instead they namespace it, e.g. libevdev/libevdev.h. Because we already
install our headers under the libx52/ directory, having the pkg-config
files specify `-Ilibx52/` is a legacy from the old days, and should no
longer be used.

This commit also adds pkg-config files for x52dcomm and vkm, installing
them in their proper locations.
2026-04-03 22:42:37 -07:00
nirenjan 7bdaea442e cleanup: Remove autotools build infrastructure
The autotools build infrastructure was deprecated back in 0.3.3, and any
bugs in the Meson build infrastructure have been fixed now. This
eliminates the legacy build scripts which were hard to maintain.
2026-04-03 22:36:10 -07:00
nirenjan 03d58c62e8 feat: Improve virtual mouse speed calculations
Prior to this change, the mouse speed was controlled by an opaque
numeric value, that controlled both the speed and the delay between
updates. This caused a lot of choppy behavior with lower speeds, and the
really low speeds had as little as 1% speed difference between them in
the practical pixels/second speed, while there was effectively a 50%
jump in the speed between speed settings 11 and 12, due to the
hyperbolic relationship between steps. Post that, it was an even 25%
increase in sensitivity for every step.

This change modifies it so that the old Speed option is deprecated, it
is now replaced by the Sensitivity option, which is a direct percentage
scale from 10% to 500%. In addition, there is a CurveFactor option to
let it have fine control when there is little deflection, and move
faster when further away from the center. This also adds an
IsometricMode option which computes the speed as a function of the
cartesian distance from the center (`sqrt(dx^2 + dy^2)`). The default
behavior uses the existing linear speed which controls the speed of the
X and Y axes independently, but now uses the sensitivity and curve
factors to get better behavior. Also, the mouse events are consistently
reported every 10ms. This should make it a lot smoother.

Finally, this change also adds a Deadzone factor, which allows the user
to ignore small changes near the center of the joystick that can cause
mouse drift. This deadzone uses the total distance, so if just the X or
Y axis has moved, it will still allow suppressing any play in the thumb
stick.

Issue: #44
2026-04-01 22:49:04 -07:00
nirenjan 991a307191 fix: Handle shortcut execution in x52d_mouse_report_event
Prior to this change, there is a potential bug where if the left and
right mouse buttons and/or wheel are reported in the same HID report,
the first one to have a change would block any subsequent items. This is
due to the shortcut execution of the `||` operator. By switching the
order in which we evaluate the operands, we can ensure that the report_*
functions are always called.
2026-04-01 20:41:38 -07:00
nirenjan 667e8e2a7b feat: Update symbol visibility 2026-03-30 22:35:52 -07:00
nirenjan 357ea96676 fix: Fix syntax issue with logical operators 2026-03-30 11:52:41 -07:00
nirenjan 6a36fc7764 fix: Use logical operators with boolean arguments
SonarQube flagged the use of bitwise operators with boolean variables.
This is changed to use the correct logical operators instead of their
bitwise equivalents.
2026-03-30 11:47:12 -07:00
nirenjan 283b476c5e fix: Handle issues found by SonarQube 2026-03-30 10:52:47 -07:00
nirenjan 75e6f253c9 feat: Add virtual keyboard/mouse library support
Previously, x52d had conditional compilation flags linking to libevdev
on Linux. However, I wanted to change this so that we use an abstraction
layer that will link to the appropriate backend (evdev on Linux only for
now). The idea is that we get rid of all conditional compilation blocks
and deal with the backend through the vkm library.

This new library handles the mouse scrolling, clicking, as well as
adding the ability to include keyboard events so that we can support the
profiles feature in a future commit.
2026-03-30 10:01:50 -07:00
nirenjan dfbe3e6d21 fix: Enable install for libx52dcomm
The change to build using Meson broke the install target, causing x52ctl
and x52d to fail with a missing libx52dcomm library. This was fixed by
setting `install: true` in the library call.

In addition, several features were used that were leftover from my
earlier attempts to migrate to Meson, but targeted older Meson versions.
Some of these features were deprecated in newer Meson versions, and
therefore, cause warnings to show up during meson setup.

GH-Issue: #63
GH-Issue-URL: https://github.com/nirenjan/libx52/issues/63
2026-03-22 15:47:13 -07:00
nirenjan 732bc21b65 fix: Address compiler warnings
When enabling --warnlevel=3 during Meson setup, the build threw up
several warnings, mostly related to either unused parameters, or
sometimes an integer type mismatch. This commit addresses all of those
changes and ensures that the build does not contain any unnecessary
warnings.
2026-03-19 00:10:18 -07:00
nirenjan ae077dbed8 fix: Add library version for libx52dcomm
This change adds the library version for libx52dcomm, so that it can be
versioned if necessary.
2026-03-17 16:43:54 -07:00
nirenjan 273ed22f8e refactor(x52ctl): Break out interactive mode
SonarQube keeps complaining about issues with cognitive complexity and
bad practices, this commit addresses those commits.
2026-03-16 23:07:39 -07:00
nirenjan cdb00739ca fix(x52ctl): Remove unnecessary goto statements
The `goto cleanup` statements are not really needed, and can be safely
replaced with `break` statements in x52ctl.
2026-03-16 22:50:11 -07:00
nirenjan e1e020a4f5 fix: Handle test dependency on x52ctl
Prior to this change, running meson test without running meson compile
first would cause the daemon communication tests to fail since it
wouldn't find the x52ctl binary. While I could rewrite the test runner
to directly talk to the daemon, it's faster to just ensure the
dependencies are setup correctly.
2026-03-13 09:27:51 -07:00
nirenjan 33bbafe970 fix: Fix systemd service installation in Meson
The Meson build change broke the systemd service file installation. This
commit fixes that, while retaining Autotools support.
2026-03-12 13:21:59 -07:00
nirenjan b4ec8d4629 build: Migrate to meson build
Meson is a far more robust build framework, compared to autotools. This
greatly simplifies adding new features, since it's far easier to
maintain a set of meson.build files vs the autotools mishmash.

DEPRECATION NOTICE: Autotools based build is deprecated and will be
removed in the future.
2026-03-12 10:20:01 -07:00
nirenjan 74fe559f4a build!: Update build to use system inih
When the x52d daemon was originally implemented, the inih library was
not bundled with any major distribution, and had to be compiled from
source everytime. However, with recent distributions (starting with
Ubuntu 22.04 LTS), this is no longer an issue, and inih is available in
the distro package manager. As a result, there is no longer a need to
vendor the inih sources with thiis repository.

However, as a result of this change, third party packaging scripts such
as those on the AUR or other similar registries that directly query the
git repository will fail unless they update the dependencies.

BREAKING CHANGE: Packaging scripts (AUR, etc.) need dependency update
2026-03-12 09:50:58 -07:00
nirenjan b6e61fc54e fix: Avoid backward jumps using goto
SonarQube cloud identified a maintainability issue based on MISRA C
guidelines that prohibit backward jumps. While not a mandatory fix, it
helps to clean up the codebase and improves readability.

Ref. MISRA C:2012, 15.2 - The goto statement shall jump to a label
declared later in the same function.
2026-03-12 08:34:58 -07:00
nirenjan 2fa9f52ddb build: Fix the GCC pragma to only apply for GCC > 13
The -Wanalyzer-fd-leak flag was introduced in GCC 13, so this pragma
fails to build on older GCC versions.
2026-03-09 00:26:06 -07:00
nirenjan a17312dcbc fix: Fix potential error scenarios
Configuring the build with CFLAGS="-O2 -g -fanalyzer", we ran into some
build errors, which we address in this commit.

First off, GCC identified a false positive file descriptor leak in
x52d_client.c, this instance is suppressed to avoid breaking the build.

There was a bug in x52d_clock.c, where if the original timezone could
not have a copy due to malloc failure, it would fail when resetting the
TZ environment. This is fixed by ensuring the copy is valid.

Finally, there was a potential NULL pointer dereference if the pinelog
module messes up the log levels, and the lmap_get_string method ends up
returning a NULL which was passed to the DATA macro. This is fixed by
checking for NULL and handling it in case of failure.
2026-03-09 00:13:19 -07:00
nirenjan b0b9123a2e fix: Add CMOCKA_CFLAGS to test program CFLAGS
In macos-14, programs that rely on cmocka need to specify CMOCKA_CFLAGS
as part of their CFLAGS. This has not been an issue so far on older
versions of macOS, or on any release of Ubuntu, but it should be done to
ensure that the library headers can be found.
2024-06-08 21:25:42 -07:00
nirenjan 7a56af032b fix: Disable mouse tests if cmocka is not present
Cmocka is optional for the builds, but the absence of cmocka causes the
Daemon build to fail when running `make check`. This commit addresses
that issue, while keeping tests that don't need cmocka.
2024-06-05 09:18:01 -07:00
nirenjan d3973a0abf Update daemon protocol documentation
This change ensures that the documentation is in sync with the code.

[skip ci]
2023-01-04 10:07:20 -08:00
nirenjan ebca9566d7 Move common socket code into x52d_comm_internal.c 2023-01-04 08:42:47 -08:00
nirenjan 4b411d6767 Add notifications when device is connected/disconnected 2022-09-23 15:15:49 -07:00
nirenjan b810c457f9 Use x52ctl to test daemon communication
This allows us to test x52ctl as well as the daemon communication
infrastructure.
2022-09-23 10:02:17 -07:00
nirenjan ccabb5c953 Add test case for setting unknown configuration value 2022-09-22 22:14:44 -07:00
nirenjan b2f292bf58 Cleanup config dump routine 2022-09-22 21:31:49 -07:00
nirenjan 7f59984357 Ensure notification socket is bound when starting daemon 2022-09-22 21:28:20 -07:00
nirenjan d60ab7e1e4 Add logging test cases to EXTRA_DIST 2022-09-22 14:45:15 -07:00
nirenjan 2b7c643537 Add test cases for logging command 2022-09-22 14:23:30 -07:00
nirenjan d96b86a817 Return module name in "logging show" command 2022-09-22 14:23:13 -07:00
nirenjan fea095dc50 Add notify module to logging list
The notify module controls the logging settings for the notify socket
code. While missing this doesn't cause any impact to the notify code, an
invalid module name sent on the command socket could cause the daemon to
crash with a NULL pointer access.
2022-09-22 14:21:14 -07:00
nirenjan 1dcadb9428 Rename test cases and add them to EXTRA_DIST 2022-09-22 11:21:53 -07:00
nirenjan ecfb865c58 Fix pattern for daemon tests and sort by filename 2022-09-22 09:39:30 -07:00
nirenjan b1c7a16eac Update daemon documentation to include notify socket
[skip ci]
2022-09-21 20:08:58 -07:00
nirenjan 619d516ccc Add notify API
This change adds a notification API to libx52dcomm. It also pulls in the
logic to join multiple arguments into a single buffer for later use.
2022-09-06 23:19:03 -07:00
nirenjan c3a4fea139 Update int_parser to reject invalid input 2022-09-01 20:50:36 -07:00
nirenjan b822d3aed8 Move command processing into separate thread
This will help in moving a lot of the functionality out of the main
thread, and limit the main thread to just signal handling.
2022-07-27 12:47:53 -07:00
nirenjan d3d32cf278 Block signals on child threads
This change adds logic to block signals on child threads. This is done
so that we can migrate signal handling to the main thread, even if we
add additional threads in the future.
2022-07-27 11:33:44 -07:00
nirenjan 41812e3c1e Add unit tests for mouse reverse scroll 2022-07-03 16:00:13 -07:00
nirenjan 95a10b5ac9 Add option to reverse mouse scroll direction
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
2022-06-14 09:36:13 -07:00
nirenjan 8c8f261c80 Disable use of PID file when running in foreground
When running in foreground, it is likely that it is running within
systemd. In this case, a stale PID file is likely to have a PID that
corresponds to a different process, which can still be kill'ed by the
root user. This results in a false positive that the process is still
running and causes the daemon to abort prematurely.

Fixes #42
2022-05-16 10:33:04 -07:00
nirenjan 6a8dff0a17 Fix mouse test linker failure on macOS 2022-04-28 02:18:13 -07:00
nirenjan 8f9ab9cefd Add tests for mouse configuration
This change adds a test suite for validating mouse configuration. This
only tests the logic for mouse thread enable/disable and mouse speed
calculations.
2022-04-28 01:54:09 -07:00
nirenjan 251ccfde0d Close command socket in test harness before terminating daemon 2022-04-08 22:59:37 -07:00