本文整理汇总了Java中org.lwjgl.input.Keyboard类的典型用法代码示例。如果您正苦于以下问题:Java Keyboard类的具体用法?Java Keyboard怎么用?Java Keyboard使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Keyboard类属于org.lwjgl.input包,在下文中一共展示了Keyboard类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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();
}
}
示例2: initGui
import org.lwjgl.input.Keyboard; //导入依赖的package包/类
/**
* Adds the buttons (and other controls) to the screen in question. Called when the GUI is displayed and when the
* window resizes, the buttonList is cleared beforehand.
*/
public void initGui()
{
this.buttonList.clear();
Keyboard.enableRepeatEvents(true);
if (this.bookIsUnsigned)
{
this.buttonList.add(this.buttonSign = new GuiButton(3, this.width / 2 - 100, 4 + this.bookImageHeight, 98, 20, I18n.format("book.signButton", new Object[0])));
this.buttonList.add(this.buttonDone = new GuiButton(0, this.width / 2 + 2, 4 + this.bookImageHeight, 98, 20, I18n.format("gui.done", new Object[0])));
this.buttonList.add(this.buttonFinalize = new GuiButton(5, this.width / 2 - 100, 4 + this.bookImageHeight, 98, 20, I18n.format("book.finalizeButton", new Object[0])));
this.buttonList.add(this.buttonCancel = new GuiButton(4, this.width / 2 + 2, 4 + this.bookImageHeight, 98, 20, I18n.format("gui.cancel", new Object[0])));
}
else
{
this.buttonList.add(this.buttonDone = new GuiButton(0, this.width / 2 - 100, 4 + this.bookImageHeight, 200, 20, I18n.format("gui.done", new Object[0])));
}
int i = (this.width - this.bookImageWidth) / 2;
int j = 2;
this.buttonList.add(this.buttonNextPage = new GuiScreenBook.NextPageButton(1, i + 120, j + 154, true));
this.buttonList.add(this.buttonPreviousPage = new GuiScreenBook.NextPageButton(2, i + 38, j + 154, false));
this.updateButtons();
}
示例3: dispatchKeypresses
import org.lwjgl.input.Keyboard; //导入依赖的package包/类
public void dispatchKeypresses()
{
int i = Keyboard.getEventKey() == 0 ? Keyboard.getEventCharacter() + 256 : Keyboard.getEventKey();
if (i != 0 && !Keyboard.isRepeatEvent())
{
if (!(this.currentScreen instanceof GuiControls) || ((GuiControls)this.currentScreen).time <= getSystemTime() - 20L)
{
if (Keyboard.getEventKeyState())
{
if (i == this.gameSettings.keyBindFullscreen.getKeyCode())
{
this.toggleFullscreen();
}
else if (i == this.gameSettings.keyBindScreenshot.getKeyCode())
{
this.ingameGUI.getChatGUI().printChatMessage(ScreenShotHelper.saveScreenshot(this.mcDataDir, this.displayWidth, this.displayHeight, this.framebufferMc));
}
}
}
}
}
示例4: handleInput
import org.lwjgl.input.Keyboard; //导入依赖的package包/类
/**
* Delegates mouse and keyboard input.
*/
public void handleInput() throws IOException
{
if (Mouse.isCreated())
{
while (Mouse.next())
{
if (net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.client.event.GuiScreenEvent.MouseInputEvent.Pre(this))) continue;
this.handleMouseInput();
if (this.equals(this.mc.currentScreen)) net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.client.event.GuiScreenEvent.MouseInputEvent.Post(this));
}
}
if (Keyboard.isCreated())
{
while (Keyboard.next())
{
if (net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.client.event.GuiScreenEvent.KeyboardInputEvent.Pre(this))) continue;
this.handleKeyboardInput();
if (this.equals(this.mc.currentScreen)) net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.client.event.GuiScreenEvent.KeyboardInputEvent.Post(this));
}
}
}
示例5: 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;
}
示例6: onGuiClosed
import org.lwjgl.input.Keyboard; //导入依赖的package包/类
/**
* "Called when the screen is unloaded. Used to disable keyboard repeat
* events."
*/
@Override
public void onGuiClosed()
{
state = ServerFinderState.CANCELLED;
WurstClient.INSTANCE.analytics.trackEvent("server finder", "cancel",
"gui closed", working);
if(MiscUtils.isInteger(maxThreadsBox.getText()))
{
WurstClient.INSTANCE.options.serverFinderThreads =
Integer.valueOf(maxThreadsBox.getText());
ConfigFiles.OPTIONS.save();
}
Keyboard.enableRepeatEvents(false);
}
示例7: call
import org.lwjgl.input.Keyboard; //导入依赖的package包/类
@Override
public void call(KeyEvent event) {
int key = Keyboard.KEY_RSHIFT;
if (event.getKey() == key) {
if (mc.currentScreen == null) {
for (KeyBinding keyBinding : mc.gameSettings.keyBindings)
if (keyBinding.getKeyCode() == key)
return;
if (!wasSetUp) {
setup(guiManager);
wasSetUp = true;
}
mc.displayGuiScreen(new GuiSerenity(guiManager));
}
}
}
示例8: onBlockActivated
import org.lwjgl.input.Keyboard; //导入依赖的package包/类
@Override
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
if(!worldIn.isRemote) {
if(playerIn.inventory.getCurrentItem().getItem() == MItems.WRENCH) {
TileEntityAccumulator tile = (TileEntityAccumulator) worldIn.getTileEntity(pos);
EnumFacing face = facing;
if(Keyboard.isKeyDown(Keyboard.KEY_LCONTROL)){
face = face.getOpposite();
}
AccumulatorInfo info = tile.getInfoForFace(face);
tile.getInfoForFace(face).setIoInfo(info.getIoInfo().getNext());
tile.markDirty();
return true;
} else
playerIn.openGui(MAS.INSTANCE, 1, worldIn, pos.getX(), pos.getY(), pos.getZ());
}
return true;
}
示例9: initGui
import org.lwjgl.input.Keyboard; //导入依赖的package包/类
/**
* Adds the buttons (and other controls) to the screen in question. Called when the GUI is displayed and when the
* window resizes, the buttonList is cleared beforehand.
*/
public void initGui()
{
Keyboard.enableRepeatEvents(true);
this.buttonList.clear();
this.buttonList.add(new GuiButton(0, this.width / 2 - 100, this.height / 4 + 96 + 18, I18n.format("addServer.add", new Object[0])));
this.buttonList.add(new GuiButton(1, this.width / 2 - 100, this.height / 4 + 120 + 18, I18n.format("gui.cancel", new Object[0])));
this.buttonList.add(this.serverResourcePacks = new GuiButton(2, this.width / 2 - 100, this.height / 4 + 72, I18n.format("addServer.resourcePack", new Object[0]) + ": " + this.serverData.getResourceMode().getMotd().getFormattedText()));
this.serverNameField = new GuiTextField(0, this.fontRendererObj, this.width / 2 - 100, 66, 200, 20);
this.serverNameField.setFocused(true);
this.serverNameField.setText(this.serverData.serverName);
this.serverIPField = new GuiTextField(1, this.fontRendererObj, this.width / 2 - 100, 106, 200, 20);
this.serverIPField.setMaxStringLength(128);
this.serverIPField.setText(this.serverData.serverIP);
this.serverIPField.func_175205_a(this.field_181032_r);
((GuiButton)this.buttonList.get(0)).enabled = this.serverIPField.getText().length() > 0 && this.serverIPField.getText().split(":").length > 0 && this.serverNameField.getText().length() > 0;
}
示例10: initGui
import org.lwjgl.input.Keyboard; //导入依赖的package包/类
@Override
public void initGui()
{
Keyboard.enableRepeatEvents(true);
this.guiLeft = (this.width - this.xSize) / 2;
this.guiTop = (this.height - this.ySize) / 2;
buttonList.clear();
buttonList.add(new GuiButton(ID_CONFIRM, guiLeft + (xSize - 50) / 2, guiTop + ySize + 2, 50, 20, I18n.translateToLocal("gui.done")));
buttonList.add(new GuiButton(ID_WIRELESS_ORDER, guiLeft + xSize + 1, guiTop , 20, 20, ""));
buttonList.add(new GuiButton(ID_UP, guiLeft + xSize + 1, guiTop + 21 , 20, 20, "^"));
buttonList.add(new GuiButton(ID_DOWN, guiLeft + xSize + 1, guiTop + 41, 20, 20, "v"));
channels = new ArrayList<>(master.wirelessPos);
trackList = new GuiWirelessList(this, 93 - 10, ySize - 22, guiTop + 11, guiTop + ySize - 5, guiLeft + 5, 8, channels);
rotateX = 0F;
rotateY = 0F;
releasedMouse = false;
}
示例11: initGui
import org.lwjgl.input.Keyboard; //导入依赖的package包/类
/**
* Adds the buttons (and other controls) to the screen in question. Called when the GUI is displayed and when the
* window resizes, the buttonList is cleared beforehand.
*/
public void initGui()
{
this.buttonList.clear();
Keyboard.enableRepeatEvents(true);
this.presetsTitle = I18n.format("createWorld.customize.presets.title", new Object[0]);
this.presetsShare = I18n.format("createWorld.customize.presets.share", new Object[0]);
this.listText = I18n.format("createWorld.customize.presets.list", new Object[0]);
this.export = new GuiTextField(2, this.fontRendererObj, 50, 40, this.width - 100, 20);
this.list = new GuiFlatPresets.ListSlot();
this.export.setMaxStringLength(1230);
this.export.setText(this.parentScreen.getPreset());
this.btnSelect = this.addButton(new GuiButton(0, this.width / 2 - 155, this.height - 28, 150, 20, I18n.format("createWorld.customize.presets.select", new Object[0])));
this.buttonList.add(new GuiButton(1, this.width / 2 + 5, this.height - 28, 150, 20, I18n.format("gui.cancel", new Object[0])));
this.updateButtonValidity();
}
示例12: initGui
import org.lwjgl.input.Keyboard; //导入依赖的package包/类
/**
* Adds the buttons (and other controls) to the screen in question. Called when the GUI is displayed and when the
* window resizes, the buttonList is cleared beforehand.
*/
public void initGui()
{
Keyboard.enableRepeatEvents(true);
this.buttonList.clear();
this.buttonList.add(this.doneBtn = new GuiButton(0, this.width / 2 - 4 - 150, this.height / 4 + 120 + 12, 150, 20, I18n.format("gui.done", new Object[0])));
this.buttonList.add(this.cancelBtn = new GuiButton(1, this.width / 2 + 4, this.height / 4 + 120 + 12, 150, 20, I18n.format("gui.cancel", new Object[0])));
this.buttonList.add(this.field_175390_s = new GuiButton(4, this.width / 2 + 150 - 20, 150, 20, 20, "O"));
this.commandTextField = new GuiTextField(2, this.fontRendererObj, this.width / 2 - 150, 50, 300, 20);
this.commandTextField.setMaxStringLength(32767);
this.commandTextField.setFocused(true);
this.commandTextField.setText(this.localCommandBlock.getCommand());
this.previousOutputTextField = new GuiTextField(3, this.fontRendererObj, this.width / 2 - 150, 150, 276, 20);
this.previousOutputTextField.setMaxStringLength(32767);
this.previousOutputTextField.setEnabled(false);
this.previousOutputTextField.setText("-");
this.field_175389_t = this.localCommandBlock.shouldTrackOutput();
this.func_175388_a();
this.doneBtn.enabled = this.commandTextField.getText().trim().length() > 0;
}
示例13: onGuiClosed
import org.lwjgl.input.Keyboard; //导入依赖的package包/类
/**
* Called when the screen is unloaded. Used to disable keyboard repeat events
*/
public void onGuiClosed()
{
Keyboard.enableRepeatEvents(false);
this.mc.gameSettings.lastServer = this.ipEdit.getText();
this.mc.gameSettings.saveOptions();
}
示例14: onDisable
import org.lwjgl.input.Keyboard; //导入依赖的package包/类
@Override
protected void onDisable() {
if (!Keyboard.isKeyDown(mc.gameSettings.keyBindSneak.getKeyCode())) {
KeyBinding.setKeyBindState(mc.gameSettings.keyBindSneak.getKeyCode(), false);
if (this.sneaking) {
mc.thePlayer.sendQueue.addToSendQueue(new C0BPacketEntityAction(mc.thePlayer, C0BPacketEntityAction.Action.STOP_SNEAKING));
this.sneaking = false;
}
}
this.sneaking = false;
}
示例15: onGuiClosed
import org.lwjgl.input.Keyboard; //导入依赖的package包/类
/**
* Called when the screen is unloaded. Used to disable keyboard repeat events
*/
public void onGuiClosed()
{
super.onGuiClosed();
Keyboard.enableRepeatEvents(false);
this.inventorySlots.removeCraftingFromCrafters(this);
}