@Override public boolean isPeripheralAvailable (Peripheral peripheral) { return input.isPeripheralAvailable(peripheral); }
public RemoteSender (String ip, int port) { try { Socket socket = new Socket(ip, port); socket.setTcpNoDelay(true); socket.setSoTimeout(3000); out = new DataOutputStream(socket.getOutputStream()); out.writeBoolean(Gdx.input.isPeripheralAvailable(Peripheral.MultitouchScreen)); connected = true; Gdx.input.setInputProcessor(this); } catch (Exception e) { Gdx.app.log("RemoteSender", "couldn't connect to " + ip + ":" + port); } }
public RemoteSender (String ip, int port) { try { Socket socket = new Socket(ip, port); socket.setTcpNoDelay(true); socket.setSoTimeout(3000); out = new DataOutputStream(socket.getOutputStream()); out.writeBoolean(Gdx.input.isPeripheralAvailable(Peripheral.MultitouchScreen)); connected = true; Gdx.input.setInputProcessor(this); } catch (Exception e) { Gdx.app.log("RemoteSender", "couldn't connect to " + ip + ":" + port); } }
@Override public void create () { Gdx.app.log("Multitouch", "multitouch supported: " + Gdx.input.isPeripheralAvailable(Peripheral.MultitouchScreen)); renderer = new ShapeRenderer(); camera = new OrthographicCamera(); viewport = new ScreenViewport(camera); Gdx.input.setInputProcessor(this); }
public static boolean isKeyboardEnabled() { return Gdx.input.isPeripheralAvailable(Peripheral.HardwareKeyboard); }
public RemoteSender (String ip, int port) { try { Socket socket = new Socket(ip, port); socket.setTcpNoDelay(true); socket.setSoTimeout(3000); out = new DataOutputStream(socket.getOutputStream()); out.writeBoolean(Gdx.input.isPeripheralAvailable(Peripheral.MultitouchScreen)); connected = true; Gdx.input.setInputProcessor(this); } catch (Exception e) { Gdx.app.log("RemoteSender", "couldn't connect to " + ip + ":" + port); } }
public void show() { if (!Gdx.input.isPeripheralAvailable(Peripheral.MultitouchScreen)) { setVisible(true); } else { setVisible(false); } }
/** * Convenience method that does essentially the same thing as init(Map<Character, String>). * This assumes that each String passed to this is an action, and the first letter of a String is the character that * a keypress would generate to perform the action named by the String. For example, calling this with * {@code init("fire", "Fortify")} would register "fire" under 'f' and "Fortify" under 'F', displaying the Strings * instead of the characters if possible. The first char of each String should be unique in the arguments. * <br> * This also initializes the displayed buttons if there is no hardware keyboard available. This uses the color and * eightWay fields to determine what color the buttons will be drawn with and if directions should be 8-way or * 4-way, respectively. These fields should be set before calling init() if you don't want the defaults, which are * white buttons and 8-way directions. * @param font the TextCellFactory to use for the buttons, usually a distance field font from DefaultResources * @param enabled an array or vararg of Strings that name actions; the first char of each String should be unique */ public void init(TextCellFactory font, String... enabled) { if(!forceButtons && Gdx.input.isPeripheralAvailable(Input.Peripheral.HardwareKeyboard)) return; ready(font); availableKeys = new TreeMap<>(); if(enabled == null) return; for (int i = 0; i < enabled.length; i++) { if(enabled[i] != null && !enabled[i].isEmpty()) availableKeys.put(enabled[i].charAt(0), enabled[i]); } fillActions(); } /**
/** * For each char and String in available, registers each keyboard key (as a char, such as 'A' or * SquidInput.LEFT_ARROW) with a String that names the action that key is used to perform, and makes these Strings * available as buttons on the right side of the screen if on a device with no hardware keyboard. Arrows will be * provided on the left side of the screen for directions. * <br> * This uses the color and eightWay fields to determine what color the buttons will be drawn with and if directions * should be 8-way or 4-way, respectively. These fields should be set before calling init() if you don't want the * defaults, which are white buttons and 8-way directions. * @param font the TextCellFactory to use for the buttons, usually a distance field font from DefaultResources * @param available a Map of Character keys representing keyboard keys and Strings for the actions they trigger */ public void init(TextCellFactory font, Map<Character, String> available) { if(!forceButtons && Gdx.input.isPeripheralAvailable(Input.Peripheral.HardwareKeyboard)) return; ready(font); if(available != null) { availableKeys = new TreeMap<>(available); fillActions(); } } private VisualInput() {
private InteractiveActor getActorUnderCursor() { final float tolerance; if (inventoryUI.isDragging()) tolerance = DPIUtils.getTouchMinSize(); else if (Gdx.input.isPeripheralAvailable(Peripheral.MultitouchScreen)) tolerance = DPIUtils.getTouchMinSize() / 2; else tolerance = 0; return ui.getWorld().getInteractiveActorAtInput(viewport, tolerance); }
@Override public void show() { final Locale locale = I18N.getCurrentLocale(); String filename = null; UIModes uiMode = UIModes.valueOf(Config.getProperty(Config.UI_MODE, "TWO_BUTTONS").toUpperCase(Locale.ENGLISH)); if (Gdx.input.isPeripheralAvailable(Peripheral.MultitouchScreen) && uiMode == UIModes.TWO_BUTTONS) { uiMode = UIModes.PIE; } switch (uiMode) { case PIE: filename = PIE_FILENAME; break; case SINGLE_CLICK: filename = SINGLE_CLICK_FILENAME; break; case TWO_BUTTONS: filename = TWO_BUTTONS_FILENAME; break; } localeFilename = MessageFormat.format("{0}_{1}.png", filename, locale.getLanguage()); if (!EngineAssetManager.getInstance().assetExists(localeFilename)) localeFilename = MessageFormat.format("{0}.png", filename); tex = new Texture(EngineAssetManager.getInstance().getResAsset(localeFilename)); tex.setFilter(TextureFilter.Linear, TextureFilter.Linear); Gdx.input.setInputProcessor(inputProcessor); }
boolean accelerometer = Gdx.input.isPeripheralAvailable(Peripheral.Accelerometer); boolean compass = Gdx.input.isPeripheralAvailable(Peripheral.Compass); boolean hardwareKeyboard = Gdx.input.isPeripheralAvailable(Peripheral.HardwareKeyboard); boolean multitouch = Gdx.input.isPeripheralAvailable(Peripheral.MultitouchScreen); boolean screenKeyboard = Gdx.input.isPeripheralAvailable(Peripheral.OnscreenKeyboard); boolean vibrator = Gdx.input.isPeripheralAvailable(Peripheral.Vibrator);
private void update(float delta) { final World world = ui.getWorld(); currentActor = null; if (!world.isDisposed()) { world.update(delta * speed); } AssetState assetState = world.getAssetState(); if (assetState != AssetState.LOADED) { ui.setCurrentScreen(Screens.LOADING_SCREEN); return; } stage.act(delta); worldViewportStage.act(delta); if (world.isPaused()) return; recorder.update(delta * speed); testerBot.update(delta * speed); if (uiEnabled && !world.hasDialogOptions()) { final float tolerance; if (Gdx.input.isPeripheralAvailable(Peripheral.MultitouchScreen)) tolerance = DPIUtils.getTouchMinSize(); else tolerance = 0; currentActor = world.getInteractiveActorAtInput(worldViewport, tolerance); verbUI.setCurrentActor(currentActor); } }
if (Gdx.input.isPeripheralAvailable(Peripheral.MultitouchScreen) && uiMode == UIModes.TWO_BUTTONS) { uiMode = UIModes.PIE;
boolean multiTouch = Gdx.input.isPeripheralAvailable(Peripheral.MultitouchScreen);