• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 
2 package com.badlogic.gdx.scenes.scene2d.utils;
3 
4 import com.badlogic.gdx.Gdx;
5 import com.badlogic.gdx.Input.Buttons;
6 import com.badlogic.gdx.Input.Keys;
7 
8 public class UIUtils {
9 	static public boolean isMac = System.getProperty("os.name").contains("OS X");
10 	static public boolean isWindows = System.getProperty("os.name").contains("Windows");
11 	static public boolean isLinux = System.getProperty("os.name").contains("Linux");
12 
left()13 	static public boolean left () {
14 		return Gdx.input.isButtonPressed(Buttons.LEFT);
15 	}
16 
left(int button)17 	static public boolean left (int button) {
18 		return button == Buttons.LEFT;
19 	}
20 
right()21 	static public boolean right () {
22 		return Gdx.input.isButtonPressed(Buttons.RIGHT);
23 	}
24 
right(int button)25 	static public boolean right (int button) {
26 		return button == Buttons.RIGHT;
27 	}
28 
middle()29 	static public boolean middle () {
30 		return Gdx.input.isButtonPressed(Buttons.MIDDLE);
31 	}
32 
middle(int button)33 	static public boolean middle (int button) {
34 		return button == Buttons.MIDDLE;
35 	}
36 
shift()37 	static public boolean shift () {
38 		return Gdx.input.isKeyPressed(Keys.SHIFT_LEFT) || Gdx.input.isKeyPressed(Keys.SHIFT_RIGHT);
39 	}
40 
shift(int keycode)41 	static public boolean shift (int keycode) {
42 		return keycode == Keys.SHIFT_LEFT || keycode == Keys.SHIFT_RIGHT;
43 	}
44 
ctrl()45 	static public boolean ctrl () {
46 		if (isMac)
47 			return Gdx.input.isKeyPressed(Keys.SYM);
48 		else
49 			return Gdx.input.isKeyPressed(Keys.CONTROL_LEFT) || Gdx.input.isKeyPressed(Keys.CONTROL_RIGHT);
50 	}
51 
ctrl(int keycode)52 	static public boolean ctrl (int keycode) {
53 		if (isMac)
54 			return keycode == Keys.SYM;
55 		else
56 			return keycode == Keys.CONTROL_LEFT || keycode == Keys.CONTROL_RIGHT;
57 	}
58 
alt()59 	static public boolean alt () {
60 		return Gdx.input.isKeyPressed(Keys.ALT_LEFT) || Gdx.input.isKeyPressed(Keys.ALT_RIGHT);
61 	}
62 
alt(int keycode)63 	static public boolean alt (int keycode) {
64 		return keycode == Keys.ALT_LEFT || keycode == Keys.ALT_RIGHT;
65 	}
66 }
67