Java Code Examples for com.jme3.input.Joystick#getButtons()

The following examples show how to use com.jme3.input.Joystick#getButtons() . 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
protected void dumpJoysticks( Joystick[] joysticks, PrintWriter out ) {
    for( Joystick j : joysticks ) {
        out.println( "Joystick[" + j.getJoyId() + "]:" + j.getName() );
        out.println( "  buttons:" + j.getButtonCount() );
        for( JoystickButton b : j.getButtons() ) {
            out.println( "   " + b );
        }
        
        out.println( "  axes:" + j.getAxisCount() );
        for( JoystickAxis axis : j.getAxes() ) {
            out.println( "   " + axis );
        }
    }
}
 
Example 2
Source File: TestJoystick.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
protected void setViewedJoystick( Joystick stick ) {
    if( this.viewedJoystick == stick )
        return;
 
    if( this.viewedJoystick != null ) {
        joystickInfo.detachAllChildren();
    }
               
    this.viewedJoystick = stick;
 
    if( this.viewedJoystick != null ) {       
        // Draw the hud
        yInfo = 0;
 
        addInfo(  "Joystick:\"" + stick.getName() + "\"  id:" + stick.getJoyId(), 0 );
 
        yInfo -= 5;
                   
        float ySave = yInfo;
        
        // Column one for the buttons
        addInfo( "Buttons:", 0 );
        for( JoystickButton b : stick.getButtons() ) {
            addInfo( " '" + b.getName() + "' id:'" + b.getLogicalId() + "'", 0 );
        }
        yInfo = ySave;
        
        // Column two for the axes
        addInfo( "Axes:", 1 );
        for( JoystickAxis a : stick.getAxes() ) {
            addInfo( " '" + a.getName() + "' id:'" + a.getLogicalId() + "' analog:" + a.isAnalog(), 1 );
        }
        
    } 
}