port revision 240684
1238438Sdteske#!/bin/sh 2238438Sdteske#- 3238438Sdteske# Copyright (c) 2012 Devin Teske 4238438Sdteske# All Rights Reserved. 5238438Sdteske# 6238438Sdteske# Redistribution and use in source and binary forms, with or without 7238438Sdteske# modification, are permitted provided that the following conditions 8238438Sdteske# are met: 9238438Sdteske# 1. Redistributions of source code must retain the above copyright 10238438Sdteske# notice, this list of conditions and the following disclaimer. 11238438Sdteske# 2. Redistributions in binary form must reproduce the above copyright 12238438Sdteske# notice, this list of conditions and the following disclaimer in the 13238438Sdteske# documentation and/or other materials provided with the distribution. 14238438Sdteske# 15238438Sdteske# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 16238438Sdteske# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING BUT NOT LIMITED TO, THE 17238438Sdteske# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18238438Sdteske# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 19238438Sdteske# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 20238438Sdteske# DAMAGES (INLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 21238438Sdteske# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22238438Sdteske# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 23238438Sdteske# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24238438Sdteske# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25238438Sdteske# SUCH DAMAGE. 26238438Sdteske# 27238438Sdteske# $FreeBSD: head/usr.sbin/bsdconfig/mouse/port 240684 2012-09-18 22:28:42Z dteske $ 28238438Sdteske# 29238438Sdteske############################################################ INCLUDES 30238438Sdteske 31240684SdteskeBSDCFG_SHARE="/usr/share/bsdconfig" 32240684Sdteske. $BSDCFG_SHARE/common.subr || exit 1 33240684Sdteskef_include $BSDCFG_SHARE/dialog.subr 34240684Sdteskef_include $BSDCFG_SHARE/mustberoot.subr 35240684Sdteskef_include $BSDCFG_SHARE/sysrc.subr 36238438Sdteske 37240684SdteskeBSDCFG_LIBE="/usr/libexec/bsdconfig" APP_DIR="110.mouse" 38238438Sdteskef_include_lang $BSDCFG_LIBE/$APP_DIR/include/messages.subr 39238438Sdteske 40238438Sdteskeipgm=$( f_index_menu_selection $BSDCFG_LIBE/$APP_DIR/INDEX "$pgm" ) 41238438Sdteske[ $? -eq $SUCCESS -a "$ipgm" ] && pgm="$ipgm" 42238438Sdteske 43238438Sdteske############################################################ FUNCTIONS 44238438Sdteske 45238438Sdteske# dialog_menu_main 46238438Sdteske# 47238438Sdteske# Display the dialog(1)-based application main menu. 48238438Sdteske# 49238438Sdteskedialog_menu_main() 50238438Sdteske{ 51238438Sdteske local menu_list size 52238438Sdteske local hline="" 53238438Sdteske local prompt="$msg_port_menu_text" 54238438Sdteske 55238438Sdteske menu_list=" 56238438Sdteske '1 $msg_ps2' '$msg_ps2_desc' 57238438Sdteske '2 $msg_com1' '$msg_com1_desc' 58238438Sdteske '3 $msg_com2' '$msg_com2_desc' 59238438Sdteske '4 $msg_com3' '$msg_com3_desc' 60238438Sdteske '5 $msg_com4' '$msg_com4_desc' 61238438Sdteske '6 $msg_busmouse' '$msg_busmouse_desc' 62238438Sdteske " # END-QUOTE 63238438Sdteske 64238438Sdteske size=$( eval f_dialog_menu_size \ 65238438Sdteske \"\$DIALOG_TITLE\" \ 66238438Sdteske \"\$DIALOG_BACKTITLE\" \ 67238438Sdteske \"\$prompt\" \ 68238438Sdteske \"\$hline\" \ 69238438Sdteske $menu_list ) 70238438Sdteske 71238438Sdteske eval $DIALOG \ 72238438Sdteske --clear --title \"\$DIALOG_TITLE\" \ 73238438Sdteske --backtitle \"\$DIALOG_BACKTITLE\" \ 74238438Sdteske --hline \"\$hline\" \ 75238438Sdteske --ok-label \"\$msg_ok\" \ 76238438Sdteske --cancel-label \"\$msg_cancel\" \ 77238438Sdteske --menu \"\$prompt\" $size \ 78238438Sdteske $menu_list \ 79238438Sdteske 2> "$DIALOG_TMPDIR/dialog.menu.$$" 80238438Sdteske} 81238438Sdteske 82238438Sdteske############################################################ MAIN 83238438Sdteske 84238438Sdteske# Incorporate rc-file if it exists 85238438Sdteske[ -f "$HOME/.bsdconfigrc" ] && f_include "$HOME/.bsdconfigrc" 86238438Sdteske 87238438Sdteske# 88238438Sdteske# Process command-line arguments 89238438Sdteske# 90238438Sdteskewhile getopts hSX flag; do 91238438Sdteske case "$flag" in 92238438Sdteske h|\?) f_usage $BSDCFG_LIBE/$APP_DIR/USAGE "PROGRAM_NAME" "$pgm";; 93238438Sdteske esac 94238438Sdteskedone 95238438Sdteskeshift $(( $OPTIND - 1 )) 96238438Sdteske 97238438Sdteske# 98238438Sdteske# Initialize 99238438Sdteske# 100238438Sdteskef_dialog_init 101238438Sdteskef_dialog_title "$msg_select_your_mouse_port_from_the_following_menu" 102238438Sdteskef_dialog_backtitle "${ipgm:+bsdconfig }$pgm" 103238438Sdteskef_mustberoot_init 104238438Sdteske 105238438Sdteske# 106238438Sdteske# Launch application main menu 107238438Sdteske# 108238438Sdteskewhile :; do 109238438Sdteske dialog_menu_main 110238438Sdteske retval=$? 111238438Sdteske mtag=$( f_dialog_menutag ) 112238438Sdteske 113238438Sdteske [ $retval -eq 0 ] || f_die 114238438Sdteske 115238438Sdteske case "$mtag" in 116238438Sdteske "1 $msg_ps2") # PS/2 style mouse (/dev/psm0) 117238438Sdteske f_sysrc_set moused_port "/dev/psm0" || f_die 118238438Sdteske break ;; 119238438Sdteske "2 $msg_com1") # Serial mouse on COM1 (/dev/cuau0) 120238438Sdteske f_sysrc_set moused_port "/dev/cuau0" || f_die 121238438Sdteske break ;; 122238438Sdteske "3 $msg_com2") # Serial mouse on COM2 (/dev/cuau1) 123238438Sdteske f_sysrc_set moused_port "/dev/cuau1" || f_die 124238438Sdteske break ;; 125238438Sdteske "4 $msg_com3") # Serial mouse on COM3 (/dev/cuau2) 126238438Sdteske f_sysrc_set moused_port "/dev/cuau2" || f_die 127238438Sdteske break ;; 128238438Sdteske "5 $msg_com4") # Serial mouse on COM4 (/dev/cuau3) 129238438Sdteske f_sysrc_set moused_port "/dev/cuau3" || f_die 130238438Sdteske break ;; 131238438Sdteske "6 $msg_busmouse") # Logitech, ATI or MS bus mouse (/dev/mse0) 132238438Sdteske f_sysrc_set moused_port "/dev/mse0" || f_die 133238438Sdteske break ;; 134238438Sdteske esac 135238438Sdteske 136238438Sdteskedone 137238438Sdteske 138238438Sdteskeexit $SUCCESS 139238438Sdteske 140238438Sdteske################################################################################ 141238438Sdteske# END 142238438Sdteske################################################################################ 143