本文整理匯總了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);
}
示例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;
}
示例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();
}
}
示例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);
}
示例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;
}
示例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);
}
}
示例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);
}
}
示例8: getObjectFromString
import org.lwjgl.input.Keyboard; //導入方法依賴的package包/類
@Override
public Integer getObjectFromString(String string) throws ArgumentParsingException {
return Keyboard.getKeyIndex(string.toUpperCase());
}