예제 #1
0
파일: USBManager.java 프로젝트: JiroDan/vv
  /** Set up the system properties needed to configure JInput. */
  private void setupProperties() {
    try {
      AccessController.doPrivileged(
          new PrivilegedExceptionAction() {
            public Object run() {
              String osName = System.getProperty("os.name").toLowerCase();

              if (!(osName.startsWith("windows")
                  || osName.startsWith("mac")
                  || osName.startsWith("linux"))) {
                I18nManager intl_mgr = I18nManager.getManager();
                String msg_pattern = intl_mgr.getString(MISSING_OS_PROP);

                Locale lcl = intl_mgr.getFoundLocale();
                Object[] msg_args = {osName};
                Format[] fmts = {null};
                MessageFormat msg_fmt = new MessageFormat(msg_pattern, lcl);
                String msg = msg_fmt.format(msg_args);
                msg_fmt.setFormats(fmts);

                errorReporter.warningReport(msg, null);
              }

              return null;
            }
          });
    } catch (PrivilegedActionException pae) {
      I18nManager intl_mgr = I18nManager.getManager();
      String msg = intl_mgr.getString(DETECT_OS_FAIL_PROP);

      errorReporter.warningReport(msg, null);
    }
  }
예제 #2
0
파일: USBManager.java 프로젝트: JiroDan/vv
  /**
   * Print a devices functions.
   *
   * @param controller
   */
  private void printDevice(Controller c) {
    Component[] axes = c.getComponents();

    int len = axes.length;

    I18nManager intl_mgr = I18nManager.getManager();
    String msg_pattern = intl_mgr.getString(DEVICE_AXIS_DESC_PROP);
    Locale lcl = intl_mgr.getFoundLocale();

    NumberFormat n_fmt = NumberFormat.getNumberInstance(lcl);

    Format[] fmts = {null, null};
    MessageFormat msg_fmt = new MessageFormat(msg_pattern, lcl);
    msg_fmt.setFormats(fmts);

    for (int j = 0; j < len; j++) {
      Object[] msg_args = {axes[j].getName(), axes[j].getIdentifier().getName()};

      String msg = msg_fmt.format(msg_args);
      errorReporter.messageReport(msg);
    }
  }
예제 #3
0
파일: USBManager.java 프로젝트: JiroDan/vv
  /** Initialise all the devices now. */
  private void loadDevices() {
    setupProperties();

    ControllerEnvironment ce = ControllerEnvironment.getDefaultEnvironment();

    Controller[] ca = ce.getControllers();

    InputDevice device;
    int gamepadCnt = 0;
    int joystickCnt = 0;
    int wheelCnt = 0;
    int sixDOFCnt = 0;

    String name;

    int cnt = ca.length;

    I18nManager intl_mgr = I18nManager.getManager();
    String msg_pattern = intl_mgr.getString(DETECT_INTRO_PROP);
    Locale lcl = intl_mgr.getFoundLocale();

    NumberFormat n_fmt = NumberFormat.getNumberInstance(lcl);

    Object[] msg_args = {new Float(cnt)};
    Format[] fmts = {n_fmt};
    MessageFormat msg_fmt = new MessageFormat(msg_pattern, lcl);
    msg_fmt.setFormats(fmts);
    String msg = msg_fmt.format(msg_args);

    errorReporter.messageReport(msg);

    String list_pattern = intl_mgr.getString(DETECT_LIST_PROP);
    Format[] list_fmts = {null, n_fmt};
    MessageFormat list_fmt = new MessageFormat(list_pattern, lcl);
    list_fmt.setFormats(fmts);

    for (int i = 0; i < cnt; ++i) {
      Controller dev = ca[i];

      Object[] list_args = {dev.getName(), new Integer(dev.getRumblers().length)};

      String list_msg = list_fmt.format(list_args);
      errorReporter.messageReport(list_msg);

      Controller.Type type = dev.getType();

      name = dev.getName();

      if (name == null) {
        msg = intl_mgr.getString(MISSING_DEVICE_NAME_PROP);
        errorReporter.warningReport(msg, null);
      } else if (name.indexOf("RumblePad") > -1
          || name.indexOf("WingMan Cordless Gamepad") > -1
          || name.indexOf("Logitech Dual Action") > -1) {
        devices.add(new Gamepad(dev, "Gamepad-" + gamepadCnt));
        gamepadCnt++;
      } else if (name.indexOf("Extreme Digital 3D") > -1 || name.indexOf("Freedom 2.4") > -1) {
        devices.add(new Joystick(dev, "Joystick-" + joystickCnt));
        joystickCnt++;
      } else if ((name.indexOf("MOMO Racing") > -1) || name.indexOf("Logitech Racing Wheel") > -1) {
        devices.add(new Wheel(dev, "Wheel-" + wheelCnt));
        wheelCnt++;
      } else if (name.indexOf("SpaceBall 5000") > -1) {
        /*
        devices.add(new SixDOF(dev, "SixDOF-" + sixDOFCnt));
        sixDOFCnt++;
        */
      } else if (name.startsWith("Mouse") || name.startsWith("Keyboard")) {
        // ignore
      } else {
        msg = intl_mgr.getString(UNKNOWN_DEVICE_PROP);
        errorReporter.messageReport(msg);
        printDevice(dev);
      }
    }

    deviceListInit = true;
  }