Commit Graph

55 Commits (53957d08135fbf0b73c64df7f3600778c417bf9c)

Author SHA1 Message Date
nirenjan 53957d0813 Enable verbose logging in systemd service 2021-09-14 17:34:20 -07:00
nirenjan 2a8ca8424e Reset reports on thread create and device disconnection
This ensures that if the device gets disconnected while the axis is held
outside of the default position, the axis will get reset.
2021-09-14 17:34:07 -07:00
nirenjan 7f29f5f5fe Add mouse update thread
This change adds a thread to translate thumbstick events to a virtual
mouse.
2021-09-14 17:08:01 -07:00
nirenjan 42850bc4cd Create I/O thread to read and process events
This change adds a separate thread to initialize and read reports from
the supported X52 device. This will then process and raise input events
for a virtual device.
2021-09-14 13:33:36 -07:00
nirenjan b9e5f34aa4 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.
2021-09-14 10:40:48 -07:00
nirenjan 016851478a Add framework for virtual mouse driver
This change adds the configuration and build related changes for
supporting the virtual mouse. Subsequent commits will add support for
reading the IO interface and translating it to mouse commands.
2021-09-14 10:02:21 -07:00
nirenjan 7d757dd40f Disable device check routine in daemon
Prior to this change, the device check was sending a vendor specific
command with wIndex and wValue both set to 0 every 50 ms. On some
systems, this was causing issues with the joystick flapping the state,
and reporting weird values from the stick, and generally sluggish
response.

This change uses the updated libx52 library which uses the hotplug
notification to determine if the device is connected, and should resolve
the issues seen.

Fixes #33
2021-09-14 09:10:52 -07:00
nirenjan f2884c57b7 Print integer representation of LED state when setting it 2021-09-13 15:49:20 -07:00
nirenjan f34f84a3ee Add routine to check device connectivity
Prior to this change, if the clock thread is disabled, then
disconnecting and reconnecting the X52 device would cause the daemon to
not detect the transition. As a result, the daemon would stay in a state
where it thinks the device is still connected, and therefore, not
actually apply any of the saved configuration, until it received a
SIGHUP to refresh the configuration.

This change adds a routine that sends a dummy vendor command. This
vendor command does nothing on my X52 Pro (VID 06a3, PID 0762), but
serves as a check to see if the daemon can send vendor commands to the
device. If the device is indeed disconnected, then that is a sufficient
indicator to disable the update thread and re-enable the acquisition
thread.
2021-08-30 12:33:52 -07:00
nirenjan 0f83cd5a95 Ignore changes to clock settings if clock is disabled 2021-08-30 12:01:41 -07:00
nirenjan 2290900da6 Call tzset before computing timezone offset
POSIX.1-2004 requires that localtime() is required to behave as if
tzset() was called, but there is no such requirement imposed upon
localtime_r(). Therefore, we need to call tzset ourselves to ensure that
the timezone fields are updated.
2021-08-30 11:53:35 -07:00
nirenjan 91f378c4fc Apply configuration immediately when device is connected 2021-08-30 10:41:21 -07:00
nirenjan 0899df60c2 Add signal handler to dump configuration to disk on SIGUSR1 2021-08-30 10:28:29 -07:00
nirenjan 76b1b99717 Make sure config file is closed after dumping configuration 2021-08-30 10:28:26 -07:00
nirenjan a39945f461 Import inih library into source tree
Prior to this change, the user needed to install inih as a dependency,
either from the distribution repositories, or from source. On some
platforms (notably macOS), inih is not available prepackaged, and must
be installed by the user. This tends to cause needless friction.

This change imports the ini.c and ini.h files from the upstream inih
repository into the X52 source tree. This will allow us to build the
repository on any system with the original set of dependencies, and not
have to force the user to install packages themselves.
2021-08-26 22:16:38 -07:00
nirenjan 874c46705a Add config save routines 2021-08-09 22:16:30 -07:00
nirenjan 3d15da385f Change the config macro definitions to use a type
This change changes the parser element in the CFG macros to be a "type"
element instead. This is handled in the config parser source, where the
macro definition appends `_parser` to the type field. This allows us to
(in the future) add a `_dump` function to dump the configuration to a
file.
2021-08-09 21:25:06 -07:00
nirenjan 2b664513a7 Add Install section to service file to allow enabling the service 2021-08-05 11:46:44 -07:00
nirenjan a09a8bee84 Enable INFO log level in systemd unit file 2021-08-05 10:43:13 -07:00
nirenjan 86960e7e20 Create the log and run directories for daemon to store files 2021-08-05 10:25:45 -07:00
nirenjan 0cf6f247be Add systemd unit file to start X52 daemon 2021-08-05 10:21:28 -07:00
nirenjan 65f4ec9659 Add PID file argument to documentation 2021-08-05 05:47:44 -07:00
nirenjan 0fae24b5d0 Allow x52d to daemonize
Prior to this change, x52d could only run in the foreground, regardless
of the value of the foreground flag. This change adds the standard
double-fork routine to daemonize the program.

This change also adds a PID file argument to x52d, which is used to
ensure that only one instance of the x52d daemon is running at any time.
2021-08-04 13:13:12 -07:00
nirenjan f5331cdef3 Use localtime_r instead of localtime 2021-08-03 13:04:46 -07:00
nirenjan 3efdce5abe Fix make distcheck 2021-08-01 23:56:37 -07:00
nirenjan 38917ed6e5 Add documentation for x52d 2021-08-01 23:47:24 -07:00
nirenjan ac68ee07e5 Use non-recursive Automake 2021-07-29 23:53:21 -07:00
nirenjan 7f30863e5d Move libx52io to top level 2021-07-29 21:51:11 -07:00
nirenjan 34adeaec45 Move libx52util to top level 2021-07-29 21:47:07 -07:00
nirenjan e3bccd3ac3 Move libx52 to top level 2021-07-29 21:41:07 -07:00
nirenjan 06b8d15dda Make stringification function names similar to libx52io 2021-07-27 09:34:57 -07:00
nirenjan 50906b0a92 Ensure x52d.conf is included in the distribution tarball 2021-07-27 03:07:52 -07:00
nirenjan 009fba0151 Install x52d.conf to sysconfdir 2021-07-27 02:26:32 -07:00
nirenjan d003e7f7c4 Make daemon use libx52 stringification functions 2021-07-27 02:13:59 -07:00
nirenjan f422202ec8 Update translations and logs for setting config parameters 2021-07-26 11:02:38 -07:00
nirenjan bd2dbbb9cc Make thread startup and shutdown logs as INFO 2021-07-26 10:30:29 -07:00
nirenjan 52232b1a14 Stop device threads on daemon termination 2021-07-26 10:12:23 -07:00
nirenjan e0d15961e0 Add signal handlers to handle termination and reload 2021-07-25 15:39:20 -07:00
nirenjan e4d1b6aff2 Add update thread enable flag
Prior to this change, the update thread was only checking on
device_update_needed. However, this causes an issue when calling any of
the set methods where the update thread fires, fails to find a device,
and signals the acquisition thread every 50 ms, since the update flag
was never cleared.

This change adds a thread enable flag for the update thread. The update
thread will check that both the thread enable flag and the update needed
flag are set before proceeding with the call to libx52_update.
2021-07-25 08:42:33 -07:00
nirenjan 9941234bbe Replace printf with PINELOG_DEBUG in main 2021-07-25 08:42:12 -07:00
nirenjan 9970a8edc4 Fix key names for clock formats in default configuration file 2021-07-23 14:31:58 -07:00
nirenjan 2cecd1890a Allow set_led_state calls to ignore unsupported feature 2021-07-23 14:31:14 -07:00
nirenjan bd682cd5c7 Add LED state and brightness functionality 2021-07-23 14:24:22 -07:00
nirenjan 88955418b8 Fix trace log to print section.key 2021-07-23 14:23:11 -07:00
nirenjan 0fa638fa16 Add support for clock and date format 2021-07-23 13:43:21 -07:00
nirenjan 499cad666f Add clock update functionality 2021-07-23 10:13:18 -07:00
nirenjan ae13480717 Allow libx52 calls to return TRY_AGAIN
Some libx52 APIs, notably the clock related ones, can return
LIBX52_ERROR_TRY_AGAIN. This is not a real error, but it is useful
information. It indicates to the application that there is no change
applied to the internal state, and that it should wait until trying
again.

Given that the clock thread calls the libx52_set_clock method every
second, treating the TRY_AGAIN state as a failure and logging it causes
a lot of spurious noise in the logs.  This change ensures that the API
returns a real error before logging it.
2021-07-23 09:43:02 -07:00
nirenjan 6175dcabe6 Remove trace logging in device update thread
Having the trace log in there adds unnecessary logging for no real
reason. It is better to disable the log here to help trace other
portions of the daemon.
2021-07-23 09:41:18 -07:00
nirenjan c45a84bd38 Replace autogenerated stubs with extern functions
This allows us to slowly replace the stubs with the real functions
2021-07-22 15:56:12 -07:00
nirenjan 50f77119ff Add stub to apply configuration 2021-07-21 10:49:16 -07:00