Example #1
0
  static {
    controller_ZX_4way.addKey(
        "Left",
        "Z",
        0,
        -1,
        1f,
        1f,
        BeebKeys.BBCKEY_Z,
        KeyEvent.KEYCODE_DPAD_LEFT,
        KeyEvent.KEYCODE_BUTTON_X);
    controller_ZX_4way.addKey(
        "Right",
        "X",
        1,
        -1,
        1f,
        1f,
        BeebKeys.BBCKEY_X,
        KeyEvent.KEYCODE_DPAD_RIGHT,
        KeyEvent.KEYCODE_BACK);
    controller_ZX_4way.addKey(
        "Up",
        ":",
        -1,
        0,
        1f,
        1f,
        BeebKeys.BBCKEY_COLON,
        KeyEvent.KEYCODE_DPAD_UP,
        KeyEvent.KEYCODE_BUTTON_Y);
    controller_ZX_4way.addKey(
        "Down",
        "/",
        -1,
        1,
        1f,
        1f,
        BeebKeys.BBCKEY_SLASH,
        KeyEvent.KEYCODE_DPAD_DOWN,
        KeyEvent.KEYCODE_DPAD_CENTER);
    controller_ZX_4way.useDPad = true;
    controller_ZX_5way.addKey(
        "Left",
        "Z",
        0,
        -1,
        1f,
        1f,
        BeebKeys.BBCKEY_Z,
        KeyEvent.KEYCODE_DPAD_LEFT,
        KeyEvent.KEYCODE_BUTTON_X);
    controller_ZX_5way.addKey(
        "Right",
        "X",
        1,
        -1,
        1f,
        1f,
        BeebKeys.BBCKEY_X,
        KeyEvent.KEYCODE_DPAD_RIGHT,
        KeyEvent.KEYCODE_BACK);
    controller_ZX_5way.addKey(
        "Up",
        ":",
        -2,
        0,
        1f,
        1f,
        BeebKeys.BBCKEY_COLON,
        KeyEvent.KEYCODE_DPAD_UP,
        KeyEvent.KEYCODE_BUTTON_Y);
    controller_ZX_5way.addKey(
        "Down",
        "/",
        -2,
        1,
        1f,
        1f,
        BeebKeys.BBCKEY_SLASH,
        KeyEvent.KEYCODE_DPAD_DOWN,
        KeyEvent.KEYCODE_DPAD_CENTER);
    controller_ZX_5way.addKey(
        "Fire",
        "Return",
        -1,
        0,
        1f,
        2f,
        BeebKeys.BBCKEY_ENTER,
        KeyEvent.KEYCODE_BUTTON_L1,
        KeyEvent.KEYCODE_BUTTON_R1);
    controller_ZX_5way.useDPad = true;
    controller_RocketRaid_Game.addKey(
        "Left", "SPACE", 0, -1, 1f, 1f, BeebKeys.BBCKEY_SPACE, KeyEvent.KEYCODE_DPAD_LEFT);
    controller_RocketRaid_Game.addKey(
        "Right", "SHIFT", 1, -1, 1f, 1f, BeebKeys.BBCKEY_SHIFT, KeyEvent.KEYCODE_DPAD_RIGHT);
    controller_RocketRaid_Game.addKey(
        "Up", "A", -2, 0, 1f, 1f, BeebKeys.BBCKEY_A, KeyEvent.KEYCODE_DPAD_UP);
    controller_RocketRaid_Game.addKey(
        "Down", "Z", -2, 1, 1f, 1f, BeebKeys.BBCKEY_Z, KeyEvent.KEYCODE_DPAD_DOWN);
    controller_RocketRaid_Game.addKey(
        "Fire", "Return", -1, 0, 1f, 1f, BeebKeys.BBCKEY_ENTER, KeyEvent.KEYCODE_DPAD_CENTER);
    controller_RocketRaid_Game.addKey(
        "Bomb", "Tab", -1, 1, 1f, 1f, BeebKeys.BBCKEY_TAB, KeyEvent.KEYCODE_BACK);
    controller_RocketRaid_Game.useDPad = true;
    controller_Qman_Game.addKey(
        "Up-Left", "A", 0, 0, 1f, 1f, BeebKeys.BBCKEY_A, KeyEvent.KEYCODE_BUTTON_X);
    controller_Qman_Game.addKey(
        "Down-Left", "Z", 0, -1, 1f, 1f, BeebKeys.BBCKEY_Z, KeyEvent.KEYCODE_DPAD_DOWN);
    controller_Qman_Game.addKey(
        "Up-Right", ":", -1, 0, 1f, 1f, BeebKeys.BBCKEY_COLON, KeyEvent.KEYCODE_DPAD_RIGHT);
    controller_Qman_Game.addKey(
        "Down-Right", "/", -1, 1, 1f, 1f, BeebKeys.BBCKEY_SLASH, KeyEvent.KEYCODE_DPAD_CENTER);

    // Arcadians has 2 controllers and uses PC triggers to switch between them
    //		controller_Arcadians_Menu.addKey("1","1",    0f,  0, 1.5f, 1.5f,  BeebKeys.BBCKEY_1);
    //		controller_Arcadians_Menu.addKey("2","2",    1.5f,  0, 1.5f, 1.5f,  BeebKeys.BBCKEY_2);
    //		controller_Arcadians_Menu.addTrigger((short) 0x3203, controller_Arcadians_Game);
    controller_Arcadians_Menu.addKey(
        "Left",
        "Caps",
        0f,
        0,
        1.25f,
        1.25f,
        BeebKeys.BBCKEY_CAPS,
        KeyEvent.KEYCODE_DPAD_LEFT,
        KeyEvent.KEYCODE_BUTTON_X);
    controller_Arcadians_Menu.addKey(
        "Right",
        "Ctrl",
        1.25f,
        0,
        1.25f,
        1.25f,
        BeebKeys.BBCKEY_CTRL,
        KeyEvent.KEYCODE_DPAD_RIGHT,
        KeyEvent.KEYCODE_BACK);
    controller_Arcadians_Menu.addKey(
        "Fire",
        "Return",
        -1f,
        0,
        1f,
        1.25f,
        BeebKeys.BBCKEY_ENTER,
        KeyEvent.KEYCODE_BUTTON_L1,
        KeyEvent.KEYCODE_BUTTON_R1);
    //		controller_Arcadians_Game.addTrigger((short) 0x4d95, controller_Arcadians_Menu);

    controller_CastleQuest_Game.addKey(
        "Left", "Z", 0, -1, 1f, 1f, BeebKeys.BBCKEY_Z, KeyEvent.KEYCODE_DPAD_LEFT);
    controller_CastleQuest_Game.addKey(
        "Right", "X", 1, -1, 1f, 1f, BeebKeys.BBCKEY_X, KeyEvent.KEYCODE_DPAD_RIGHT);
    controller_CastleQuest_Game.addKey(
        "Up", ":", -1, 0, 1f, 1f, BeebKeys.BBCKEY_COLON, KeyEvent.KEYCODE_DPAD_UP);
    controller_CastleQuest_Game.addKey(
        "Down", "/", -1, 1, 1f, 1f, BeebKeys.BBCKEY_SLASH, KeyEvent.KEYCODE_DPAD_DOWN);
    controller_CastleQuest_Game.addKey(
        "Jump",
        "Return",
        -2,
        1,
        2f,
        1f,
        BeebKeys.BBCKEY_ENTER,
        KeyEvent.KEYCODE_BUTTON_L1,
        KeyEvent.KEYCODE_BUTTON_R1);
    controller_CastleQuest_Game.addKey(
        "Pick Up", "P", -1, 0, 1f, 1f, BeebKeys.BBCKEY_P, KeyEvent.KEYCODE_BUTTON_Y);
    controller_CastleQuest_Game.addKey(
        "Drop", "D", -2, 0, 1f, 1f, BeebKeys.BBCKEY_D, KeyEvent.KEYCODE_DPAD_CENTER);
    controller_CastleQuest_Game.useDPad = true;
    controller_ChuckieEgg_Game.addKey(
        "Left", ",", 0, -1, 1f, 1f, BeebKeys.BBCKEY_COMMA, KeyEvent.KEYCODE_DPAD_LEFT);
    controller_ChuckieEgg_Game.addKey(
        "Right", ".", 1, -1, 1f, 1f, BeebKeys.BBCKEY_PERIOD, KeyEvent.KEYCODE_DPAD_RIGHT);
    controller_ChuckieEgg_Game.addKey(
        "Up",
        "A",
        -2,
        0,
        1f,
        1f,
        BeebKeys.BBCKEY_A,
        KeyEvent.KEYCODE_DPAD_UP,
        KeyEvent.KEYCODE_BUTTON_Y);
    controller_ChuckieEgg_Game.addKey(
        "Down", "Z", -2, 1, 1f, 1f, BeebKeys.BBCKEY_Z, KeyEvent.KEYCODE_DPAD_CENTER);
    controller_ChuckieEgg_Game.addKey(
        "Jump", " ", -1, 0, 1f, 2f, BeebKeys.BBCKEY_SPACE, KeyEvent.KEYCODE_BACK);
    controller_ChuckieEgg_Game.addKey("S", "S", -1.75f, 1f, .5f, .5f, BeebKeys.BBCKEY_S);
    controller_ChuckieEgg_Game.addKey("1", "1", -1.75f, 1.5f, .5f, .5f, BeebKeys.BBCKEY_1);
    controller_ChuckieEgg_Game.useDPad = true;
    controller_ChuckieEgg_Game_Alt.addKey(
        "Left",
        ",",
        0,
        -1,
        1f,
        1f,
        BeebKeys.BBCKEY_COMMA,
        KeyEvent.KEYCODE_DPAD_LEFT,
        KeyEvent.KEYCODE_BUTTON_X);
    controller_ChuckieEgg_Game_Alt.addKey(
        "Right",
        ".",
        1,
        -1,
        1f,
        1f,
        BeebKeys.BBCKEY_PERIOD,
        KeyEvent.KEYCODE_DPAD_RIGHT,
        KeyEvent.KEYCODE_BACK);
    controller_ChuckieEgg_Game_Alt.addKey(
        "Up",
        "A",
        -2,
        0,
        1f,
        1f,
        BeebKeys.BBCKEY_A,
        KeyEvent.KEYCODE_DPAD_UP,
        KeyEvent.KEYCODE_BUTTON_Y);
    controller_ChuckieEgg_Game_Alt.addKey(
        "Down",
        "Z",
        -2,
        1,
        1f,
        1f,
        BeebKeys.BBCKEY_Z,
        KeyEvent.KEYCODE_DPAD_DOWN,
        KeyEvent.KEYCODE_DPAD_CENTER);
    controller_ChuckieEgg_Game_Alt.addKey(
        "Jump",
        " ",
        -1,
        0,
        1f,
        2f,
        BeebKeys.BBCKEY_SPACE,
        KeyEvent.KEYCODE_BUTTON_L1,
        KeyEvent.KEYCODE_BUTTON_R1);
    controller_ChuckieEgg_Game_Alt.addKey("S", "S", -1.75f, 1f, .5f, .5f, BeebKeys.BBCKEY_S);
    controller_ChuckieEgg_Game_Alt.addKey("1", "1", -1.75f, 1.5f, .5f, .5f, BeebKeys.BBCKEY_1);
    controller_ChuckieEgg_Game_Alt.useDPad = true;
    controller_DareDevilDennis_Game.addKey(
        "Accel",
        "Shift",
        0,
        0,
        1f,
        2f,
        BeebKeys.BBCKEY_SHIFT,
        KeyEvent.KEYCODE_DPAD_RIGHT,
        KeyEvent.KEYCODE_BACK);
    controller_DareDevilDennis_Game.addKey(
        "Stop",
        "Return",
        1,
        0,
        1f,
        2f,
        BeebKeys.BBCKEY_ENTER,
        KeyEvent.KEYCODE_DPAD_LEFT,
        KeyEvent.KEYCODE_BUTTON_X);
    controller_DareDevilDennis_Game.addKey(
        "Jump",
        "",
        -2,
        0,
        2f,
        2f,
        BeebKeys.BBCKEY_SPACE,
        KeyEvent.KEYCODE_BUTTON_L1,
        KeyEvent.KEYCODE_BUTTON_R1);
    controller_Imogen_Game.addKey(
        "Left",
        "Z",
        0,
        -1,
        1f,
        1f,
        BeebKeys.BBCKEY_Z,
        KeyEvent.KEYCODE_DPAD_LEFT,
        KeyEvent.KEYCODE_BUTTON_X);
    controller_Imogen_Game.addKey(
        "Right",
        "X",
        1,
        -1,
        1f,
        1f,
        BeebKeys.BBCKEY_X,
        KeyEvent.KEYCODE_DPAD_RIGHT,
        KeyEvent.KEYCODE_BACK);
    controller_Imogen_Game.addKey(
        "Up",
        ":",
        -2,
        0,
        1f,
        1f,
        BeebKeys.BBCKEY_COLON,
        KeyEvent.KEYCODE_DPAD_UP,
        KeyEvent.KEYCODE_BUTTON_Y);
    controller_Imogen_Game.addKey(
        "Down",
        "/",
        -2,
        1,
        1f,
        1f,
        BeebKeys.BBCKEY_SLASH,
        KeyEvent.KEYCODE_DPAD_DOWN,
        KeyEvent.KEYCODE_DPAD_CENTER);
    controller_Imogen_Game.addKey(
        "Fire",
        "Return",
        -1,
        0,
        1f,
        2f,
        BeebKeys.BBCKEY_ENTER,
        KeyEvent.KEYCODE_BUTTON_L1,
        KeyEvent.KEYCODE_BUTTON_R1);
    controller_Imogen_Game.addKey(
        "<-", "<-", -2, 0, .5f, .5f, BeebKeys.BBCKEY_ARROW_LEFT, KeyEvent.KEYCODE_BUTTON_Y);
    controller_Imogen_Game.addKey(
        "->", "->", -2, 0.5f, .5f, .5f, BeebKeys.BBCKEY_ARROW_RIGHT, KeyEvent.KEYCODE_BACK);
    controller_Imogen_Game.addKey(
        "[]", "[]", -2, 1, .5f, .5f, BeebKeys.BBCKEY_SPACE, KeyEvent.KEYCODE_DPAD_CENTER);
    controller_Imogen_Game.useDPad = true;
    controller_Thrust_Game.addKey(
        "Left",
        "Caps",
        0f,
        -1,
        1f,
        1f,
        BeebKeys.BBCKEY_CAPS,
        KeyEvent.KEYCODE_DPAD_LEFT,
        KeyEvent.KEYCODE_BUTTON_X);
    controller_Thrust_Game.addKey(
        "Right",
        "Ctrl",
        1f,
        -1,
        1f,
        1f,
        BeebKeys.BBCKEY_CTRL,
        KeyEvent.KEYCODE_DPAD_RIGHT,
        KeyEvent.KEYCODE_BACK);
    controller_Thrust_Game.addKey(
        "Thrust",
        "Shift",
        -1f,
        0,
        1f,
        2f,
        BeebKeys.BBCKEY_SHIFT,
        KeyEvent.KEYCODE_DPAD_DOWN,
        KeyEvent.KEYCODE_DPAD_CENTER);
    controller_Thrust_Game.addKey(
        "Fire", "Return", -2f, 0, 1f, 1f, BeebKeys.BBCKEY_ENTER, KeyEvent.KEYCODE_BUTTON_R1);
    controller_Thrust_Game.addKey(
        "Shield", "", -2f, 1, 1f, 1f, BeebKeys.BBCKEY_SPACE, KeyEvent.KEYCODE_BUTTON_L1);
    controller_Planetoid_Game.addKey(
        "Up", "A", 1, 0, 1f, 1f, BeebKeys.BBCKEY_A, KeyEvent.KEYCODE_DPAD_UP);
    controller_Planetoid_Game.addKey(
        "Down", "Z", 1, 1, 1f, 1f, BeebKeys.BBCKEY_Z, KeyEvent.KEYCODE_DPAD_DOWN);
    controller_Planetoid_Game.addKey(
        "Forwards", "SHIFT", 2, 0.5f, 1f, 1f, BeebKeys.BBCKEY_SHIFT, KeyEvent.KEYCODE_DPAD_RIGHT);
    controller_Planetoid_Game.addKey(
        "Reverse", "SPACE", 0, 0.5f, 1f, 1f, BeebKeys.BBCKEY_SPACE, KeyEvent.KEYCODE_DPAD_LEFT);
    controller_Planetoid_Game.addKey(
        "Fire", "Return", -2, 0, 2f, 1f, BeebKeys.BBCKEY_ENTER, KeyEvent.KEYCODE_DPAD_CENTER);
    controller_Planetoid_Game.addKey(
        "Bomb", "Tab", -1.5f, 1.2f, 1f, 1f, BeebKeys.BBCKEY_TAB, KeyEvent.KEYCODE_BACK);
    controller_Elite_Game.addKey(
        "Left", "<", 0, 0.8f, .75f, .75f, BeebKeys.BBCKEY_LESS_THAN, KeyEvent.KEYCODE_DPAD_LEFT);
    controller_Elite_Game.addKey(
        "Right",
        ">",
        1.5f,
        0.8f,
        .75f,
        .75f,
        BeebKeys.BBCKEY_MORE_THAN,
        KeyEvent.KEYCODE_DPAD_RIGHT);
    controller_Elite_Game.addKey(
        "Up", "S", .75f, .5f, .75f, .75f, BeebKeys.BBCKEY_S, KeyEvent.KEYCODE_DPAD_UP);
    controller_Elite_Game.addKey(
        "Down", "X", .75f, 1.25f, .75f, .75f, BeebKeys.BBCKEY_X, KeyEvent.KEYCODE_DPAD_DOWN);
    controller_Elite_Game.addKey(
        "Fire", "A", -.75f, 0, .75f, 2f, BeebKeys.BBCKEY_A, KeyEvent.KEYCODE_DPAD_CENTER);
    controller_Elite_Game.addKey(
        "Acc.", "SPC", -1.35f, 0, .5f, 1f, BeebKeys.BBCKEY_SPACE, KeyEvent.KEYCODE_DPAD_CENTER);
    controller_Elite_Game.addKey(
        "Dec.",
        "?",
        -1.35f,
        1,
        .5f,
        1f,
        BeebKeys.BBCKEY_QUESTIONMARK,
        KeyEvent.KEYCODE_DPAD_CENTER);
    controller_Elite_Game.addKey("F0", "Launch", 0f, 0, .5f, .5f, BeebKeys.BBCKEY_F0);
    controller_Elite_Game.addKey("F1", "Rear", .5f, 0, .5f, .5f, BeebKeys.BBCKEY_F1);
    controller_Elite_Game.addKey("F2", "Left", 1f, 0, .5f, .5f, BeebKeys.BBCKEY_F2);
    controller_Elite_Game.addKey("F3", "Right", 1.5f, 0, .5f, .5f, BeebKeys.BBCKEY_F3);
    controller_Zalaga_Game.addKey(
        "Left",
        "Caps",
        0f,
        0,
        1.25f,
        1.25f,
        BeebKeys.BBCKEY_CAPS,
        KeyEvent.KEYCODE_DPAD_LEFT,
        KeyEvent.KEYCODE_BUTTON_X);
    controller_Zalaga_Game.addKey(
        "Right",
        "Ctrl",
        1.25f,
        0,
        1.25f,
        1.25f,
        BeebKeys.BBCKEY_CTRL,
        KeyEvent.KEYCODE_DPAD_RIGHT,
        KeyEvent.KEYCODE_BACK);
    controller_Zalaga_Game.addKey(
        "Fire",
        "Return",
        -1f,
        0,
        1f,
        1.25f,
        BeebKeys.BBCKEY_ENTER,
        KeyEvent.KEYCODE_BUTTON_L1,
        KeyEvent.KEYCODE_BUTTON_R1);
  }
Example #2
0
  /**
   * Scan WEB-INF/lib and WEB-INF/classes for Controller classes and puts all in controllerClasses
   * map.
   *
   * @throws IOException
   */
  @SuppressWarnings("unchecked")
  private void collectControllers() throws IOException {
    AnnotationDB adb = new AnnotationDB();
    adb.setScanClassAnnotations(true);
    adb.setScanFieldAnnotations(false);
    adb.setScanMethodAnnotations(false);
    adb.setScanParameterAnnotations(false);
    adb.scanArchives(WarUrlFinder.findWebInfClassesPath(applicationContext));
    adb.scanArchives(WarUrlFinder.findWebInfLibClasspaths(applicationContext));

    Set<String> ctrls = adb.getAnnotationIndex().get(Controller.class.getName());

    for (String fqcn : ctrls) {
      Class<? extends BaseController> clazz = null;
      try {
        clazz = (Class<? extends BaseController>) Class.forName(fqcn);
      } catch (Exception e) {
        log.warn("Class " + fqcn + " not found or not derived from Controller class. Ignoring it.");
        continue;
      }
      Controller controllerAnnotation = clazz.getAnnotation(Controller.class);

      ControllerInfo controllerInfo = new ControllerInfo();
      controllerInfo.controllerClass = clazz;
      controllerInfo.defaultActionName = controllerAnnotation.defaultAction();

      controllers.put(fqcn, controllerInfo);
      boolean isDefaultController = clazz.getAnnotation(Controller.class).isDefaultController();
      if (isDefaultController) {
        controllers.put(DEFAULT_CONTROLLER_KEY, controllerInfo);
      }

      String alias = controllerAnnotation.alias();
      if (StringUtils.isNotEmpty(alias)) {
        alias = alias.trim();
        if (alias.contains("/")) {
          log.warn("Controller alias '" + alias + "' contains illegal characters. Ignoring alias.");
          alias = null;
        } else if (controllers.containsKey(alias)) {
          log.warn(
              "Duplicate Controller alias '"
                  + alias
                  + "' detected. Used by "
                  + fqcn
                  + " and "
                  + controllers.get(alias).controllerClass.getName()
                  + ". Using alias only for the latter.");
          alias = null;
        } else {
          controllers.put(alias, controllerInfo);
        }
      }
      log.debug(
          (StringUtils.isNotEmpty(alias) ? alias + ", " : "")
              + fqcn
              + " -> "
              + fqcn
              + (isDefaultController ? " (default controller)" : ""));

      collectActions(controllerInfo);
    }
  }