当前位置: 首页>>代码示例>>Java>>正文


Java Keyboard.getKeyIndex方法代码示例

本文整理汇总了Java中org.lwjgl.input.Keyboard.getKeyIndex方法的典型用法代码示例。如果您正苦于以下问题:Java Keyboard.getKeyIndex方法的具体用法?Java Keyboard.getKeyIndex怎么用?Java Keyboard.getKeyIndex使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.lwjgl.input.Keyboard的用法示例。


在下文中一共展示了Keyboard.getKeyIndex方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: remove

import org.lwjgl.input.Keyboard; //导入方法依赖的package包/类
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);
}
 
开发者ID:Wurst-Imperium,项目名称:Wurst-MC-1.12,代码行数:17,代码来源:BindsCmd.java

示例2: getKeyId

import org.lwjgl.input.Keyboard; //导入方法依赖的package包/类
public static int getKeyId(String name) {
    if (name.equals("") || name.equals("NONE")) return Keyboard.KEY_NONE;
    name = name.toUpperCase();
    String param = null;
    if (name.startsWith("MOUSE")) {
        param = name.substring(5);
    }
    if (name.startsWith("BUTTON")) {
        param = name.substring(6);
    }
    if (param != null) {
        try {
            int button = Integer.parseInt(param);
            if (button >= 0 && button < 256) return button | MOUSE;
        } catch (Exception e) {
        }
        return -1;
    }
    int key = Keyboard.getKeyIndex(name.toUpperCase());
    return key;
}
 
开发者ID:NSExceptional,项目名称:Zombe-Modpack,代码行数:22,代码来源:KeyHelper.java

示例3: loadMacros

import org.lwjgl.input.Keyboard; //导入方法依赖的package包/类
public void loadMacros() {
	try {
		File file = new File(xdolfDir.getAbsolutePath(), "macros.txt");
		FileInputStream fstream = new FileInputStream(file.getAbsolutePath());
		DataInputStream in = new DataInputStream(fstream);
		BufferedReader br = new BufferedReader(new InputStreamReader(in));
		String line;
		while((line = br.readLine()) != null) {
			String curLine = line.toLowerCase().trim();
			String[] s = curLine.split(":");
			String cmd = s[0];
			int id = Keyboard.getKeyIndex(s[1].toUpperCase());
			Macro m = new Macro(id, cmd);
		}
		br.close();
	} catch(Exception e) {
		e.printStackTrace();
		saveMacros();
	}
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:21,代码来源:FileManager.java

示例4: add

import org.lwjgl.input.Keyboard; //导入方法依赖的package包/类
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);
}
 
开发者ID:Wurst-Imperium,项目名称:Wurst-MC-1.12,代码行数:16,代码来源:BindsCmd.java

示例5: setKey

import org.lwjgl.input.Keyboard; //导入方法依赖的package包/类
@Override
public void setKey(String key)
{
	WurstClient.INSTANCE.options.zoom.keybind = Keyboard.getKeyIndex(key);
	ConfigFiles.OPTIONS.save();
	buttonList.get(1).displayString = "Zoom Key: " + key;
}
 
开发者ID:Wurst-Imperium,项目名称:Wurst-MC-1.12,代码行数:8,代码来源:GuiZoomManager.java

示例6: runCommand

import org.lwjgl.input.Keyboard; //导入方法依赖的package包/类
@Override
public void runCommand(String[] args) {
    String modName = "";
    String keyName = "";
    if (args.length > 1) {
        modName = args[1];
        if (args.length > 2) {
            keyName = args[2];
        }
    }
    Module module = ModuleManager.getModule(modName);
    if (module.name.equalsIgnoreCase("null")) {
        ChatUtils.sendClientMessage("Invalid Module.");
        return;
    }
    if (keyName == "") {
        ChatUtils.sendClientMessage(String.valueOf(module.name) + "'s bind has been cleared.");
        module.keyBind = 0;
        ModuleManager.save();
        return;
    }
    module.keyBind = Keyboard.getKeyIndex((String)keyName.toUpperCase());
    ModuleManager.save();
    if (Keyboard.getKeyIndex((String)keyName.toUpperCase()) == 0) {
        ChatUtils.sendClientMessage("Invalid Key entered, Bind cleared.");
    } else {
        ChatUtils.sendClientMessage(String.valueOf(module.name) + " bound to " + keyName);
    }
}
 
开发者ID:SkidJava,项目名称:BaseClient,代码行数:30,代码来源:Bind.java

示例7: loadKeybinds

import org.lwjgl.input.Keyboard; //导入方法依赖的package包/类
public void loadKeybinds()
{
	try
	{
		File file = new File(xdolfDir.getAbsolutePath(), "keys.txt");
		FileInputStream fstream = new FileInputStream(file.getAbsolutePath());
		DataInputStream in = new DataInputStream(fstream);
		BufferedReader br = new BufferedReader(new InputStreamReader(in));
		String line;
		while((line = br.readLine()) != null)
		{
			String curLine = line.toLowerCase().trim();
			String[] s = curLine.split(":");
			String hack = s[0];
			int id = Keyboard.getKeyIndex(s[1].toUpperCase());
			for(Module mod: Hacks.hackList)
			{
				if(hack.equalsIgnoreCase("key-" + mod.getName().toLowerCase().replace(" ", "")))
				{
					mod.setKey(id);
				}
			}
		}
		br.close();
	}catch(Exception err)
	{
		err.printStackTrace();
		saveKeybinds();
		System.out.println("[Xdolf] Failed to initialize Xdolf, tell Sgt Pepper or x0XP. " + err.toString());
		err.printStackTrace();
		
		String logString = "FT|CrashLog\r\n[PLAIN]\r\n---Begin plain text---\r\n";
		logString += "Console Log:\r\n";
		logString += "[Xdolf] Failed to initialize Xdolf, tell Sgt Pepper or x0XP. " + err.toString() + "\r\n\r\n";
		for(StackTraceElement ele: err.getStackTrace()) {
			logString += ele.getClassName() + " " + ele.toString() + "\r\n";
		}
		writeCrash(logString);
	}
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:41,代码来源:FileManager.java

示例8: getObjectFromString

import org.lwjgl.input.Keyboard; //导入方法依赖的package包/类
@Override
public Integer getObjectFromString(String string) throws ArgumentParsingException {
    return Keyboard.getKeyIndex(string.toUpperCase());
}
 
开发者ID:SerenityEnterprises,项目名称:SerenityCE,代码行数:5,代码来源:KeyArgument.java


注:本文中的org.lwjgl.input.Keyboard.getKeyIndex方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。