當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。