Package com.iizix.term
Class KeyboardRemapper
- java.lang.Object
- com.iizix.term.KeyboardRemapper
- All Implemented Interfaces:
TerminalKeys
public class KeyboardRemapper extends java.lang.Object implements TerminalKeys
The keyboard remapper that maps KeyEvents to Send Keys.
Field Summary
Fields inherited from interface com.iizix.term.TerminalKeys
KEY_AlternateCursor, KEY_Attention, KEY_Backspace, KEY_BackwardWordTab, KEY_CapsLock, KEY_Clear, KEY_CmdKey, KEY_CursorDown, KEY_CursorDownFast, KEY_CursorLeft, KEY_CursorLeftFast, KEY_CursorRight, KEY_CursorRightFast, KEY_CursorSelect, KEY_CursorUp, KEY_CursorUpFast, KEY_Delete, KEY_DestructiveBackspace, KEY_Dup, KEY_End, KEY_Enter, KEY_EraseEOF, KEY_EraseInput, KEY_FieldExit, KEY_FieldMark, KEY_FieldMinus, KEY_FieldPlus, KEY_ForwardWordTab, KEY_Help, KEY_Home, KEY_Insert, KEY_InsertToggle, KEY_LeftTab, KEY_MinusSign, KEY_NewLine, KEY_PA1, KEY_PA2, KEY_PA3, KEY_PageDown, KEY_PageUp, KEY_PF1, KEY_PF10, KEY_PF11, KEY_PF12, KEY_PF13, KEY_PF14, KEY_PF15, KEY_PF16, KEY_PF17, KEY_PF18, KEY_PF19, KEY_PF2, KEY_PF20, KEY_PF21, KEY_PF22, KEY_PF23, KEY_PF24, KEY_PF3, KEY_PF4, KEY_PF5, KEY_PF6, KEY_PF7, KEY_PF8, KEY_PF9, KEY_PlusSign, KEY_Print, KEY_PrintPC, KEY_PrintPS, KEY_RecordBackspace, KEY_Reset, KEY_RightTab, KEY_Space, KEY_SystemRequest, KEY_Test, KEY_WordDelete
Constructor Summary
Constructors Constructor Description KeyboardRemapper()
Creates a keyboard remapper with the defaults.KeyboardRemapper(KeyboardRemapper kr)
Creates a keyboard remapper with the settings from another keyboard remapper.KeyboardRemapper(XFile file)
Initializes the keyboard map from a file.
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addKey(int key, int[] augmentations)
Adds a key with augmentations.static KeyboardRemapper
cloneCurrentKeyboardRemapper()
Creates a clone of the current manager.static int[]
getDefaultSendKeys(int key)
Gets default settings for a key.static int
getHostKey(int index)
Gets the host key value from an index.static int
getKeyFromName(java.lang.String name)
Gets the key from a key name.static int
getKeyIndex(int key)
Gets the index of a key for the key names table.static java.lang.String
getKeyName(int key)
Gets the name for a key.static java.lang.String[]
getKeyNames()
Returns an enumeration of String object instance of all available key strings.int[]
getKeys()
Gets the array of defined keys.int[]
getSendKeys(int key)
Gets the send keys for all the augmentation keys assigned on a particular key.java.util.HashMap<java.lang.Integer,byte[]>
getTerminalMap()
Gets the table for Terminal remap.static void
initializeKeyboardRemapper(XFile file)
Initializes the keyboard map from a file.static void
installKeyboardRemapper(KeyboardRemapper kr)
Installs a new keyboard mapper as the current one.static void
installKeyboardRemapper(KeyboardRemapper kr, boolean doLogEvent)
Installs a new keyboard mapper as the current one.static int
mapToDefaultSendKey(int key, boolean isShift, boolean isControl, boolean isAlt)
Default keyboard remapper.static int
mapToSendKey(int key, boolean isShift, boolean isControl, boolean isAlt)
Default keyboard remapper.int
mapToSendKey2(int key, boolean isShift, boolean isControl, boolean isAlt)
Custom keyboard remapper.boolean
saveToFile()
Saves the current definition to the default file "ProgramName.keyboardMap".void
writeToFile(XOutputFile file)
Writes the definition of the keyboard map to the file.
Constructor Detail
KeyboardRemapper
public KeyboardRemapper()
Creates a keyboard remapper with the defaults.
KeyboardRemapper
public KeyboardRemapper(KeyboardRemapper kr)
Creates a keyboard remapper with the settings from another keyboard remapper. If the parameterKeyboardRemapper kr
is null, a default remapper is created.
KeyboardRemapper
public KeyboardRemapper(XFile file) throws java.io.IOException
Initializes the keyboard map from a file.- Throws:
java.io.IOException
- when a file error occurs.
Method Detail
initializeKeyboardRemapper
public static void initializeKeyboardRemapper(XFile file) throws java.io.IOException
Initializes the keyboard map from a file.- Throws:
java.io.IOException
- when a file error occurs.
getKeyName
public static java.lang.String getKeyName(int key)
Gets the name for a key.- Returns:
- null if not found.
getKeyIndex
public static int getKeyIndex(int key)
Gets the index of a key for the key names table.- Returns:
- -1 if not found.
getHostKey
public static int getHostKey(int index)
Gets the host key value from an index.
getKeyNames
public static java.lang.String[] getKeyNames()
Returns an enumeration of String object instance of all available key strings.
getKeyFromName
public static int getKeyFromName(java.lang.String name)
Gets the key from a key name.- Returns:
- -1 if not found.
cloneCurrentKeyboardRemapper
public static KeyboardRemapper cloneCurrentKeyboardRemapper()
Creates a clone of the current manager.
installKeyboardRemapper
public static void installKeyboardRemapper(KeyboardRemapper kr)
Installs a new keyboard mapper as the current one.
installKeyboardRemapper
public static void installKeyboardRemapper(KeyboardRemapper kr, boolean doLogEvent)
Installs a new keyboard mapper as the current one. ThedoLogEvent
flag will cause (or not) an event to be written in the event log.
mapToSendKey
public static int mapToSendKey(int key, boolean isShift, boolean isControl, boolean isAlt)
Default keyboard remapper.- Returns:
- the send key used by HostSession.sendKey, or -1 for no valid send key.
mapToDefaultSendKey
public static int mapToDefaultSendKey(int key, boolean isShift, boolean isControl, boolean isAlt)
Default keyboard remapper.- Returns:
- the send key used by HostSession.sendKey, -1 for no valid send key.
getDefaultSendKeys
public static int[] getDefaultSendKeys(int key)
Gets default settings for a key.
mapToSendKey2
public int mapToSendKey2(int key, boolean isShift, boolean isControl, boolean isAlt)
Custom keyboard remapper.- Returns:
- the send key used by HostSession.sendKey, -1 for no valid send key.
saveToFile
public boolean saveToFile()
Saves the current definition to the default file "ProgramName.keyboardMap".
writeToFile
public void writeToFile(XOutputFile file) throws java.io.IOException
Writes the definition of the keyboard map to the file.- Throws:
java.io.IOException
- when a file error occurs.
getKeys
public int[] getKeys()
Gets the array of defined keys.
getSendKeys
public int[] getSendKeys(int key)
Gets the send keys for all the augmentation keys assigned on a particular key.The augmentation keys table:
0 - Shift=0, Control=0, Alt=0: No augmentation 1 - Shift=1, Control=0, Alt=0: Shift 2 - Shift=0, Control=1, Alt=0: Control 3 - Shift=1, Control=1, Alt=0: Shift+Control 4 - Shift=0, Control=0, Alt=1: Alt 5 - Shift=1, Control=0, Alt=1: Shift+Alt 6 - Shift=0, Control=1, Alt=1: Control+Alt 7 - Shift=1, Control=1, Alt=1: Shift+Control+Alt
addKey
public void addKey(int key, int[] augmentations)
Adds a key with augmentations.
getTerminalMap
public java.util.HashMap<java.lang.Integer,byte[]> getTerminalMap()
Gets the table for Terminal remap.