# # tkMOO # ~/.tkMOO-lite/plugins/keypad.tcl # # keypad.tcl is Copyright (c) Joshua May 1999 # # All Rights Reserved # # Permission is hereby granted to use this software for private, academic # and non-commercial use. No commercial or profitable use of this # software may be made without the prior permission of the author. # # THIS PLUGIN IS PROVIDED BY JOSHUA MAY ``AS IS'' AND ANY # EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, # THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR # PURPOSE ARE DISCLAIMED. IN NO EVENT JOSHUA MAY BE LIABLE FOR # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE # GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER # IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS PLUGIN, EVEN # IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # # Manage keypad bindings to commands. # # Default bindings: # ________________________ # /| un- |/ |* |- | # | used| @who| look| up | # |_____|_____|_____|_____| # /|7 |8 |9 |+ | # | nw | n | ne | | # |_____|_____|_____| down| # /|4 |5 |6 | | # | w | home| e | | # |_____|_____|_____|_____| # /|1 |2 |3 |Enter| # | sw | s | se | | # |_____|_____|_____| | # /|0 |. | | # | in | out | | # |___________|_____|_____| # / / / / # client.register keypad start client.register keypad client_connected client.register keypad client_disconnected proc keypad.start {} { preferences.register keypad {Keypad Controls} { { {directive UseKeypadCont} {type boolean} {default On} {display "Use Keypad Plugin"} } { {directive KeyKP_EndMacro} {type string} {default "sw"} {default_if_empty} {display "Keypad 1"} } { {directive KeyKP_DownMacro} {type string} {default "s"} {default_if_empty} {display "Keypad 2"} } { {directive KeyKP_NextMacro} {type string} {default "se"} {default_if_empty} {display "Keypad 3"} } { {directive KeyKP_LeftMacro} {type string} {default "w"} {default_if_empty} {display "Keypad 4"} } { {directive KeyKP_BeginMacro} {type string} {default "home"} {default_if_empty} {display "Keypad 5"} } { {directive KeyKP_RightMacro} {type string} {default "e"} {default_if_empty} {display "Keypad 6"} } { {directive KeyKP_HomeMacro} {type string} {default "nw"} {default_if_empty} {display "Keypad 7"} } { {directive KeyKP_UpMacro} {type string} {default "n"} {default_if_empty} {display "Keypad 8"} } { {directive KeyKP_PriorMacro} {type string} {default "ne"} {default_if_empty} {display "Keypad 9"} } { {directive KeyKP_InsertMacro} {type string} {default "in"} {default_if_empty} {display "Keypad 0"} } { {directive KeyKP_DeleteMacro} {type string} {default "out"} {default_if_empty} {display "Keypad ."} } { {directive KeyKP_AddMacro} {type string} {default "d"} {default_if_empty} {display "Keypad +"} } { {directive KeyKP_SubtractMacro} {type string} {default "u"} {default_if_empty} {display "Keypad -"} } { {directive KeyKP_MultiplyMacro} {type string} {default "look"} {default_if_empty} {display "Keypad *"} } { {directive KeyKP_DivideMacro} {type string} {default "@who"} {default_if_empty} {display "Keypad /"} } { {directive KeyKP_EnterMacro} {type string} {default ""} {default_if_empty} {display "Keypad Enter"} } } } proc keypad.client_connected {} { set use [worlds.get_generic On {} {} UseKeypadCont] if { [string tolower $use] == "on" } { foreach key {KP_Home KP_Up KP_Down KP_Left KP_Right KP_End KP_Prior KP_Next KP_Insert KP_Delete KP_Begin KP_Add KP_Subtract KP_Multiply KP_Divide KP_Enter} { bind .input <$key> "keypad.invoke $key;break" } } } proc keypad.client_disconnected {} { foreach key {KP_Home KP_Up KP_Down KP_Left KP_Right KP_End KP_Prior KP_Next KP_Insert KP_Delete KP_Begin KP_Add KP_Subtract KP_Multiply KP_Divide KP_Enter} { bind .input <$key> "continue" } } proc keypad.invoke key { set action [worlds.get_generic {} {} {} Key${key}Macro] if { $action != "" } { client.outgoing "$action" } }