Java Code Examples for com.jme3.system.AppSettings#setUseJoysticks()

The following examples show how to use com.jme3.system.AppSettings#setUseJoysticks() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TestJoystick.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public static void main(String[] args){
    TestJoystick app = new TestJoystick();
    AppSettings settings = new AppSettings(true);
    settings.setUseJoysticks(true);
    app.setSettings(settings);
    app.start();
}
 
Example 2
Source File: TestJoystick.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public static void main(String[] args){
    TestJoystick app = new TestJoystick();
    AppSettings settings = new AppSettings(true);
    settings.setUseJoysticks(true);
    app.setSettings(settings);
    app.start();
}
 
Example 3
Source File: AndroidHarnessFragment.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
/**
 * This Fragment uses setRetainInstance(true) so the onCreate method will only
 * be called once. During device configuration changes, the instance of
 * this Fragment will be reused in the new Activity.  This method should not
 * contain any View related objects.  They are created and destroyed by
 * other methods.  View related objects should not be reused, but rather
 * created and destroyed along with the Activity.
 *
 * @param savedInstanceState
 */
@Override
public void onCreate(Bundle savedInstanceState) {
    initializeLogHandler();
    logger.fine("onCreate");
    super.onCreate(savedInstanceState);

    // Create Settings
    logger.log(Level.FINE, "Creating settings");
    AppSettings settings = new AppSettings(true);
    settings.setEmulateMouse(mouseEventsEnabled);
    settings.setEmulateMouseFlipAxis(mouseEventsInvertX, mouseEventsInvertY);
    settings.setUseJoysticks(joystickEventsEnabled);
    settings.setEmulateKeyboard(keyEventsEnabled);

    settings.setBitsPerPixel(eglBitsPerPixel);
    settings.setAlphaBits(eglAlphaBits);
    settings.setDepthBits(eglDepthBits);
    settings.setSamples(eglSamples);
    settings.setStencilBits(eglStencilBits);
    settings.setAudioRenderer(audioRendererType);

    settings.setFrameRate(frameRate);

    // Create application instance
    try {
        if (app == null) {
            Class clazz = Class.forName(appClass);
            app = (LegacyApplication)clazz.newInstance();
        }

        app.setSettings(settings);
        app.start();
    } catch (Exception ex) {
        handleError("Class " + appClass + " init failed", ex);
    }

    OGLESContext ctx = (OGLESContext) app.getContext();
    // AndroidHarness wraps the app as a SystemListener.
    ctx.setSystemListener(this);

    setRetainInstance(true);
}
 
Example 4
Source File: AndroidHarness.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
    initializeLogHandler();

    logger.fine("onCreate");
    super.onCreate(savedInstanceState);

    if (screenFullScreen) {
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                             WindowManager.LayoutParams.FLAG_FULLSCREEN);
    } else {
        if (!screenShowTitle) {
            requestWindowFeature(Window.FEATURE_NO_TITLE);
        }
    }

    final DataObject data = (DataObject) getLastNonConfigurationInstance();
    if (data != null) {
        logger.log(Level.FINE, "Using Retained App");
        this.app = data.app;
    } else {
        // Discover the screen reolution
        //TODO try to find a better way to get a hand on the resolution
        WindowManager wind = this.getWindowManager();
        Display disp = wind.getDefaultDisplay();
        Log.d("AndroidHarness", "Resolution from Window, width:" + disp.getWidth() + ", height: " + disp.getHeight());

        // Create Settings
        logger.log(Level.FINE, "Creating settings");
        AppSettings settings = new AppSettings(true);
        settings.setEmulateMouse(mouseEventsEnabled);
        settings.setEmulateMouseFlipAxis(mouseEventsInvertX, mouseEventsInvertY);
        settings.setUseJoysticks(joystickEventsEnabled);
        settings.setEmulateKeyboard(keyEventsEnabled);

        settings.setBitsPerPixel(eglBitsPerPixel);
        settings.setAlphaBits(eglAlphaBits);
        settings.setDepthBits(eglDepthBits);
        settings.setSamples(eglSamples);
        settings.setStencilBits(eglStencilBits);

        settings.setResolution(disp.getWidth(), disp.getHeight());
        settings.setAudioRenderer(audioRendererType);

        settings.setFrameRate(frameRate);

        // Create application instance
        try {
            if (app == null) {
                Class clazz = Class.forName(appClass);
                app = (LegacyApplication)clazz.newInstance();
            }

            app.setSettings(settings);
            app.start();
        } catch (Exception ex) {
            handleError("Class " + appClass + " init failed", ex);
            setContentView(new TextView(this));
        }
    }

    ctx = (OGLESContext) app.getContext();
    view = ctx.createView(this);
    // store the glSurfaceView in JmeAndroidSystem for future use
    JmeAndroidSystem.setView(view);
    // AndroidHarness wraps the app as a SystemListener.
    ctx.setSystemListener(this);
    layoutDisplay();
}