Jogl

You may want to try using the AWT input system at com.jmex.awt.input and Jinput for the joystick after the initial release.  I will be glad to help you any way I can, just tell me what you need.

i need an input system  XD i'm horrible when it comes to input systems.  I'll take a crack at it and hope for the best.

i couldn't really use com.jmex.awt.input because the whole point of the com.jmex package is stuff that isn't essental in the com.jme package if I use that i'd defeat the purpose of that.  Do i need to use Jinput ofr joystick isn't there already something there for it.  All i see lwjgl related is the keyboard and mouse.

Also i need somebody to help me on something.  How do i get jogl to actually show up on the thing for selecting renderer.  I see in abstract game under getAttributes it reads the properites files and goes straight into a LWJGLProperies Dialog Box is that what i have to change?

Patrick said:

i couldn't really use com.jmex.awt.input because the whole point of the com.jmex package is stuff that isn't essental in the com.jme package if I use that i'd defeat the purpose of that.  Do i need to use Jinput ofr joystick isn't there already something there for it.  All i see lwjgl related is the keyboard and mouse.


If com.jmex.awt.input is usefull for jogl then the developers may consider moving it to com.jme. Do not be afraid to use it.

If I remember correctly you need jinput for joystics.

Yes, I wouldn't rewrite com.jmex.awt.input  just because it's in the wrong package. After all your JOGL renderer itself is rather" jmex" at the moment. AFAIK JInput is the only joystick input lib for java.

you mean only joystick input libary besides lwjgl or does com.jme.input.joystick.lwjgl use Jinput?

yup

what about getting jogl to show up when the window pops up asking for info like window size,refresh rate,full screen, renderer

That dialog is actually LWJGL specific (which makes sense, how else will it retrieve displaymodes and such?), it's called LWJGLPropertiesDialog. So you'll have to make a JOGLPropertiesDialog, or somehow make it work with both…


sorta got that to work and compiled everything but still doesn't wanna work.  All that doesn't matter because PropertiesDialog should retrive and add JOGL to the list of renderer's under the options page.  I added it under DisplaySystem to the array but when the propertiesDialog thing pops up it isn't on the list.  Any ideas?

Also anybody any good with Jinput?  I gave it a shot couldn't figure it out.  Also since everything is written I might update my like on hosting.  Just because the code is written doesn't mean it's bug free or even work for that matter



so updates so far all code except joystick is in.  And I think i'm gonna need the help of a developer to hold my hand while and tell me how to get JOGL to show up on the JDialog thing.

LWJGLPropertiesDialog was a hack until java supported the necessary functions on all platforms. If I remember correctly, there was a PropertiesDialog that did not relay on LWJGL used for some time, until it was found that it did not work in some cases.



The AWT inpit code should work well for mouse and keyboard, I will got Jinput to work last time, I will be happy to try to help you this time. 

Patrick said:

sorta got that to work and compiled everything but still doesn't wanna work.

https://jme.dev.java.net/source/browse/jme/src/com/jme/system/PropertiesDialog2.java?rev=1.5&view=markup



is what I was refuting to. LWJGLPropertiesDialog needs LWJGL PropertiesDialog2 dose not.

That could be a point to start too.

So i looked into it (PropertiesDialog2) and back during the 0.7 release they found out some of the stuff was broken under linux and were waiting for 5 to see if it got fixed.  It'd be a good guess to say they never checked up on it.  Sounds like EricTheRed did some good work so i might compile the with 5 and see if it works. 



Com.jmex.awt.input was easy and will work great.  I found some documentation on Jinput read it and was left more confused that I started.  If it wouldn't be to much to ask for, could I get some help on the joystick. 



Besides the PropertiesDialog jme is pretty pluggable Renderer wise.

I can write the code for the joystick, it will take a few days.

Here is what I have so far:


package com.jme.input.joystick.jinput;


import com.jme.input.joystick.Joystick;
import net.java.games.input.Rumbler;
import net.java.games.input.Controller;
import net.java.games.input.Component;
/**
 * jInput Implementation of {@link Joystick}.
 */
class JinputJoystick implements Joystick {

    private Controller controller;
    private Rumbler[] rumblers;

    int axisCount;
    int buttonCount;
    JinputJoystick( Controller controller ) {
        this.controller = controller;

        rumblers=controller.getRumblers();
       
        for(int i=0;i<controller.getComponents().length;i++)
        {
            if(!(controller.getComponents()[i].getIdentifier() instanceof Component.Identifier.Axis))
                buttonCount++;
            else
                axisCount++;
        }
    }

    public void rumble( int axis, float intensity ) {
        if ( rumblers != null && axis < rumblers.length ) {
            Rumbler rumbler = rumblers[axis];
            if ( rumbler != null ) {
                rumbler.rumble( intensity );
            }
        }
    }
    Component getComponent(int a,boolean button)
    {
        int index=-1;
        for(int i=0;i<controller.getComponents().length;i++)
        {
            if((!(controller.getComponents()[i].getIdentifier() instanceof Component.Identifier.Axis))==button)
                index++;
           
            if(index==a)
                return controller.getComponents()[i];
        }
        //This should never hapen if a is a small anofe number
        return null;
    }
    public String[] getAxisNames() {
        Controller c = controller;
        String[] axises = new String[getAxisCount()];
        for ( int i = 0; i < axises.length; i++ ) {
            if((controller.getComponents()[i].getIdentifier() instanceof Component.Identifier.Axis))
                axises[i] = c.getComponents()[i].getName();
        }
        return axises;
    }

    public int getAxisCount() {
        return axisCount;
    }

    public float getAxisValue( int axis ) {
        Controller c = controller;
        if ( axis < getAxisCount() ) {
            return getComponent(axis,false).getPollData();
        }
        else {
            return 0;
        }
    }

    public int getButtonCount() {
        return buttonCount;
    }

    public boolean isButtonPressed( int button ) {
        Controller c = controller;
        if ( button < getButtonCount() ) {
            //TODO: what is the corect way of doing this?
            return getComponent(button,true).getPollData()>0.0;
        }
        else {
            return false;
        }
    }

    public String getName() {
        return controller.getName();
    }
   
    public void poll()
    {
        controller.poll();
    }
}



package com.jme.input.joystick.jinput;

import java.util.ArrayList;

import net.java.games.input.ControllerEnvironment;
import net.java.games.input.Controller;

import com.jme.input.joystick.DummyJoystickInput;
import com.jme.input.joystick.Joystick;
import com.jme.input.joystick.JoystickInput;
import com.jme.input.joystick.JoystickInputListener;

/**
 * jInput Implementation of {@link JoystickInput}.
 */
public class JinputJoystickInput extends JoystickInput {
    private ArrayList joysticks;
    private DummyJoystickInput.DummyJoystick dummyJoystick;


    /**
     *
     * @throws RuntimeException if initialization failed
     */
    protected JinputJoystickInput() throws RuntimeException {
            updateJoystickList();
    }

    private void updateJoystickList() {
        Controller[] theControllers=ControllerEnvironment.getDefaultEnvironment().getControllers();
        joysticks = new ArrayList();
        for ( int i = 0; i < theControllers.length; i++ ) {
        if(!theControllers[i].getType().equals(Controller.Type.KEYBOARD)&&!theControllers[i].getType().equals(Controller.Type.MOUSE))
            joysticks.add( new JinputJoystick( theControllers[i] ) );
        }
    }


    public void update() {
       
        for(int i=0;i<joysticks.size();i++)
        {
            ((JinputJoystick)joysticks.get(i)).poll();
        }
//        Controllers.poll();
//        while ( Controllers.next() ) {
//            if ( listeners != null && listeners.size() > 0 ) {
//                Joystick joystick = getJoystick( Controllers.getEventSource().getIndex() );
//                int controlIndex = Controllers.getEventControlIndex();
//                if ( Controllers.isEventButton() ) {
//                    boolean buttonPressed = joystick.isButtonPressed( controlIndex );
//                    for ( int i = 0; i < listeners.size(); i++ ) {
//                        JoystickInputListener listener = (JoystickInputListener) listeners.get( i );
//                        listener.onButton( joystick, controlIndex, buttonPressed );
//                    }
//                }
//                else if ( Controllers.isEventAxis() ) {
//                    float axisValue = joystick.getAxisValue( controlIndex );
//                    for ( int i = 0; i < listeners.size(); i++ ) {
//                        JoystickInputListener listener = (JoystickInputListener) listeners.get( i );
//                        listener.onAxis( joystick, controlIndex, axisValue );
//                    }
//                }
//            }
//        }
    }

    public int getJoystickCount() {
        int numJoysticks = joysticks.size();
        if ( numJoysticks != ControllerEnvironment.getDefaultEnvironment().getControllers().length )
        {
            updateJoystickList();
        }
        return numJoysticks;
    }

    public Joystick getJoystick( int index ) {
        return (Joystick) joysticks.get( index );
    }

    public Joystick getDefaultJoystick() {
        if ( getJoystickCount() > 0 )
        {
            return getJoystick( getJoystickCount()-1 );
        }
        else
        {
            if ( dummyJoystick == null )
            {
                dummyJoystick = new DummyJoystickInput.DummyJoystick();
            }
            return dummyJoystick;
        }
    }

    protected void destroy() {
       //not needed
    }

}



I am unable to test it, since I do not have a working joystick on the computer I am using.

The one problem that I had while writing the code was that Jinput dose not support Manual Polling. Any one have an idea how to get around the problem?

looks good i'll plug in my joystick tomm and try it out