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

The following examples show how to use org.lwjgl.input.Keyboard#KEY_P . 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: Example17_1.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:
			persViewPole.reset();
			break;
		case Keyboard.KEY_T:
			drawCameraPos = !drawCameraPos;
			break;
		case Keyboard.KEY_Y:
			depthClampProj = !depthClampProj;
			break;
		case Keyboard.KEY_P:
			timer.togglePause();
			break;
		case Keyboard.KEY_RETURN:
			try {
				loadAndSetupScene();
			} catch(Exception exc) {
				exc.printStackTrace();
				destroy();
			}
			break;
	}
}
 
Example 2
Source File: Example14_2.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_S:
			useFakeHallway = !useFakeHallway;
			if(useFakeHallway)
				System.out.println("Fake Hallway");
			else
				System.out.println("Real Hallway");
			break;
		case Keyboard.KEY_P:
			useSmoothInterpolation = !useSmoothInterpolation;
			if(useSmoothInterpolation)
				System.out.println("Perspective correct interpolation.");
			else
				System.out.println("Just lienar interpolation.");
			break;
	}
}
 
Example 3
Source File: Example13_2.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_P:
			sphereTimer.togglePause();
			break;
		case Keyboard.KEY_MINUS:
			sphereTimer.rewind(0.5f);
			break;
		case Keyboard.KEY_EQUALS:
			sphereTimer.fastForward(0.5f);
			break;
		case Keyboard.KEY_T:
			drawCameraPos = !drawCameraPos;
			break;
		case Keyboard.KEY_G:
			drawLights = !drawLights;
			break;
	}
}
 
Example 4
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 5
Source File: KeybindManager.java    From MediaMod with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Fired when you want to register keybinds
 *
 * @see MediaMod#preInit(FMLPreInitializationEvent)
 */
public void register() {
    // Initialize and declare keybinds
    INSTANCE.disableKeybind = new KeyBinding("key.disableKeybind", Keyboard.KEY_P, "key.categories.mediamod");
    INSTANCE.menuKeybind = new KeyBinding("key.menuKeybind", Keyboard.KEY_M, "key.categories.mediamod");
    INSTANCE.skipKeybind = new KeyBinding("key.skipKeybind", Keyboard.KEY_F, "key.categories.mediamod");
    INSTANCE.pausePlayKeybind = new KeyBinding("key.pausePlayKeybind", Keyboard.KEY_N, "key.categories.mediamod");

    ClientRegistry.registerKeyBinding(disableKeybind);
    ClientRegistry.registerKeyBinding(menuKeybind);
    ClientRegistry.registerKeyBinding(skipKeybind);
    ClientRegistry.registerKeyBinding(pausePlayKeybind);
}
 
Example 6
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 7
Source File: Example15_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) {
	final String[] samplerNames = {
			"Nearest",
			"Linear",
			"Linear with nearest mipmaps",
			"Linear with linear mipmaps",
			"Low anisotropic",
			"Max anisotropic"
	};
	
	switch(key) {
		case Keyboard.KEY_SPACE:
			useMipmapTexture = !useMipmapTexture;
			break;
		case Keyboard.KEY_Y:
			drawCorridor = !drawCorridor;
			break;
		case Keyboard.KEY_P:
			camTimer.togglePause();
			break;
	}
	
	if(c >= '1' && c <= '9') {
		int number = c - '1';
		if(number < NUM_SAMPLERS) {
			System.out.println("Sampler: " + samplerNames[number]);
			currSampler = number;
		}
	}
}
 
Example 8
Source File: Example14_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:
			useTexture = !useTexture;
			if(useTexture)
				System.out.println("Texture");
			else
				System.out.println("Shader");
			break;
		case Keyboard.KEY_P:
			lightTimer.togglePause();
			break;
		case Keyboard.KEY_MINUS:
			lightTimer.rewind(0.5f);
			break;
		case Keyboard.KEY_EQUALS:
			lightTimer.fastForward(0.5f);
			break;
		case Keyboard.KEY_T:
			drawCameraPos = !drawCameraPos;
			break;
		case Keyboard.KEY_G:
			drawLights = !drawLights;
			break;
	}
	
	if(c >= '1' && c <= '9') {
		int number = c - '1';
		if(number < NUM_GAUSS_TEXTURES) {
			System.out.println("Angle resolution: " + calcCosAngResolution(number));
			currTexture = number;
		}
	}
}
 
Example 9
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 10
Source File: Example12_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) {
	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_K:
			setupHDRLighting();
			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 11
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 12
Source File: Example12_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) {
	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))
				setupGammaLighting();
			else
				setupHDRLighting();
			break;
		case Keyboard.KEY_K:
			isGammaCorrect = !isGammaCorrect;
			if(isGammaCorrect)
				System.out.println("Gamma on!");
			else
				System.out.println("Gamma off!");
			break;
		case Keyboard.KEY_Y:
			gammaValue += 0.1f;
			System.out.println("Gamma: " + gammaValue);
			break;
		case Keyboard.KEY_H:
			gammaValue -= 0.1f;
			if(gammaValue < 1f)
				gammaValue = 1;
			System.out.println("Gamma: " + gammaValue);
			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 13
Source File: Example14_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) {
	final String[] shaderModeNames = {
			"Fixed Shininess with Gaussian Texture",
			"Texture shininess with Gaussian Texture",
			"Texture Shininess with computed Gaussian"
	};
	
	switch(key) {
		case Keyboard.KEY_SPACE:
			mode = ShaderMode.values()[(mode.ordinal() + 1) % ShaderMode.length];
			System.out.println(shaderModeNames[mode.ordinal()]);
			break;
		case Keyboard.KEY_P:
			lightTimer.togglePause();
			break;
		case Keyboard.KEY_MINUS:
			lightTimer.rewind(0.5f);
			break;
		case Keyboard.KEY_EQUALS:
			lightTimer.fastForward(0.5f);
			break;
		case Keyboard.KEY_T:
			drawCameraPos = !drawCameraPos;
			break;
		case Keyboard.KEY_G:
			drawLights = !drawLights;
			break;
		case Keyboard.KEY_Y:
			useInfinity = !useInfinity;
			break;
	}
	
	if(c >= '1' && c <= '9') {
		int number = c - '1';
		if(number < NUM_GAUSS_TEXTURES) {
			System.out.println("Angle resolution: " + calcCosAngResolution(number));
			currentTexture = number;
		}
		
		if(number >= 9 - NUMBER_OF_MATERIALS) {
			number -= 9 - NUMBER_OF_MATERIALS;
			System.out.println("Material Number: " + number);
			currentMaterial = number;
		}
	}
}
 
Example 14
Source File: Example13_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:
			sphereTimer.togglePause();
			break;
		case Keyboard.KEY_MINUS:
			sphereTimer.rewind(0.5f);
			break;
		case Keyboard.KEY_EQUALS:
			sphereTimer.fastForward(0.5f);
			break;
		case Keyboard.KEY_T:
			drawCameraPos = !drawCameraPos;
			break;
		case Keyboard.KEY_G:
			drawLights = !drawLights;
			break;
		case Keyboard.KEY_1:
			drawImpostor[0] = !drawImpostor[0];
			break;
		case Keyboard.KEY_2:
			drawImpostor[1] = !drawImpostor[1];
			break;
		case Keyboard.KEY_3:
			drawImpostor[2] = !drawImpostor[2];
			break;
		case Keyboard.KEY_4:
			drawImpostor[3] = !drawImpostor[3];
			break;
		case Keyboard.KEY_L:
			currentImpostor = Impostors.BASIC;
			break;
		case Keyboard.KEY_J:
			currentImpostor = Impostors.PERSPECTIVE;
			break;
		case Keyboard.KEY_H:
			currentImpostor = Impostors.DEPTH;
			break;
	}
}
 
Example 15
Source File: Example17_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) {
	switch(key) {
		case Keyboard.KEY_SPACE:
			lightViewPole.reset();
			break;
		case Keyboard.KEY_T:
			drawCameraPos = !drawCameraPos;
			break;
		case Keyboard.KEY_G:
			showOtherLights = !showOtherLights;
			break;
		case Keyboard.KEY_H:
			currSampler = (currSampler + 1) % NUM_SAMPLERS;
			break;
		case Keyboard.KEY_P:
			timer.togglePause();
			break;
		case Keyboard.KEY_Y:
			currFOVIndex = Math.min(currFOVIndex + 1, lightFOVS.length - 1);
			System.out.println("Curr FOV: " + lightFOVS[currFOVIndex]);
			break;
		case Keyboard.KEY_N:
			currFOVIndex = Math.max(currFOVIndex - 1, 0);
			System.out.println("Curr FOV: " + lightFOVS[currFOVIndex]);
			break;
		case Keyboard.KEY_RETURN:
			try {
				loadAndSetupScene();
			} catch(Exception exc) {
				exc.printStackTrace();
				destroy();
			}
			break;
	}
	
	int posibleIndex = c - '1';
	if(posibleIndex >= 0 && posibleIndex < NUM_LIGHT_TEXTURES) {
		currTextureIndex = posibleIndex;
		System.out.println(texDefs[currTextureIndex][1]);
	}
}
 
Example 16
Source File: ActionButtonPanel.java    From tribaltrouble with GNU General Public License v2.0 4 votes vote down vote up
public final boolean doKeyReleased(KeyboardEvent event) {
	switch (event.getKeyCode()) {
		case Keyboard.KEY_C:
			if (current_armory) {
				if (current_submenu == harvest_group) {
					harvest_rubber_button.shortcutReleased(event.isShiftDown(), event.isControlDown());
				} else if (current_submenu == build_group) {
					build_weapon_rubber_button.shortcutReleased(event.isShiftDown(), event.isControlDown());
				} else if (current_submenu == army_group) {
					army_warrior_rubber_button.shortcutReleased(event.isShiftDown(), event.isControlDown());
				} else if (current_submenu == transport_group) {
					transport_rubber_button.shortcutReleased(event.isShiftDown(), event.isControlDown());
				} else {
					break;
				}
				return true;
			}
			break;
		case Keyboard.KEY_P:
			if (current_quarters) {
				quarters_peon_button.shortcutReleased(event.isShiftDown(), event.isControlDown());
				return true;
			}
			if (current_armory) {
				if (current_submenu == army_group) {
					army_peon_button.shortcutReleased(event.isShiftDown(), event.isControlDown());
				} else {
					break;
				}
				return true;
			}
			break;
		case Keyboard.KEY_I:
			if (current_armory) {
				if (current_submenu == harvest_group) {
					harvest_iron_button.shortcutReleased(event.isShiftDown(), event.isControlDown());
				} else if (current_submenu == build_group) {
					build_weapon_iron_button.shortcutReleased(event.isShiftDown(), event.isControlDown());
				} else if (current_submenu == army_group) {
					army_warrior_iron_button.shortcutReleased(event.isShiftDown(), event.isControlDown());
				} else if (current_submenu == transport_group) {
					transport_iron_button.shortcutReleased(event.isShiftDown(), event.isControlDown());
				} else {
					break;
				}
				return true;
			}
			break;
		case Keyboard.KEY_R:
			if (current_armory) {
				if (current_submenu == harvest_group) {
					harvest_rock_button.shortcutReleased(event.isShiftDown(), event.isControlDown());
				} else if (current_submenu == build_group) {
					build_weapon_rock_button.shortcutReleased(event.isShiftDown(), event.isControlDown());
				} else if (current_submenu == army_group) {
					army_warrior_rock_button.shortcutReleased(event.isShiftDown(), event.isControlDown());
				} else if (current_submenu == transport_group) {
					transport_rock_button.shortcutReleased(event.isShiftDown(), event.isControlDown());
				} else {
					break;
				}
				return true;
			}
			break;
		case Keyboard.KEY_T:
			if (current_armory) {
				if (current_submenu == null) {
					transport_button.mouseClickedAll(LocalInput.LEFT_BUTTON, 0, 0, 1);
				} else {
					break;
				}
				return true;
			}
			break;
		case Keyboard.KEY_W:
			if (current_armory) {
				if (current_submenu == harvest_group) {
					harvest_tree_button.shortcutReleased(event.isShiftDown(), event.isControlDown());
				} else if (current_submenu == transport_group) {
					transport_tree_button.shortcutReleased(event.isShiftDown(), event.isControlDown());
				} else {
					break;
				}
			return true;
			}
			break;
		default:
			break;
	}
	return false;
}
 
Example 17
Source File: ActionButtonPanel.java    From tribaltrouble with GNU General Public License v2.0 4 votes vote down vote up
public final boolean doKeyPressed(KeyboardEvent event) {
	switch (event.getKeyCode()) {
		case Keyboard.KEY_M:
		case Keyboard.KEY_Q:
			if (current_unit)
				return true;
			break;
		case Keyboard.KEY_A:
			if ((current_unit || current_armory || current_tower) && !event.isControlDown())
				return true;
			break;
		case Keyboard.KEY_P:
			if (current_quarters)
				return true;
			if (current_unit)
				break;
		case Keyboard.KEY_G:
		case Keyboard.KEY_T:
			if (current_unit || current_armory)
				return true;
		case Keyboard.KEY_C:
		case Keyboard.KEY_I:
		case Keyboard.KEY_W:
		case Keyboard.KEY_ESCAPE:
			if (current_armory)
				if (current_submenu == harvest_group ||
						current_submenu == build_group ||
						current_submenu == army_group ||
						current_submenu == transport_group)
					return true;
			break;
		case Keyboard.KEY_R:
			if (current_armory || current_quarters)
				return true;
			break;
		case Keyboard.KEY_X:
			if (current_tower)
				return true;
			break;
		default:
			break;
	}
	return false;
}
 
Example 18
Source File: TogglePerspectiveKeybind.java    From Hyperium with GNU Lesser General Public License v3.0 4 votes vote down vote up
public TogglePerspectiveKeybind() {
    super("Perspective", Keyboard.KEY_P);
}