com.harium.etyl.commons.event.KeyEvent.<init>()方法的使用及代码示例

x33g5p2x  于2022-01-24 转载在 其他  
字(4.7k)|赞(0)|评价(0)|浏览(96)

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

KeyEvent.<init>介绍

暂无

代码示例

代码示例来源:origin: com.harium.etyl/etyl

private void axisXEvent(long time, int value) {
  if (value > 0) {
    lastXEvent = KeyEvent.VK_JOYSTICK_RIGHT;
    list.add(new KeyEvent(id, lastXEvent, value, KeyState.PRESSED, time));
  } else if(value < 0) {
    lastXEvent = KeyEvent.VK_JOYSTICK_LEFT;
    list.add(new KeyEvent(id, lastXEvent, value, KeyState.PRESSED, time));
  } else {
    list.add(new KeyEvent(id, lastXEvent, value, KeyState.RELEASED, time));
    list.add(new KeyEvent(id, KeyEvent.VK_JOYSTICK_CENTER_X, value,  KeyState.RELEASED, time));
  }
}

代码示例来源:origin: com.harium/etyl

private void buttonEvent(long time, int value, int channel) {
  int buttonCode = (KeyEvent.VK_JOYSTICK_BUTTON_1)+channel;
  if (value == 1) {
    list.add(new KeyEvent(id, buttonCode, 0,  KeyState.PRESSED, time));
  } else {
    list.add(new KeyEvent(id, buttonCode, 0, KeyState.RELEASED, time));
  }
}

代码示例来源:origin: com.harium/etyl

private void axisXEvent(long time, int value) {
  if (value > 0) {
    lastXEvent = KeyEvent.VK_JOYSTICK_RIGHT;
    list.add(new KeyEvent(id, lastXEvent, value, KeyState.PRESSED, time));
  } else if(value < 0) {
    lastXEvent = KeyEvent.VK_JOYSTICK_LEFT;
    list.add(new KeyEvent(id, lastXEvent, value, KeyState.PRESSED, time));
  } else {
    list.add(new KeyEvent(id, lastXEvent, value, KeyState.RELEASED, time));
    list.add(new KeyEvent(id, KeyEvent.VK_JOYSTICK_CENTER_X, value,  KeyState.RELEASED, time));
  }
}

代码示例来源:origin: com.harium.etyl/etyl

private void buttonEvent(long time, int value, int channel) {
  int buttonCode = (KeyEvent.VK_JOYSTICK_BUTTON_1)+channel;
  if (value == 1) {
    list.add(new KeyEvent(id, buttonCode, 0,  KeyState.PRESSED, time));
  } else {
    list.add(new KeyEvent(id, buttonCode, 0, KeyState.RELEASED, time));
  }
}

代码示例来源:origin: com.harium.etyl/etyl

private void axisYEvent(long time, int value) {
  if (value > 0) {
    lastYEvent = KeyEvent.VK_JOYSTICK_DOWN;
    list.add(new KeyEvent(id, lastYEvent, value, KeyState.PRESSED, time));
  } else if(value < 0) {
    lastYEvent = KeyEvent.VK_JOYSTICK_UP;
    list.add(new KeyEvent(id, lastYEvent, value, KeyState.PRESSED, time));
  } else {
    list.add(new KeyEvent(id, lastYEvent, value, KeyState.RELEASED, time));
    list.add(new KeyEvent(id, KeyEvent.VK_JOYSTICK_CENTER_Y, value,  KeyState.RELEASED, time));
  }
}

代码示例来源:origin: com.harium/etyl

private void axisYEvent(long time, int value) {
  if (value > 0) {
    lastYEvent = KeyEvent.VK_JOYSTICK_DOWN;
    list.add(new KeyEvent(id, lastYEvent, value, KeyState.PRESSED, time));
  } else if(value < 0) {
    lastYEvent = KeyEvent.VK_JOYSTICK_UP;
    list.add(new KeyEvent(id, lastYEvent, value, KeyState.PRESSED, time));
  } else {
    list.add(new KeyEvent(id, lastYEvent, value, KeyState.RELEASED, time));
    list.add(new KeyEvent(id, KeyEvent.VK_JOYSTICK_CENTER_Y, value,  KeyState.RELEASED, time));
  }
}

代码示例来源:origin: com.harium.etyl/etyl

@Override
public void keyTyped(java.awt.event.KeyEvent ke) {
  int code = getKeyFromEvent(ke);
  char c = ke.getKeyChar();
  //TODO Fix typed
  if (c != KeyEvent.CHAR_UNDEFINED) {
    addKeyEvent(new KeyEvent(code, c, KeyState.TYPED));
  }
  ke.consume();
}

代码示例来源:origin: com.harium/etyl

@Override
public void keyTyped( java.awt.event.KeyEvent ke) {
  int code = getKeyFromEvent(ke);
  char c = ke.getKeyChar();
  //TODO Fix typed
  if ( c != KeyEvent.CHAR_UNDEFINED ) {
    addKeyEvent(new KeyEvent(code, c, KeyState.TYPED));
  }
  ke.consume();
}

代码示例来源:origin: com.harium.etyl/etyl

public void update(long now) {
  Iterator<Integer> changedIterator = changed.iterator();
  while (changedIterator.hasNext()) {
    Integer key = changedIterator.next();
    KeyState keyState = getState(key);
    boolean pressed = keys.get(key);
    if (pressed) {
      if (keyState == KeyState.RELEASED) {
        keyStates.put(key, KeyState.ONCE);
        addKeyEvent(new KeyEvent(key, KeyState.PRESSED));
      } else if (keyState != KeyState.PRESSED) {
        keyStates.put(key, KeyState.PRESSED);
      }
    } else {
      if ((keyState == KeyState.ONCE) || (keyState == KeyState.PRESSED)) {
        keyStates.put(key, KeyState.FIRST_RELEASED);
      } else if (keyState == KeyState.FIRST_RELEASED) {
        keyStates.put(key, KeyState.RELEASED);
        addKeyEvent(new KeyEvent(key, KeyState.RELEASED));
        changedIterator.remove();
      }
    }
  }
  poll(listener);
}

代码示例来源:origin: com.harium/etyl

public void update(long now) {
  
  Set<Integer> changedCopy = changed.lock();
  for(Integer key: changedCopy) {
    KeyState keyState = getState(key);
    boolean pressed = keys.get(key); 
    
    if (pressed) {
      if (keyState == KeyState.RELEASED) {
        keyStates.put(key,KeyState.ONCE);
        addKeyEvent(new KeyEvent(key, KeyState.PRESSED));
      } else if (keyState != KeyState.PRESSED) {
        keyStates.put(key, KeyState.PRESSED);
      }
    } else {
      if ((keyState == KeyState.ONCE) || (keyState == KeyState.PRESSED)) {
        keyStates.put(key,KeyState.FIRST_RELEASED);
      } else if (keyState == KeyState.FIRST_RELEASED) {
        keyStates.put(key, KeyState.RELEASED);
        addKeyEvent(new KeyEvent(key, KeyState.RELEASED));
        changed.remove(key);
      }
    }
  }
  poll(listener);
  
  changed.unlock();
}

相关文章