JInput Polling Issues [Problem for Months]

I have been for a long time now (4-5 months) been trying on and off to get JInput to work. I have installed it correctly, all of the testing programs work with my controller, but anytime I try to get poll data it is all either 0.0 for buttons, or -1.5258789E-5 for joysticks. Ive posted in the Jinput section of the forum but only got one answer that told me nothing but gave me code for another game (not an answer). Ive also posted on Stack Overflow with no avail. I have read through and followed the JInput getting started guide on this forum, along with looking anywhere I can on the internet to get something that might help me. All I find are dead links, links to the same tutorials I have already seen, or simply code for games that seems to do nothing different than me. I know this is the not the exact spot to be putting this post but I am getting desperate as nobody seems to visit that section of this forum anymore. Here is the code I am using to test my controller:


public class ControllerTest {

	public static void main(String[] args){
		ControllerTest test = new ControllerTest();
		test.controllerTest();
	}

	void controllerTest(){
		//System.out.println("Hello World");

		Controller[] ca = ControllerEnvironment.getDefaultEnvironment().getControllers();
		Controller gamepad = null;
		Component[] components = null;
		// Run through the list of available input devices and get the gamepad
		for(int i = 0; i < ca.length; i ++){
			if(ca[i].getType().equals(Controller.Type.GAMEPAD)){  // Snag the first instance of a gamepad
				gamepad = ca[i];
			}
		}
		// Print the name of the controller and its type
		if(gamepad != null){
			System.out.println(gamepad.getName() + ": " + gamepad.getType());
			components = gamepad.getComponents();
			System.out.println("COMPONENTS:");
			for(int i = 0; i < components.length; i ++){
				StringBuffer buffer = new StringBuffer();
				buffer.append("Component #" + i + ": ");  // Get the Component #
				buffer.append("\t" + components[i].getName());  // Get the component name
				// Check if the component is analog or relative
				// Relative relies on its past position for values
				// Analog is a current position
				// Analog absolute is a toggle (think your a,b,y,x button)
				if(components[i].isRelative()){
					buffer.append(" [Relative]");
				}
				else if(components[i].isAnalog()){
					buffer.append(" [Analog]");
				}
				else{
					buffer.append(" [Analog Absolute]");
				}
				System.out.println(buffer.toString());
			}
		}
		else{
			System.out.println("No gamepad connected");
		}
		
		float data = 0f;

		while(gamepad.poll()){
			for(int i = 0; i < components.length; i ++){
				if(i == 0){
					data = components[i].getPollData();
					System.out.println(components[i].getName() + ": " + components[i].getPollData());
				}
				else if(i == 1){
					data = components[i].getPollData();
					System.out.println(components[i].getName() + ": " + components[i].getPollData());
				}
				else if(i == 4){
					data = components[i].getPollData();
					System.out.println(components[i].getName() + ": " + components[i].getPollData());
				}
			}

			try{
				Thread.sleep(20);
			}
			catch(Exception e){
				e.printStackTrace();
			}
		}
		System.out.println("Exited");
	}
	
}

The reason I only print out the polled values of components[] at 0,1, and 4 is because those are the axis I am most interested in.
(I also realize I am not using the data variable for anything, I was simply using that variable for debugging)

Sorry for the long post, any help would be greatly appreciated.

Hi again! I see you didn’t get it working yet. Also, I gave you a skeleton of working code that I always use, so you could compare it with yours. I did not just copy and paste it directly from my game. Have you tried any other tests? Such as if the A button is pressed, then do something? Or are you strictly looking at what the poll data returns?

All I am really after is the raw polling data. This is for a robotics project and not really for a game so I will be taking the raw data and converting it into something the robot can interpret. I looked at the code you posted on my other topic but the problem is that it really doesn’t tell me anything new, and you reference classes that are not apart of the JInput library. I also took a look at the link to the full game source code you posted but it was not that helpful since It is incredibly long. As far as testing goes, I have downloaded the actual source code for the Controller test that Jinput has to look at, and confirmed it works with my controller. There seems to be something I am missing as far as polling goes. As I understand it, after grabbing the object for your specific gamepad (which works in my code above, as I can see all of the components for the gamepad and such), you simply call

gamepad.poll()

. Then you work through the list of components and get their float representing the poll data using

component.getPollData()

. However when I do this none of the values change regardless of input.