本文整理汇总了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());
}