Class KeyboardRemapper

  • All Implemented Interfaces:
    TerminalKeys

    public class KeyboardRemapper
    extends java.lang.Object
    implements TerminalKeys
    The keyboard remapper that maps KeyEvents to Send Keys.
    • 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 parameter KeyboardRemapper 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. The doLogEvent 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.