mirror of
https://github.com/libratbag/libratbag.git
synced 2026-11-07 15:14:38 +01:00
Compare commits
49 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bf20845249 | ||
|
|
eb01399f26 | ||
|
|
c815654c94 | ||
|
|
f1ce908b50 | ||
|
|
fb07204d9f | ||
|
|
1e5648b11d | ||
|
|
0902e3420f | ||
|
|
698d8ab365 | ||
|
|
ad1fa22196 | ||
|
|
04ebd96bb7 | ||
|
|
09b5ae14b1 | ||
|
|
8aa127186c | ||
|
|
a962082173 | ||
|
|
5c0dbe4d5c | ||
|
|
5934816b11 | ||
|
|
28dd84713f | ||
|
|
11b31cf9bd | ||
|
|
dfd2d88953 | ||
|
|
6a097bd691 | ||
|
|
2776d1ce8e | ||
|
|
0834b210ca | ||
|
|
cc41adbbf9 | ||
|
|
63a666025f | ||
|
|
08ce9773dd | ||
|
|
f745734d90 | ||
|
|
5443083b1d | ||
|
|
cc19496699 | ||
|
|
b595691c5e | ||
|
|
7d784a1a91 | ||
|
|
a664042f64 | ||
|
|
5bc4470a8c | ||
|
|
b8ed1ea3a4 | ||
|
|
f2ad49cf20 | ||
|
|
fd6a9e73ed | ||
|
|
db57a8e7b6 | ||
|
|
2a35bf009f | ||
|
|
42d49d74ab | ||
|
|
a9f34249fc | ||
|
|
1ce59bcc1f | ||
|
|
bb35821c45 | ||
|
|
bbec42c426 | ||
|
|
cb487a6d1a | ||
|
|
7fdcf62bf2 | ||
|
|
f82c1119bf | ||
|
|
f60f8a12ab | ||
|
|
fd348d456d | ||
|
|
0f73a97bc8 | ||
|
|
7783f50110 | ||
|
|
b85fcd0cee |
42
.gitignore
vendored
42
.gitignore
vendored
@@ -1,7 +1,5 @@
|
||||
*.o
|
||||
*.pc
|
||||
*.la
|
||||
*.lo
|
||||
*.swp
|
||||
*~
|
||||
*.sig
|
||||
@@ -10,44 +8,4 @@
|
||||
*.patch
|
||||
*.rej
|
||||
*.trs
|
||||
Makefile
|
||||
Makefile.in
|
||||
aclocal.m4
|
||||
autom4te.cache/
|
||||
config.guess
|
||||
config.h
|
||||
config.h.in
|
||||
config.log
|
||||
config.status
|
||||
config.sub
|
||||
configure
|
||||
depcomp
|
||||
install-sh
|
||||
libtool
|
||||
ltmain.sh
|
||||
missing
|
||||
stamp-h1
|
||||
.libs/
|
||||
.deps/
|
||||
src/libratbag-version.h
|
||||
doc/libratbag.doxygen
|
||||
doc/html
|
||||
tags
|
||||
test-driver
|
||||
compile
|
||||
m4
|
||||
symbols-leak-test
|
||||
symbols-leak-test.log
|
||||
test-build-cxx
|
||||
test-build-linker
|
||||
test-build-pedantic-c99
|
||||
test-build-std-gnuc90
|
||||
test-iconv-helper
|
||||
test-suite.log
|
||||
test-context
|
||||
test-device
|
||||
test-*.log
|
||||
ratbag-command
|
||||
hidpp10-dump-page
|
||||
hidpp20-dump-page
|
||||
lur-command
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
SUBDIRS = src doc test tools hwdb data
|
||||
|
||||
ACLOCAL_AMFLAGS = -I m4 ${ACLOCAL_FLAGS}
|
||||
|
||||
valgrind:
|
||||
(cd test; $(MAKE) valgrind)
|
||||
26
README.md
26
README.md
@@ -1,5 +1,3 @@
|
||||
/*!@mainpage
|
||||
|
||||
libratbag
|
||||
=========
|
||||
|
||||
@@ -67,6 +65,28 @@ Source
|
||||
|
||||
git clone https://github.com/libratbag/libratbag.git
|
||||
|
||||
Building
|
||||
--------
|
||||
|
||||
libratbag uses the meson build system, see http://mesonbuild.com which in
|
||||
turn uses ninja to invoke the compiler (`ninja` may be `ninja-build` on your
|
||||
distribution). From a fresh git checkout, run the
|
||||
following commands to init the repository:
|
||||
|
||||
meson builddir --prefix=/usr/
|
||||
|
||||
And to build or re-build after code-changes, run:
|
||||
|
||||
ninja -C builddir
|
||||
sudo ninja -C builddir install
|
||||
|
||||
Note: 'builddir' is the build output directory and can be changed to any
|
||||
other directory name. To set configure-time options, use e.g.
|
||||
|
||||
mesonconf builddir -Denable-documentation=no
|
||||
|
||||
Run 'mesonconf builddir' to list the options.
|
||||
|
||||
Bugs
|
||||
----
|
||||
|
||||
@@ -100,5 +120,3 @@ libratbag is licensed under the MIT license.
|
||||
See the COPYING file for the full license information.
|
||||
|
||||
[](https://semaphoreci.com/libratbag/libratbag)
|
||||
|
||||
*/
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
test -n "$srcdir" || srcdir=`dirname "$0"`
|
||||
test -n "$srcdir" || srcdir=.
|
||||
(
|
||||
cd "$srcdir" &&
|
||||
autoreconf --force -v --install
|
||||
) || exit
|
||||
test -n "$NOCONFIGURE" || "$srcdir/configure" "$@"
|
||||
164
configure.ac
164
configure.ac
@@ -1,164 +0,0 @@
|
||||
AC_PREREQ([2.64])
|
||||
|
||||
m4_define([libratbag_major_version], [0])
|
||||
m4_define([libratbag_minor_version], [6])
|
||||
m4_define([libratbag_micro_version], [0])
|
||||
m4_define([libratbag_version],
|
||||
[libratbag_major_version.libratbag_minor_version.libratbag_micro_version])
|
||||
|
||||
AC_INIT([libratbag],
|
||||
[libratbag_version],
|
||||
[],
|
||||
[libratbag],
|
||||
[])
|
||||
|
||||
AC_SUBST([LIBRATBAG_VERSION_MAJOR], [libratbag_major_version])
|
||||
AC_SUBST([LIBRATBAG_VERSION_MINOR], [libratbag_minor_version])
|
||||
AC_SUBST([LIBRATBAG_VERSION_MICRO], [libratbag_micro_version])
|
||||
AC_SUBST([LIBRATBAG_VERSION], [libratbag_version])
|
||||
|
||||
AC_CONFIG_HEADERS([config.h])
|
||||
AC_CONFIG_MACRO_DIR([m4])
|
||||
|
||||
AM_INIT_AUTOMAKE([1.11 foreign no-dist-gzip dist-xz])
|
||||
|
||||
# Before making a release, the LIBRATBAG_LT_VERSION and LIBLUR_LT_VERSION
|
||||
# strings should be modified.
|
||||
# The strings are of the form C:R:A.
|
||||
# a) If binary compatibility has been broken (eg removed or changed interfaces)
|
||||
# change to C+1:0:0.
|
||||
# b) If interfaces have been changed or added, but binary compatibility has
|
||||
# been preserved, change to C+1:0:A+1
|
||||
# c) If the interface is the same as the previous version, change to C:R+1:A
|
||||
LIBRATBAG_LT_VERSION=4:0:0
|
||||
LIBLUR_LT_VERSION=3:2:0
|
||||
AC_SUBST(LIBRATBAG_LT_VERSION)
|
||||
AC_SUBST(LIBLUR_LT_VERSION)
|
||||
|
||||
AM_SILENT_RULES([yes])
|
||||
AC_USE_SYSTEM_EXTENSIONS
|
||||
|
||||
# Check for programs
|
||||
AC_PROG_CC_C99
|
||||
AC_PROG_CXX # Only used by build C++ test
|
||||
AC_PROG_GREP
|
||||
|
||||
# Initialize libtool
|
||||
LT_PREREQ([2.2])
|
||||
LT_INIT
|
||||
|
||||
PKG_PROG_PKG_CONFIG()
|
||||
PKG_CHECK_MODULES(LIBUDEV, [libudev])
|
||||
PKG_CHECK_MODULES(LIBEVDEV, [libevdev])
|
||||
|
||||
if test "x$GCC" = "xyes"; then
|
||||
GCC_CXXFLAGS="-Wall -Wextra -Wno-unused-parameter -g -fvisibility=hidden"
|
||||
GCC_CFLAGS="$GCC_CXXFLAGS -Wmissing-prototypes -Wstrict-prototypes"
|
||||
fi
|
||||
AC_SUBST(GCC_CFLAGS)
|
||||
AC_SUBST(GCC_CXXFLAGS)
|
||||
|
||||
AC_ARG_WITH(udev-base-dir, AS_HELP_STRING([--with-udev-base-dir=DIR], [where udev base directory is]))
|
||||
if test -n "$with_udev_base_dir" ; then
|
||||
UDEV_BASE_DIR="$with_udev_base_dir"
|
||||
else
|
||||
UDEV_BASE_DIR="$prefix/lib/udev"
|
||||
fi
|
||||
AC_SUBST(UDEV_BASE_DIR)
|
||||
|
||||
AC_ARG_ENABLE([documentation],
|
||||
[AC_HELP_STRING([--enable-documentation],
|
||||
[Enable building the documentation (default=auto)])],
|
||||
[build_documentation="$enableval"],
|
||||
[build_documentation="auto"])
|
||||
|
||||
if test "x$build_documentation" = "xyes" -o "x$build_documentation" = "xauto"; then
|
||||
AC_PATH_PROG(DOXYGEN, doxygen)
|
||||
if test "x$DOXYGEN" = "x"; then
|
||||
if test "x$build_documentation" = "xyes"; then
|
||||
AC_MSG_ERROR([Documentation build requested but doxygen not found. Install doxygen or disable the documentation using --disable-documentation])
|
||||
fi
|
||||
else
|
||||
AC_MSG_CHECKING([for compatible doxygen version])
|
||||
doxygen_version=`$DOXYGEN --version`
|
||||
AS_VERSION_COMPARE([$doxygen_version], [1.6.0],
|
||||
[AC_MSG_RESULT([no])
|
||||
DOXYGEN=""],
|
||||
[AC_MSG_RESULT([yes])],
|
||||
[AC_MSG_RESULT([yes])])
|
||||
if test "x$DOXYGEN" = "x" -a "x$build_documentation" = "xyes"; then
|
||||
AC_MSG_ERROR([Doxygen $doxygen_version too old. Doxygen 1.6+ required for documentation build. Install required doxygen version or disable the documentation using --disable-documentation])
|
||||
fi
|
||||
fi
|
||||
|
||||
AC_PATH_PROG(DOT, dot)
|
||||
if test "x$DOT" = "x"; then
|
||||
if test "x$build_documentation" = "xyes"; then
|
||||
AC_MSG_ERROR([Documentation build requested but graphviz's dot not found. Install graphviz or disable the documentation using --disable-documentation])
|
||||
fi
|
||||
else
|
||||
AC_MSG_CHECKING([for compatible dot version])
|
||||
dot_version=`$DOT -V 2>&1|$GREP -oP '(?<=version\W)@<:@0-9.@:>@*(?=\W(.*))'`
|
||||
AS_VERSION_COMPARE([$dot_version], [2.26.0],
|
||||
[AC_MSG_RESULT([no])
|
||||
DOT=""],
|
||||
[AC_MSG_RESULT([yes])],
|
||||
[AC_MSG_RESULT([yes])])
|
||||
if test "x$DOT" = "x" -a "x$build_documentation" = "xyes"; then
|
||||
AC_MSG_ERROR([Graphviz dot $dot_version too old. Graphviz 2.26+ required for documentation build. Install required graphviz version or disable the documentation using --disable-documentation])
|
||||
fi
|
||||
fi
|
||||
|
||||
if test "x$DOXYGEN" != "x" -a "x$DOT" != "x"; then
|
||||
build_documentation="yes"
|
||||
else
|
||||
build_documentation="no"
|
||||
fi
|
||||
fi
|
||||
|
||||
AC_ARG_ENABLE(tests,
|
||||
AS_HELP_STRING([--enable-tests], [Build the tests (default=auto)]),
|
||||
[build_tests="$enableval"],
|
||||
[build_tests="auto"])
|
||||
|
||||
PKG_CHECK_MODULES(CHECK, [check >= 0.9.10], [HAVE_CHECK="yes"], [HAVE_CHECK="no"])
|
||||
|
||||
if test "x$build_tests" = "xauto"; then
|
||||
build_tests="$HAVE_CHECK"
|
||||
fi
|
||||
if test "x$build_tests" = "xyes"; then
|
||||
if test "x$HAVE_CHECK" = "xno"; then
|
||||
AC_MSG_ERROR([Cannot build tests, check is missing])
|
||||
fi
|
||||
|
||||
AC_PATH_PROG(VALGRIND, [valgrind])
|
||||
fi
|
||||
|
||||
AC_DEFINE(BUILD_TESTS, [1], ["Build the test suite])
|
||||
AM_CONDITIONAL(HAVE_VALGRIND, [test "x$VALGRIND" != "x"])
|
||||
AM_CONDITIONAL(BUILD_TESTS, [test "x$build_tests" = "xyes"])
|
||||
AM_CONDITIONAL(BUILD_DOCS, [test "x$build_documentation" = "xyes"])
|
||||
|
||||
AC_CONFIG_FILES([Makefile
|
||||
data/Makefile
|
||||
doc/Makefile
|
||||
doc/libratbag.doxygen
|
||||
hwdb/Makefile
|
||||
src/Makefile
|
||||
src/libratbag.pc
|
||||
src/libratbag-version.h
|
||||
src/liblur.pc
|
||||
test/Makefile
|
||||
tools/Makefile])
|
||||
AC_CONFIG_FILES([test/symbols-leak-test],
|
||||
[chmod +x test/symbols-leak-test])
|
||||
AC_OUTPUT
|
||||
|
||||
AC_MSG_RESULT([
|
||||
Prefix ${prefix}
|
||||
udev base directory: ${UDEV_BASE_DIR}
|
||||
|
||||
Build documentation ${build_documentation}
|
||||
Build tests ${build_tests}
|
||||
Tests use valgrind ${VALGRIND}
|
||||
])
|
||||
@@ -1,2 +0,0 @@
|
||||
libratbagdatadir = $(datadir)/libratbag
|
||||
dist_libratbagdata_DATA = $(shell find $(top_srcdir)/data -name "*.svg" -printf "%P\n")
|
||||
@@ -1,38 +0,0 @@
|
||||
if BUILD_DOCS
|
||||
|
||||
noinst_DATA = html/index.html
|
||||
|
||||
header_files = \
|
||||
$(top_srcdir)/src/libratbag.h \
|
||||
$(top_srcdir)/README.md
|
||||
|
||||
style_files = \
|
||||
style/header.html \
|
||||
style/footer.html \
|
||||
style/customdoxygen.css \
|
||||
style/bootstrap.css
|
||||
|
||||
html/index.html: libratbag.doxygen $(header_files) $(diagram_files) $(style_files)
|
||||
$(AM_V_GEN)(cat $<; \
|
||||
echo "INPUT = $(header_files)"; \
|
||||
) | $(DOXYGEN) -
|
||||
|
||||
clean-local:
|
||||
$(AM_V_at)rm -rf html
|
||||
|
||||
doc_src= $(shell find html -type f -printf "html/%P\n" 2>/dev/null)
|
||||
EXTRA_DIST = $(builddir)/html/index.html \
|
||||
$(doc_src) \
|
||||
$(diagram_files) \
|
||||
$(header_files) \
|
||||
$(style_files)
|
||||
endif
|
||||
|
||||
# make sure doc was built before running dist
|
||||
dist-hook:
|
||||
@test -f $(distdir)/html/index.html || (\
|
||||
echo "******************************************************" && \
|
||||
echo "Couldn't find documentation files, refusing make dist." && \
|
||||
echo "Install doxygen to build documentation for tarball." && \
|
||||
echo "******************************************************" && \
|
||||
test )
|
||||
@@ -8,8 +8,9 @@ EXTRACT_ALL = YES
|
||||
EXTRACT_STATIC = YES
|
||||
MAX_INITIALIZER_LINES = 0
|
||||
QUIET = YES
|
||||
# Keep this list in sync with meson.build
|
||||
INPUT = @top_srcdir@/src/libratbag.h \
|
||||
@top_srcdir@/README.txt
|
||||
@top_srcdir@/README.md
|
||||
GENERATE_HTML = YES
|
||||
HTML_TIMESTAMP = YES
|
||||
USE_MATHJAX = YES
|
||||
@@ -24,3 +25,4 @@ HTML_HEADER = @top_srcdir@/doc/style/header.html
|
||||
HTML_FOOTER = @top_srcdir@/doc/style/footer.html
|
||||
HTML_EXTRA_STYLESHEET = @top_srcdir@/doc/style/customdoxygen.css \
|
||||
@top_srcdir@/doc/style/bootstrap.css
|
||||
USE_MDFILE_AS_MAINPAGE = README.md
|
||||
|
||||
@@ -180,6 +180,10 @@ mouse:usb:v046dp4011:name:*:
|
||||
mouse:usb:v046dpc537:name:*:
|
||||
RATBAG_HIDPP20_INDEX=1
|
||||
|
||||
# G900 over USB
|
||||
mouse:usb:v046dpc081:name:*:
|
||||
RATBAG_SVG=logitech-g900.svg
|
||||
|
||||
# G900 over wireless USB
|
||||
mouse:usb:v046dpc539:name:*:
|
||||
RATBAG_DRIVER=hidpp20
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
udevrulesdir = $(UDEV_BASE_DIR)/rules.d
|
||||
udevrules_DATA = 70-libratbag-mouse.rules
|
||||
|
||||
hwdbdir = $(UDEV_BASE_DIR)/hwdb.d
|
||||
hwdb_DATA = 70-libratbag-mouse.hwdb
|
||||
|
||||
EXTRA_DIST = \
|
||||
$(udevrules_DATA) \
|
||||
$(hwdb_DATA)
|
||||
395
meson.build
Normal file
395
meson.build
Normal file
@@ -0,0 +1,395 @@
|
||||
project('libratbag', 'c', 'cpp',
|
||||
version : '0.8.0',
|
||||
license : 'MIT/Expat',
|
||||
default_options : [ 'c_std=gnu99', 'warning_level=2' ])
|
||||
|
||||
libratbag_version = meson.project_version().split('.')
|
||||
|
||||
# We use libtool-version numbers because it's easier to understand.
|
||||
# Before making a release, the libratbag_so_* and liblur_so_*
|
||||
# numbers should be modified. The components are of the form C:R:A.
|
||||
# a) If binary compatibility has been broken (eg removed or changed interfaces)
|
||||
# change to C+1:0:0.
|
||||
# b) If interfaces have been changed or added, but binary compatibility has
|
||||
# been preserved, change to C+1:0:A+1
|
||||
# c) If the interface is the same as the previous version, change to C:R+1:A
|
||||
libratbag_so_c=4
|
||||
libratbag_so_r=2
|
||||
libratbag_so_a=0
|
||||
liblur_so_c=3
|
||||
liblur_so_r=2
|
||||
liblur_so_a=0
|
||||
|
||||
# convert to sonames
|
||||
libratbag_so_version = '@0@.@1@.@2@'.format((libratbag_so_c - libratbag_so_a),
|
||||
libratbag_so_a, libratbag_so_r)
|
||||
liblur_so_version = '@0@.@1@.@2@'.format((liblur_so_c-liblur_so_a),
|
||||
liblur_so_a, liblur_so_r)
|
||||
|
||||
# Compiler setup
|
||||
cc = meson.get_compiler('c')
|
||||
cpp = meson.get_compiler('cpp')
|
||||
cppflags = ['-Wno-unused-parameter', '-fvisibility=hidden']
|
||||
cflags = cppflags + ['-Wmissing-prototypes', '-Wstrict-prototypes']
|
||||
add_project_arguments(cflags, language: 'c')
|
||||
add_project_arguments(cppflags, language: 'cpp')
|
||||
|
||||
# Initialize config.h, to be added to in the various options below, config.h
|
||||
# is generated at the end of this file
|
||||
config_h = configuration_data()
|
||||
config_h.set('_GNU_SOURCE', '1')
|
||||
|
||||
# dependencies
|
||||
pkgconfig = import('pkgconfig')
|
||||
dep_udev = dependency('libudev')
|
||||
dep_libevdev = dependency('libevdev')
|
||||
dep_lm = cc.find_library('m')
|
||||
|
||||
#### libutil.a ####
|
||||
src_libutil = [
|
||||
'src/libratbag-util.c',
|
||||
'src/libratbag-util.h'
|
||||
]
|
||||
|
||||
deps_libutil = [
|
||||
dep_udev,
|
||||
]
|
||||
|
||||
lib_libutil = static_library('util',
|
||||
src_libutil,
|
||||
dependencies : deps_libutil
|
||||
)
|
||||
dep_libutil = declare_dependency(link_with: lib_libutil)
|
||||
|
||||
### libhidpp.a ####
|
||||
src_libhidpp = [
|
||||
'src/hidpp-generic.h',
|
||||
'src/hidpp-generic.c',
|
||||
'src/hidpp10.h',
|
||||
'src/hidpp10.c',
|
||||
'src/hidpp20.h',
|
||||
'src/hidpp20.c',
|
||||
'src/usb-ids.h'
|
||||
]
|
||||
|
||||
deps_libhidpp = [ dep_lm ]
|
||||
|
||||
lib_libhidpp = static_library('hidpp',
|
||||
src_libhidpp,
|
||||
dependencies : deps_libhidpp)
|
||||
dep_libhidpp = declare_dependency(link_with: lib_libhidpp)
|
||||
|
||||
### liblur.a ####
|
||||
install_headers('src/liblur.h')
|
||||
|
||||
src_liblur = [
|
||||
'src/liblur.c',
|
||||
'src/liblur.h'
|
||||
]
|
||||
|
||||
deps_liblur = [
|
||||
dep_libutil,
|
||||
dep_libhidpp,
|
||||
]
|
||||
|
||||
lur_mapfile = 'src/liblur.sym'
|
||||
lur_version_flag = '-Wl,--version-script,@0@/@1@'.format(meson.current_source_dir(), lur_mapfile)
|
||||
lib_liblur = shared_library('lur',
|
||||
src_liblur,
|
||||
include_directories : include_directories('.'),
|
||||
dependencies : deps_liblur,
|
||||
version : liblur_so_version,
|
||||
link_args : lur_version_flag,
|
||||
link_depends : lur_mapfile,
|
||||
install : true,
|
||||
)
|
||||
|
||||
dep_liblur = declare_dependency(link_with: lib_liblur)
|
||||
|
||||
pkgconfig.generate (
|
||||
filebase: 'liblur',
|
||||
name: 'Liblur',
|
||||
description: 'Logitech Unifying Receiver configuration library',
|
||||
version: meson.project_version(),
|
||||
libraries: lib_liblur
|
||||
)
|
||||
|
||||
#### libratbag.so ####
|
||||
install_headers('src/libratbag.h')
|
||||
|
||||
src_libratbag = [
|
||||
'src/driver-etekcity.c',
|
||||
'src/driver-hidpp20.c',
|
||||
'src/driver-hidpp10.c',
|
||||
'src/driver-logitech-g300.c',
|
||||
'src/driver-roccat.c',
|
||||
'src/driver-gskill.c',
|
||||
'src/driver-test.c',
|
||||
'src/libratbag.c',
|
||||
'src/libratbag.h',
|
||||
'src/libratbag-hidraw.c',
|
||||
'src/libratbag-hidraw.h',
|
||||
'src/libratbag-private.h',
|
||||
'src/libratbag-test.c',
|
||||
'src/libratbag-test.h',
|
||||
'src/usb-ids.h'
|
||||
]
|
||||
|
||||
deps_libratbag = [
|
||||
dep_udev,
|
||||
dep_libevdev,
|
||||
dep_libutil,
|
||||
dep_libhidpp,
|
||||
]
|
||||
|
||||
libratbag_version_h_config = configuration_data()
|
||||
libratbag_version_h_config.set('LIBRATBAG_VERSION_MAJOR', libratbag_version[0])
|
||||
libratbag_version_h_config.set('LIBRATBAG_VERSION_MINOR', libratbag_version[1])
|
||||
libratbag_version_h_config.set('LIBRATBAG_VERSION_MICRO', libratbag_version[2])
|
||||
libratbag_version_h_config.set_quoted('LIBRATBAG_VERSION', meson.project_version())
|
||||
|
||||
libratbag_version_h = configure_file(
|
||||
output : 'libratbag-version.h',
|
||||
configuration : libratbag_version_h_config,
|
||||
install: false,
|
||||
)
|
||||
|
||||
mapfile = 'src/libratbag.sym'
|
||||
version_flag = '-Wl,--version-script,@0@/@1@'.format(meson.current_source_dir(), mapfile)
|
||||
lib_libratbag = shared_library('ratbag',
|
||||
src_libratbag,
|
||||
include_directories : include_directories('.'),
|
||||
dependencies : deps_libratbag,
|
||||
version : libratbag_so_version,
|
||||
link_args : version_flag,
|
||||
link_depends : mapfile,
|
||||
install : true,
|
||||
)
|
||||
|
||||
dep_libratbag = declare_dependency(
|
||||
link_with : lib_libratbag,
|
||||
dependencies : deps_libratbag
|
||||
)
|
||||
|
||||
pkgconfigdata = configuration_data()
|
||||
pkgconfigdata.set('prefix', get_option('prefix'))
|
||||
pkgconfigdata.set('libdir', get_option('libdir'))
|
||||
pkgconfigdata.set('datadir', get_option('datadir'))
|
||||
pkgconfigdata.set('includedir', get_option('includedir'))
|
||||
pkgconfigdata.set('LIBRATBAG_VERSION', meson.project_version())
|
||||
pkgconfigfile = configure_file(
|
||||
input : 'src/libratbag.pc.in',
|
||||
output : 'libratbag.pc',
|
||||
configuration : pkgconfigdata,
|
||||
install : true,
|
||||
install_dir : get_option('libdir') + '/pkgconfig'
|
||||
)
|
||||
|
||||
#### libshared.a ####
|
||||
src_libshared = [
|
||||
'tools/shared.c',
|
||||
'tools/shared.h'
|
||||
]
|
||||
|
||||
deps_libshared = [
|
||||
dep_udev,
|
||||
dep_libevdev,
|
||||
]
|
||||
lib_libshared = static_library('shared',
|
||||
src_libshared,
|
||||
dependencies : deps_libshared,
|
||||
include_directories : include_directories('src')
|
||||
)
|
||||
dep_libshared = declare_dependency(link_with: lib_libshared)
|
||||
|
||||
#### ratbag-command ####
|
||||
src_ratbag_command = [ 'tools/ratbag-command.c' ]
|
||||
deps_ratbag_command = [
|
||||
dep_libshared,
|
||||
dep_libratbag,
|
||||
dep_libevdev
|
||||
]
|
||||
|
||||
executable('ratbag-command',
|
||||
src_ratbag_command,
|
||||
dependencies : deps_ratbag_command,
|
||||
include_directories : include_directories('src'),
|
||||
install : true,
|
||||
)
|
||||
|
||||
man_config = configuration_data()
|
||||
|
||||
man_config.set('version', meson.project_version())
|
||||
|
||||
man_ratbag_command = configure_file (
|
||||
input: 'tools/ratbag-command.man',
|
||||
output: 'ratbag-command.1',
|
||||
configuration: man_config,
|
||||
install : true,
|
||||
install_dir : join_paths(get_option('mandir'), 'man1')
|
||||
)
|
||||
|
||||
#### hidpp10-dump-page ####
|
||||
src_hidpp10_dump_page = [ 'tools/hidpp10-dump-page.c' ]
|
||||
executable('hidpp10-dump-page',
|
||||
src_hidpp10_dump_page,
|
||||
dependencies : [ dep_libhidpp ],
|
||||
include_directories : include_directories('src'),
|
||||
install : false,
|
||||
)
|
||||
|
||||
#### hidpp20-dump-page ####
|
||||
src_hidpp20_dump_page = [ 'tools/hidpp20-dump-page.c' ]
|
||||
executable('hidpp20-dump-page',
|
||||
src_hidpp20_dump_page,
|
||||
dependencies : [ dep_libhidpp ],
|
||||
include_directories : include_directories('src'),
|
||||
install : false,
|
||||
)
|
||||
|
||||
#### lur-command ####
|
||||
src_lur_command = [ 'tools/lur-command.c' ]
|
||||
executable('lur-command',
|
||||
src_lur_command,
|
||||
dependencies : [ dep_libshared, dep_liblur ],
|
||||
include_directories : include_directories('src'),
|
||||
install : true,
|
||||
)
|
||||
|
||||
#### hwdb ####
|
||||
udev_dir = get_option('udev-dir')
|
||||
if udev_dir == ''
|
||||
udev_dir = '@0@/lib/udev'.format(get_option('prefix'))
|
||||
endif
|
||||
udev_rules_dir = '@0@/rules.d'.format(udev_dir)
|
||||
udev_hwdb_dir = '@0@/hwdb.d'.format(udev_dir)
|
||||
|
||||
install_data('hwdb/70-libratbag-mouse.rules',
|
||||
install_dir : udev_rules_dir)
|
||||
install_data('hwdb/70-libratbag-mouse.hwdb',
|
||||
install_dir : udev_hwdb_dir)
|
||||
|
||||
#### svg files ####
|
||||
svg_files = [
|
||||
'data/etekcity.svg',
|
||||
'data/logitech-g300.svg',
|
||||
'data/logitech-g303.svg',
|
||||
'data/logitech-g500s.svg',
|
||||
'data/logitech-g502.svg',
|
||||
'data/logitech-g700.svg',
|
||||
'data/logitech-g900.svg',
|
||||
'data/logitech-mx_master.svg',
|
||||
'data/roccat-kone-xtd.svg'
|
||||
]
|
||||
install_data(svg_files,
|
||||
install_dir : '@0@/libratbag'.format(get_option('datadir')))
|
||||
|
||||
#### tests ####
|
||||
enable_tests = get_option('enable-tests')
|
||||
if enable_tests
|
||||
dep_check = dependency('check', version: '>= 0.9.10')
|
||||
|
||||
config_h.set('BUILD_TESTS', '1')
|
||||
env_test = ['RATBAG_TEST=1']
|
||||
valgrind_args = [ '--leak-check=full',
|
||||
'--quiet',
|
||||
'--error-exitcode=3',
|
||||
'--suppressions=@0@/test/valgrind.suppressions'.format(meson.current_source_dir()) ]
|
||||
|
||||
test_context = executable('test-context',
|
||||
['test/test-context.c'],
|
||||
dependencies : [ dep_libratbag, dep_check ],
|
||||
include_directories : include_directories('src'),
|
||||
install : false)
|
||||
test_device = executable('test-device',
|
||||
['test/test-device.c'],
|
||||
dependencies : [ dep_libratbag, dep_check ],
|
||||
include_directories : include_directories('src'),
|
||||
install : false)
|
||||
test_iconv_helper = executable('test-iconv-helper',
|
||||
['test/test-iconv-helper.c'],
|
||||
dependencies : [ dep_libratbag,
|
||||
dep_check,
|
||||
dep_libutil],
|
||||
include_directories : include_directories('src'),
|
||||
install : false)
|
||||
test('test-context', test_context, env : env_test, valgrind_args : valgrind_args)
|
||||
test('test-device', test_device, env : env_test, valgrind_args : valgrind_args)
|
||||
test('test-iconv-helper', test_iconv_helper, env : env_test, valgrind_args : valgrind_args)
|
||||
|
||||
executable('test-build-cxx',
|
||||
['test/build-cxx.cc'],
|
||||
dependencies : [ dep_libratbag ],
|
||||
include_directories : include_directories('src'),
|
||||
cpp_args : ['-Wall', '-Wextra', '-Wno-unused-parameter'],
|
||||
install : false)
|
||||
executable('test-build-linker',
|
||||
['test/build-pedantic.c'],
|
||||
dependencies : [ dep_libratbag ],
|
||||
include_directories : include_directories('src'),
|
||||
install : false)
|
||||
executable('test-build-gnuc90',
|
||||
['test/build-pedantic.c'],
|
||||
dependencies : [ dep_libratbag ],
|
||||
include_directories : include_directories('src'),
|
||||
c_args : ['-std=gnu90', '-Werror'],
|
||||
install : false)
|
||||
executable('test-build-pedantic',
|
||||
['test/build-pedantic.c'],
|
||||
dependencies : [ dep_libratbag ],
|
||||
include_directories : include_directories('src'),
|
||||
c_args : ['-std=c99', '-pedantic', '-Werror'],
|
||||
install : false)
|
||||
endif
|
||||
|
||||
test_symbols_leak = find_program('test/symbols-leak-test')
|
||||
test('symbols-leak-test',
|
||||
test_symbols_leak,
|
||||
args : [ meson.current_source_dir() ])
|
||||
|
||||
#### documentation ####
|
||||
enable_doc = get_option('enable-documentation')
|
||||
|
||||
if enable_doc
|
||||
cmd_doxygen = find_program('doxygen')
|
||||
cmd_dot = find_program('dot')
|
||||
|
||||
v = run_command(cmd_doxygen, ['--version']).stdout()
|
||||
if not v.version_compare('>=1.8.3')
|
||||
error('Doxygen $doxygen_version too old. ' +
|
||||
'Doxygen 1.8.3+ required for documentation build. ' +
|
||||
'Install required doxygen version or ' +
|
||||
'disable the documentation using --disable-documentation')
|
||||
endif
|
||||
|
||||
v = run_command(cmd_dot, ['-V']).stderr()
|
||||
v = v.split(' ')[4]
|
||||
if v.version_compare('<2.26.0')
|
||||
error('Graphviz dot $dot_version too old. ' +
|
||||
'Graphviz 2.26+ required for documentation build. ' +
|
||||
'Install required graphviz version or ' +
|
||||
'disable the documentation using --disable-documentation')
|
||||
endif
|
||||
|
||||
doc_config = configuration_data()
|
||||
doc_config.set('PACKAGE_NAME', meson.project_name())
|
||||
doc_config.set('PACKAGE_VERSION', meson.project_version())
|
||||
doc_config.set('top_srcdir', meson.source_root())
|
||||
|
||||
doxyfile = configure_file(input : 'doc/libratbag.doxygen.in',
|
||||
output : 'libratbag.doxygen',
|
||||
configuration : doc_config,
|
||||
install : false)
|
||||
src_doxygen = [ doxyfile,
|
||||
'src/libratbag.h',
|
||||
'README.md']
|
||||
custom_target('doxygen',
|
||||
input : src_doxygen,
|
||||
output : [ 'html' ],
|
||||
command : [ cmd_doxygen, doxyfile ],
|
||||
install : false,
|
||||
build_by_default : true)
|
||||
endif
|
||||
|
||||
#### output files ####
|
||||
configure_file(output: 'config.h', install: false, configuration: config_h)
|
||||
14
meson_options.txt
Normal file
14
meson_options.txt
Normal file
@@ -0,0 +1,14 @@
|
||||
option('udev-dir',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: 'udev base directory [default=$prefix/lib/udev]')
|
||||
|
||||
option('enable-tests',
|
||||
type: 'boolean',
|
||||
value: true,
|
||||
description: 'Build the tests (default=yes)')
|
||||
|
||||
option('enable-documentation',
|
||||
type: 'boolean',
|
||||
value: true,
|
||||
description: 'Build the documentation (default=yes)')
|
||||
38
release.sh
38
release.sh
@@ -342,19 +342,9 @@ process_module() {
|
||||
return 1
|
||||
fi
|
||||
|
||||
# Run 'make dist/distcheck' to ensure the tarball matches the git module content
|
||||
# Important to run make dist/distcheck before looking in Makefile, may need to reconfigure
|
||||
echo "Info: running \"make $MAKE_DIST_CMD\" to create tarballs:"
|
||||
${MAKE} $MAKEFLAGS $MAKE_DIST_CMD > /dev/null
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Error: \"$MAKE $MAKEFLAGS $MAKE_DIST_CMD\" failed."
|
||||
cd $top_src
|
||||
return 1
|
||||
fi
|
||||
|
||||
# Find out the tarname from the makefile
|
||||
pkg_name=`$GREP '^PACKAGE = ' Makefile | sed 's|PACKAGE = ||'`
|
||||
pkg_version=`$GREP '^VERSION = ' Makefile | sed 's|VERSION = ||'`
|
||||
# Find out the tarname from meson.build
|
||||
pkg_name=$($GREP '^project(' meson.build | sed 's|project(\([^\s,]*\).*|\1|' | sed "s/'//g")
|
||||
pkg_version=$($GREP -m 1 '^ version : ' meson.build | sed 's| version : \([^\s,]*\).*|\1|' | sed "s/'//g")
|
||||
tar_name="$pkg_name-$pkg_version"
|
||||
targz=$tar_name.tar.gz
|
||||
tag_name=$(echo "v$pkg_version" | sed 's|.0$||')
|
||||
@@ -497,17 +487,11 @@ Usage: $basename [options] path...
|
||||
Where "path" is a relative path to a git module, including '.'.
|
||||
|
||||
Options:
|
||||
--dist make 'dist' instead of 'distcheck'; use with caution
|
||||
--distcheck Default, ignored for compatibility
|
||||
--dry-run Does everything except tagging and uploading tarballs
|
||||
--force Force overwriting an existing release
|
||||
--help Display this help and exit successfully
|
||||
--no-quit Do not quit after error; just print error message
|
||||
|
||||
Environment variables defined by the "make" program and used by release.sh:
|
||||
MAKE The name of the make command [make]
|
||||
MAKEFLAGS: Options to pass to all \$(MAKE) invocations
|
||||
|
||||
HELP
|
||||
}
|
||||
|
||||
@@ -516,9 +500,6 @@ HELP
|
||||
#------------------------------------------------------------------------------
|
||||
#
|
||||
|
||||
# Choose which make program to use (could be gmake)
|
||||
MAKE=${MAKE:="make"}
|
||||
|
||||
# Choose which grep program to use (on Solaris, must be gnu grep)
|
||||
if [ "x$GREP" = "x" ] ; then
|
||||
if [ -x /usr/gnu/bin/grep ] ; then
|
||||
@@ -528,23 +509,10 @@ if [ "x$GREP" = "x" ] ; then
|
||||
fi
|
||||
fi
|
||||
|
||||
# Set the default make tarball creation command
|
||||
MAKE_DIST_CMD=distcheck
|
||||
|
||||
# Process command line args
|
||||
while [ $# != 0 ]
|
||||
do
|
||||
case $1 in
|
||||
# Use 'dist' rather than 'distcheck' to create tarballs
|
||||
# You really only want to do this if you're releasing a module you can't
|
||||
# possibly build-test. Please consider carefully the wisdom of doing so.
|
||||
--dist)
|
||||
MAKE_DIST_CMD=dist
|
||||
;;
|
||||
# Use 'distcheck' to create tarballs
|
||||
--distcheck)
|
||||
MAKE_DIST_CMD=distcheck
|
||||
;;
|
||||
# Does everything except uploading tarball
|
||||
--dry-run)
|
||||
DRY_RUN=yes
|
||||
|
||||
@@ -8,6 +8,18 @@
|
||||
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y valgrind check libevdev-dev libudev-dev doxygen graphviz
|
||||
autoreconf -ivf
|
||||
./configure --prefix=$PWD/_build --with-udev-base-dir=$PWD/_build
|
||||
DISTCHECK_CONFIGURE_FLAGS="--with-udev-base-dir=$PWD/_build" make distcheck
|
||||
|
||||
# no meson on 14.04
|
||||
sudo apt-get install -y python3-pip
|
||||
sudo pip3 install meson
|
||||
|
||||
# ninja on 14.04 is too old
|
||||
git clone git://github.com/ninja-build/ninja.git
|
||||
cd ninja
|
||||
git checkout release
|
||||
./configure.py --bootstrap
|
||||
sudo cp ninja /usr/bin/ninja
|
||||
cd ..
|
||||
|
||||
meson builddir
|
||||
ninja -C builddir test
|
||||
|
||||
@@ -1,78 +0,0 @@
|
||||
lib_LTLIBRARIES = libratbag.la \
|
||||
liblur.la
|
||||
noinst_LTLIBRARIES = libhidpp.la \
|
||||
libutil.la
|
||||
|
||||
include_HEADERS = \
|
||||
libratbag.h \
|
||||
liblur.h
|
||||
|
||||
libratbag_la_SOURCES = \
|
||||
driver-etekcity.c \
|
||||
driver-hidpp20.c \
|
||||
driver-hidpp10.c \
|
||||
driver-logitech-g300.c \
|
||||
driver-roccat.c \
|
||||
driver-gskill.c \
|
||||
driver-test.c \
|
||||
libratbag.c \
|
||||
libratbag.h \
|
||||
libratbag-hidraw.c \
|
||||
libratbag-hidraw.h \
|
||||
libratbag-private.h \
|
||||
libratbag-test.c \
|
||||
libratbag-test.h \
|
||||
usb-ids.h
|
||||
|
||||
libratbag_la_LIBADD = \
|
||||
libhidpp.la \
|
||||
libutil.la \
|
||||
$(LIBUDEV_LIBS) $(LIBEVDEV_LIBS)
|
||||
|
||||
libratbag_la_CFLAGS = -I$(top_srcdir)/include \
|
||||
$(LIBUDEV_CFLAGS) \
|
||||
$(LIBEVDEV_CFLAGS) \
|
||||
$(GCC_CFLAGS)
|
||||
EXTRA_libratbag_la_DEPENDENCIES = $(srcdir)/libratbag.sym
|
||||
|
||||
libratbag_la_LDFLAGS = -version-info $(LIBRATBAG_LT_VERSION) -shared \
|
||||
-Wl,--version-script=$(srcdir)/libratbag.sym
|
||||
|
||||
liblur_la_SOURCES = \
|
||||
liblur.c \
|
||||
liblur.h
|
||||
liblur_la_LIBADD = \
|
||||
libhidpp.la \
|
||||
libutil.la
|
||||
liblur_la_CFLAGS = \
|
||||
-I$(top_srcdir)/include \
|
||||
$(GCC_CFLAGS)
|
||||
EXTRA_liblur_la_DEPENDENCIES = $(srcdir)/liblur.sym
|
||||
|
||||
liblur_la_LDFLAGS = -version-info $(LIBLUR_LT_VERSION) -shared \
|
||||
-Wl,--version-script=$(srcdir)/liblur.sym
|
||||
|
||||
pkgconfigdir = $(libdir)/pkgconfig
|
||||
pkgconfig_DATA = libratbag.pc \
|
||||
liblur.pc
|
||||
|
||||
AM_CFLAGS = $(GCC_CFLAGS)
|
||||
|
||||
DISTCLEANFILES = libratbag-version.h
|
||||
EXTRA_DIST = libratbag-version.h.in libratbag.sym liblur.sym
|
||||
|
||||
# The hidpp libraries are static libraries only for in-tree tools. No API
|
||||
# stability is guaranteed here.
|
||||
libhidpp_la_SOURCES = \
|
||||
hidpp-generic.h \
|
||||
hidpp-generic.c \
|
||||
hidpp10.h \
|
||||
hidpp10.c \
|
||||
hidpp20.h \
|
||||
hidpp20.c \
|
||||
usb-ids.h
|
||||
libhidpp_la_LDFLAGS = -lm
|
||||
libutil_la_SOURCES = \
|
||||
libratbag-util.c \
|
||||
libratbag-util.h
|
||||
libutil_la_LIBADD = $(LIBUDEV_LIBS)
|
||||
@@ -731,8 +731,10 @@ gskill_macro_from_report(struct ratbag_device *device,
|
||||
ret = ratbag_utf8_from_enc(report->macro_name,
|
||||
report->macro_name_length, "UTF-16LE",
|
||||
¯o->macro.name);
|
||||
if (ret < 0)
|
||||
if (ret < 0) {
|
||||
ratbag_button_macro_unref(macro);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
for (i = 0, event_idx = 0, increment = 1;
|
||||
i < report->macro_length;
|
||||
|
||||
@@ -909,12 +909,15 @@ hidpp20_log(void *userdata, enum hidpp_log_priority priority, const char *format
|
||||
static void
|
||||
hidpp20drv_remove(struct ratbag_device *device)
|
||||
{
|
||||
struct hidpp20drv_data *drv_data = ratbag_get_drv_data(device);
|
||||
struct hidpp20_device *dev = drv_data->dev;
|
||||
struct hidpp20drv_data *drv_data;
|
||||
struct hidpp20_device *dev;
|
||||
|
||||
if (!device)
|
||||
return;
|
||||
|
||||
drv_data = ratbag_get_drv_data(device);
|
||||
dev = drv_data->dev;
|
||||
|
||||
ratbag_close_hidraw(device);
|
||||
|
||||
if (drv_data->profiles)
|
||||
|
||||
@@ -303,6 +303,7 @@ roccat_wait_ready(struct ratbag_device *device)
|
||||
return 2;
|
||||
|
||||
msleep(10);
|
||||
count++;
|
||||
}
|
||||
|
||||
return -ETIMEDOUT;
|
||||
|
||||
@@ -26,13 +26,12 @@
|
||||
* https://drive.google.com/folderview?id=0BxbRzx7vEV7eWmgwazJ3NUFfQ28&usp=sharing
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdarg.h>
|
||||
#include <stddef.h>
|
||||
|
||||
#ifndef HIDPP_GENERIC_H
|
||||
#define HIDPP_GENERIC_H
|
||||
|
||||
#define HIDPP_RECEIVER_IDX 0xFF
|
||||
#define HIDPP_WIRED_DEVICE_IDX 0x00
|
||||
|
||||
@@ -211,5 +210,3 @@ hidpp_get_unaligned_be_u32(uint8_t *buf)
|
||||
{
|
||||
return (buf[0] << 24) | (buf[1] << 16) | (buf[2] << 8) | buf[3];
|
||||
}
|
||||
|
||||
#endif /* HIDPP_GENERIC_H */
|
||||
|
||||
@@ -1397,7 +1397,7 @@ hidpp10_profile_set_names(struct hidpp10_device *dev, struct hidpp10_profile *pr
|
||||
memcpy(metadata->lgs02.marker, "LGS02", sizeof(metadata->lgs02.marker));
|
||||
hidpp10_uchar8_to_uchar16(metadata->lgs02.name,
|
||||
profile->name,
|
||||
sizeof(metadata->lgs02.name));
|
||||
ARRAY_LENGTH(metadata->lgs02.name));
|
||||
for (i = 0; i < ARRAY_LENGTH(metadata->lgs02.macro_names); i++) {
|
||||
hidpp10_uchar8_to_uchar16(metadata->lgs02.macro_names[i],
|
||||
profile->macro_names[i],
|
||||
|
||||
@@ -26,8 +26,7 @@
|
||||
* https://drive.google.com/folderview?id=0BxbRzx7vEV7eWmgwazJ3NUFfQ28&usp=sharing
|
||||
*/
|
||||
|
||||
#ifndef HIDPP_10_H
|
||||
#define HIDPP_10_H
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
@@ -695,5 +694,3 @@ hidpp10_get_firmare_information(struct hidpp10_device *dev,
|
||||
uint8_t *major,
|
||||
uint8_t *minor,
|
||||
uint8_t *build_number);
|
||||
|
||||
#endif /* HIDPP_10_H */
|
||||
|
||||
@@ -1583,8 +1583,8 @@ hidpp20_onboard_profiles_parse_macro(struct hidpp20_device *device,
|
||||
}
|
||||
|
||||
static unsigned int
|
||||
hidpp20_onboard_profiles_compute_dict_size(struct hidpp20_device *device,
|
||||
struct hidpp20_profiles *profiles)
|
||||
hidpp20_onboard_profiles_compute_dict_size(const struct hidpp20_device *device,
|
||||
const struct hidpp20_profiles *profiles)
|
||||
{
|
||||
unsigned p, num_offset;
|
||||
|
||||
|
||||
@@ -26,8 +26,7 @@
|
||||
* https://drive.google.com/folderview?id=0BxbRzx7vEV7eWmgwazJ3NUFfQ28&usp=sharing
|
||||
*/
|
||||
|
||||
#ifndef HIDPP_20_H
|
||||
#define HIDPP_20_H
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
@@ -544,5 +543,3 @@ hidpp20_onboard_profiles_read_memory(struct hidpp20_device *device,
|
||||
#define HIDPP_PAGE_MOUSE_BUTTON_SPY 0x8110
|
||||
|
||||
|
||||
|
||||
#endif /* HIDPP_20_H */
|
||||
|
||||
11
src/liblur.c
11
src/liblur.c
@@ -38,6 +38,13 @@
|
||||
#define _EXPORT_ __attribute__ ((visibility("default")))
|
||||
#define MAX_DEVICES 6
|
||||
|
||||
static inline void
|
||||
cleanup_hidpp10_device_destroy(struct hidpp10_device **hidpp10_device) {
|
||||
if (*hidpp10_device)
|
||||
hidpp10_device_destroy(*hidpp10_device);
|
||||
}
|
||||
#define _cleanup_hidpp10_device_destroy_ _cleanup_(cleanup_hidpp10_device_destroy)
|
||||
|
||||
struct lur_receiver {
|
||||
int refcount;
|
||||
int fd;
|
||||
@@ -186,7 +193,7 @@ lur_receiver_enumerate(struct lur_receiver *lur,
|
||||
dev->present = false;
|
||||
|
||||
for (i = 0; i < MAX_DEVICES; i++) {
|
||||
struct hidpp10_device *d;
|
||||
_cleanup_hidpp10_device_destroy_ struct hidpp10_device *d;
|
||||
size_t name_size = 64;
|
||||
char name[name_size];
|
||||
uint8_t interval, type;
|
||||
@@ -240,8 +247,6 @@ lur_receiver_enumerate(struct lur_receiver *lur,
|
||||
dev->present = true;
|
||||
list_insert(&lur->devices, &dev->node);
|
||||
}
|
||||
|
||||
hidpp10_device_destroy(d);
|
||||
}
|
||||
|
||||
devices = zalloc(MAX_DEVICES * sizeof(*devices));
|
||||
|
||||
@@ -23,8 +23,7 @@
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef _LIBLUR_H_
|
||||
#define _LIBLUR_H_ 1
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@@ -268,4 +267,3 @@ lur_device_get_user_data(const struct lur_device *dev);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
prefix=@prefix@
|
||||
exec_prefix=@exec_prefix@
|
||||
datarootdir=@datarootdir@
|
||||
pkgdatadir=@datadir@/@PACKAGE@
|
||||
libdir=@libdir@
|
||||
includedir=@includedir@
|
||||
|
||||
Name: Liblur
|
||||
Description: Logitech Unifying Receiver configuration library
|
||||
Version: @LIBRATBAG_VERSION@
|
||||
Cflags: -I${includedir}
|
||||
Libs: -L${libdir} -llur
|
||||
Libs.private: -lm -lrt
|
||||
@@ -1405,7 +1405,7 @@ ratbag_find_hidraw_node(struct ratbag_device *device,
|
||||
udev_enumerate_add_match_parent(e, parent_udev);
|
||||
udev_enumerate_scan_devices(e);
|
||||
udev_list_entry_foreach(entry, udev_enumerate_get_list_entry(e)) {
|
||||
_cleanup_udev_device_unref_ struct udev_device *udev_device;
|
||||
_cleanup_udev_device_unref_ struct udev_device *udev_device = NULL;
|
||||
|
||||
path = udev_list_entry_get_name(entry);
|
||||
udev_device = udev_device_new_from_syspath(udev, path);
|
||||
|
||||
@@ -21,8 +21,7 @@
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef LIBRATBAG_HIDRAW_H
|
||||
#define LIBRATBAG_HIDRAW_H
|
||||
#pragma once
|
||||
|
||||
#include <linux/hid.h>
|
||||
#include <stdint.h>
|
||||
@@ -186,4 +185,3 @@ ratbag_hidraw_get_keycode_from_consumer_usage(struct ratbag_device *device,
|
||||
uint16_t
|
||||
ratbag_hidraw_get_consumer_usage_from_keycode(struct ratbag_device *device,
|
||||
unsigned keycode);
|
||||
#endif /* LIBRATBAG_HIDRAW_H */
|
||||
|
||||
@@ -21,8 +21,7 @@
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef LIBRATBAG_PRIVATE_H
|
||||
#define LIBRATBAG_PRIVATE_H
|
||||
#pragma once
|
||||
|
||||
#include <linux/input.h>
|
||||
#include <stdint.h>
|
||||
@@ -491,5 +490,3 @@ void
|
||||
ratbag_button_copy_macro(struct ratbag_button *button,
|
||||
const struct ratbag_button_macro *macro);
|
||||
|
||||
#endif /* LIBRATBAG_PRIVATE_H */
|
||||
|
||||
|
||||
@@ -22,8 +22,7 @@
|
||||
*/
|
||||
|
||||
|
||||
#ifndef LIBRATBAG_TEST_H
|
||||
#define LIBRATBAG_TEST_H
|
||||
#pragma once
|
||||
|
||||
#include "libratbag.h"
|
||||
|
||||
@@ -84,4 +83,3 @@ struct ratbag_test_device {
|
||||
struct ratbag_device* ratbag_device_new_test_device(struct ratbag *ratbag,
|
||||
struct ratbag_test_device *test_device);
|
||||
|
||||
#endif /* LIBRATBAG_TEST_H */
|
||||
|
||||
@@ -144,7 +144,7 @@ ratbag_utf8_from_enc(char *in_buf, size_t in_len, const char *from_enc,
|
||||
/*
|
||||
* We *could* dynamically allocate the out buffer. However iconv's
|
||||
* obnoxious semantics, mainly the fact that it modifies every pointer
|
||||
* given to it, would make this code a lot larger and complex then it
|
||||
* given to it, would make this code a lot larger and complex than it
|
||||
* needs to be for a mouse with blinking lights.
|
||||
*
|
||||
* So, since there's no encoding that takes more then 6 bytes per
|
||||
|
||||
@@ -21,8 +21,7 @@
|
||||
* OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef LIBRATBAG_UTIL_H
|
||||
#define LIBRATBAG_UTIL_H
|
||||
#pragma once
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
@@ -217,4 +216,3 @@ ratbag_utf8_to_enc(char *buf, size_t buf_len, const char *to_enc,
|
||||
ssize_t
|
||||
ratbag_utf8_from_enc(char *in_buf, size_t in_len, const char *from_enc,
|
||||
char **out);
|
||||
#endif /* LIBRATBAG_UTIL_H */
|
||||
|
||||
@@ -1,32 +0,0 @@
|
||||
/*
|
||||
* Copyright © 2013 Jonas Ådahl
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice (including the next
|
||||
* paragraph) shall be included in all copies or substantial portions of the
|
||||
* Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef LIBRATBAG_VERSION_H
|
||||
#define LIBRATBAG_VERSION_H
|
||||
|
||||
#define LIBRATBAG_VERSION_MAJOR @LIBRATBAG_VERSION_MAJOR@
|
||||
#define LIBRATBAG_VERSION_MINOR @LIBRATBAG_VERSION_MINOR@
|
||||
#define LIBRATBAG_VERSION_MICRO @LIBRATBAG_VERSION_MICRO@
|
||||
#define LIBRATBAG_VERSION "@LIBRATBAG_VERSION@"
|
||||
|
||||
#endif
|
||||
@@ -1292,7 +1292,7 @@ ratbag_button_set_key(struct ratbag_button *button,
|
||||
LIBRATBAG_EXPORT enum ratbag_error_code
|
||||
ratbag_button_disable(struct ratbag_button *button)
|
||||
{
|
||||
struct ratbag_button_action action;
|
||||
struct ratbag_button_action action = {0};
|
||||
|
||||
if (!ratbag_device_has_capability(button->profile->device,
|
||||
RATBAG_DEVICE_CAP_BUTTON_KEY))
|
||||
|
||||
@@ -21,8 +21,7 @@
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef LIBRATBAG_H
|
||||
#define LIBRATBAG_H
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@@ -1818,4 +1817,3 @@ ratbag_led_unref(struct ratbag_led *led);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* LIBRATBAG_H */
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
prefix=@prefix@
|
||||
exec_prefix=@exec_prefix@
|
||||
datarootdir=@datarootdir@
|
||||
pkgdatadir=@datadir@/@PACKAGE@
|
||||
libdir=@libdir@
|
||||
includedir=@includedir@
|
||||
datadir=${prefix}/@datadir@
|
||||
pkgdatadir=${datadir}/libratbag
|
||||
libdir=${prefix}/@libdir@
|
||||
includedir=${prefix}/@includedir@
|
||||
|
||||
Name: Libratbag
|
||||
Description: Mouse configuration library
|
||||
|
||||
@@ -20,10 +20,7 @@
|
||||
* OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef USB_IDS_H
|
||||
#define USB_IDS_H
|
||||
#pragma once
|
||||
|
||||
#define USB_VENDOR_ID_LOGITECH 0x046d
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -1,70 +0,0 @@
|
||||
if BUILD_TESTS
|
||||
AM_CPPFLAGS = -I$(top_srcdir)/include \
|
||||
-I$(top_srcdir)/src \
|
||||
$(CHECK_CFLAGS) \
|
||||
$(LIBEVDEV_CFLAGS)
|
||||
|
||||
AM_CFLAGS = $(GCC_CFLAGS)
|
||||
AM_CXXFLAGS = $(GCC_CXXFLAGS)
|
||||
|
||||
TEST_LIBS = $(CHECK_LIBS) $(LIBEVDEV_LIBS) $(top_builddir)/src/libratbag.la
|
||||
|
||||
run_tests = \
|
||||
test-context \
|
||||
test-device \
|
||||
test-iconv-helper
|
||||
|
||||
build_tests = \
|
||||
test-build-cxx \
|
||||
test-build-linker \
|
||||
test-build-pedantic-c99 \
|
||||
test-build-std-gnuc90
|
||||
|
||||
noinst_PROGRAMS = $(build_tests) $(run_tests)
|
||||
noinst_SCRIPTS = symbols-leak-test
|
||||
TESTS = $(run_tests) symbols-leak-test
|
||||
|
||||
test_context_SOURCES = test-context.c
|
||||
test_context_LDADD = $(TEST_LIBS)
|
||||
test_context_LDFLAGS = -no-install
|
||||
|
||||
test_device_SOURCES = test-device.c
|
||||
test_device_LDADD = $(TEST_LIBS)
|
||||
test_device_LDFLAGS = -no-install
|
||||
|
||||
test_iconv_helper_SOURCES = test-iconv-helper.c
|
||||
test_iconv_helper_LDADD = $(TEST_LIBS) $(top_builddir)/src/libutil.la
|
||||
test_iconv_helper_LDFLAGS = -no-install
|
||||
|
||||
# build-test only
|
||||
test_build_pedantic_c99_SOURCES = build-pedantic.c
|
||||
test_build_pedantic_c99_CFLAGS = -std=c99 -pedantic -Werror
|
||||
|
||||
test_build_std_gnuc90_SOURCES = build-pedantic.c
|
||||
test_build_std_gnuc90_CFLAGS = -std=gnu90 -Werror
|
||||
|
||||
# test for linking with the minimal linker flags
|
||||
test_build_linker_SOURCES = build-pedantic.c
|
||||
test_build_linker_CFLAGS = -I$(top_srcdir)/src
|
||||
test_build_linker_LDADD = $(top_builddir)/src/libratbag.la
|
||||
|
||||
# test including from C++
|
||||
test_build_cxx_SOURCES = build-cxx.cc
|
||||
test_build_cxx_CXXFLAGS = -Wall -Wextra -Wno-unused-parameter $(AM_CXXFLAGS)
|
||||
|
||||
AM_TESTS_ENVIRONMENT=RATBAG_TEST=1; export RATBAG_TEST;
|
||||
|
||||
if HAVE_VALGRIND
|
||||
VALGRIND_FLAGS=--leak-check=full \
|
||||
--quiet \
|
||||
--error-exitcode=3 \
|
||||
--suppressions=$(srcdir)/valgrind.suppressions
|
||||
|
||||
valgrind:
|
||||
$(MAKE) check-TESTS LOG_COMPILER="$(VALGRIND)" LOG_FLAGS="$(VALGRIND_FLAGS)" CK_FORK=no USING_VALGRIND=yes
|
||||
|
||||
check: valgrind
|
||||
|
||||
endif
|
||||
endif
|
||||
EXTRA_DIST=valgrind.suppressions
|
||||
13
test/symbols-leak-test.in → test/symbols-leak-test
Normal file → Executable file
13
test/symbols-leak-test.in → test/symbols-leak-test
Normal file → Executable file
@@ -2,16 +2,21 @@
|
||||
|
||||
### simple check for exported symbols
|
||||
|
||||
TOP_SRCDIR="$1"
|
||||
|
||||
if [ -z "$TOP_SRCDIR" ]; then
|
||||
echo "usage: $0 path/to/top_srcdir"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# make bash exit if any command will exit with non-0 return value
|
||||
set -e
|
||||
|
||||
# make sure the paths are alright
|
||||
cd `dirname $0`
|
||||
|
||||
diff -a -u \
|
||||
<(cat @top_srcdir@/src/libratbag.sym | \
|
||||
<(cat "$TOP_SRCDIR"/src/libratbag.sym | \
|
||||
grep '^\s\+ratbag_.*' | \
|
||||
sed -e 's/^\s\+\(.*\);/\1/' | sort) \
|
||||
<(cat @top_srcdir@/src/*.c | \
|
||||
<(cat "$TOP_SRCDIR"/src/*.c | \
|
||||
grep LIBRATBAG_EXPORT -A 1 | grep '^ratbag_.*' | \
|
||||
sed -e 's/(.*//' | sort)
|
||||
@@ -1,32 +0,0 @@
|
||||
noinst_PROGRAMS = hidpp10-dump-page hidpp20-dump-page
|
||||
bin_PROGRAMS = ratbag-command lur-command
|
||||
noinst_LTLIBRARIES = libshared.la
|
||||
|
||||
AM_CPPFLAGS = -I$(top_srcdir)/include \
|
||||
-I$(top_srcdir)/src \
|
||||
-I$(top_builddir)/src # for libratbag-version.h
|
||||
|
||||
libshared_la_SOURCES = \
|
||||
shared.c \
|
||||
shared.h
|
||||
libshared_la_CFLAGS = $(LIBUDEV_LIBS) $(LIBEVDEV_CFLAGS)
|
||||
libshared_la_LIBADD = $(LIBUDEV_CFLAGS) $(LIBEVDEV_LIBS)
|
||||
|
||||
ratbag_command_SOURCES = ratbag-command.c
|
||||
ratbag_command_LDADD = ../src/libratbag.la libshared.la $(LIBUDEV_LIBS) $(LIBEVDEV_LIBS)
|
||||
ratbag_command_CFLAGS = $(LIBUDEV_CFLAGS) $(LIBEVDEV_CFLAGS)
|
||||
dist_man1_MANS = ratbag-command.man
|
||||
|
||||
hidpp10_dump_page_SOURCES = hidpp10-dump-page.c
|
||||
hidpp10_dump_page_LDADD = ../src/libhidpp.la
|
||||
hidpp10_dump_page_LDFLAGS = -no-install
|
||||
hidpp10_dump_page_CFLAGS = -I$(top_srcdir)/src
|
||||
|
||||
hidpp20_dump_page_SOURCES = hidpp20-dump-page.c
|
||||
hidpp20_dump_page_LDADD = ../src/libhidpp.la
|
||||
hidpp20_dump_page_LDFLAGS = -no-install
|
||||
hidpp20_dump_page_CFLAGS = -I$(top_srcdir)/src
|
||||
|
||||
lur_command_SOURCeS = lur-command.c
|
||||
lur_command_LDADD = ../src/liblur.la
|
||||
lur_command_CFLAGS = -I$(top_srcdir)/src
|
||||
@@ -71,7 +71,7 @@ dump_all_pages(struct hidpp10_device *dev)
|
||||
return rc;
|
||||
}
|
||||
|
||||
void
|
||||
static void
|
||||
usage(void)
|
||||
{
|
||||
printf("Usage: %s [page] [offset] /dev/hidraw0\n", program_invocation_short_name);
|
||||
@@ -80,7 +80,7 @@ usage(void)
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
_cleanup_close_ int fd;
|
||||
_cleanup_close_ int fd = 0;
|
||||
const char *path;
|
||||
size_t page = 0, offset = 0;
|
||||
struct hidpp10_device *dev = NULL;
|
||||
|
||||
@@ -83,7 +83,7 @@ dump_everything(struct hidpp20_device *dev)
|
||||
return dump_all_pages(dev, 1);
|
||||
}
|
||||
|
||||
void
|
||||
static void
|
||||
usage(void)
|
||||
{
|
||||
printf("Usage: %s [page] [offset] /dev/hidraw0\n", program_invocation_short_name);
|
||||
@@ -92,7 +92,7 @@ usage(void)
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
_cleanup_close_ int fd;
|
||||
_cleanup_close_ int fd = 0;
|
||||
const char *path;
|
||||
size_t page = 0, offset = 0;
|
||||
struct hidpp20_device *dev = NULL;
|
||||
|
||||
@@ -119,7 +119,7 @@ disconnect_device(struct lur_receiver *receiver, int index)
|
||||
return;
|
||||
}
|
||||
|
||||
if (index >= ndevices) {
|
||||
if (index < 0 || index >= ndevices) {
|
||||
fprintf(stderr, "Invalid index %d, only %d devices connected\n",
|
||||
index, ndevices);
|
||||
} else {
|
||||
|
||||
@@ -21,7 +21,8 @@
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#define _GNU_SOURCE
|
||||
#include "config.h"
|
||||
|
||||
#include <errno.h>
|
||||
#include <dirent.h>
|
||||
#include <fcntl.h>
|
||||
@@ -34,9 +35,11 @@
|
||||
#include <sys/stat.h>
|
||||
#include <linux/input.h>
|
||||
|
||||
#include "libratbag-version.h"
|
||||
#include "shared.h"
|
||||
|
||||
enum options {
|
||||
OPT_VERSION,
|
||||
OPT_VERBOSE,
|
||||
OPT_HELP,
|
||||
};
|
||||
@@ -186,6 +189,12 @@ usage(void)
|
||||
program_invocation_short_name);
|
||||
}
|
||||
|
||||
static void
|
||||
version(void)
|
||||
{
|
||||
printf("%s\n", LIBRATBAG_VERSION);
|
||||
}
|
||||
|
||||
static inline int
|
||||
ratbag_cmd_device_from_arg(struct ratbag *ratbag,
|
||||
int *argc, char **argv,
|
||||
@@ -216,9 +225,8 @@ static inline struct ratbag_profile *
|
||||
ratbag_cmd_get_active_profile(struct ratbag_device *device)
|
||||
{
|
||||
struct ratbag_profile *profile = NULL;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < ratbag_device_get_num_profiles(device); i++) {
|
||||
for (unsigned int i = 0; i < ratbag_device_get_num_profiles(device); i++) {
|
||||
profile = ratbag_device_get_profile(device, i);
|
||||
if (ratbag_profile_is_active(profile))
|
||||
return profile;
|
||||
@@ -237,9 +245,8 @@ static inline struct ratbag_resolution *
|
||||
ratbag_cmd_get_active_resolution(struct ratbag_profile *profile)
|
||||
{
|
||||
struct ratbag_resolution *resolution = NULL;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < ratbag_profile_get_num_resolutions(profile); i++) {
|
||||
for (unsigned int i = 0; i < ratbag_profile_get_num_resolutions(profile); i++) {
|
||||
resolution = ratbag_profile_get_resolution(profile, i);
|
||||
if (ratbag_resolution_is_active(resolution))
|
||||
return resolution;
|
||||
@@ -341,7 +348,7 @@ ratbag_cmd_info(const struct ratbag_cmd *cmd,
|
||||
struct ratbag_led *led;
|
||||
char *action;
|
||||
int num_profiles, num_buttons, num_leds;
|
||||
int i, j, b, l;
|
||||
int b, l;
|
||||
struct ratbag_color color;
|
||||
|
||||
device = options->device;
|
||||
@@ -375,7 +382,7 @@ ratbag_cmd_info(const struct ratbag_cmd *cmd,
|
||||
num_profiles = ratbag_device_get_num_profiles(device);
|
||||
printf("Profiles supported: %d\n", num_profiles);
|
||||
|
||||
for (i = 0; i < num_profiles; i++) {
|
||||
for (int i = 0; i < num_profiles; i++) {
|
||||
int dpi, rate;
|
||||
profile = ratbag_device_get_profile(device, i);
|
||||
if (!profile)
|
||||
@@ -385,7 +392,7 @@ ratbag_cmd_info(const struct ratbag_cmd *cmd,
|
||||
ratbag_profile_is_enabled(profile) ? "enabled" : "disabled",
|
||||
ratbag_profile_is_active(profile) ? " (active)" : "");
|
||||
printf(" Resolutions:\n");
|
||||
for (j = 0; j < ratbag_profile_get_num_resolutions(profile); j++) {
|
||||
for (unsigned int j = 0; j < ratbag_profile_get_num_resolutions(profile); j++) {
|
||||
struct ratbag_resolution *res;
|
||||
|
||||
res = ratbag_profile_get_resolution(profile, j);
|
||||
@@ -436,7 +443,7 @@ ratbag_cmd_info(const struct ratbag_cmd *cmd,
|
||||
led = ratbag_led_unref(led);
|
||||
}
|
||||
|
||||
profile = ratbag_profile_unref(profile);
|
||||
ratbag_profile_unref(profile);
|
||||
}
|
||||
|
||||
return SUCCESS;
|
||||
@@ -518,7 +525,7 @@ str_to_macro(const char *action_arg, struct macro *m)
|
||||
char *str, *s;
|
||||
enum ratbag_macro_event_type type;
|
||||
int code;
|
||||
int idx = 0;
|
||||
unsigned int idx = 0;
|
||||
int rc = ERR_USAGE;
|
||||
|
||||
/* FIXME: handle per-device maximum lengths of macros */
|
||||
@@ -606,10 +613,9 @@ ratbag_cmd_change_button(const struct ratbag_cmd *cmd,
|
||||
int button_index;
|
||||
enum ratbag_button_action_type action_type;
|
||||
int rc = ERR_DEVICE;
|
||||
unsigned int btnkey;
|
||||
unsigned int btnkey = 0;
|
||||
enum ratbag_button_action_special special;
|
||||
struct macro macro = {0};
|
||||
int i;
|
||||
|
||||
if (argc != 3)
|
||||
return ERR_USAGE;
|
||||
@@ -678,7 +684,7 @@ ratbag_cmd_change_button(const struct ratbag_cmd *cmd,
|
||||
break;
|
||||
case RATBAG_BUTTON_ACTION_TYPE_MACRO:
|
||||
m = ratbag_button_macro_new(macro.name);
|
||||
for (i = 0; i < ARRAY_LENGTH(macro.events); i++) {
|
||||
for (size_t i = 0; i < ARRAY_LENGTH(macro.events); i++) {
|
||||
if (macro.events[i].type == RATBAG_MACRO_EVENT_NONE)
|
||||
break;
|
||||
|
||||
@@ -757,7 +763,7 @@ ratbag_cmd_list_supported_devices(const struct ratbag_cmd *cmd,
|
||||
device = ratbag_cmd_open_device(ratbag, path);
|
||||
if (device) {
|
||||
printf("%s:\t%s\n", path, ratbag_device_get_name(device));
|
||||
device = ratbag_device_unref(device);
|
||||
ratbag_device_unref(device);
|
||||
supported++;
|
||||
}
|
||||
free(input_list[i]);
|
||||
@@ -1316,13 +1322,12 @@ ratbag_cmd_button_set_macro(const struct ratbag_cmd *cmd,
|
||||
struct ratbag_button_macro *m;
|
||||
struct macro macro = {0};
|
||||
int rc;
|
||||
int i;
|
||||
char macro_str[PATH_MAX] = {0};
|
||||
|
||||
if (argc < 1)
|
||||
return ERR_USAGE;
|
||||
|
||||
for (i = 0; i < argc; i++) {
|
||||
for (int i = 0; i < argc; i++) {
|
||||
strncat(macro_str, argv[i], sizeof(macro_str) - strlen(macro_str) - 1);
|
||||
strcat(macro_str, " ");
|
||||
}
|
||||
@@ -1339,7 +1344,7 @@ ratbag_cmd_button_set_macro(const struct ratbag_cmd *cmd,
|
||||
|
||||
button = options->button;
|
||||
m = ratbag_button_macro_new(macro.name);
|
||||
for (i = 0; i < ARRAY_LENGTH(macro.events); i++) {
|
||||
for (size_t i = 0; i < ARRAY_LENGTH(macro.events); i++) {
|
||||
if (macro.events[i].type == RATBAG_MACRO_EVENT_NONE)
|
||||
break;
|
||||
|
||||
@@ -1483,10 +1488,8 @@ ratbag_cmd_led_set_brightness(const struct ratbag_cmd *cmd,
|
||||
struct ratbag_cmd_options *options,
|
||||
int argc, char **argv)
|
||||
{
|
||||
struct ratbag_device *device;
|
||||
struct ratbag_led *led;
|
||||
char *str, *endptr;
|
||||
int brightness, b;
|
||||
int brightness;
|
||||
int rc;
|
||||
|
||||
if (argc < 1)
|
||||
@@ -1495,8 +1498,6 @@ ratbag_cmd_led_set_brightness(const struct ratbag_cmd *cmd,
|
||||
led = options->led;
|
||||
brightness = atoi(argv[0]);
|
||||
|
||||
device = options->device;
|
||||
|
||||
rc = ratbag_led_set_brightness(led, brightness);
|
||||
if (rc != 0)
|
||||
return ERR_DEVICE;
|
||||
@@ -1520,10 +1521,9 @@ ratbag_cmd_led_set_effect_rate(const struct ratbag_cmd *cmd,
|
||||
int argc, char **argv)
|
||||
{
|
||||
|
||||
struct ratbag_device *device;
|
||||
struct ratbag_led *led;
|
||||
char *str, *endptr;
|
||||
int hz, b;
|
||||
int hz;
|
||||
int rc;
|
||||
|
||||
if (argc < 1)
|
||||
@@ -1557,12 +1557,10 @@ ratbag_cmd_led_set_color(const struct ratbag_cmd *cmd,
|
||||
struct ratbag_cmd_options *options,
|
||||
int argc, char **argv)
|
||||
{
|
||||
struct ratbag_device *device;
|
||||
struct ratbag_led *led;
|
||||
struct ratbag_color color;
|
||||
char *str, *endptr;
|
||||
int rc;
|
||||
char red[2], green[2], blue[2];
|
||||
char red[3], green[3], blue[3];
|
||||
char *p;
|
||||
|
||||
if (argc < 1)
|
||||
@@ -1570,7 +1568,7 @@ ratbag_cmd_led_set_color(const struct ratbag_cmd *cmd,
|
||||
|
||||
led = options->led;
|
||||
|
||||
sscanf(argv[0], "%2s%2s%2s", &red, &green, &blue);
|
||||
sscanf(argv[0], "%2s%2s%2s", red, green, blue);
|
||||
|
||||
color.red = strtoul(red, &p, 16);
|
||||
color.green = strtoul(green, &p, 16);
|
||||
@@ -1598,10 +1596,10 @@ ratbag_cmd_led_set_mode(const struct ratbag_cmd *cmd,
|
||||
struct ratbag_cmd_options *options,
|
||||
int argc, char **argv)
|
||||
{
|
||||
struct ratbag_device *device;
|
||||
struct ratbag_led *led;
|
||||
struct ratbag_color color;
|
||||
char *str, *endptr;
|
||||
enum ratbag_led_mode mode;
|
||||
char *str;
|
||||
int rc;
|
||||
|
||||
if (argc < 1)
|
||||
@@ -1610,8 +1608,6 @@ ratbag_cmd_led_set_mode(const struct ratbag_cmd *cmd,
|
||||
led = options->led;
|
||||
str = argv[0];
|
||||
|
||||
enum ratbag_led_mode mode;
|
||||
|
||||
if (streq(str, "off"))
|
||||
mode = RATBAG_LED_OFF;
|
||||
else if (streq(str, "on"))
|
||||
@@ -1637,6 +1633,9 @@ ratbag_cmd_led_set_mode(const struct ratbag_cmd *cmd,
|
||||
case RATBAG_LED_BREATHING:
|
||||
ratbag_led_set_effect_rate(led, 20);
|
||||
ratbag_led_set_brightness(led, 100);
|
||||
break;
|
||||
case RATBAG_LED_OFF:
|
||||
break;
|
||||
}
|
||||
|
||||
rc = ratbag_led_set_mode(led, mode);
|
||||
@@ -2047,8 +2046,10 @@ main(int argc, char **argv)
|
||||
int c;
|
||||
int option_index = 0;
|
||||
static struct option opts[] = {
|
||||
{ "verbose", 2, 0, OPT_VERBOSE },
|
||||
{ "help", 0, 0, OPT_HELP },
|
||||
{ "verbose", optional_argument, 0, OPT_VERBOSE },
|
||||
{ "version", no_argument, 0, OPT_VERSION },
|
||||
{ "help", no_argument, 0, OPT_HELP },
|
||||
{ 0, 0, 0, 0 },
|
||||
};
|
||||
|
||||
c = getopt_long(argc, argv, "+h", opts, &option_index);
|
||||
@@ -2059,6 +2060,9 @@ main(int argc, char **argv)
|
||||
case OPT_HELP:
|
||||
usage();
|
||||
goto out;
|
||||
case OPT_VERSION:
|
||||
version();
|
||||
goto out;
|
||||
case OPT_VERBOSE:
|
||||
if (optarg && streq(optarg, "raw"))
|
||||
options.flags |= FLAG_VERBOSE_RAW;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
.TH RATBAG_COMMAND "1"
|
||||
.TH RATBAG_COMMAND "1" "@version@"
|
||||
.SH NAME
|
||||
ratbag-command \- Query or change a device's settings
|
||||
.SH SYNOPSIS
|
||||
|
||||
@@ -129,7 +129,7 @@ button_type_to_str(enum ratbag_button_type type)
|
||||
return str;
|
||||
}
|
||||
|
||||
const static struct map {
|
||||
static const struct map {
|
||||
enum ratbag_button_action_special special;
|
||||
const char *str;
|
||||
} special_map[] = {
|
||||
|
||||
@@ -21,6 +21,8 @@
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <errno.h>
|
||||
|
||||
Reference in New Issue
Block a user