Esempio n. 1
0
 /** {@inheritDoc} */
 @Override
 public void pressKey(Key key, RemoteType remoteType) throws KeyException {
   Map<String, Object> params = new HashMap<String, Object>();
   params.put(COMMAND, key.getKey());
   URL url = formKeyUrl(IrOperation.pressKey, params, remoteType.name());
   executeRequest(url, key.name());
 }
Esempio n. 2
0
  /**
   * Holds a single key for a given amount of time
   *
   * @param key The key to hold
   * @param holdTime The time in milliseconds to hold the key
   * @throws KeyException
   */
  @Override
  public void holdKey(Key key, long holdTime) throws KeyException {
    Map<String, Object> params = new HashMap<String, Object>();

    // 1 keypress in every 100 milliseconds. So dividing by 100 to get the repeat count for keys.
    int repeatCount = Long.valueOf(holdTime / SINGLE_KEY_PRESS_TIME).intValue();
    logger.info("[Hold Key] Key: " + key.name() + " with repeat count: " + repeatCount);

    params.put(COMMAND, key.getKey());
    params.put(HOLD_TIME, repeatCount);
    URL url = formKeyUrl(IrOperation.pressKeyAndHold, params, null);
    executeRequest(url, key.name());
  }
Esempio n. 3
0
  /**
   * Sends multiple keys with a given delay between the keys
   *
   * @param delay The amount of time to wait between keys in milliseconds
   * @param keys The keys to send
   * @throws KeyException
   */
  @Override
  public void pressKeys(long delay, Key... keys) throws KeyException {
    StringBuilder keyStr = new StringBuilder();
    for (Key key : keys) {
      if (!keyStr.toString().isEmpty()) {
        keyStr.append(",");
      }
      keyStr.append(key.getKey());
    }
    Map<String, Object> params = new HashMap<String, Object>();

    params.put(COMMAND_LIST, keyStr.toString());
    params.put(DELAY_IN_MILLIS, delay);
    URL url = formKeyUrl(IrOperation.pressKeys, params, null);
    executeRequest(url, keyStr.toString());
  }