Java Code Examples for org.lwjgl.input.Keyboard#getKeyIndex()
The following examples show how to use
org.lwjgl.input.Keyboard#getKeyIndex() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GuiHudEditor.java From seppuku with GNU General Public License v3.0 | 6 votes |
@Override public void keyTyped(char typedChar, int keyCode) throws IOException { super.keyTyped(typedChar, keyCode); final HudEditorModule mod = (HudEditorModule) Seppuku.INSTANCE.getModuleManager().find(HudEditorModule.class); if (mod != null) { if (keyCode == Keyboard.getKeyIndex(mod.getKey())) { if (mod.isOpen()) { mod.setOpen(false); } else { Minecraft.getMinecraft().displayGuiScreen(null); } } } for (HudComponent component : Seppuku.INSTANCE.getHudManager().getComponentList()) { if (component.isVisible()) { component.keyTyped(typedChar, keyCode); } } }
Example 2
Source File: BindCommand.java From Happy_MinecraftClient with GNU General Public License v3.0 | 6 votes |
@Override public void execute(String[] strings) { if(strings.length > 2) { final Module module = ModuleManager.getModule(strings[1]); if(module == null) { ChatUtils.displayMessage("§c§lError: §r§aThe entered module not exist."); return; } final int key = Keyboard.getKeyIndex(strings[2].toUpperCase()); module.setKeyBind(key); ChatUtils.displayMessage("§cThe keybind of §a§l" + module.getModuleName() + " §r§cwas set to §a§l" + Keyboard.getKeyName(key) + "§c."); return; } ChatUtils.displayMessage("§c§lSyntax: §r§a.bind <module> <key>"); }
Example 3
Source File: BindsCmd.java From ForgeWurst with GNU General Public License v3.0 | 6 votes |
private void remove(String[] args) throws CmdException { if(args.length != 2) throw new CmdSyntaxError(); String key = args[1].toUpperCase(); if(Keyboard.getKeyIndex(key) == Keyboard.KEY_NONE) throw new CmdSyntaxError("Unknown key: " + key); String oldCommands = wurst.getKeybinds().getCommands(key); if(oldCommands == null) throw new CmdError("Nothing to remove."); wurst.getKeybinds().remove(key); ChatUtils.message("Keybind removed: " + key + " -> " + oldCommands); }
Example 4
Source File: FEResources.java From FEMultiPlayer-V2 with GNU General Public License v3.0 | 6 votes |
/** * Gets the key mapped. * * @param internalKey the internal key * @return the key mapped */ public static int getKeyMapped(int internalKey){ //NOTE: LevelEditorStage does not use this. So its controls are still hard-coded. // However the level editor is not part of the user-facing game, so doesn't need them at the moment. // To fix that, this method should be changed so that instead of using "internalKey" as a keyboard // it should take in an Enum or const that tells the meaning, not the key // for example "back" instead of "key_z" // right now this method has no way of knowing if Z is used for something other than backing out // therefore, right now it has to assume Z is always back out when translating String mappedKey = getProperties().getProperty(Keyboard.getKeyName(internalKey)); if(mappedKey!=null && !mappedKey.equals("")){ return Keyboard.getKeyIndex(mappedKey); } //other controls: //left/right/up/down //backspace //delete //enter return internalKey; }
Example 5
Source File: FEResources.java From FEMultiPlayer-V2 with GNU General Public License v3.0 | 6 votes |
/** * Gets the key mapped name. * * @param internalKeyName the internal key name * @return the key mapped name */ public static String getKeyMappedName(String internalKeyName){ if(internalKeyName.toUpperCase().equals("ENTER")){ internalKeyName = "RETURN"; } int key = Keyboard.getKeyIndex(internalKeyName.toUpperCase()); int mappedKey = getKeyMapped(key); String mappedName = Keyboard.getKeyName(mappedKey); //this might seem redundant, but it's to allow code using the string "Enter" to map to the key "Return" //which then maps the key according to the bindings (possibly to something else) //if it's still "return" we want this translated back to "enter" if(mappedName.equals("RETURN")){ return "ENTER"; } return mappedName; }
Example 6
Source File: MacroModule.java From seppuku with GNU General Public License v3.0 | 5 votes |
@Listener public void keyPress(EventKeyPress event) { for(Macro macro : Seppuku.INSTANCE.getMacroManager().getMacroList()) { if(event.getKey() == Keyboard.getKeyIndex(macro.getKey()) && Keyboard.getKeyIndex(macro.getKey()) != Keyboard.KEY_NONE) { final String[] split = macro.getMacro().split(";"); for(String s : split) { Minecraft.getMinecraft().player.sendChatMessage(s); } } } }
Example 7
Source File: KeybindsModule.java From seppuku with GNU General Public License v3.0 | 5 votes |
@Listener public void keyPress(EventKeyPress event) { for(Module mod : Seppuku.INSTANCE.getModuleManager().getModuleList()) { if(mod != null) { if(mod.getType() != ModuleType.HIDDEN && event.getKey() == Keyboard.getKeyIndex(mod.getKey()) && Keyboard.getKeyIndex(mod.getKey()) != Keyboard.KEY_NONE) { mod.toggle(); } } } }
Example 8
Source File: KeybindCommand.java From ehacks-pro with GNU General Public License v3.0 | 5 votes |
@Override public void process(String[] args) { if (args.length > 0) { Module smod = null; for (Module mod : ModuleController.INSTANCE.modules) { if (mod.getClass().getSimpleName().toLowerCase().replace(" ", "").equals(args[0])) { smod = mod; } } if (smod == null) { InteropUtils.log("&cNo such module '" + escape(args[0]) + "'", "Keybind"); return; } if (args.length == 1) { smod.setKeybinding(0); InteropUtils.log("Keybinding cleared", "Keybind"); ConfigurationManager.instance().saveConfigs(); return; } if (Keyboard.getKeyIndex(args[1].toUpperCase()) == 0) { InteropUtils.log("&cNo such key '" + escape(args[1].toUpperCase()) + "'", "Keybind"); return; } smod.setKeybinding(Keyboard.getKeyIndex(args[1].toUpperCase())); InteropUtils.log("Keybinding set", "Keybind"); ConfigurationManager.instance().saveConfigs(); return; } EHacksGui.clickGui.consoleGui.printChatMessage(new ChatComponentText("\u00a7c/" + this.getName() + " " + this.getCommandArgs())); }
Example 9
Source File: BindsCmd.java From ForgeWurst with GNU General Public License v3.0 | 5 votes |
private void add(String[] args) throws CmdException { if(args.length < 3) throw new CmdSyntaxError(); String key = args[1].toUpperCase(); if(Keyboard.getKeyIndex(key) == Keyboard.KEY_NONE) throw new CmdSyntaxError("Unknown key: " + key); String commands = String.join(" ", Arrays.copyOfRange(args, 2, args.length)); wurst.getKeybinds().add(key, commands); ChatUtils.message("Keybind set: " + key + " -> " + commands); }
Example 10
Source File: KeyOption.java From opsu-dance with GNU General Public License v3.0 | 5 votes |
@Override public void read(String s) { this.keycode = Keyboard.getKeyIndex(s); if (this.keycode == Keyboard.KEY_NONE) { this.keycode = Keyboard.KEY_X; } }
Example 11
Source File: KeyHandler.java From SimplyJetpacks with MIT License | 4 votes |
public static void updateCustomKeybinds(String flyKeyName, String descendKeyName) { flyKey = Keyboard.getKeyIndex(flyKeyName); descendKey = Keyboard.getKeyIndex(descendKeyName); }
Example 12
Source File: ArchimedesConfig.java From archimedes-ships with MIT License | 4 votes |
@SideOnly(Side.CLIENT) private int getKeyIndex(Configuration config, String name, int defaultkey) { return Keyboard.getKeyIndex(config.get("control", name, Keyboard.getKeyName(defaultkey)).getString()); }