From 69eee2fff9e5abda5a30bb435366519d76a17f58 Mon Sep 17 00:00:00 2001 From: Benjamin Schieder Date: Fri, 9 Jun 2006 11:33:51 +0000 Subject: [PATCH] Benjamin Schieder: add joystick stone module and init script [2006060911022927386] (https://www.rocklinux.net/submaster) git-svn-id: http://www.rocklinux.org/svn/rock-linux/trunk@7631 c5f82cb5-29bc-0310-9cd0-bff59a50e3bc --- package/blindcoder/joystick/joystick.conf | 3 + package/blindcoder/joystick/joystick.init | 56 ++++++++++++++ .../blindcoder/joystick/stone_mod_joystick.sh | 76 +++++++++++++++++++ 3 files changed, 135 insertions(+) create mode 100644 package/blindcoder/joystick/joystick.init create mode 100644 package/blindcoder/joystick/stone_mod_joystick.sh diff --git a/package/blindcoder/joystick/joystick.conf b/package/blindcoder/joystick/joystick.conf index b063b50fd..715ee40ca 100644 --- a/package/blindcoder/joystick/joystick.conf +++ b/package/blindcoder/joystick/joystick.conf @@ -25,6 +25,9 @@ joystick_pm() install -m 755 jscal $bindir install -m 755 jstest $bindir install -m 755 inputattach $bindir + + install_init joystick ${confdir}/joystick.init + install -m 755 ${confdir}/stone_mod_joystick.sh ${root}/etc/stone.d/mod_joystick.sh } makeopt="CFLAGS="" jscal jstest inputattach" diff --git a/package/blindcoder/joystick/joystick.init b/package/blindcoder/joystick/joystick.init new file mode 100644 index 000000000..8638d5ecf --- /dev/null +++ b/package/blindcoder/joystick/joystick.init @@ -0,0 +1,56 @@ +#!/bin/bash +# +# --- ROCK-COPYRIGHT-NOTE-BEGIN --- +# +# This copyright note is auto-generated by ./scripts/Create-CopyPatch. +# Please add additional copyright information _after_ the line containing +# the ROCK-COPYRIGHT-NOTE-END tag. Otherwise it might get removed by +# the ./scripts/Create-CopyPatch script. Do not edit this copyright text! +# +# ROCK Linux: rock-src/package/blindcoder/joystick/joystick.init +# ROCK Linux is Copyright (C) 1998 - 2006 Clifford Wolf +# +# 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 of the License, or +# (at your option) any later version. A copy of the GNU General Public +# License can be found at Documentation/COPYING. +# +# Many people helped and are helping developing ROCK Linux. Please +# have a look at http://www.rocklinux.org/ and the Documentation/TEAM +# file for details. +# +# --- ROCK-COPYRIGHT-NOTE-END --- +# +# Desc: joystick Run joystick devices +# Runlevel: 99 rcX +# + +main_begin + block_begin(start, `initialising joysticks') + while read command driver device setting ; do + read long short name < <( D_prefix/bin/inputattach --help | grep -- ${driver} ) + block_split(`${name} on ${device}') + D_prefix/bin/inputattach ${driver} ${device} & + sleep 1 + for x in /dev/input/js* ; do : ; done + if [ "recalibrate" == ${setting} ] ; then + D_prefix/bin/jscal -c ${x} + read command parameter setting dev < <( jscal -p ${x} ) + sed -e "s=^joystick ${driver} ${device} recalibrate=joystick ${driver} ${device} ${setting}=g" -i /etc/conf/joystick + else + block_split(`setting calibration for ${name}') + D_prefix/bin/jscal -s ${setting} ${x} + fi + done < /etc/conf/joystick + block_end + + block_begin(stop, `removing joysticks') + check(`killall inputattach') + block_end + + block_begin(restart, `restarting joysticks') + rc joystick stop + rc joystick start + block_end +main_end diff --git a/package/blindcoder/joystick/stone_mod_joystick.sh b/package/blindcoder/joystick/stone_mod_joystick.sh new file mode 100644 index 000000000..19d8fc7a5 --- /dev/null +++ b/package/blindcoder/joystick/stone_mod_joystick.sh @@ -0,0 +1,76 @@ +#!/bin/bash +# --- ROCK-COPYRIGHT-NOTE-BEGIN --- +# +# This copyright note is auto-generated by ./scripts/Create-CopyPatch. +# Please add additional copyright information _after_ the line containing +# the ROCK-COPYRIGHT-NOTE-END tag. Otherwise it might get removed by +# the ./scripts/Create-CopyPatch script. Do not edit this copyright text! +# +# ROCK Linux: rock-src/package/base/sysfiles/stone_mod_joystick.sh +# ROCK Linux is Copyright (C) 1998 - 2006 Clifford Wolf +# +# 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 of the License, or +# (at your option) any later version. A copy of the GNU General Public +# License can be found at Documentation/COPYING. +# +# Many people helped and are helping developing ROCK Linux. Please +# have a look at http://www.rocklinux.org/ and the Documentation/TEAM +# file for details. +# +# --- ROCK-COPYRIGHT-NOTE-END --- +# +# [MAIN] 80 joystick Joystick Configuration + +#jstest output +#Driver version is 2.1.0. +#Joystick (LogiCad3D Magellan / SpaceMouse) has 6 axes (X, Y, Z, Rx, Ry, Rz) +#and 9 buttons (Btn0, Btn1, Btn2, Btn3, Btn4, Btn5, Btn6, Btn7, Btn8). + +add_js() { #{{{ + unset cmd + while read long short desc ; do + cmd="${cmd} '${desc}' 'driver=\"${long}\"'" + done < <( inputattach --help | grep -- -- ) + eval "gui_menu add_js 'Add new joystick' ${cmd}" + [ -z "${driver}" ] && return + gui_input "Enter device to attach ${desc} to" "/dev/tts/0" device + [ -z "${device}" ] && return + if grep -q "joystick ${driver} ${device}" /etc/conf/joystick ; then + gui_message "This device is already configured!" + return + fi + inputattach ${driver} ${device} & + sleep 1 + for x in /dev/input/js* ; do : ; done + jscal -c ${x} + read command parameter setting dev < <( jscal -p ${x} ) + echo "joystick ${driver} ${device} ${setting}" >> /etc/conf/joystick +} #}}} +edit_js() { + driver="${1}" ; shift + device="${1}" ; shift + setting="${1}" ; shift + name="${@}" + gui_menu edit_js "Edit ${name} on ${device}" "Change device ${device}" "gui_input 'Enter new device name' '${device}' device" \ + "Recalibrate this joystick" "sed -e 's=^joystick ${driver} ${device} ${setting}=joystick ${driver} ${device} recalibrate=g' -i /etc/conf/joystick ; rc joystick restart" +} +main() { + [ -e /etc/conf/joystick ] || touch /etc/conf/joystick + tmp="$( mktemp )" + inputattach --help > ${tmp} + while + unset cmd + while read type driver device setting ; do + [ "${type}" == "joystick" ] || continue + read long short name < <( grep -- ${driver} ${tmp} ) + if [ -z "${name}" ] ; then + gui_message "Unknown driver \"${long}\" on device \"${device}\"!" + fi + cmd="${cmd} 'Edit ${name} on ${device}' 'edit_js ${driver} ${device} ${setting} ${name}'" + done < /etc/conf/joystick + eval "gui_menu joystick 'Joystick settings' 'Add new joystick' 'add_js' 'Configured joysticks' '' ${cmd}" + do : + done +}