com.badlogic.gdx.Input.isPeripheralAvailable()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(8.0k)|赞(0)|评价(0)|浏览(127)

本文整理了Java中com.badlogic.gdx.Input.isPeripheralAvailable()方法的一些代码示例,展示了Input.isPeripheralAvailable()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Input.isPeripheralAvailable()方法的具体详情如下:
包路径:com.badlogic.gdx.Input
类名称:Input
方法名:isPeripheralAvailable

Input.isPeripheralAvailable介绍

[英]Queries whether a Peripheral is currently available. In case of Android and the Peripheral#HardwareKeyboardthis returns the whether the keyboard is currently slid out or not.
[中]查询外围设备当前是否可用。如果是Android和外围设备#HardwareKeyboard,则返回当前是否滑出键盘的信息。

代码示例

代码示例来源:origin: libgdx/libgdx

@Override
public boolean isPeripheralAvailable (Peripheral peripheral) {
  return input.isPeripheralAvailable(peripheral);
}

代码示例来源:origin: libgdx/libgdx

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);
  }
}

代码示例来源:origin: libgdx/libgdx

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);
  }
}

代码示例来源:origin: libgdx/libgdx

@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);
}

代码示例来源:origin: Catacomb-Snatch/Catacomb-Snatch

public static boolean isKeyboardEnabled() {
  return Gdx.input.isPeripheralAvailable(Peripheral.HardwareKeyboard);
}

代码示例来源:origin: com.badlogicgames.gdx/gdx

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);
  }
}

代码示例来源:origin: bladecoder/bladecoder-adventure-engine

public void show() {
  if (!Gdx.input.isPeripheralAvailable(Peripheral.MultitouchScreen)) {
    setVisible(true);
  } else {
    setVisible(false);
  }
}

代码示例来源:origin: SquidPony/SquidLib

/**
 * 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();
}
/**

代码示例来源:origin: SquidPony/SquidLib

/**
 * 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() {

代码示例来源:origin: bladecoder/bladecoder-adventure-engine

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);
}

代码示例来源:origin: bladecoder/bladecoder-adventure-engine

@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);
}

代码示例来源:origin: dsaltares/libgdx-cookbook

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);

代码示例来源:origin: bladecoder/bladecoder-adventure-engine

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);
  }
}

代码示例来源:origin: bladecoder/bladecoder-adventure-engine

if (Gdx.input.isPeripheralAvailable(Peripheral.MultitouchScreen) && uiMode == UIModes.TWO_BUTTONS) {
  uiMode = UIModes.PIE;

代码示例来源:origin: bladecoder/bladecoder-adventure-engine

boolean multiTouch = Gdx.input.isPeripheralAvailable(Peripheral.MultitouchScreen);

相关文章