예제 #1
0
파일: FastTimer.java 프로젝트: eswartz/emul
 public void cancelTask(Runnable runnable) {
   synchronized (controlLock) {
     for (Object o : taskinfos.toArray()) {
       if (((RunnableInfo) o).task == runnable) {
         taskinfos.remove((RunnableInfo) o);
         // break;
       }
     }
   }
 }
예제 #2
0
파일: FastTimer.java 프로젝트: eswartz/emul
 public void cancel() {
   synchronized (controlLock) {
     if (timerThread != null) {
       timerThread.interrupt();
       taskinfos.clear();
       timerThread = null;
     }
   }
 }
예제 #3
0
  private void fireKeyboardListeners(final boolean onoff) {
    if (!listeners.isEmpty() && !pressedKeyCodes.isEmpty()) {
      listeners.fire(
          new IFire<IKeyboardListener>() {

            @Override
            public void fire(IKeyboardListener listener) {
              listener.keyEvent(pressedKeyCodes, onoff);
            }
          });

      listeners.fire(
          new IFire<IKeyboardListener>() {

            @Override
            public void fire(IKeyboardListener listener) {
              listener.physKeyEvent(pressedKeyIds, onoff);
            }
          });
    }
  }
예제 #4
0
파일: FastTimer.java 프로젝트: eswartz/emul
  /**
   * Schedule a task to occur the given number of times per second.
   *
   * @param task
   * @param perSecond
   */
  public void scheduleTask(Runnable task, long perSecond) {
    synchronized (controlLock) {
      for (RunnableInfo info : taskinfos) if (info.task == task) return;

      if (perSecond != 0) {
        RunnableInfo info = new RunnableInfo(task, NS / perSecond);
        taskinfos.add(info);

        if (timerThread == null) startTimer();
      }
    }
  }
예제 #5
0
  /* (non-Javadoc)
   * @see v9t9.engine.keyboard.IKeyboardState#setJoystick(int, int, int, int, boolean, long)
   */
  @Override
  public synchronized void setJoystick(final int joy, int mask, int x, int y, boolean fire) {
    int joyRow = JOY1_C + joy - 1;
    byte oldValue = crukeyboardmap[joyRow];

    if ((mask & JOY_X) != 0) {
      // logger(_L | L_1, _("changing JOY_X (%d)\n\n"), x);
      changeJoyMatrix(joy, JOY_LEFT_R, x < 0);
      changeJoyMatrix(joy, JOY_RIGHT_R, x > 0);
    }
    if ((mask & JOY_Y) != 0) {
      // logger(_L | L_1, _("changing JOY_Y (%d)\n\n"), y);
      changeJoyMatrix(joy, JOY_UP_R, y < 0);
      changeJoyMatrix(joy, JOY_DOWN_R, y > 0);
    }
    if ((mask & JOY_B) != 0) {
      // logger(_L | L_1, _("changing JOY_B (%d)\n\n"), fire);
      changeJoyMatrix(joy, JOY_FIRE_R, fire);
    }

    /*  clear unused bits  */
    changeJoyMatrix(joy, 0, false);
    changeJoyMatrix(joy, 1, false);
    changeJoyMatrix(joy, 2, false);

    final byte newValue = crukeyboardmap[joyRow];

    fireListeners();

    if (oldValue != newValue && !listeners.isEmpty()) {
      listeners.fire(
          new IFire<IKeyboardListener>() {

            @Override
            public void fire(IKeyboardListener listener) {
              listener.joystickChangeEvent(joy, newValue);
            }
          });
    }
  }
예제 #6
0
 /* (non-Javadoc)
  * @see v9t9.common.keyboard.IKeyboardState#removeKeyboardListener(v9t9.common.keyboard.IKeyboardListener)
  */
 @Override
 public synchronized void removeKeyboardListener(IKeyboardListener listener) {
   listeners.remove(listener);
 }
예제 #7
0
 /* (non-Javadoc)
  * @see v9t9.common.keyboard.IKeyboardState#addKeyboardListener(v9t9.common.keyboard.IKeyboardListener)
  */
 @Override
 public synchronized void addKeyboardListener(IKeyboardListener listener) {
   listeners.add(listener);
 }
예제 #8
0
파일: FastTimer.java 프로젝트: eswartz/emul
 /**
  * Invoke a runnable as soon as possible
  *
  * @param runnable
  */
 public void invoke(Runnable runnable) {
   synchronized (controlLock) {
     invokes.add(runnable);
     if (timerThread == null) startTimer();
   }
 }