mirror of the now-defunct rocklinux.org
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

76 lines
2.9 KiB

  1. #!/bin/bash
  2. # --- ROCK-COPYRIGHT-NOTE-BEGIN ---
  3. #
  4. # This copyright note is auto-generated by ./scripts/Create-CopyPatch.
  5. # Please add additional copyright information _after_ the line containing
  6. # the ROCK-COPYRIGHT-NOTE-END tag. Otherwise it might get removed by
  7. # the ./scripts/Create-CopyPatch script. Do not edit this copyright text!
  8. #
  9. # ROCK Linux: rock-src/package/base/sysfiles/stone_mod_joystick.sh
  10. # ROCK Linux is Copyright (C) 1998 - 2006 Clifford Wolf
  11. #
  12. # This program is free software; you can redistribute it and/or modify
  13. # it under the terms of the GNU General Public License as published by
  14. # the Free Software Foundation; either version 2 of the License, or
  15. # (at your option) any later version. A copy of the GNU General Public
  16. # License can be found at Documentation/COPYING.
  17. #
  18. # Many people helped and are helping developing ROCK Linux. Please
  19. # have a look at http://www.rocklinux.org/ and the Documentation/TEAM
  20. # file for details.
  21. #
  22. # --- ROCK-COPYRIGHT-NOTE-END ---
  23. #
  24. # [MAIN] 80 joystick Joystick Configuration
  25. #jstest output
  26. #Driver version is 2.1.0.
  27. #Joystick (LogiCad3D Magellan / SpaceMouse) has 6 axes (X, Y, Z, Rx, Ry, Rz)
  28. #and 9 buttons (Btn0, Btn1, Btn2, Btn3, Btn4, Btn5, Btn6, Btn7, Btn8).
  29. add_js() { #{{{
  30. unset cmd
  31. while read long short desc ; do
  32. cmd="${cmd} '${desc}' 'driver=\"${long}\"'"
  33. done < <( inputattach --help | grep -- -- )
  34. eval "gui_menu add_js 'Add new joystick' ${cmd}"
  35. [ -z "${driver}" ] && return
  36. gui_input "Enter device to attach ${desc} to" "/dev/tts/0" device
  37. [ -z "${device}" ] && return
  38. if grep -q "joystick ${driver} ${device}" /etc/conf/joystick ; then
  39. gui_message "This device is already configured!"
  40. return
  41. fi
  42. inputattach ${driver} ${device} &
  43. sleep 1
  44. for x in /dev/input/js* ; do : ; done
  45. jscal -c ${x}
  46. read command parameter setting dev < <( jscal -p ${x} )
  47. echo "joystick ${driver} ${device} ${setting}" >> /etc/conf/joystick
  48. } #}}}
  49. edit_js() {
  50. driver="${1}" ; shift
  51. device="${1}" ; shift
  52. setting="${1}" ; shift
  53. name="${@}"
  54. gui_menu edit_js "Edit ${name} on ${device}" "Change device ${device}" "gui_input 'Enter new device name' '${device}' device" \
  55. "Recalibrate this joystick" "sed -e 's=^joystick ${driver} ${device} ${setting}=joystick ${driver} ${device} recalibrate=g' -i /etc/conf/joystick ; rc joystick restart"
  56. }
  57. main() {
  58. [ -e /etc/conf/joystick ] || touch /etc/conf/joystick
  59. tmp="$( mktemp )"
  60. inputattach --help > ${tmp}
  61. while
  62. unset cmd
  63. while read type driver device setting ; do
  64. [ "${type}" == "joystick" ] || continue
  65. read long short name < <( grep -- ${driver} ${tmp} )
  66. if [ -z "${name}" ] ; then
  67. gui_message "Unknown driver \"${long}\" on device \"${device}\"!"
  68. fi
  69. cmd="${cmd} 'Edit ${name} on ${device}' 'edit_js ${driver} ${device} ${setting} ${name}'"
  70. done < /etc/conf/joystick
  71. eval "gui_menu joystick 'Joystick settings' 'Add new joystick' 'add_js' 'Configured joysticks' '' ${cmd}"
  72. do :
  73. done
  74. }