diff --git a/.gitignore b/.gitignore index 21c0ef7..86f08a3 100644 --- a/.gitignore +++ b/.gitignore @@ -14,3 +14,24 @@ Module.symvers # Vim swap files .*.swp + +# Autotools objects +.deps +.dirstamp +.libs +ar-lib +autom4te.cache +m4 +compile +config.* +configure +depcomp +install-sh +libtool +ltmain.sh +missing +Makefile +Makefile.in +*.la +*.lo +*.m4 diff --git a/Makefile.am b/Makefile.am new file mode 100644 index 0000000..d179d97 --- /dev/null +++ b/Makefile.am @@ -0,0 +1,47 @@ +ACLOCAL_AMFLAGS = -I m4 + +SUBDIRS = libx52 test cli util +# lib_LTLIBRARIES = libx52.la libx52util.la +# +# # Core libx52 library +# # This library handles the USB communication between the host and the X52 +# libx52_la_SOURCES = src/x52_common.h src/x52_commands.h \ +# src/x52_control.c src/x52_core.c \ +# src/x52_date_time.c src/x52_mfd_led.c +# libx52_la_LDFLAGS = -version-info 2:0:1 -lusb-1.0 +# +# # libx52 utility library +# # This library provides extra utilities for ease of use +# libx52util_la_SOURCES = src/util_char_map.c +# libx52util_la_CFLAGS = -I $(srcdir)/src +# libx52util_la_LDFLAGS = -version-info 1:0:0 +# libx52util_la_LIBADD = libx52.la +# +# # Header files that need to be copied +# pkginclude_HEADERS = src/libx52.h +# +# # Binaries that use the above libraries +# bin_PROGRAMS = x52cli x52test +# +# # Command line utility that front ends the core library +# x52cli_SOURCES = src/x52_cli.c +# x52cli_LDADD = libx52.la +# +# # Test utility that exercises all the library functions +# x52test_SOURCES = src/x52_test.c src/x52_test_mfd.c src/x52_test_led.c \ +# src/x52_test_clock.c src/x52_test_common.h +# x52test_LDADD = libx52.la +# +# # Extra files that need to be in the distribution +# EXTRA_DIST = src/x52_char_map.cfg \ +# src/x52_char_map.h \ +# src/libx52.h +# +# # Character map generator +# noinst_PROGRAMS = x52charmapgen +# x52charmapgen_SOURCES = src/char_map_parser_gen.c +# +# # Autogenerated file that needs to be cleaned up +# CLEANFILES = src/util_char_map.c +# src/util_char_map.c: $(srcdir)/src/x52_char_map.cfg x52charmapgen$(EXEEXT) +# $(AM_V_GEN) ./x52charmapgen$(EXEEXT) $(srcdir)/src/x52_char_map.cfg $@ diff --git a/README.md b/README.md index f6af464..9f928c6 100644 --- a/README.md +++ b/README.md @@ -8,16 +8,27 @@ display which is programmable. Currently, only Windows drivers are available from Saitek PLC, which led me to develop a new Linux driver which can program the MFD and -the individual LEDs on the joystick. Although the standard usbhid -driver is capable of reading the joystick, it is not sufficient to -really utilize all the capabilities of this system. +the individual LEDs on the joystick. The standard usbhid driver is +capable of reading the joystick, but it cannot control the MFD or LEDs. -This project is currently a work-in-progress. However a high level -outline of the current objectives are listed below: +Most of the extra functionality can be handled from userspace. See +the individual folders for README information. + +# Building + +Build has been tested on Ubuntu 14.04 LTS on x86_64. + +## Prerequisites + +You will need the following packages: + +* automake +* autoconf +* libusb-1.0-0-dev (Package name may vary across distributions) + +## Installation + +1. Clone the repository +2. Run autogen.sh +3. Run configure; make and sudo make install. -* Write a kernel module and export sysfs interfaces to act as a -driver. -* Write a userspace program that can configure the kernel module -and create custom button mappings to keyboard or mouse events. -* Add interrupt handling and export a /dev/input/jsX interface. -* Allow userspace programs to register callbacks on MFD button events. diff --git a/libx52/autogen.sh b/autogen.sh similarity index 100% rename from libx52/autogen.sh rename to autogen.sh diff --git a/cli/Makefile.am b/cli/Makefile.am new file mode 100644 index 0000000..2ad414e --- /dev/null +++ b/cli/Makefile.am @@ -0,0 +1,8 @@ +ACLOCAL_AMFLAGS = -I m4 + +bin_PROGRAMS = x52cli + +# Command line utility that front ends the core library +x52cli_SOURCES = x52_cli.c +x52cli_CFLAGS = @X52_INCLUDE@ +x52cli_LDADD = @X52_CORE_LIB@ diff --git a/libx52/src/x52_cli.c b/cli/x52_cli.c similarity index 100% rename from libx52/src/x52_cli.c rename to cli/x52_cli.c diff --git a/libx52/configure.ac b/configure.ac similarity index 63% rename from libx52/configure.ac rename to configure.ac index 5fb51d8..39bfe5d 100644 --- a/libx52/configure.ac +++ b/configure.ac @@ -1,4 +1,4 @@ -AC_INIT([libx52], [1.1.0], [nirenjan@gmail.com]) +AC_INIT([x52pro-linux], [0.1.0], [nirenjan@gmail.com]) AC_CONFIG_MACRO_DIR([m4]) AM_INIT_AUTOMAKE([-Wall -Werror foreign subdir-objects]) AC_PROG_CC @@ -16,11 +16,21 @@ if test "x${have_libusb}" != xyes; then AC_MSG_ERROR([ ------------------------------------------------------- The library libusb-1.0 and header file libusb.h - are required to build libx52. Stopping... + are required to build x52pro-linux. Stopping... Check 'config.log' for more information. ------------------------------------------------------- ]) fi -AC_CONFIG_FILES([Makefile]) +AC_SUBST([X52_PKG_VERSION], [0.1]) +AC_SUBST([X52_INCLUDE], ["-I \$(top_srcdir)/libx52"]) +AC_SUBST([X52_CORE_LIB], [../libx52/libx52.la]) + +AC_CONFIG_FILES([ + Makefile + libx52/Makefile + test/Makefile + cli/Makefile + util/Makefile +]) AC_OUTPUT diff --git a/libx52/.gitignore b/libx52/.gitignore deleted file mode 100644 index f844ba1..0000000 --- a/libx52/.gitignore +++ /dev/null @@ -1,21 +0,0 @@ -# Ignore autogenerated files -.deps -.dirstamp -.libs -ar-lib -autom4te.cache -m4 -compile -config.* -configure -depcomp -install-sh -libtool -ltmain.sh -missing -Makefile -Makefile.in -*.la -*.lo -*.m4 -libx52-*.* diff --git a/libx52/Makefile.am b/libx52/Makefile.am index c9d3b85..51a778b 100644 --- a/libx52/Makefile.am +++ b/libx52/Makefile.am @@ -1,46 +1,16 @@ ACLOCAL_AMFLAGS = -I m4 -lib_LTLIBRARIES = libx52.la libx52util.la +lib_LTLIBRARIES = libx52.la # Core libx52 library # This library handles the USB communication between the host and the X52 -libx52_la_SOURCES = src/x52_common.h src/x52_commands.h \ - src/x52_control.c src/x52_core.c \ - src/x52_date_time.c src/x52_mfd_led.c +libx52_la_SOURCES = x52_control.c x52_core.c x52_date_time.c x52_mfd_led.c libx52_la_LDFLAGS = -version-info 2:0:1 -lusb-1.0 -# libx52 utility library -# This library provides extra utilities for ease of use -libx52util_la_SOURCES = src/util_char_map.c -libx52util_la_CFLAGS = -I $(srcdir)/src -libx52util_la_LDFLAGS = -version-info 1:0:0 -libx52util_la_LIBADD = libx52.la - # Header files that need to be copied -pkginclude_HEADERS = src/libx52.h - -# Binaries that use the above libraries -bin_PROGRAMS = x52cli x52test - -# Command line utility that front ends the core library -x52cli_SOURCES = src/x52_cli.c -x52cli_LDADD = libx52.la - -# Test utility that exercises all the library functions -x52test_SOURCES = src/x52_test.c src/x52_test_mfd.c src/x52_test_led.c \ - src/x52_test_clock.c src/x52_test_common.h -x52test_LDADD = libx52.la +x52includedir = $(includedir)/x52pro-@X52_PKG_VERSION@ +x52include_HEADERS = libx52.h +# pkginclude_HEADERS = libx52.h # Extra files that need to be in the distribution -EXTRA_DIST = src/x52_char_map.cfg \ - src/x52_char_map.h \ - src/libx52.h - -# Character map generator -noinst_PROGRAMS = x52charmapgen -x52charmapgen_SOURCES = src/char_map_parser_gen.c - -# Autogenerated file that needs to be cleaned up -CLEANFILES = src/util_char_map.c -src/util_char_map.c: $(srcdir)/src/x52_char_map.cfg x52charmapgen$(EXEEXT) - $(AM_V_GEN) ./x52charmapgen$(EXEEXT) $(srcdir)/src/x52_char_map.cfg $@ +EXTRA_DIST = libx52.h x52_commands.h x52_common.h diff --git a/libx52/README.md b/libx52/README.md index 69e2c0e..53bbd49 100644 --- a/libx52/README.md +++ b/libx52/README.md @@ -17,22 +17,3 @@ Note that when writing text to the MFD, the line length is limited to 16 characters. While you can pass a longer string, the library will only consider the first 16 characters for writing to the display. -# Building the library - -Build has been tested on Ubuntu 14.04 LTS on x86_64. -## Prerequisites - -You will need the following packages: - -* automake -* autoconf -* libusb-1.0-0-dev (Package name may vary across distributions) - -## Installation - -1. Clone the parent Git repository -2. Run autogen.sh -3. Run configure; make and sudo make install. - -The test program is not installed. Use x52cli to communicate with the joystick -and set the LEDs and MFD state. diff --git a/libx52/src/libx52.h b/libx52/libx52.h similarity index 100% rename from libx52/src/libx52.h rename to libx52/libx52.h diff --git a/libx52/src/x52_commands.h b/libx52/x52_commands.h similarity index 100% rename from libx52/src/x52_commands.h rename to libx52/x52_commands.h diff --git a/libx52/src/x52_common.h b/libx52/x52_common.h similarity index 100% rename from libx52/src/x52_common.h rename to libx52/x52_common.h diff --git a/libx52/src/x52_control.c b/libx52/x52_control.c similarity index 100% rename from libx52/src/x52_control.c rename to libx52/x52_control.c diff --git a/libx52/src/x52_core.c b/libx52/x52_core.c similarity index 100% rename from libx52/src/x52_core.c rename to libx52/x52_core.c diff --git a/libx52/src/x52_date_time.c b/libx52/x52_date_time.c similarity index 100% rename from libx52/src/x52_date_time.c rename to libx52/x52_date_time.c diff --git a/libx52/src/x52_mfd_led.c b/libx52/x52_mfd_led.c similarity index 100% rename from libx52/src/x52_mfd_led.c rename to libx52/x52_mfd_led.c diff --git a/test/Makefile.am b/test/Makefile.am new file mode 100644 index 0000000..22b8423 --- /dev/null +++ b/test/Makefile.am @@ -0,0 +1,11 @@ +ACLOCAL_AMFLAGS = -I m4 + +bin_PROGRAMS = x52test + +# Test utility that exercises all the library functions +x52test_SOURCES = x52_test.c x52_test_mfd.c x52_test_led.c x52_test_clock.c +x52test_CFLAGS = @X52_INCLUDE@ +x52test_LDADD = @X52_CORE_LIB@ + +# Extra files that need to be in the distribution +EXTRA_DIST = x52_test_common.h diff --git a/libx52/src/x52_test.c b/test/x52_test.c similarity index 100% rename from libx52/src/x52_test.c rename to test/x52_test.c diff --git a/libx52/src/x52_test_clock.c b/test/x52_test_clock.c similarity index 100% rename from libx52/src/x52_test_clock.c rename to test/x52_test_clock.c diff --git a/libx52/src/x52_test_common.h b/test/x52_test_common.h similarity index 100% rename from libx52/src/x52_test_common.h rename to test/x52_test_common.h diff --git a/libx52/src/x52_test_led.c b/test/x52_test_led.c similarity index 100% rename from libx52/src/x52_test_led.c rename to test/x52_test_led.c diff --git a/libx52/src/x52_test_mfd.c b/test/x52_test_mfd.c similarity index 100% rename from libx52/src/x52_test_mfd.c rename to test/x52_test_mfd.c diff --git a/util/Makefile.am b/util/Makefile.am new file mode 100644 index 0000000..61f929f --- /dev/null +++ b/util/Makefile.am @@ -0,0 +1,26 @@ +ACLOCAL_AMFLAGS = -I m4 + +lib_LTLIBRARIES = libx52util.la + +# libx52 utility library +# This library provides extra utilities for ease of use +libx52util_la_SOURCES = util_char_map.c +libx52util_la_CFLAGS = -I $(top_srcdir)/libx52 +libx52util_la_LDFLAGS = -version-info 1:0:0 +libx52util_la_LIBADD = ../libx52/libx52.la + +# Header files that need to be copied +# pkginclude_HEADERS = + +# Extra files that need to be in the distribution +EXTRA_DIST = x52_char_map.cfg \ + x52_char_map.h + +# Character map generator +noinst_PROGRAMS = x52charmapgen +x52charmapgen_SOURCES = char_map_parser_gen.c + +# Autogenerated file that needs to be cleaned up +CLEANFILES = util_char_map.c +util_char_map.c: $(srcdir)/x52_char_map.cfg x52charmapgen$(EXEEXT) + $(AM_V_GEN) ./x52charmapgen$(EXEEXT) $(srcdir)/x52_char_map.cfg $@ diff --git a/libx52/src/char_map_parser_gen.c b/util/char_map_parser_gen.c similarity index 100% rename from libx52/src/char_map_parser_gen.c rename to util/char_map_parser_gen.c diff --git a/libx52/src/x52_char_map.cfg b/util/x52_char_map.cfg similarity index 100% rename from libx52/src/x52_char_map.cfg rename to util/x52_char_map.cfg diff --git a/libx52/src/x52_char_map.h b/util/x52_char_map.h similarity index 100% rename from libx52/src/x52_char_map.h rename to util/x52_char_map.h