Java-Gaming.org    
Featured games (91)
games approved by the League of Dukes
Games in Showcase (580)
games submitted by our members
Games in WIP (499)
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  
  Another newb scratching for any help he can get  (Read 1479 times)
0 Members and 1 Guest are viewing this topic.
Offline Swift2568

Innocent Bystander





« Posted 2006-07-19 07:55:37 »

I'm in a robotics class here at Lawrence Tech. University.  The class is based around laptop robots running java.  I thaught it would be great if I could drive my robot like a remote control car via my playstation controller (with usb adapter).  The goal is to eventually control the robot across campus (LTU is a wireless campus) from my desk.

While trying to understand Jinput, I found the tutorial at https://freefodder.dev.java.net/tutorial/jinputTutorialOne.html

It's a great tutorial, but the examples seem to be broken. Running in Eclipse 3.1.1 and on the command line with ant result in the same error for the ControllerDetails example. 

"
Exception in thread "main" java.lang.NoSuchMethodError: net.java.games.input.Controller.getAxes()[Lnet/java/games/input/Axis;
   at net.java.games.input.tutorialone.ControllerDetails.printControllerDetails(ControllerDetails.java:74)
   at net.java.games.input.tutorialone.ControllerDetails.main(ControllerDetails.java:46)
"

I understand that the tutorial is out of date and may have been broken with new versions of Jinput.  What I need is a solution for the example.

-Swift-


Here is the code for the example:

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  
48  
49  
50  
51  
52  
53  
54  
55  
56  
57  
58  
59  
60  
61  
62  
63  
64  
65  
66  
67  
68  
69  
70  
71  
72  
73  
74  
75  
76  
77  
78  
79  
80  
81  
82  
83  
84  
85  
86  
87  
88  
89  
90  
91  
92  
93  
94  
95  
96  
97  
98  
99  
100  
101  
102  
103  
104  
105  
106  
107  
108  
109  
110  
111  
112  
113  
114  
115  
116  
package net.java.games.input.tutorialone;

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

/** A simple application that shows detailed information
 * about one of the controllers.
 *  
 * @author Robert Schuster
 */

public class ControllerDetails {

   /** Shows details about the controller represented
    * by an index number. Use ListControllers to find
    * out which index belongs to which controller.
    *
    * @param args
    */

   public static void main(String[] args) {
      if (args.length < 1) {
         printUsage();
      } else {
         // treat first argument as a number
        try {
            //int index = Integer.parseInt(args[0]);
           int index = 2;
            /* access the default controller environment
             * which contains all identified controllers
             */

            ControllerEnvironment ce =
               ControllerEnvironment.getDefaultEnvironment();

            // retrieve the available controllers
           Controller[] controllers = ce.getControllers();

            // fail if the number argument is not a valid index for the Controller array
           if (index < 0 || index >= controllers.length) {
               System.out.println(
                  "The provided index is out of range.\nUse a value between 0 and "
                     + (controllers.length - 1));
               return;
            }

            // hand control over to a method printing the details for this controller
           printControllerDetails(controllers[index]);
           
         } catch (NumberFormatException nfe) {
            printUsage();
         }
      }
   }

   private static void printUsage() {
      // show a hint if the parameter format was not correct
     System.out.println("Start application with an index as an argument");
      System.out.println(
         "denoting the controller you want detailed information");
      System.out.println("from.");
   }

   /** Prints an input controller's details to the console. The
    * method is called recursively for each subcontroller.
    *
    * @param c
    */

   private static void printControllerDetails(Controller c) {
      // shows basic information about this controller
     System.out.println("name: " + c.getName());
      System.out.println("type: " + c.getType());
      System.out.println("port: " + c.getPortType());

      // shows information about each Axis instance of this controller
     printAxesDetails(c.getAxes());
     
      // shows details about this controller's subcontroller      
     Controller[] subControllers = c.getControllers();
      if (subControllers.length > 0) {
         for (int i = 0; i < subControllers.length; i++) {
            System.out.println("subcontroller: " + i);
            printControllerDetails(subControllers[i]);
         }
      }
   }

   /** Prints detailed information about each Axis instance in the given
    * array.
    *
    * @param axes
    */

   private static void printAxesDetails(Axis[] axes) {
      if (axes.length > 0) {
         System.out.println("axes:");

         // iterate through all axes and print their information
        for (int i = 0; i < axes.length; i++) {
            System.out.println(
               i
                  + " - "
                  + axes[i].getName()
                  + " - "
                  + axes[i].getIdentifier()
                  + " - "
                  + (axes[i].isRelative() ? "relative" : "absolute")
                  + " - "
                  + (axes[i].isNormalized() ? "normalized" : "arbitrary")
                  + " - "
                  + (axes[i].isAnalog() ? "analog" : "digital")
                  + " - "
                  + axes[i].getDeadZone());
         }
      }

   }

}
Offline Jeff

JGO Coder




Got any cats?


« Reply #1 - Posted 2006-07-19 08:58:58 »

I believe getAcis was renamed somethign like "getComponent" but check the javadoc, It shiuld jump right out at you

Got a question about Java and game programming?  Just new to the Java Game Development Community?  Try my FAQ.  Its likely you'll learn something!

http://wiki.java.net/bin/view/Games/JeffFAQ
Offline endolf

JGO Knight


Medals: 7
Projects: 1


Current project release date: sometime in 3003


« Reply #2 - Posted 2006-07-19 13:32:37 »

Yup

Was renamed to getComponents.

There are test applications that are in the jinput cvs repository that show examples of using the API.

HTH

Endolf

Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

xsi3rr4x (42 views)
2014-04-15 18:08:23

BurntPizza (38 views)
2014-04-15 03:46:01

UprightPath (54 views)
2014-04-14 17:39:50

UprightPath (36 views)
2014-04-14 17:35:47

Porlus (53 views)
2014-04-14 15:48:38

tom_mai78101 (75 views)
2014-04-10 04:04:31

BurntPizza (134 views)
2014-04-08 23:06:04

tom_mai78101 (234 views)
2014-04-05 13:34:39

trollwarrior1 (195 views)
2014-04-04 12:06:45

CJLetsGame (203 views)
2014-04-01 02:16:10
List of Learning Resources
by SHC
2014-04-18 03:17:39

List of Learning Resources
by Longarmx
2014-04-08 03:14:44

Good Examples
by matheus23
2014-04-05 13:51:37

Good Examples
by Grunnt
2014-04-03 15:48:46

Good Examples
by Grunnt
2014-04-03 15:48:37

Good Examples
by matheus23
2014-04-01 18:40:51

Good Examples
by matheus23
2014-04-01 18:40:34

Anonymous/Local/Inner class gotchas
by Roquen
2014-03-11 15:22:30
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!