Joystick input exceptions..?

Hi…



I've bought a Gametrak Controller, and use it for my staff-Fight application.

It works well, most of the time.



For getting the input data, i use the classes from the "com.jme.input.joystick" package.

I wrote my own listenerClass and this is my init():

   public static void init() {
      JoystickInput.setProvider(InputSystem.INPUT_SYSTEM_LWJGL);
      input = JoystickInput.get();
      input.addListener(new JoystickInputListener(){

         public void onAxis(Joystick controller, int axis, float axisValue) {
            switch (axis) {
            case 0:
               rightYbuf.setValue(axisValue*-1);
               break;
            case 1:
               rightZbuf.setValue(axisValue*-1);
               break;
            case 2:
               rightXbuf.setValue(axisValue);
               break;
            case 3:
               leftYbuf.setValue(axisValue*-1);
               break;
            case 4:
               leftZbuf.setValue(axisValue*-1);
               break;
            case 5:
               leftXbuf.setValue(axisValue);
               break;
            default:
               break;
            }         
         }

         public void onButton(Joystick controller, int button, boolean pressed) {
            switch (button) {
            case 0:
               if(pressed ){
                  buttonPressed = true;
                  System.err.println("JOOOOOOOOOOOO");
               }
               else{
                  buttonPressed = false;
               }
               break;

            default:
               buttonPressed = false;
               break;
            }
         }
         
      });
      //input.update();
   }



As i said, most of the time it works well, but sometimes exceptions occur.

SCHWERWIEGEND: Exception in game loop
java.lang.NullPointerException
at org.lwjgl.input.Controllers.getEventControlIndex(Controllers.java:180)
at com.jme.input.joystick.lwjgl.LWJGLJoystickInput.update(LWJGLJoystickInput.java:79)
at com.jme.input.InputSystem.update(InputSystem.java:69)
at com.jme.app.BaseGame.start(BaseGame.java:76)
at emp.gametrak.StaffFight.main(StaffFight.java:116)

This seems to be the old GL Thread synchronization problem… Are you using StandardGame or SimpleGame? Make sure you only try to update information regarding the input and/or graphics in the rendering thread. Perhaps the GL context is not yet ready by the time the update method is called.