Update to xf86-input-joystick 1.6.3

This commit is contained in:
matthieu 2017-01-22 09:44:15 +00:00
parent 145ab60397
commit b90c377899
13 changed files with 514 additions and 151 deletions

View File

@ -1,3 +1,64 @@
commit de424865ece983d8da62b7f7e3d013eabac0b8b5
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date: Fri Nov 18 08:58:35 2016 +1000
joystick 1.6.3
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
commit 60d0e9c451b3f259d524b0ddcc5c1f21a4f82293
Author: Matthieu Herrb <matthieu@herrb.eu>
Date: Sun Jul 31 12:54:14 2016 +0200
use xf86{Add,Remove}EnabledDevice()
Signed-off-by: Matthieu Herrb <matthieu@herrb.eu>
Reviewed-by: Adam Jackson <ajax@redhat.com>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
commit baf8bd4441d5dc6cdd687e066bf13cc1c3df1a41
Author: Hans de Goede <hdegoede@redhat.com>
Date: Thu Mar 13 14:49:53 2014 +0100
Add support for server managed fds
Keep things simple by handling server managed fds in the common parts
of the open and close paths.
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
commit 341d23ceaa9d5483b5318425e7308e09f8941957
Author: Hans de Goede <hdegoede@redhat.com>
Date: Thu Mar 13 14:49:52 2014 +0100
Add a generic jstkCloseDevice helper function
This is a preparation patch for adding support for server managed fds.
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
commit 6de3b75c453e4687b21f6d6acfcf87e7041c4fc5
Author: Hans de Goede <hdegoede@redhat.com>
Date: Thu Mar 13 14:49:51 2014 +0100
Use jstkCloseDevice_* on error in jstkOpenDevice_* backend functions
This is a preparation patch for adding support for server managed fds, this
also fixes a missing free() in an error handling path in the evdev back-end.
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
commit a976a85aeff4f2511544c0385533d9387957afae
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date: Wed Jan 30 12:57:51 2013 +1000
Handle DEVICE_ABORT for input ABI 19.1
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
commit 426c3aa3c8a2385f17e37ae73c1e78f072656027 commit 426c3aa3c8a2385f17e37ae73c1e78f072656027
Author: Sascha Hlusiak <saschahlusiak@arcor.de> Author: Sascha Hlusiak <saschahlusiak@arcor.de>
Date: Wed Jan 16 10:52:12 2013 +0100 Date: Wed Jan 16 10:52:12 2013 +0100

View File

@ -74,8 +74,8 @@ subdir = .
DIST_COMMON = README $(am__configure_deps) $(srcdir)/Makefile.am \ DIST_COMMON = README $(am__configure_deps) $(srcdir)/Makefile.am \
$(srcdir)/Makefile.in $(srcdir)/config.h.in \ $(srcdir)/Makefile.in $(srcdir)/config.h.in \
$(srcdir)/xorg-joystick.pc.in $(top_srcdir)/configure COPYING \ $(srcdir)/xorg-joystick.pc.in $(top_srcdir)/configure COPYING \
ChangeLog INSTALL config.guess config.sub depcomp install-sh \ ChangeLog INSTALL compile config.guess config.sub depcomp \
ltmain.sh missing install-sh ltmain.sh missing
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/configure.ac am__aclocal_m4_deps = $(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \

View File

@ -0,0 +1,347 @@
#! /bin/sh
# Wrapper for compilers which do not understand '-c -o'.
scriptversion=2012-10-14.11; # UTC
# Copyright (C) 1999-2014 Free Software Foundation, Inc.
# Written by Tom Tromey <tromey@cygnus.com>.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# As a special exception to the GNU General Public License, if you
# distribute this file as part of a program that contains a
# configuration script generated by Autoconf, you may include it under
# the same distribution terms that you use for the rest of that program.
# This file is maintained in Automake, please report
# bugs to <bug-automake@gnu.org> or send patches to
# <automake-patches@gnu.org>.
nl='
'
# We need space, tab and new line, in precisely that order. Quoting is
# there to prevent tools from complaining about whitespace usage.
IFS=" "" $nl"
file_conv=
# func_file_conv build_file lazy
# Convert a $build file to $host form and store it in $file
# Currently only supports Windows hosts. If the determined conversion
# type is listed in (the comma separated) LAZY, no conversion will
# take place.
func_file_conv ()
{
file=$1
case $file in
/ | /[!/]*) # absolute file, and not a UNC file
if test -z "$file_conv"; then
# lazily determine how to convert abs files
case `uname -s` in
MINGW*)
file_conv=mingw
;;
CYGWIN*)
file_conv=cygwin
;;
*)
file_conv=wine
;;
esac
fi
case $file_conv/,$2, in
*,$file_conv,*)
;;
mingw/*)
file=`cmd //C echo "$file " | sed -e 's/"\(.*\) " *$/\1/'`
;;
cygwin/*)
file=`cygpath -m "$file" || echo "$file"`
;;
wine/*)
file=`winepath -w "$file" || echo "$file"`
;;
esac
;;
esac
}
# func_cl_dashL linkdir
# Make cl look for libraries in LINKDIR
func_cl_dashL ()
{
func_file_conv "$1"
if test -z "$lib_path"; then
lib_path=$file
else
lib_path="$lib_path;$file"
fi
linker_opts="$linker_opts -LIBPATH:$file"
}
# func_cl_dashl library
# Do a library search-path lookup for cl
func_cl_dashl ()
{
lib=$1
found=no
save_IFS=$IFS
IFS=';'
for dir in $lib_path $LIB
do
IFS=$save_IFS
if $shared && test -f "$dir/$lib.dll.lib"; then
found=yes
lib=$dir/$lib.dll.lib
break
fi
if test -f "$dir/$lib.lib"; then
found=yes
lib=$dir/$lib.lib
break
fi
if test -f "$dir/lib$lib.a"; then
found=yes
lib=$dir/lib$lib.a
break
fi
done
IFS=$save_IFS
if test "$found" != yes; then
lib=$lib.lib
fi
}
# func_cl_wrapper cl arg...
# Adjust compile command to suit cl
func_cl_wrapper ()
{
# Assume a capable shell
lib_path=
shared=:
linker_opts=
for arg
do
if test -n "$eat"; then
eat=
else
case $1 in
-o)
# configure might choose to run compile as 'compile cc -o foo foo.c'.
eat=1
case $2 in
*.o | *.[oO][bB][jJ])
func_file_conv "$2"
set x "$@" -Fo"$file"
shift
;;
*)
func_file_conv "$2"
set x "$@" -Fe"$file"
shift
;;
esac
;;
-I)
eat=1
func_file_conv "$2" mingw
set x "$@" -I"$file"
shift
;;
-I*)
func_file_conv "${1#-I}" mingw
set x "$@" -I"$file"
shift
;;
-l)
eat=1
func_cl_dashl "$2"
set x "$@" "$lib"
shift
;;
-l*)
func_cl_dashl "${1#-l}"
set x "$@" "$lib"
shift
;;
-L)
eat=1
func_cl_dashL "$2"
;;
-L*)
func_cl_dashL "${1#-L}"
;;
-static)
shared=false
;;
-Wl,*)
arg=${1#-Wl,}
save_ifs="$IFS"; IFS=','
for flag in $arg; do
IFS="$save_ifs"
linker_opts="$linker_opts $flag"
done
IFS="$save_ifs"
;;
-Xlinker)
eat=1
linker_opts="$linker_opts $2"
;;
-*)
set x "$@" "$1"
shift
;;
*.cc | *.CC | *.cxx | *.CXX | *.[cC]++)
func_file_conv "$1"
set x "$@" -Tp"$file"
shift
;;
*.c | *.cpp | *.CPP | *.lib | *.LIB | *.Lib | *.OBJ | *.obj | *.[oO])
func_file_conv "$1" mingw
set x "$@" "$file"
shift
;;
*)
set x "$@" "$1"
shift
;;
esac
fi
shift
done
if test -n "$linker_opts"; then
linker_opts="-link$linker_opts"
fi
exec "$@" $linker_opts
exit 1
}
eat=
case $1 in
'')
echo "$0: No command. Try '$0 --help' for more information." 1>&2
exit 1;
;;
-h | --h*)
cat <<\EOF
Usage: compile [--help] [--version] PROGRAM [ARGS]
Wrapper for compilers which do not understand '-c -o'.
Remove '-o dest.o' from ARGS, run PROGRAM with the remaining
arguments, and rename the output as expected.
If you are trying to build a whole package this is not the
right script to run: please start by reading the file 'INSTALL'.
Report bugs to <bug-automake@gnu.org>.
EOF
exit $?
;;
-v | --v*)
echo "compile $scriptversion"
exit $?
;;
cl | *[/\\]cl | cl.exe | *[/\\]cl.exe )
func_cl_wrapper "$@" # Doesn't return...
;;
esac
ofile=
cfile=
for arg
do
if test -n "$eat"; then
eat=
else
case $1 in
-o)
# configure might choose to run compile as 'compile cc -o foo foo.c'.
# So we strip '-o arg' only if arg is an object.
eat=1
case $2 in
*.o | *.obj)
ofile=$2
;;
*)
set x "$@" -o "$2"
shift
;;
esac
;;
*.c)
cfile=$1
set x "$@" "$1"
shift
;;
*)
set x "$@" "$1"
shift
;;
esac
fi
shift
done
if test -z "$ofile" || test -z "$cfile"; then
# If no '-o' option was seen then we might have been invoked from a
# pattern rule where we don't need one. That is ok -- this is a
# normal compilation that the losing compiler can handle. If no
# '.c' file was seen then we are probably linking. That is also
# ok.
exec "$@"
fi
# Name of file we expect compiler to create.
cofile=`echo "$cfile" | sed 's|^.*[\\/]||; s|^[a-zA-Z]:||; s/\.c$/.o/'`
# Create the lock directory.
# Note: use '[/\\:.-]' here to ensure that we don't use the same name
# that we are using for the .o file. Also, base the name on the expected
# object file name, since that is what matters with a parallel build.
lockdir=`echo "$cofile" | sed -e 's|[/\\:.-]|_|g'`.d
while true; do
if mkdir "$lockdir" >/dev/null 2>&1; then
break
fi
sleep 1
done
# FIXME: race condition here if user kills between mkdir and trap.
trap "rmdir '$lockdir'; exit 1" 1 2 15
# Run the compile.
"$@"
ret=$?
if test -f "$cofile"; then
test "$cofile" = "$ofile" || mv "$cofile" "$ofile"
elif test -f "${cofile}bj"; then
test "${cofile}bj" = "$ofile" || mv "${cofile}bj" "$ofile"
fi
rmdir "$lockdir"
exit $ret
# Local Variables:
# mode: shell-script
# sh-indentation: 2
# eval: (add-hook 'write-file-hooks 'time-stamp)
# time-stamp-start: "scriptversion="
# time-stamp-format: "%:y-%02m-%02d.%02H"
# time-stamp-time-zone: "UTC"
# time-stamp-end: "; # UTC"
# End:

View File

@ -56,54 +56,3 @@ Section "InputClass"
# Option "XkbVariant" "nodeadkeys" # Option "XkbVariant" "nodeadkeys"
# Option "AutoRepeat" "400 25" # Option "AutoRepeat" "400 25"
EndSection EndSection
# Example xorg.conf.d snippet that assigns the joystick driver
# to all joysticks. See xorg.conf.d(5) for more information on
# InputClass.
# DO NOT EDIT THIS FILE, your distribution will likely overwrite
# it when updating. Copy (and rename) this file into
# /etc/X11/xorg.conf.d first.
# Additional options may be added in the form of
# Option "OptionName" "value"
#
Section "InputClass"
Identifier "joystick-all"
# UNCOMMENT TO ENABLE HOTPLUGGING OF JOYSTICKS
# Driver "joystick"
# MatchIsJoystick "on"
# MatchDevicePath "/dev/input/event*"
Option "MapButton1" "button=1"
Option "MapButton2" "button=2"
Option "MapButton3" "button=3"
Option "MapAxis1" "mode=relative axis=+1x deadzone=5000"
Option "MapAxis2" "mode=relative axis=+1y deadzone=5000"
Option "MapAxis3" "mode=relative axis=+1zx deadzone=5000"
Option "MapAxis4" "mode=relative axis=+1zy deadzone=5000"
Option "MapAxis5" "mode=accelerated axis=+1x deadzone=5000"
Option "MapAxis6" "mode=accelerated axis=+1y deadzone=5000"
# Map Alt+Tab to button #4
# Option "MapButton4" "key=64+23"
# Button 8 will slow down all movement to factor 0.3
# Option "MapButton8" "amplify=0.3"
# Button 9 will disable all events except button #9 itself
# Option "MapButton9" "disable-all"
# Map button #10 to Space
# Option "MapButton10" "key=65"
# Map axis #1 and #2 to the keycodes for Left, Right, Up and Down rather
# than pointer movement
# Option "MapAxis1" "mode=accelerated keylow=113 keyhigh=114"
# Option "MapAxis2" "mode=accelerated keylow=111 keyhigh=116"
# Option "XkbLayout" "de"
# Option "XkbVariant" "nodeadkeys"
# Option "AutoRepeat" "400 25"
EndSection

View File

@ -1,6 +1,6 @@
#! /bin/sh #! /bin/sh
# Guess values for system-dependent variables and create Makefiles. # Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.69 for xf86-input-joystick 1.6.2. # Generated by GNU Autoconf 2.69 for xf86-input-joystick 1.6.3.
# #
# Report bugs to <https://bugs.freedesktop.org/enter_bug.cgi?product=xorg>. # Report bugs to <https://bugs.freedesktop.org/enter_bug.cgi?product=xorg>.
# #
@ -591,8 +591,8 @@ MAKEFLAGS=
# Identity of this package. # Identity of this package.
PACKAGE_NAME='xf86-input-joystick' PACKAGE_NAME='xf86-input-joystick'
PACKAGE_TARNAME='xf86-input-joystick' PACKAGE_TARNAME='xf86-input-joystick'
PACKAGE_VERSION='1.6.2' PACKAGE_VERSION='1.6.3'
PACKAGE_STRING='xf86-input-joystick 1.6.2' PACKAGE_STRING='xf86-input-joystick 1.6.3'
PACKAGE_BUGREPORT='https://bugs.freedesktop.org/enter_bug.cgi?product=xorg' PACKAGE_BUGREPORT='https://bugs.freedesktop.org/enter_bug.cgi?product=xorg'
PACKAGE_URL='' PACKAGE_URL=''
@ -1360,7 +1360,7 @@ if test "$ac_init_help" = "long"; then
# Omit some internal or obsolete options to make the list less imposing. # Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh. # This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF cat <<_ACEOF
\`configure' configures xf86-input-joystick 1.6.2 to adapt to many kinds of systems. \`configure' configures xf86-input-joystick 1.6.3 to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]... Usage: $0 [OPTION]... [VAR=VALUE]...
@ -1431,7 +1431,7 @@ fi
if test -n "$ac_init_help"; then if test -n "$ac_init_help"; then
case $ac_init_help in case $ac_init_help in
short | recursive ) echo "Configuration of xf86-input-joystick 1.6.2:";; short | recursive ) echo "Configuration of xf86-input-joystick 1.6.3:";;
esac esac
cat <<\_ACEOF cat <<\_ACEOF
@ -1557,7 +1557,7 @@ fi
test -n "$ac_init_help" && exit $ac_status test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then if $ac_init_version; then
cat <<\_ACEOF cat <<\_ACEOF
xf86-input-joystick configure 1.6.2 xf86-input-joystick configure 1.6.3
generated by GNU Autoconf 2.69 generated by GNU Autoconf 2.69
Copyright (C) 2012 Free Software Foundation, Inc. Copyright (C) 2012 Free Software Foundation, Inc.
@ -1972,7 +1972,7 @@ cat >config.log <<_ACEOF
This file contains any messages produced by compilers while This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake. running configure, to aid debugging if configure makes a mistake.
It was created by xf86-input-joystick $as_me 1.6.2, which was It was created by xf86-input-joystick $as_me 1.6.3, which was
generated by GNU Autoconf 2.69. Invocation command line was generated by GNU Autoconf 2.69. Invocation command line was
$ $0 $@ $ $0 $@
@ -2801,7 +2801,7 @@ fi
# Define the identity of the package. # Define the identity of the package.
PACKAGE='xf86-input-joystick' PACKAGE='xf86-input-joystick'
VERSION='1.6.2' VERSION='1.6.3'
cat >>confdefs.h <<_ACEOF cat >>confdefs.h <<_ACEOF
@ -18597,7 +18597,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
# report actual input values of CONFIG_FILES etc. instead of their # report actual input values of CONFIG_FILES etc. instead of their
# values after options handling. # values after options handling.
ac_log=" ac_log="
This file was extended by xf86-input-joystick $as_me 1.6.2, which was This file was extended by xf86-input-joystick $as_me 1.6.3, which was
generated by GNU Autoconf 2.69. Invocation command line was generated by GNU Autoconf 2.69. Invocation command line was
CONFIG_FILES = $CONFIG_FILES CONFIG_FILES = $CONFIG_FILES
@ -18663,7 +18663,7 @@ _ACEOF
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
ac_cs_version="\\ ac_cs_version="\\
xf86-input-joystick config.status 1.6.2 xf86-input-joystick config.status 1.6.3
configured by $0, generated by GNU Autoconf 2.69, configured by $0, generated by GNU Autoconf 2.69,
with options \\"\$ac_cs_config\\" with options \\"\$ac_cs_config\\"

View File

@ -23,7 +23,7 @@
# Initialize Autoconf # Initialize Autoconf
AC_PREREQ([2.60]) AC_PREREQ([2.60])
AC_INIT([xf86-input-joystick], AC_INIT([xf86-input-joystick],
[1.6.2], [1.6.3],
[https://bugs.freedesktop.org/enter_bug.cgi?product=xorg], [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg],
[xf86-input-joystick]) [xf86-input-joystick])
AC_CONFIG_SRCDIR([Makefile.am]) AC_CONFIG_SRCDIR([Makefile.am])

View File

@ -91,38 +91,38 @@ jstkOpenDevice_bsd(JoystickDevPtr joystick, Bool probe)
report_desc_t rd; report_desc_t rd;
struct jstk_bsd_hid_data *bsddata; struct jstk_bsd_hid_data *bsddata;
if (joystick->fd == -1) {
if ((joystick->fd = open(joystick->device, O_RDWR | O_NDELAY, 0)) < 0) { if ((joystick->fd = open(joystick->device, O_RDWR | O_NDELAY, 0)) < 0) {
xf86Msg(X_ERROR, "Cannot open joystick '%s' (%s)\n", joystick->device, xf86Msg(X_ERROR, "Cannot open joystick '%s' (%s)\n",
strerror(errno)); joystick->device, strerror(errno));
return -1; return -1;
} }
}
if ((rd = hid_get_report_desc(joystick->fd)) == 0) { if ((rd = hid_get_report_desc(joystick->fd)) == 0) {
xf86Msg(X_ERROR, "Joystick: hid_get_report_desc failed: %s\n", xf86Msg(X_ERROR, "Joystick: hid_get_report_desc failed: %s\n",
strerror(errno)); strerror(errno));
close(joystick->fd); jstkCloseDevice_bsd(joystick);
joystick->fd = -1;
return -1; return -1;
} }
if (ioctl(joystick->fd, USB_GET_REPORT_ID, &report_id) < 0) { if (ioctl(joystick->fd, USB_GET_REPORT_ID, &report_id) < 0) {
xf86Msg(X_ERROR, "Joystick: ioctl USB_GET_REPORT_ID failed: %s\n", xf86Msg(X_ERROR, "Joystick: ioctl USB_GET_REPORT_ID failed: %s\n",
strerror(errno)); strerror(errno));
close(joystick->fd); jstkCloseDevice_bsd(joystick);
joystick->fd = -1;
return -1; return -1;
} }
bsddata = (struct jstk_bsd_hid_data*) bsddata = (struct jstk_bsd_hid_data*)
malloc(sizeof(struct jstk_bsd_hid_data)); malloc(sizeof(struct jstk_bsd_hid_data));
joystick->devicedata = (void*) bsddata;
bsddata->dlen = hid_report_size(rd, hid_input, report_id); bsddata->dlen = hid_report_size(rd, hid_input, report_id);
if ((bsddata->data_buf = malloc(bsddata->dlen)) == NULL) { if ((bsddata->data_buf = malloc(bsddata->dlen)) == NULL) {
fprintf(stderr, "error: couldn't malloc %d bytes\n", bsddata->dlen); fprintf(stderr, "error: couldn't malloc %d bytes\n", bsddata->dlen);
hid_dispose_report_desc(rd); hid_dispose_report_desc(rd);
free(bsddata); jstkCloseDevice_bsd(joystick);
close(joystick->fd);
joystick->fd = -1;
return -1; return -1;
} }
@ -181,14 +181,11 @@ jstkOpenDevice_bsd(JoystickDevPtr joystick, Bool probe)
if (!got_something) { if (!got_something) {
free(bsddata->data_buf); free(bsddata->data_buf);
xf86Msg(X_ERROR, "Joystick: Didn't find any usable axes.\n"); xf86Msg(X_ERROR, "Joystick: Didn't find any usable axes.\n");
free(bsddata); jstkCloseDevice_bsd(joystick);
close(joystick->fd);
joystick->fd = -1;
return -1; return -1;
} }
bsddata->hotdata = 0; bsddata->hotdata = 0;
joystick->devicedata = (void*) bsddata;
if (probe == TRUE) { if (probe == TRUE) {
xf86Msg(X_INFO, "Joystick: %d buttons, %d axes\n", xf86Msg(X_INFO, "Joystick: %d buttons, %d axes\n",
joystick->num_buttons, joystick->num_axes); joystick->num_buttons, joystick->num_axes);
@ -214,14 +211,12 @@ jstkOpenDevice_bsd(JoystickDevPtr joystick, Bool probe)
static void static void
jstkCloseDevice_bsd(JoystickDevPtr joystick) jstkCloseDevice_bsd(JoystickDevPtr joystick)
{ {
if ((joystick->fd >= 0)) { jstkCloseDevice(joystick);
xf86CloseSerial(joystick->fd);
joystick->fd = -1;
}
if (joystick->devicedata != NULL) { if (joystick->devicedata != NULL) {
if (((struct jstk_bsd_hid_data*)joystick->devicedata)->data_buf) if (((struct jstk_bsd_hid_data*)joystick->devicedata)->data_buf)
free(((struct jstk_bsd_hid_data*)joystick->devicedata)->data_buf); free(((struct jstk_bsd_hid_data*)joystick->devicedata)->data_buf);
free(joystick->devicedata); free(joystick->devicedata);
joystick->devicedata = NULL;
} }
} }

View File

@ -90,25 +90,25 @@ jstkOpenDevice_evdev(JoystickDevPtr joystick, Bool probe)
unsigned long key_bits[NBITS(KEY_MAX)]; unsigned long key_bits[NBITS(KEY_MAX)];
int axes, buttons, j; int axes, buttons, j;
if (joystick->fd == -1) {
if ((joystick->fd = open(joystick->device, O_RDONLY | O_NDELAY, 0)) < 0) { if ((joystick->fd = open(joystick->device, O_RDONLY | O_NDELAY, 0)) < 0) {
xf86Msg(X_ERROR, "Cannot open joystick '%s' (%s)\n", xf86Msg(X_ERROR, "Cannot open joystick '%s' (%s)\n",
joystick->device, strerror(errno)); joystick->device, strerror(errno));
return -1; return -1;
} }
}
if (ioctl(joystick->fd, EVIOCGVERSION, &driver_version) == -1) { if (ioctl(joystick->fd, EVIOCGVERSION, &driver_version) == -1) {
xf86Msg(X_ERROR, "Joystick: ioctl EVIOCGVERSION on '%s' failed: %s\n", xf86Msg(X_ERROR, "Joystick: ioctl EVIOCGVERSION on '%s' failed: %s\n",
joystick->device, strerror(errno)); joystick->device, strerror(errno));
close(joystick->fd); jstkCloseDevice_evdev(joystick);
joystick->fd = -1;
return -1; return -1;
} }
if (ioctl(joystick->fd, EVIOCGID, &id) == -1) { if (ioctl(joystick->fd, EVIOCGID, &id) == -1) {
xf86Msg(X_ERROR, "Joystick: ioctl EVIOCGID on '%s' failed: %s\n", xf86Msg(X_ERROR, "Joystick: ioctl EVIOCGID on '%s' failed: %s\n",
joystick->device, strerror(errno)); joystick->device, strerror(errno));
close(joystick->fd); jstkCloseDevice_evdev(joystick);
joystick->fd = -1;
return -1; return -1;
} }
@ -118,13 +118,14 @@ jstkOpenDevice_evdev(JoystickDevPtr joystick, Bool probe)
{ {
xf86Msg(X_ERROR, "Joystick: ioctl EVIOCGBIT on '%s' failed: %s\n", xf86Msg(X_ERROR, "Joystick: ioctl EVIOCGBIT on '%s' failed: %s\n",
joystick->device, strerror(errno)); joystick->device, strerror(errno));
close(joystick->fd); jstkCloseDevice_evdev(joystick);
joystick->fd = -1;
return -1; return -1;
} }
evdevdata = (struct jstk_evdev_data*) evdevdata = (struct jstk_evdev_data*)
malloc(sizeof(struct jstk_evdev_data)); malloc(sizeof(struct jstk_evdev_data));
joystick->devicedata = (void*) evdevdata;
for (axes=0; axes<ABS_MAX; axes++) for (axes=0; axes<ABS_MAX; axes++)
{ {
evdevdata->axis[axes].number = -1; evdevdata->axis[axes].number = -1;
@ -144,9 +145,7 @@ jstkOpenDevice_evdev(JoystickDevPtr joystick, Bool probe)
if (ioctl(joystick->fd, EVIOCGABS(j), &absinfo) == -1) { if (ioctl(joystick->fd, EVIOCGABS(j), &absinfo) == -1) {
xf86Msg(X_ERROR, "Joystick: ioctl EVIOCGABS on '%s' failed: %s\n", xf86Msg(X_ERROR, "Joystick: ioctl EVIOCGABS on '%s' failed: %s\n",
joystick->device, strerror(errno)); joystick->device, strerror(errno));
close(joystick->fd); jstkCloseDevice_evdev(joystick);
joystick->fd = -1;
free(evdevdata);
return -1; return -1;
} }
evdevdata->axis[j].number = axes; /* physical -> logical mapping */ evdevdata->axis[j].number = axes; /* physical -> logical mapping */
@ -163,8 +162,7 @@ jstkOpenDevice_evdev(JoystickDevPtr joystick, Bool probe)
{ {
xf86Msg(X_ERROR, "Joystick: ioctl EVIOCGBIT on '%s' failed: %s\n", xf86Msg(X_ERROR, "Joystick: ioctl EVIOCGBIT on '%s' failed: %s\n",
joystick->device, strerror(errno)); joystick->device, strerror(errno));
close(joystick->fd); jstkCloseDevice_evdev(joystick);
joystick->fd = -1;
return -1; return -1;
} }
buttons = 0; /* Our logical index */ buttons = 0; /* Our logical index */
@ -191,7 +189,6 @@ jstkOpenDevice_evdev(JoystickDevPtr joystick, Bool probe)
joystick->open_proc = jstkOpenDevice_evdev; joystick->open_proc = jstkOpenDevice_evdev;
joystick->read_proc = jstkReadData_evdev; joystick->read_proc = jstkReadData_evdev;
joystick->close_proc = jstkCloseDevice_evdev; joystick->close_proc = jstkCloseDevice_evdev;
joystick->devicedata = (void*) evdevdata;
if (buttons > MAXBUTTONS) if (buttons > MAXBUTTONS)
buttons = MAXBUTTONS; buttons = MAXBUTTONS;
@ -215,14 +212,11 @@ jstkOpenDevice_evdev(JoystickDevPtr joystick, Bool probe)
static void static void
jstkCloseDevice_evdev(JoystickDevPtr joystick) jstkCloseDevice_evdev(JoystickDevPtr joystick)
{ {
if ((joystick->fd >= 0)) { jstkCloseDevice(joystick);
xf86CloseSerial(joystick->fd);
if (joystick->devicedata) { if (joystick->devicedata) {
free(joystick->devicedata); free(joystick->devicedata);
joystick->devicedata = NULL; joystick->devicedata = NULL;
} }
joystick->fd = -1;
}
} }

View File

@ -49,7 +49,6 @@
#include "backend_joystick.h" #include "backend_joystick.h"
static void jstkCloseDevice_joystick(JoystickDevPtr joystick);
static int jstkReadData_joystick(JoystickDevPtr joystick, static int jstkReadData_joystick(JoystickDevPtr joystick,
JOYSTICKEVENT *event, JOYSTICKEVENT *event,
int *number); int *number);
@ -73,17 +72,18 @@ jstkOpenDevice_joystick(JoystickDevPtr joystick, Bool probe)
unsigned char axes, buttons; unsigned char axes, buttons;
int driver_version; int driver_version;
if (joystick->fd == -1) {
if ((joystick->fd = open(joystick->device, O_RDONLY | O_NDELAY, 0)) < 0) { if ((joystick->fd = open(joystick->device, O_RDONLY | O_NDELAY, 0)) < 0) {
xf86Msg(X_ERROR, "Cannot open joystick '%s' (%s)\n", xf86Msg(X_ERROR, "Cannot open joystick '%s' (%s)\n",
joystick->device, strerror(errno)); joystick->device, strerror(errno));
return -1; return -1;
} }
}
if (ioctl(joystick->fd, JSIOCGVERSION, &driver_version) == -1) { if (ioctl(joystick->fd, JSIOCGVERSION, &driver_version) == -1) {
xf86Msg(X_ERROR, "Joystick: ioctl JSIOCGVERSION on '%s' failed: %s\n", xf86Msg(X_ERROR, "Joystick: ioctl JSIOCGVERSION on '%s' failed: %s\n",
joystick->device, strerror(errno)); joystick->device, strerror(errno));
close(joystick->fd); jstkCloseDevice(joystick);
joystick->fd = -1;
return -1; return -1;
} }
if ((driver_version >> 16) < 1) { if ((driver_version >> 16) < 1) {
@ -96,24 +96,21 @@ jstkOpenDevice_joystick(JoystickDevPtr joystick, Bool probe)
if (ioctl(joystick->fd, JSIOCGAXES, &axes) == -1) { if (ioctl(joystick->fd, JSIOCGAXES, &axes) == -1) {
xf86Msg(X_ERROR, "Joystick: ioctl JSIOCGAXES on '%s' failed: %s\n", xf86Msg(X_ERROR, "Joystick: ioctl JSIOCGAXES on '%s' failed: %s\n",
joystick->device, strerror(errno)); joystick->device, strerror(errno));
close(joystick->fd); jstkCloseDevice(joystick);
joystick->fd = -1;
return -1; return -1;
} }
if (ioctl(joystick->fd, JSIOCGBUTTONS, &buttons) == -1) { if (ioctl(joystick->fd, JSIOCGBUTTONS, &buttons) == -1) {
xf86Msg(X_ERROR, "Joystick: ioctl JSIOCGBUTTONS on '%s' failed: %s\n", xf86Msg(X_ERROR, "Joystick: ioctl JSIOCGBUTTONS on '%s' failed: %s\n",
joystick->device, strerror(errno)); joystick->device, strerror(errno));
close(joystick->fd); jstkCloseDevice(joystick);
joystick->fd = -1;
return -1; return -1;
} }
if (ioctl(joystick->fd, JSIOCGNAME(128), joy_name) == -1) { if (ioctl(joystick->fd, JSIOCGNAME(128), joy_name) == -1) {
xf86Msg(X_ERROR, "Joystick: ioctl JSIOCGNAME on '%s' failed: %s\n", xf86Msg(X_ERROR, "Joystick: ioctl JSIOCGNAME on '%s' failed: %s\n",
joystick->device, strerror(errno)); joystick->device, strerror(errno));
close(joystick->fd); jstkCloseDevice(joystick);
joystick->fd = -1;
return -1; return -1;
} }
@ -131,30 +128,11 @@ jstkOpenDevice_joystick(JoystickDevPtr joystick, Bool probe)
joystick->open_proc = jstkOpenDevice_joystick; joystick->open_proc = jstkOpenDevice_joystick;
joystick->read_proc = jstkReadData_joystick; joystick->read_proc = jstkReadData_joystick;
joystick->close_proc = jstkCloseDevice_joystick; joystick->close_proc = jstkCloseDevice;
return joystick->fd; return joystick->fd;
} }
/***********************************************************************
*
* jstkCloseDevice --
*
* close the handle.
*
***********************************************************************
*/
static void
jstkCloseDevice_joystick(JoystickDevPtr joystick)
{
if ((joystick->fd >= 0)) {
xf86CloseSerial(joystick->fd);
joystick->fd = -1;
}
}
/*********************************************************************** /***********************************************************************
* *
* jstkReadData -- * jstkReadData --

View File

@ -34,6 +34,7 @@
#include <xf86Xinput.h> #include <xf86Xinput.h>
#include <exevents.h> /* Needed for InitValuator/Proximity stuff */ #include <exevents.h> /* Needed for InitValuator/Proximity stuff */
#include <xf86Opt.h> #include <xf86Opt.h>
#include <xf86_OSproc.h>
#include <math.h> #include <math.h>
#include <xf86Module.h> #include <xf86Module.h>
@ -79,6 +80,9 @@ jstkOpenDevice(JoystickDevPtr priv, BOOL probe)
int fd; int fd;
fd = -1; fd = -1;
if (priv->joystick_device->flags & XI86_SERVER_FD)
priv->fd = priv->joystick_device->fd;
if (probe == FALSE && priv->open_proc) if (probe == FALSE && priv->open_proc)
return priv->open_proc(priv, probe); return priv->open_proc(priv, probe);
@ -98,6 +102,24 @@ jstkOpenDevice(JoystickDevPtr priv, BOOL probe)
return fd; return fd;
} }
/*
***************************************************************************
*
* jstkCloseDevice --
*
* Called to close the device specified in priv, this is a helper for
* backend proc_close functions
*
***************************************************************************
*/
void jstkCloseDevice(JoystickDevPtr priv)
{
if ((priv->fd >= 0)) {
if (!(priv->joystick_device->flags & XI86_SERVER_FD))
xf86CloseSerial(priv->fd);
priv->fd = -1;
}
}
/* /*
*************************************************************************** ***************************************************************************
@ -125,7 +147,7 @@ jstkReadProc(InputInfoPtr pInfo)
xf86Msg(X_WARNING, "JOYSTICK: Read failed. Deactivating device.\n"); xf86Msg(X_WARNING, "JOYSTICK: Read failed. Deactivating device.\n");
if (pInfo->fd >= 0) if (pInfo->fd >= 0)
RemoveEnabledDevice(pInfo->fd); xf86RemoveEnabledDevice(pInfo);
return; return;
} }
@ -392,7 +414,7 @@ jstkDeviceControlProc(DeviceIntPtr pJstk,
if (jstkOpenDevice(priv, FALSE) != -1) { if (jstkOpenDevice(priv, FALSE) != -1) {
pJstk->public.on = TRUE; pJstk->public.on = TRUE;
pInfo->fd = priv->fd; pInfo->fd = priv->fd;
AddEnabledDevice(pInfo->fd); xf86AddEnabledDevice(pInfo);
} else return !Success; } else return !Success;
break; break;
@ -415,13 +437,19 @@ jstkDeviceControlProc(DeviceIntPtr pJstk,
} }
if (pInfo->fd >= 0) if (pInfo->fd >= 0)
RemoveEnabledDevice(pInfo->fd); xf86RemoveEnabledDevice(pInfo);
if (!(pInfo->flags & XI86_SERVER_FD))
pInfo->fd = -1; pInfo->fd = -1;
if (priv->close_proc) if (priv->close_proc)
priv->close_proc(priv); priv->close_proc(priv);
pJstk->public.on = FALSE; pJstk->public.on = FALSE;
break; break;
#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) * 100 + GET_ABI_MINOR(ABI_XINPUT_VERSION) >= 1901
case DEVICE_ABORT:
break;
#endif
default: default:
ErrorF("unsupported mode=%d\n", what); ErrorF("unsupported mode=%d\n", what);
return BadValue; return BadValue;
@ -462,6 +490,7 @@ jstkCorePreInit(InputDriverPtr drv, InputInfoPtr pInfo, int flags)
pInfo->read_input = jstkReadProc; pInfo->read_input = jstkReadProc;
pInfo->control_proc = NULL; pInfo->control_proc = NULL;
pInfo->switch_mode = NULL; pInfo->switch_mode = NULL;
if (!(pInfo->flags & XI86_SERVER_FD))
pInfo->fd = -1; pInfo->fd = -1;
pInfo->dev = NULL; pInfo->dev = NULL;
pInfo->type_name = XI_JOYSTICK; pInfo->type_name = XI_JOYSTICK;
@ -483,6 +512,7 @@ jstkCorePreInit(InputDriverPtr drv, InputInfoPtr pInfo, int flags)
priv->mouse_enabled = TRUE; priv->mouse_enabled = TRUE;
priv->keys_enabled = TRUE; priv->keys_enabled = TRUE;
priv->amplify = 1.0f; priv->amplify = 1.0f;
priv->joystick_device = pInfo;
priv->keyboard_device = keyboard_device; priv->keyboard_device = keyboard_device;
priv->num_axes = MAXAXES; priv->num_axes = MAXAXES;
priv->num_buttons = MAXBUTTONS; priv->num_buttons = MAXBUTTONS;
@ -659,7 +689,11 @@ _X_EXPORT InputDriverRec JOYSTICK = {
NULL, NULL,
jstkCorePreInit, jstkCorePreInit,
jstkCoreUnInit, jstkCoreUnInit,
NULL NULL,
NULL,
#ifdef XI86_DRV_CAP_SERVER_FD
XI86_DRV_CAP_SERVER_FD
#endif
}; };
/* /*
@ -738,4 +772,3 @@ _X_EXPORT XF86ModuleData joystickModuleData = {
}; };
/* vim: set filetype=c.doxygen ts=4 et: */ /* vim: set filetype=c.doxygen ts=4 et: */

View File

@ -55,6 +55,9 @@
#define XI_JOYSTICK "JOYSTICK" #define XI_JOYSTICK "JOYSTICK"
#endif #endif
#ifndef XI86_SERVER_FD
#define XI86_SERVER_FD 0x20
#endif
typedef enum _JOYSTICKEVENT { typedef enum _JOYSTICKEVENT {
EVENT_NONE=0, EVENT_NONE=0,
@ -106,6 +109,7 @@ typedef struct _JoystickDevRec {
jstkReadDataProc read_proc; /* Callback for reading data from the backend */ jstkReadDataProc read_proc; /* Callback for reading data from the backend */
void *devicedata; /* Extra platform device dependend data */ void *devicedata; /* Extra platform device dependend data */
char *device; /* Name of the device */ char *device; /* Name of the device */
InputInfoPtr joystick_device; /* Back pointer to the joystick device */
InputInfoPtr keyboard_device; /* Slave device for keyboard events */ InputInfoPtr keyboard_device; /* Slave device for keyboard events */
OsTimerPtr timer; /* Timer for axis movement */ OsTimerPtr timer; /* Timer for axis movement */
@ -123,4 +127,6 @@ typedef struct _JoystickDevRec {
BUTTON button[MAXBUTTONS]; /* Configuration per button */ BUTTON button[MAXBUTTONS]; /* Configuration per button */
} JoystickDevRec; } JoystickDevRec;
void jstkCloseDevice(JoystickDevPtr priv);
#endif #endif

View File

@ -28,7 +28,6 @@
#endif #endif
#include <xorg-server.h> #include <xorg-server.h>
#include <xf86.h>
#include <xf86Xinput.h> #include <xf86Xinput.h>
#include <xf86_OSproc.h> #include <xf86_OSproc.h>
#include <math.h> #include <math.h>

View File

@ -200,6 +200,7 @@ int jstkKeyboardPreInit(InputDriverPtr drv, InputInfoPtr pInfo, int flags)
pInfo->read_input = NULL; pInfo->read_input = NULL;
pInfo->control_proc = NULL; pInfo->control_proc = NULL;
pInfo->switch_mode = NULL; pInfo->switch_mode = NULL;
if (!(pInfo->flags & XI86_SERVER_FD))
pInfo->fd = -1; pInfo->fd = -1;
pInfo->type_name = XI_JOYSTICK; pInfo->type_name = XI_JOYSTICK;