Commit Graph

601 Commits (report-buttons-in-order)

Author SHA1 Message Date
nirenjan d9ae8d4b79 Add connect/disconnect methods to libx52
Prior to this change, libx52_init needed a supported joystick to be
plugged in, otherwise it would fail with LIBX52_ERROR_NO_DEVICE. This
change modifies the behavior so that libx52_init would still succeed,
but the application should call libx52_connect to make sure that the
device handle is valid. libx52_init still tries to connect to the
joystick, but absence is no longer treated as a failure.

This change also modifies x52cli to check that the joystick is actually
connected before calling the individual handlers. Because libx52_init no
longer fails if the joystick is absent, we need to rely on the return
code from libx52_connect.
2020-05-23 02:18:40 -07:00
nirenjan 93f1091b95 Ignore additional generated files
[skip ci]
2020-05-22 23:32:17 -07:00
nirenjan 6dc5d51461 Commit automatic changes to PO files
The previous commit to restore the test order in x52test did not fix the
order in the PO files, which got automatically modified when `make
update-po` ran. This commit restores those changes.
2020-05-22 23:26:48 -07:00
nirenjan dfdf6468bc Update Doxygen documentation
This updates the Doxygen documentation so that the generated
documentation is more readable and accessible to users of libx52
2020-05-22 18:05:07 -07:00
nirenjan fd6afde59c Update libx52 soname to 2.2.0 2020-05-22 16:02:59 -07:00
nirenjan 132b72f562 Ignore generated .mo files
This change cleans up a few of the dummy translations in xx_PL using the
open source [Poedit](https://www.poedit.net) editor. Since the editor
also generates the corresponding .mo file, it makes sense to add .mo as
an ignored extension.

[skip ci]
2020-05-22 13:36:53 -07:00
nirenjan d89cce807b Add check for LED support in x52test
This commit uses the new `libx52_check_feature` API to check if the
device supports LED control. If not, it prints an error message and
exits the LED tests gracefully.

This also reverts commit 45f009ac90, which
had moved the LED tests to the end. Since this is no longer necessary,
it is moved back to avoid any issues with anything that may have relied
on the old order.
2020-05-22 11:15:27 -07:00
nirenjan 482943e7a3 Add feature check method to libx52
This change allows applications to query if the connected device
supports the requested feature. This is so that applications like
x52test can skip test routines that aren't supported, instead of bailing
out of the loop.
2020-05-22 10:39:47 -07:00
nirenjan 0b6bc8f074 Clear the structure memory on exiting libx52 2020-05-22 10:33:33 -07:00
nirenjan cc8d6e9344 Revert hotplug support in libx52
This removes the earlier work done in libx52 to support USB hotplug.
This wasn't adequately tested, and the reason to have hotplug support
was to address perceived deficiencies in the standard API.

However, on recent reflection and experimentation, it seems to be easier
to support adding methods to connect to an X52/X52Pro joystick
dynamically after initializing the library. This approach also lends
itself to adding checks when sending control packets to close the device
handle when it detects device disconnection. Also, one could add a
disconnect method to disconnect from any connected joysticks.

Finally, this commit reverts a series of commits that chronicled my
journey into implementing hotplug support and simulating it in
libusbx52. By coalescing the revert into a single commit, it makes it
easier to revert the revert in the future, if necessary.
2020-05-22 00:42:01 -07:00
nirenjan 97743d4ebd Add internationalization support for x52test
This change updates x52test to use the gettext APIs. This also adds a
fake message catalogue to verify that the code is converted correctly
and the translations are displayed.

The fake message catalogue translates the English strings into Pig
Latin, which makes it easy enough for a maintainer to verify that the
changes have been made correctly.

Finally, this also adds some documentation to tell the maintainer or
translator how to make the relevant changes.
2020-05-20 14:36:40 -07:00
nirenjan db8629a6a9 Add automatically generated objects to gitignore 2020-05-20 13:15:04 -07:00
nirenjan 84a7e0fe30 Speed up OSX Travis builds
The previous commit made a call to `brew upgrade`, but this tends to take
a very long time. More often than not, the default version in the OSX VM
image is sufficient, so we just need to call `brew install`.
2020-05-20 01:57:50 -07:00
nirenjan 94a262f13a Force OSX Travis builds to install libusb and gettext 2020-05-20 01:51:42 -07:00
nirenjan 2ea6dcd748 [skip ci] Update README 2020-05-19 16:05:15 -07:00
nirenjan 254bf6baaa Allow builds on OSX to fail without affecting the overall build 2020-05-19 14:20:18 -07:00
nirenjan 1b6736c0f8 Add autopoint to packages list
This change adds the necessary packages to install the autopoint binary
on both Ubuntu and OSX. This is necessary since the build needs the
gettext utilities.

Also remove the installation for realpath, since we are no longer
building for Trusty.
2020-05-19 12:45:00 -07:00
nirenjan ec9443dcdd Add gettext support to libx52
This change adds gettext support to libx52 using the Autotools
framework. This should allow translators to translate the error messages
provided by libx52_strerror into their corresponding localized versions.
2020-05-19 08:07:10 -07:00
nirenjan 3949550b65 Update ChangeLog.md
[skip ci]
2020-05-18 15:08:54 -07:00
nirenjan 1c822f9d6b Update ChangeLog.md 2020-05-18 15:06:19 -07:00
nirenjan 45f009ac90 Move LED tests in x52test to the end
x52test doesn't perform any checks to see if the connected device
supports setting individual LEDs. Therefore, if an X52 (non-Pro) was
connected when running x52test, it would fail when running the LED
tests, and not perform any of the subsequent tests.

By moving the LED tests to the end, this allows the other tests to run
on a non-Pro X52. Although the tests would still fail, it won't actually
break anything.

Addresses #19.
2020-05-18 14:59:24 -07:00
nirenjan be1f7e0d5a Fix error handling in x52test
x52test used to assume that a positive return code indicated a signal
was received and a negative return code indicated an error in libx52.
However, libx52 was changed a while back to return only a positive error
code of type `libx52_error_code`.

This commit changes that assumption, so that:

* The first check is always against `LIBX52_SUCCESS`, to ensure that any
  change in the enumeration won't break the rest of the code.
* Tests terminated by a signal return the negated value of the signal,
  i.e. -15 is SIGTERM and -2 is SIGINT.
* Tests that fail within libx52 return a standard `libx52_error_code`.
* Error printing uses `libx52_strerror`.

Addresses #19.
2020-05-18 14:58:31 -07:00
nirenjan 16b4ad693b Fix error reporting in x52cli
Prior to this change, x52cli assumed that the return code from the
handler was a standard error code, but negated. This is an incorrect
assumption as the libx52 API returns a `libx52_error_code` enum, which
is a positive integer.

This change fixes the printing of the error message to call
`libx52_strerror`, which translates it correctly. It also adds error
printing to any failure of `libx52_init`, as well as explicitly
specifying `LIBX52_SUCCESS` instead of `0`.

Addresses #19.
2020-05-18 14:38:49 -07:00
nirenjan 665dba187d Add build directory to gitignore 2020-05-18 14:23:08 -07:00
nirenjan 74b828a790 Update Doxygen comments
This disables the include file list and dependency graph in the file
view. In addition, the groups are updated to include `libx52` in their
names, to avoid any potential conflict.

[skip ci]
2020-04-18 02:21:12 -07:00
nirenjan 0204103ccd Add Doxygen support
This change adds Doxygen support in the configure/make step. Doxygen is
optional, and the absence of Doxygen should not break the build.
2020-04-18 01:35:57 -07:00
nirenjan 34dc1b8a32 Declare hotplug functions in libx52.h
This change exposes the libx52_hotplug_* functions in libx52.h to allow
other programs to link against them.

This commit also adds Doxygen comments, and groups the declarations by
their function, for later use in Doxygen integration.
2020-04-18 01:30:53 -07:00
nirenjan cb050f2c30 Allow NULL cb_handle in libx52_hotplug_register_callback
This allows the caller to register a callback and forget about it. This
is useful in cases where a particular callback needs to be run
everytime, and there is no point in deregistering it until the
application terminates, at which point `libx52_hotplug_exit` will take
care of the cleanup.
2020-04-18 01:28:12 -07:00
nirenjan 79b1f930b8 Change return type of libx52_hotplug_exit
There is really no need for a return code, if the service pointer is
NULL, or any of the parameters are NULL, then simply return.
2020-04-18 01:23:41 -07:00
nirenjan d45b1f7bfd Disable trusty builds on Travis
Ubuntu Trusty doesn't ship with a new enough pkg-config, which causes
the PKG_INSTALLDIR macro to fail on those systems. Since Trusty is EOL
anyway, simply disable the CI build on it.
2020-04-17 00:11:19 -07:00
nirenjan 116f7b3a57 Install libx52.pc during make install 2020-04-17 00:04:09 -07:00
nirenjan 06fa56bb9f Add missing documentation to distribution tarball 2020-04-17 00:00:46 -07:00
nirenjan 848d70fcf2 Generate pkg-config file for libx52 2020-04-16 22:10:48 -07:00
nirenjan e49261c8d6 Move pthread build logic to configure.ac
Prior to this change, the libusbx52 Makefile was manually specifying the
pthread flags to indicate that the linker needed to link against the
pthread libraries.

This change moves the pthread detection logic out to configure.ac, and
updates the flags in libusbx52 Makefile to use the pthread compiler.
2020-04-15 17:31:46 -07:00
nirenjan 9dc92eb52e Force the use of STDC when building 2020-04-14 23:45:35 -07:00
nirenjan 42f416af1d Update version and changelog for hotplug support 2020-04-14 18:38:12 -07:00
nirenjan aa259bf343 Add hotplug support to libusbx52 2020-04-14 18:36:44 -07:00
nirenjan 946916f456 Add hotplug support to libx52
Prior to this change, libx52 would require that the X52/Pro be plugged
in before initialization. This change allows the application to
initialize libx52 even before the device is plugged in.
2020-04-14 18:36:44 -07:00
nirenjan 152a3e7932 Update for release 0.2.0 2020-04-14 18:30:16 -07:00
nirenjan f9639a9a00 Update ChangeLog
[skip ci]
2020-04-13 00:44:33 -07:00
nirenjan 243b0330af Update build status in README
[skip ci]
2020-04-12 22:23:47 -07:00
nirenjan a5b69124a4 Update build matrix to include OSX, Xenial and Bionic
This commit adds OSX to the build matrix, as well as building on Trusty,
Xenial and Bionic, both with GCC and CLang on all distributions. For
now, the OSX build uses the default image provided by Travis CI, but we
may decide to add more images in the future.

Also move realpath installation out of addons::apt::packages, since on
Xenial and newer distributions, realpath is included in the coreutils
package and doesn't need to be explicitly installed. However, we still
need it on Trusty, so add a line to manually install it.
2020-04-12 22:04:43 -07:00
nirenjan dc80a0f2f1 Add option to run test without delay
x52test by default expects to run with an attached X52 unit. Since the
primary goal of the program is to test the hardware, it has embedded
delays to allow the user to verify the individual LEDs, MFD, brightness,
etc.

However, the complete test takes about 6 minutes. When using the stub
libusb library, the goal is to capture the requests, not verify it
against the hardware. In this case, the delays serve no useful purpose.

This change adds a nodelay flag, which is controlled by the presence of
a `NO_DELAY` environment variable, or the `LD_PRELOAD` environment
variable. As long as either of these variables are present in the
environment block, there will be no delays in the test execution.
2020-04-12 16:48:29 -07:00
nirenjan a7caba19df Set debug output to be line buffered
The stub libusb library used for testing writes the control request to a
dump file. By default, this file is block-buffered, and on a typical
Linux system, it waits until it receives about a page worth of data
before flushing it to disk. This results in a delay in monitoring
packets when running a debug program.

This change makes the file line-buffered instead, which results in the
debug output for every single packet getting flushed to disk without
having to wait for a full page of data.
2020-04-12 16:29:22 -07:00
nirenjan 40b2e9bdac Remove debugs from MFD test script 2020-03-31 23:22:04 -07:00
nirenjan 40c14fed24 Update calls to libusb_set_debug
With the release of libusb 1.0.22, `libusb_set_debug` has been
deprecated and replaced by `libusb_set_option`. This function is a new
generic API to add additional functionality in the future without having
to introduce new functions.

This change checks for `LIBUSB_API_VERSION` of at least `0x01000106`,
which is the version corresponding to 1.0.22, and if it matches, it
replaces the calls to `libusb_set_debug` with equivalent calls to
`libusb_set_option`.
2019-02-01 21:31:57 -08:00
nirenjan 1d51429f10 Make x52test use X macros 2018-07-17 17:21:21 -07:00
nirenjan 9e581bf051 Let libx52_init also translate libusb error codes 2018-07-17 16:00:19 -07:00
nirenjan b1139806f5 Use X-macros for x52cli commands 2018-07-17 15:46:54 -07:00
nirenjan 7dcd3049ec Add SPDX license identifiers in all files 2018-04-18 12:19:29 -07:00