Java Code Examples for org.lwjgl.input.Keyboard#KEY_SPACE

The following examples show how to use org.lwjgl.input.Keyboard#KEY_SPACE . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Example16_3.java    From LWJGL-OpenGL-Tutorials with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Override
public void keyPressed(int key, char c) {
	switch(key) {
		case Keyboard.KEY_SPACE:
			useGammaDisplay = !useGammaDisplay;
			break;
		case Keyboard.KEY_MINUS:
			lightEnv.rewindTime(1);
			break;
		case Keyboard.KEY_EQUALS:
			lightEnv.fastForwardTime(1);
			break;
		case Keyboard.KEY_T:
			drawCameraPos = !drawCameraPos;
			break;
		case Keyboard.KEY_P:
			lightEnv.togglePause();
			break;
	}
	
	if(c >= '1' && c <= '9') {
		int number = c - '1';
		if(number < NUM_SAMPLERS)
			currSampler = number;
	}
}
 
Example 2
Source File: Example16_2.java    From LWJGL-OpenGL-Tutorials with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public void keyPressed(int key, char c) {
	switch(key) {
		case Keyboard.KEY_SPACE:
			drawGammaProgram = !drawGammaProgram;
			drawGammaTexture = !drawGammaTexture;
			break;
		case Keyboard.KEY_A:
			drawGammaProgram = !drawGammaProgram;
			break;
		case Keyboard.KEY_G:
			drawGammaTexture = !drawGammaTexture;
			break;
		case Keyboard.KEY_Y:
			drawCorridor = !drawCorridor;
			break;
		case Keyboard.KEY_P:
			camTimer.togglePause();
			break;
	}
	
	System.out.println("----");
	System.out.printf("Rendering:\t\t%s\n", drawGammaProgram ? "Gamma" : "Linear");
	System.out.printf("Mipmap Generation:\t%s\n", drawGammaTexture ? "Gamma" : "Linear");
	
	if(c >= '1' && c <= '9') {
		int number = c - '1';
		if(number < NUM_SAMPLERS)
			currSampler = number;
	}
}
 
Example 3
Source File: Example7_1.java    From LWJGL-OpenGL-Tutorials with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public void keyPressed(int key, char c) {
	switch(key) {
		case Keyboard.KEY_SPACE:
			drawLookAtPoint = !drawLookAtPoint;
			System.out.printf("Target: %f, %f, %f\n", camTarget.x(), camTarget.y(), camTarget.z());
			System.out.printf("Position: %f,  %f, %f\n", sphereCamRelPos.x(), sphereCamRelPos.y(), sphereCamRelPos.z());
			break;
	}
}
 
Example 4
Source File: GuiProgrammer.java    From PneumaticCraft with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void keyTyped(char key, int keyCode){
    super.keyTyped(key, keyCode);

    if(Keyboard.KEY_I == keyCode && Loader.isModLoaded(ModIds.IGWMOD)) {
        onIGWAction();
    }
    if(Keyboard.KEY_R == keyCode) {
        if(exportButton.getBounds().contains(lastMouseX, lastMouseY)) {
            NetworkHandler.sendToServer(new PacketGuiButton(0));
        }
    }
    if(Keyboard.KEY_SPACE == keyCode) {
        toggleShowWidgets();
    }
    if(Keyboard.KEY_DELETE == keyCode) {
        IProgWidget widget = programmerUnit.getHoveredWidget(lastMouseX, lastMouseY);
        if(widget != null) {
            te.progWidgets.remove(widget);
            NetworkHandler.sendToServer(new PacketProgrammerUpdate(te));
        }
    }
    if(Keyboard.KEY_Z == keyCode) {
        NetworkHandler.sendToServer(new PacketGuiButton(undoButton.id));
    }
    if(Keyboard.KEY_Y == keyCode) {
        NetworkHandler.sendToServer(new PacketGuiButton(redoButton.id));
    }
}
 
Example 5
Source File: Example17_3.java    From LWJGL-OpenGL-Tutorials with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public void keyPressed(int key, char c) {
	switch(key) {
		case Keyboard.KEY_SPACE:
			lightPole.reset();
			break;
		case Keyboard.KEY_T:
			drawCameraPos = !drawCameraPos;
			break;
		case Keyboard.KEY_G:
			showOtherLights = !showOtherLights;
			break;
		case Keyboard.KEY_P:
			timer.togglePause();
			break;
		case Keyboard.KEY_RETURN:
			try {
				loadAndSetupScene();
			} catch(Exception exc) {
				exc.printStackTrace();
				destroy();
			}
			break;
	}
	
	int possibleIndex = c - '1';
	if(possibleIndex >= 0 && possibleIndex < NUM_LIGHT_TEXTURES) {
		currTextureIndex = possibleIndex;
		System.out.println(texDefs[currTextureIndex][1]);
	}
}
 
Example 6
Source File: ArrowButton.java    From tribaltrouble with GNU General Public License v2.0 5 votes vote down vote up
public final void keyReleased(KeyboardEvent event) {
	switch (event.getKeyCode()) {
		case Keyboard.KEY_SPACE:
		case Keyboard.KEY_RETURN:
			mouseReleasedAll(LocalInput.LEFT_BUTTON, 0, 0);
			break;
	}
}
 
Example 7
Source File: GUIObject.java    From tribaltrouble with GNU General Public License v2.0 5 votes vote down vote up
protected void keyReleased(KeyboardEvent event) {
	if (event.getKeyCode() == Keyboard.KEY_SPACE || event.getKeyCode() == Keyboard.KEY_RETURN) {
		mouseReleasedAll(LocalInput.LEFT_BUTTON, 0, 0);
		mouseClickedAll(LocalInput.LEFT_BUTTON, 0, 0, 1);
	} else {
		GUIObject parent = (GUIObject)getParent();
		if (parent != null)
			parent.keyReleasedAll(event);
	}
}
 
Example 8
Source File: Example8_2.java    From LWJGL-OpenGL-Tutorials with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public void keyPressed(int key, char c) {
	if(key == Keyboard.KEY_SPACE) {
		rightMultiply = !rightMultiply;
		System.out.println(rightMultiply ? "Right-multiply" : "Left-multiply");
	}
}
 
Example 9
Source File: Example10_1.java    From LWJGL-OpenGL-Tutorials with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public void keyPressed(int key, char c) {
	switch(key) {
		case Keyboard.KEY_SPACE:
			drawColoredCyl = !drawColoredCyl;
			break;
		case Keyboard.KEY_Y:
			drawLight = !drawLight;
			break;
		case Keyboard.KEY_B:
			lightTimer.togglePause();
			break;
	}
}
 
Example 10
Source File: Example9_2.java    From LWJGL-OpenGL-Tutorials with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public void keyPressed(int key, char c) {
	if(key == Keyboard.KEY_SPACE)
		scaleCyl = !scaleCyl;
	else if(key == Keyboard.KEY_T) {
		doInvTranspose = !doInvTranspose;
		
		if(doInvTranspose)
			System.out.println("Doing inverse transpose.");
		else
			System.out.println("Bad lighting.");
	}
}
 
Example 11
Source File: Example7_2.java    From LWJGL-OpenGL-Tutorials with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public void keyPressed(int key, char c) {
	switch(key) {
		case Keyboard.KEY_SPACE:
			drawLookAtPoint = !drawLookAtPoint;
			System.out.printf("Target: %f, %f, %f\n", camTarget.x(), camTarget.y(), camTarget.z());
			System.out.printf("Position: %f,  %f, %f\n", sphereCamRelPos.x(), sphereCamRelPos.y(), sphereCamRelPos.z());
			break;
	}
}
 
Example 12
Source File: TargetDelegate.java    From tribaltrouble with GNU General Public License v2.0 5 votes vote down vote up
public final void keyPressed(KeyboardEvent event) {
	getCamera().keyPressed(event);
	switch (event.getKeyCode()) {
		case Keyboard.KEY_ESCAPE:
			pop();
			break;
		case Keyboard.KEY_SPACE:
		case Keyboard.KEY_RETURN:
			break;
		default:
			super.keyPressed(event);
			break;
	}
}
 
Example 13
Source File: MapCamera.java    From tribaltrouble with GNU General Public License v2.0 5 votes vote down vote up
public final void keyPressed(KeyboardEvent event) {
	switch (event.getKeyCode()) {
		case Keyboard.KEY_SPACE:
		case Keyboard.KEY_NUMPAD5:
			if (map_mode == TO_MAP || map_mode == IN_MAP)
				changeMode(FROM_MAP);
			else
				changeMode(TO_MAP);
			break;
	}
}
 
Example 14
Source File: SelectionDelegate.java    From tribaltrouble with GNU General Public License v2.0 4 votes vote down vote up
public final void keyPressed(KeyboardEvent event) {
	getCamera().keyPressed(event);
	int army_number = 0;
	switch (event.getKeyCode()) {
		case Keyboard.KEY_SPACE:
		case Keyboard.KEY_NUMPAD5:
			if (!map_mode) {
				selection = false;
				getViewer().getPicker().pickRotate((GameCamera)getCamera());
				map_mode = true;
				if (observer)
					observer_label.remove();
				else
					getActionButtonPanel().remove();
				getCamera().disable();
				setCamera(new MapCamera(this, game_camera));
				getCamera().enable();
			}
			break;
		case Keyboard.KEY_TAB:
			if (!observer) {
				Notification n = getViewer().getNotificationManager().getLatestNotification();
				if (n != null) {
					if (getCamera() instanceof GameCamera)
						getGUIRoot().pushDelegate(new JumpDelegate(getViewer(), (GameCamera)getCamera(), n.getX(), n.getY()));
					else if (getCamera() instanceof MapCamera)
						((MapCamera)getCamera()).mapGoto(n.getX(), n.getY(), true);
				}
			}
			break;
		case Keyboard.KEY_9: army_number++;
		case Keyboard.KEY_8: army_number++;
		case Keyboard.KEY_7: army_number++;
		case Keyboard.KEY_6: army_number++;
		case Keyboard.KEY_5: army_number++;
		case Keyboard.KEY_4: army_number++;
		case Keyboard.KEY_3: army_number++;
		case Keyboard.KEY_2: army_number++;
		case Keyboard.KEY_1: army_number++;
		case Keyboard.KEY_0:
			if (!map_mode && !observer) {
				if (event.isControlDown()) {
					getViewer().getSelection().setShortcutArmy(army_number);
				} else {
					boolean selected = getViewer().getSelection().enableShortcutArmy(army_number);
					if (selected && event.getNumClicks() > 1) {
						Set set = getViewer().getSelection().getCurrentSelection().getSet();
						if (set.size() > 0) {
							Selectable s = (Selectable)set.iterator().next();
							getGUIRoot().pushDelegate(new JumpDelegate(getViewer(), (GameCamera)getCamera(), s.getPositionX(), s.getPositionY()));
						}
					}
				}
			}
			break;
		case Keyboard.KEY_RETURN:
				if (!chat_visible)
					chat_form.setReceivers(!event.isShiftDown());
			break;
		case Keyboard.KEY_B:
			if (event.isControlDown() && !map_mode && !observer) {
				getGUIRoot().pushDelegate(new BeaconDelegate(getViewer(), (GameCamera)getCamera()));
			}
			break;
		case Keyboard.KEY_N:
			nextIdlePeon();
			break;
		case Keyboard.KEY_F:
		case Keyboard.KEY_Z:
			if (!map_mode)
				super.keyPressed(event);
			break;
		default:
			if (map_mode || observer) {
				super.keyPressed(event);
			} else {
				if (!getActionButtonPanel().doKeyPressed(event))
					super.keyPressed(event);
			}
			break;
	}
}
 
Example 15
Source File: Example11_2.java    From LWJGL-OpenGL-Tutorials with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Override
public void keyPressed(int key, char c) {
	boolean changedShininess = false;
	boolean changedLightModel = false;
	
	switch(key) {
		case Keyboard.KEY_SPACE:
			drawColoredCyl = !drawColoredCyl;
			break;
		case Keyboard.KEY_O:
			materialParams.increment(!(Keyboard.isKeyDown(Keyboard.KEY_RSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)));
			changedShininess = true;
			break;
		case Keyboard.KEY_U:
			materialParams.decrement(!(Keyboard.isKeyDown(Keyboard.KEY_RSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)));
			changedShininess = true;
			break;
		case Keyboard.KEY_Y:
			drawLightSource = !drawLightSource;
			break;
		case Keyboard.KEY_T:
			scaleCyl = !scaleCyl;
			break;
		case Keyboard.KEY_B:
			lightTimer.togglePause();
			break;
		case Keyboard.KEY_G:
			drawDark = !drawDark;
			break;
		case Keyboard.KEY_H:
			if(Keyboard.isKeyDown(Keyboard.KEY_RSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) {
				if(lightModel.ordinal() % 2 != 0)
					lightModel = LightingModel.values()[(lightModel.ordinal() - 1) % LightingModel.values().length];
				else
					lightModel = LightingModel.values()[(lightModel.ordinal() + 1) % LightingModel.values().length];
			} else
				lightModel = LightingModel.values()[(lightModel.ordinal() + 2) % LightingModel.values().length];
			
			changedLightModel = true;
			break;
	}
	
	if(changedShininess)
		System.out.printf("Shiny: %f\n", materialParams.getSpecularValue());
	
	if(changedLightModel)
		System.out.printf("%s\n", lightModel);
}
 
Example 16
Source File: Example10_3.java    From LWJGL-OpenGL-Tutorials with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Override
public void keyPressed(int key, char c) {
	boolean changedAtten = false;
	
	switch(key) {
		case Keyboard.KEY_SPACE:
			drawColoredCyl = !drawColoredCyl;
			break;
		case Keyboard.KEY_O:
			lightAttenuation *= Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_RSHIFT) ? 1.1f : 1.5f;
			changedAtten = true;
			break;
		case Keyboard.KEY_U:
			lightAttenuation /= Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_RSHIFT) ? 1.1f : 1.5f;
			changedAtten = true;
			break;
		case Keyboard.KEY_Y:
			drawLight = !drawLight;
			break;
		case Keyboard.KEY_T:
			scaleCyl = !scaleCyl;
			break;
		case Keyboard.KEY_H:
			useRSquare = !useRSquare;
			if(useRSquare)
				System.out.println("Inverse Squared Attenuation");
			else
				System.out.println("Plain Inverse Attenuation");
			
			break;
		case Keyboard.KEY_B:
			lightTimer.togglePause();
			break;
	}
	
	if(lightAttenuation < 0.1f)
		lightAttenuation = 0.1f;
	
	if(changedAtten)
		System.out.println("Atten: " + lightAttenuation);
}
 
Example 17
Source File: Example8_1.java    From LWJGL-OpenGL-Tutorials with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Override
public void keyPressed(int key, char c) {
	if(key == Keyboard.KEY_SPACE)
		drawGimbals = !drawGimbals;
}
 
Example 18
Source File: Example9_1.java    From LWJGL-OpenGL-Tutorials with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Override
public void keyPressed(int key, char c) {
	if(key == Keyboard.KEY_SPACE)
		drawColoredCyl = !drawColoredCyl;
}
 
Example 19
Source File: Example12_1.java    From LWJGL-OpenGL-Tutorials with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Override
public void keyPressed(int key, char c) {
	switch(key) {
		case Keyboard.KEY_P:
			lights.togglePause(timerMode);
			break;
		case Keyboard.KEY_MINUS:
			lights.rewindTime(timerMode, 1);
			break;
		case Keyboard.KEY_EQUALS:
			lights.fastForwardTime(timerMode, 1);
			break;
		case Keyboard.KEY_T:
			drawCameraPos = !drawCameraPos;
			break;
		case Keyboard.KEY_1:
			timerMode = TimerTypes.TIMER_ALL;
			System.out.println("All");
			break;
		case Keyboard.KEY_2:
			timerMode = TimerTypes.TIMER_SUN;
			System.out.println("Sun");
			break;
		case Keyboard.KEY_3:
			timerMode = TimerTypes.TIMER_LIGHTS;
			System.out.println("Lights");
			break;
		case Keyboard.KEY_L:
			if(Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_RSHIFT))
				setupNighttimeLighting();
			else
				setupDaytimeLighting();
			break;
		case Keyboard.KEY_SPACE:
			float sunAlpha = lights.getSunTime();
			float sunTimeHours = sunAlpha * 24 + 12;
			sunTimeHours = sunTimeHours > 24 ? sunTimeHours - 24 : sunTimeHours;
			int sunHours = (int)sunTimeHours;
			float sunTimeMinutes = (sunTimeHours - sunHours) * 60f;
			int sunMinutes = (int)sunTimeMinutes;
			System.out.println(sunHours + ":" + sunMinutes);
			break;
	}
}
 
Example 20
Source File: Example11_1.java    From LWJGL-OpenGL-Tutorials with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Override
public void keyPressed(int key, char c) {
	boolean changedShininess = false;
	boolean changedLightModel = false;
	
	switch(key) {
		case Keyboard.KEY_SPACE:
			drawColoredCyl = !drawColoredCyl;
			break;
		case Keyboard.KEY_O:
			shininessFactor += 0.5f;
			changedShininess = true;
			break;
		case Keyboard.KEY_U:
			shininessFactor -= 0.5f;
			changedShininess = true;
			break;
		case Keyboard.KEY_Y:
			drawLightSource = !drawLightSource;
			break;
		case Keyboard.KEY_T:
			scaleCyl = !scaleCyl;
			break;
		case Keyboard.KEY_B:
			lightTimer.togglePause();
			break;
		case Keyboard.KEY_G:
			drawDark = !drawDark;
			break;
		case Keyboard.KEY_H:
			if(Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_RSHIFT))
				switch(lightModel) {
					case DIFFUSE_AND_SPECULAR:
						lightModel = LightingModel.PURE_DIFFUSE;
						break;
					case PURE_DIFFUSE:
						lightModel = LightingModel.DIFFUSE_AND_SPECULAR;
						break;
					case SPECULAR_ONLY:
						lightModel = LightingModel.PURE_DIFFUSE;
						break;
				}
			else
				lightModel = LightingModel.values()[(lightModel.ordinal() + 1) % LightingModel.values().length];
			
			changedLightModel = true;
			break;
	}
	
	if(shininessFactor <= 0)
		shininessFactor = 0.0001f;
	
	if(changedShininess)
		System.out.printf("Shiny: %f\n", shininessFactor);
	
	if(changedLightModel)
		System.out.printf("%s\n", lightModel.name());
}