summaryrefslogtreecommitdiffstats
path: root/usr.sbin/bsdconfig/mouse
diff options
context:
space:
mode:
authordteske <dteske@FreeBSD.org>2013-06-18 09:19:59 +0000
committerdteske <dteske@FreeBSD.org>2013-06-18 09:19:59 +0000
commit953191168e0980273af59b0be117609ebc4aa614 (patch)
tree4e381e8232296f211d86c0e3dbac3a0cc1d27eab /usr.sbin/bsdconfig/mouse
parentf0b4d519774767dfe6ba063497771fb12b05689d (diff)
downloadFreeBSD-src-953191168e0980273af59b0be117609ebc4aa614.zip
FreeBSD-src-953191168e0980273af59b0be117609ebc4aa614.tar.gz
Remove unnecessary loops, perform some code consolidation, and add some
additional error checking/reporting. (same thing going on here as SVN r251905 -- just this time for the mouse module instead of console)
Diffstat (limited to 'usr.sbin/bsdconfig/mouse')
-rw-r--r--usr.sbin/bsdconfig/mouse/include/messages.subr2
-rwxr-xr-xusr.sbin/bsdconfig/mouse/port49
-rwxr-xr-xusr.sbin/bsdconfig/mouse/type69
3 files changed, 58 insertions, 62 deletions
diff --git a/usr.sbin/bsdconfig/mouse/include/messages.subr b/usr.sbin/bsdconfig/mouse/include/messages.subr
index d6fe6c3..c775096 100644
--- a/usr.sbin/bsdconfig/mouse/include/messages.subr
+++ b/usr.sbin/bsdconfig/mouse/include/messages.subr
@@ -86,5 +86,7 @@ msg_thinkingmouse="ThinkingMouse"
msg_thinkingmouse_desc="Kensington ThinkingMouse (serial)"
msg_trying_to_start_the_mouse_daemon="Trying to start the mouse daemon..."
msg_type="Type"
+msg_unknown_mouse_port_selection="Unknown mouse port selection"
+msg_unknown_mouse_protocol_selection="Unknown mouse protocol selection"
msg_user_confirmation_requested="User Confirmation Requested"
msg_value_required="Value Required"
diff --git a/usr.sbin/bsdconfig/mouse/port b/usr.sbin/bsdconfig/mouse/port
index a66b29b..8900923 100755
--- a/usr.sbin/bsdconfig/mouse/port
+++ b/usr.sbin/bsdconfig/mouse/port
@@ -121,31 +121,30 @@ f_mustberoot_init
#
# Launch application main menu
#
-while :; do
- dialog_menu_main || f_die
- f_dialog_menutag_fetch mtag
-
- case "$mtag" in
- "1 $msg_ps2") # PS/2 style mouse (/dev/psm0)
- f_sysrc_set moused_port "/dev/psm0" || f_die
- break ;;
- "2 $msg_com1") # Serial mouse on COM1 (/dev/cuau0)
- f_sysrc_set moused_port "/dev/cuau0" || f_die
- break ;;
- "3 $msg_com2") # Serial mouse on COM2 (/dev/cuau1)
- f_sysrc_set moused_port "/dev/cuau1" || f_die
- break ;;
- "4 $msg_com3") # Serial mouse on COM3 (/dev/cuau2)
- f_sysrc_set moused_port "/dev/cuau2" || f_die
- break ;;
- "5 $msg_com4") # Serial mouse on COM4 (/dev/cuau3)
- f_sysrc_set moused_port "/dev/cuau3" || f_die
- break ;;
- "6 $msg_busmouse") # Logitech, ATI or MS bus mouse (/dev/mse0)
- f_sysrc_set moused_port "/dev/mse0" || f_die
- break ;;
- esac
-done
+dialog_menu_main || f_die
+f_dialog_menutag_fetch mtag
+
+moused_port_to_set=
+case "$mtag" in
+"1 $msg_ps2") # PS/2 style mouse (/dev/psm0)
+ moused_port_to_set="/dev/psm0" ;;
+"2 $msg_com1") # Serial mouse on COM1 (/dev/cuau0)
+ moused_port_to_set="/dev/cuau0" ;;
+"3 $msg_com2") # Serial mouse on COM2 (/dev/cuau1)
+ moused_port_to_set="/dev/cuau1" ;;
+"4 $msg_com3") # Serial mouse on COM3 (/dev/cuau2)
+ moused_port_to_set="/dev/cuau2" ;;
+"5 $msg_com4") # Serial mouse on COM4 (/dev/cuau3)
+ moused_port_to_set="/dev/cuau3" ;;
+"6 $msg_busmouse") # Logitech, ATI or MS bus mouse (/dev/mse0)
+ moused_port_to_set="/dev/mse0" ;;
+esac
+
+if [ "$moused_port_to_set" ]; then
+ f_sysrc_set moused_port "$moused_port_to_set" || f_die
+else
+ f_die 1 "$msg_unknown_mouse_port_selection"
+fi
exit $SUCCESS
diff --git a/usr.sbin/bsdconfig/mouse/type b/usr.sbin/bsdconfig/mouse/type
index 7327abb..c290eb4 100755
--- a/usr.sbin/bsdconfig/mouse/type
+++ b/usr.sbin/bsdconfig/mouse/type
@@ -129,43 +129,38 @@ f_mustberoot_init
#
# Launch application main menu
#
-while :; do
- dialog_menu_main || f_die
- f_dialog_menutag_fetch mtag
-
- case "$mtag" in
- "1 $msg_auto") # Bus mouse, PS/2 style mouse or PnP serial mouse
- f_sysrc_set moused_type "auto" || f_die
- break ;;
- "2 $msg_glidepoint") # ALPS GlidePoint pad (serial)
- f_sysrc_set moused_type "glidepoint" || f_die
- break ;;
- "3 $msg_hitachi") # Hitachi tablet (serial)
- f_sysrc_set moused_type "mmhittab" || f_die
- break ;;
- "4 $msg_intellimouse") # Microsoft Intellimouse (serial)
- f_sysrc_set moused_type "intellimouse" || f_die
- break ;;
- "5 $msg_logitech") # Logitech protocol (old models) (serial)
- f_sysrc_set moused_type "logitech" || f_die
- break ;;
- "6 $msg_microsoft") # Microsoft protocol (serial)
- f_sysrc_set moused_type "microsoft" || f_die
- break ;;
- "7 $msg_mm_series") # MM Series protocol (serial)
- f_sysrc_set moused_type "mmseries" || f_die
- break ;;
- "8 $msg_mouseman") # Logitech MouseMan/TrackMan models (serial)
- f_sysrc_set moused_type "mouseman" || f_die
- break ;;
- "9 $msg_mousesystems") # MouseSystems protocol (serial)
- f_sysrc_set moused_type "mousesystems" || f_die
- break ;;
- "A $msg_thinkingmouse") # Kensignton ThinkingMouse (serial)
- f_sysrc_set moused_type "thinkingmouse" || f_die
- break ;;
- esac
-done
+dialog_menu_main || f_die
+f_dialog_menutag_fetch mtag
+
+moused_type_to_set=
+case "$mtag" in
+"1 $msg_auto") # Bus mouse, PS/2 style mouse or PnP serial mouse
+ moused_type_to_set="auto" ;;
+"2 $msg_glidepoint") # ALPS GlidePoint pad (serial)
+ moused_type_to_set="glidepoint" ;;
+"3 $msg_hitachi") # Hitachi tablet (serial)
+ moused_type_to_set="mmhittab" ;;
+"4 $msg_intellimouse") # Microsoft Intellimouse (serial)
+ moused_type_to_set="intellimouse" ;;
+"5 $msg_logitech") # Logitech protocol (old models) (serial)
+ moused_type_to_set="logitech" ;;
+"6 $msg_microsoft") # Microsoft protocol (serial)
+ moused_type_to_set="microsoft" ;;
+"7 $msg_mm_series") # MM Series protocol (serial)
+ moused_type_to_set="mmseries" ;;
+"8 $msg_mouseman") # Logitech MouseMan/TrackMan models (serial)
+ moused_type_to_set="mouseman" ;;
+"9 $msg_mousesystems") # MouseSystems protocol (serial)
+ moused_type_to_set="mousesystems" ;;
+"A $msg_thinkingmouse") # Kensignton ThinkingMouse (serial)
+ moused_type_to_set="thinkingmouse" ;;
+esac
+
+if [ "$moused_type_to_set" ]; then
+ f_sysrc_set moused_type "$moused_type_to_set" || f_die
+else
+ f_die 1 "$msg_unknown_mouse_protocol_selection"
+fi
exit $SUCCESS
OpenPOWER on IntegriCloud