Java-Gaming.org Hi !
Featured games (90)
games approved by the League of Dukes
Games in Showcase (777)
Games in Android Showcase (231)
games submitted by our members
Games in WIP (856)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  getPollData() only returning 0.0  (Read 1617 times)
0 Members and 1 Guest are viewing this topic.
Offline Jugbot

Innocent Bystander





« Posted 2016-10-01 00:18:00 »

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
34  
35  
36  
37  
38  
39  
40  
41  
42  
43  
44  
45  
46  
47  
public static void getFirstGamepadData() {
      Controller[] controllers = ControllerEnvironment.getDefaultEnvironment().getControllers();
      Controller firstGamepad = null;
      for (int i = 0; i < controllers.length && firstGamepad == null; i++) {
         if (controllers[i].getType() == Controller.Type.GAMEPAD) {
            // Found a mouse
            firstGamepad = controllers[i];
         }
      }
      if (firstGamepad == null) {
         // Couldn't find a mouse
         System.out.println("Found no gamepad");
         System.exit(0);
      }
     
      System.out.println("First gamepad is: " + firstGamepad.getName());
      while (true) {
         firstGamepad.poll();
         Component[] components = firstGamepad.getComponents();
         StringBuffer buffer = new StringBuffer();
         for (int i = 0; i < components.length; i++) {
            if (i > 0) {
               buffer.append(", \n");
            }
            buffer.append(components[i].getName());
            buffer.append(": ");
           
            if (components[i].isAnalog()) {
               buffer.append(components[i].getPollData());
            } else {
               if (components[i].getPollData() == 1.0f) {
                  buffer.append("On");
               } else {
                  buffer.append("Off");
               }
            }
         }
         System.out.println(buffer.toString());

         try {
            Thread.sleep(20);
         } catch (InterruptedException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
         }
      }
   }


Using the code snippet above I only get:

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
Y Axis: -1.5258789E-5, 
X Axis: -1.5258789E-5,
Y Rotation: -1.5258789E-5,
X Rotation: -1.5258789E-5,
Z Axis: -1.5258789E-5,
Axis 6: -1.5258789E-5,
Button 0: Off,
Button 1: Off,
Button 2: Off,
Button 3: Off,
Button 4: Off,
Button 5: Off,
Button 6: Off,
Button 7: Off,
Button 8: Off,
Button 9: Off,
Hat Switch: Off,
System Main Menu: Off


I am pretty sure I have the latest version of  JInput and I am using an xbox one controller though this problem occurs for any device anyways. The test programs run fine and display correct readings for the gamepad and everything else. If I could see the source code for the test program that would probably help too.
Pages: [1]
  ignore  |  Print  
 
 

 
hadezbladez (290 views)
2018-11-16 13:46:03

hadezbladez (160 views)
2018-11-16 13:41:33

hadezbladez (291 views)
2018-11-16 13:35:35

hadezbladez (72 views)
2018-11-16 13:32:03

EgonOlsen (2152 views)
2018-06-10 19:43:48

EgonOlsen (2180 views)
2018-06-10 19:43:44

EgonOlsen (1367 views)
2018-06-10 19:43:20

DesertCoockie (1984 views)
2018-05-13 18:23:11

nelsongames (1626 views)
2018-04-24 18:15:36

nelsongames (2274 views)
2018-04-24 18:14:32
Deployment and Packaging
by mudlee
2018-08-22 18:09:50

Java Gaming Resources
by gouessej
2018-08-22 08:19:41

Deployment and Packaging
by gouessej
2018-08-22 08:04:08

Deployment and Packaging
by gouessej
2018-08-22 08:03:45

Deployment and Packaging
by philfrei
2018-08-20 02:33:38

Deployment and Packaging
by philfrei
2018-08-20 02:29:55

Deployment and Packaging
by philfrei
2018-08-19 23:56:20

Deployment and Packaging
by philfrei
2018-08-19 23:54:46
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!