Package me.hackware.api.setting.impl
Class KeybindSetting
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).
A bind is a plain key unless it opts in with withMode(); only then does
it carry a Toggle/Hold mode that the GUI shows and the config keeps.
-
Nested Class Summary
Nested Classes -
Field Summary
-
Constructor Summary
ConstructorsConstructorDescriptionKeybindSetting(String name) KeybindSetting(String name, int defaultKey) KeybindSetting(String name, String description) KeybindSetting(String name, String description, int defaultKey) -
Method Summary
Modifier and TypeMethodDescriptionvoiddefaultValue(Integer defaultValue) description(String description) displayName(String displayName) static intfromMouseButton(int button) Encodes a GLFW mouse button (0–7) into the internal code.Returns a human-readable name for the bound key / mouse button, or "..." if unbound.getMode()booleanhasMode()booleanisBound()booleanWhether the key and the mode are both what the bind was declared with.booleanisDown(long windowHandle) Polls the current state of this keybind (keyboard key or mouse button).static booleanisMouseButton(int code) Returnstrueif the stored code represents a mouse button.static StringkeyCodeToGlfwName(int keyCode) Returns the GLFW constant name for a key code (e.g.static intkeyNameToCode(String name) Resolves a key name string (as produced bygetKeyName()) back to a GLFW key code.static StringnameForCode(int key) Human-readable name for any key / mouse-button code, asgetKeyName()produces.voidResets the key and the Toggle/Hold mode, then saves once.voidvoidsetWasDown(boolean wasDown) static inttoMouseButton(int code) Decodes the internal code back to a GLFW mouse button (0–7).voidunbind()visible(boolean visible) visible(BooleanSupplier visible) booleanwasDown()withMode()Gives this bind a Toggle/Hold mode the user can switch.Methods inherited from class me.hackware.api.setting.Setting
get, getDefaultValue, getDescription, getDisplayName, getGroup, getName, getOwner, isBulkLoading, isModal, isVisible, onChanged, setBulkLoadProbe, setModal, setOwner, setValue
-
Constructor Details
-
KeybindSetting
-
KeybindSetting
-
KeybindSetting
-
KeybindSetting
-
-
Method Details
-
isMouseButton
public static boolean isMouseButton(int code) Returnstrueif 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
-
withMode
Gives this bind a Toggle/Hold mode the user can switch. -
displayName
- Overrides:
displayNamein classSetting<Integer>
-
defaultValue
- Overrides:
defaultValuein classSetting<Integer>
-
description
- Overrides:
descriptionin classSetting<Integer>
-
group
-
visible
-
visible
-
getMode
-
hasMode
public boolean hasMode() -
setMode
-
isBound
public boolean isBound() -
unbind
public void unbind() -
isDefault
public boolean isDefault()Whether the key and the mode are both what the bind was declared with. -
resetToDefault
public void resetToDefault()Resets the key and the Toggle/Hold mode, then saves once.- Overrides:
resetToDefaultin classSetting<Integer>
-
wasDown
public boolean wasDown() -
setWasDown
public void setWasDown(boolean wasDown) -
cycleMode
public void cycleMode() -
getKeyName
Returns a human-readable name for the bound key / mouse button, or "..." if unbound. -
nameForCode
Human-readable name for any key / mouse-button code, asgetKeyName()produces. -
keyNameToCode
Resolves a key name string (as produced bygetKeyName()) back to a GLFW key code. ReturnsGLFW.GLFW_KEY_UNKNOWNif the name is unrecognised. -
keyCodeToGlfwName
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). Returnstrueif the bound input is currently pressed.
-