Class KeybindSetting

java.lang.Object
me.hackware.api.setting.Setting<Integer>
me.hackware.api.setting.impl.KeybindSetting

public class KeybindSetting extends Setting<Integer>
A setting that stores a keybind (GLFW key code) and its activation mode.

The value is the GLFW key code (GLFW.GLFW_KEY_UNKNOWN = unbound). The mode determines whether the keybind toggles the module or activates it only while held.

  • Constructor Details

    • KeybindSetting

      public KeybindSetting(String name)
    • KeybindSetting

      public KeybindSetting(String name, String description)
    • KeybindSetting

      public KeybindSetting(String name, int defaultKey)
    • KeybindSetting

      public KeybindSetting(String name, String description, int defaultKey)
  • Method Details

    • isMouseButton

      public static boolean isMouseButton(int code)
      Returns true if the stored code represents a mouse button.
    • fromMouseButton

      public static int fromMouseButton(int button)
      Encodes a GLFW mouse button (0–7) into the internal code.
    • toMouseButton

      public static int toMouseButton(int code)
      Decodes the internal code back to a GLFW mouse button (0–7).
    • mode

    • displayName

      public KeybindSetting displayName(String displayName)
      Overrides:
      displayName in class Setting<Integer>
    • defaultValue

      public KeybindSetting defaultValue(Integer defaultValue)
      Overrides:
      defaultValue in class Setting<Integer>
    • description

      public KeybindSetting description(String description)
      Overrides:
      description in class Setting<Integer>
    • group

      public KeybindSetting group(String group)
      Overrides:
      group in class Setting<Integer>
    • visible

      public KeybindSetting visible(boolean visible)
      Overrides:
      visible in class Setting<Integer>
    • visible

      public KeybindSetting visible(BooleanSupplier visible)
      Overrides:
      visible in class Setting<Integer>
    • getMode

      public KeybindSetting.KeybindMode getMode()
    • setMode

      public void setMode(KeybindSetting.KeybindMode mode)
    • isBound

      public boolean isBound()
    • unbind

      public void unbind()
    • wasDown

      public boolean wasDown()
    • setWasDown

      public void setWasDown(boolean wasDown)
    • cycleMode

      public void cycleMode()
    • getKeyName

      public String getKeyName()
      Returns a human-readable name for the bound key / mouse button, or "..." if unbound.
    • nameForCode

      public static String nameForCode(int key)
      Human-readable name for any key / mouse-button code, as getKeyName() produces.
    • keyNameToCode

      public static int keyNameToCode(String name)
      Resolves a key name string (as produced by getKeyName()) back to a GLFW key code. Returns GLFW.GLFW_KEY_UNKNOWN if the name is unrecognised.
    • keyCodeToGlfwName

      public static String keyCodeToGlfwName(int keyCode)
      Returns the GLFW constant name for a key code (e.g. "GLFW_KEY_L"). Falls back to "GLFW_KEY_UNKNOWN" for unmapped codes.
    • isDown

      public boolean isDown(long windowHandle)
      Polls the current state of this keybind (keyboard key or mouse button). Returns true if the bound input is currently pressed.