Java-Gaming.org    
Featured games (79)
games approved by the League of Dukes
Games in Showcase (477)
Games in Android Showcase (108)
games submitted by our members
Games in WIP (536)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
   Home   Help   Search   Login   Register   
  Show Posts
Pages: [1]
1  Java Game APIs & Engines / JInput / Re: getControllers() gives an empty array on: 2005-06-03 14:39:37
This is it, it is not really platform independand, is it? Wink

But that doesn't matter, I only run the program in Windows

Very, very much thanks for your help Kevglass

Jos Foppele
2  Java Game APIs & Engines / JInput / Re: getControllers() gives an empty array on: 2005-06-03 13:18:20
the dxinput.jar is in ${jre.home}/lib/ext/controller/ together with the dll

I never extracted that jar, only the jars in the applications classpath (jinput.jar and jutils.jar). The reason was to see if it would work extracted. But it did not make a difference (as you would propably have expected Wink)
3  Java Game APIs & Engines / JInput / Re: getControllers() gives an empty array on: 2005-06-03 12:35:56
Ah, but where is the dll?
as said in the JInput Introduction sticky on top of this forum, I placed the dll as following:
Quote
Installation of the plugin(s):
-----------------------------------
Nearly all plugins consist of two files. One of them is the native library (e.g. dxinput.dll, libjinput.so) and the other one is the java part of the plugin (any official name for that?). There are multiple ways for installing a plugin:

1) the easiest but most (system) polluting way:
create a folder named 'controller' inside your ${jre.home}/lib/ext folder and copy the two files in.

The project itself is located on another harddrive, but that was never a problem and I don't know why it should be a problem now...
4  Java Game APIs & Engines / JInput / Re: getControllers() gives an empty array on: 2005-06-03 12:09:16
I don't have much more consoles.
This is the other, the debugging console:
Quote
Listening on 4582
User program running
User program finished

my own code is in a package called idp1
the libraries are in net/java/games/input and net/java/games/util/plugin
(were in .jar files, but that didn't work so I tried it extracted, with the same result. On the moent it is still in extracted state)
an overview:
-Source Packages
---idp1
------Bestuuring.java
------Main.java
------<more files, witch I think don't matter>
---net.java.games.input
------<All the files>
---net.java.games.input.test
------<All the files>
---net.java.games.util.plugin
------<All the files>
---net.java.games.util.plugin.test
------<All the files>
5  Java Game APIs & Engines / JInput / Re: getControllers() gives an empty array on: 2005-06-03 11:50:58
the complete console output:
1  
2  
3  
4  
5  
6  
7  
init:
deps-jar:
Compiling 1 source file to D:\School\Project Telebluppy\GUI\build\classes
compile:
controllers == null
debug:
BUILD SUCCESSFUL (total time: 32 seconds)


and teh editted code:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
    public Bestuuring() {
        ControllerEnvironment ce = ControllerEnvironment.getDefaultEnvironment();
        // retrieve the available controllers  
       net.java.games.input.Controller[] controllers = ce.getControllers();
        gp = null;
        if (controllers.length == 0) {
               System.out.println("controllers == null");
           } else {
               System.out.println("controllers found");
           }
        if (controllers.length > 0) {//error is caught in the run methode
           net.java.games.input.Controller c;
            for (int i = 0; i < controllers.length; i++) {
                c = controllers[i];
                //if(c.getType() ==  net.java.games.input.Controller.Type.GAMEPAD) { // c is a gamepad
                   gp = controllers[i];
                //}
           }
        }
    }


I should be apologizing to you that it is taking so long Wink
6  Java Game APIs & Engines / JInput / Re: getControllers() gives an empty array on: 2005-06-03 11:36:16
the complete code of the thread. The code in sendAxis() might have some errors, but I'm sure my problems are not coming from there, because he can't come in that code, because I get the errorMessage "controller is null" on screen

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  
package idp1;

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

public class Bestuuring extends Thread {
    private net.java.games.input.Controller gp;
   
    public Bestuuring() {
        ControllerEnvironment ce = ControllerEnvironment.getDefaultEnvironment();
        // retrieve the available controllers  
       net.java.games.input.Controller[] controllers = ce.getControllers();
        gp = null;
        if (controllers.length > 0) {//error is caught in the run methode
           net.java.games.input.Controller c;
            for (int i = 0; i < controllers.length; i++) {
                c = controllers[i];
                if(c.getType() ==  net.java.games.input.Controller.Type.GAMEPAD) { // c is a gamepad
                   gp = controllers[i];
                }
            }
        }
    }
   
    public void run() {
        while (true) {
            if (gp == null) {
                errorHandler("controller is null");
            } else {
                if (gp.poll()) {
                    sendAxis(gp.getAxes());
                    errorHandler("");
                } else {
                    errorHandler("controller invalid");
                }      
            }
        }
    }
   
    private void sendAxis(Axis[] assen) {
        for (int i = 0; i < assen.length; i++) {
            float data = assen[i].getPollData();
            errorHandler(assen[i].getName());//for debugging only!
           if (assen[i].getIdentifier() == Axis.Identifier.X) {
                if (data > 0) { //arrow right
                   sendButton(7);
                }
                if (data < 0) { //arrow left
                   sendButton(8);
                }
            }
            if (assen[i].getIdentifier() == Axis.Identifier.Y) {
                if (data < 0) { //arrow up
                   sendButton(5);
                }
                if (data > 0) { //arrow down
                   sendButton(6);
                }
                /* alternative buttons for up and down
                if ((assen[i].getName() == "Knop 5") || (assen[i].getName() == "Knop 7")) {//up, R1 and R2 buttons
                    sendButton(5);
                }
                if ((assen[i].getName() == "Knop 4") || (assen[i].getName() == "Knop 6")) {//down, L1 and L2 buttons
                    sendButton(6);
                }
                */

            }
            if (assen[i].getIdentifier() == Axis.Identifier.BUTTON) {
                if (assen[i].getName() == "Knop 0") {//button 1
                   sendButton(1);
                }
                if (assen[i].getName() == "Knop 1") {//button 2
                   sendButton(2);
                }
                if (assen[i].getName() == "Knop 2") {//button 3
                   sendButton(3);
                }
                if (assen[i].getName() == "Knop 3") {//button 4
                   sendButton(4);
                }
            }
        }
    }
   
    private void sendButton(int button) {
        Main.stuur.append(String.valueOf(button)); // not "k" + button
   }
   
    private void errorHandler(String message) {
        Main.stuur.append("e" + message);
    }
}
7  Java Game APIs & Engines / JInput / Re: getControllers() gives an empty array on: 2005-06-03 11:16:54
This works fine, but if I use it in my code, it (again) gives the same error Huh

my Java Version: Version 1.4.2_08 (build 1.4.2_08-b03)
8  Java Game APIs & Engines / JInput / Re: getControllers() gives an empty array on: 2005-06-03 11:00:35
To start with, where did you get your java and natives from?
I used the files from the NightlyBuilds. But after using your files I get the same problem.

I also searched my code for any addAxis method call (for the third time) but I can not seem to find where this method is called...
9  Java Game APIs & Engines / JInput / Re: getControllers() gives an empty array on: 2005-06-03 10:04:01
That would apper to be caused by the native libraries you have been out of sync with the java libraries.

Kev
I'm a newbie so could you give me some tips on solving this?
10  Java Game APIs & Engines / JInput / Re: getControllers() gives an empty array on: 2005-06-03 09:10:23
I've re-installed the driver and rewritten my code, it seems to me the driver is properly installed now. But another problem has appeared Huh, so I've not tested it yet. Can anybody help me with my next problem?

The output I received:
Quote
init:
deps-jar:
Compiling 1 source file to D:\School\Project Telebluppy\GUI\build\classes
compile:
OS name is: Windows XP
DX8 plugin is supported
OS name is: Windows XP
DX8 plugin is supported
java.lang.NoSuchMethodError: addAxis
    at net.java.games.input.DirectInputEnvironmentPlugin.directInputCreate(Native Method)
    at net.java.games.input.DirectInputEnvironmentPlugin.<init>(DirectInputEnvironmentPlugin.java:114)
    at idp1.Bestuuring.<init>(Bestuuring.java:22)
    at idp1.Main.main(Main.java:71)
Exception in thread "main"
Java Result: 1
debug:
BUILD SUCCESSFUL (total time: 10 seconds)

The error is thrown on the first line of my constructor
Quote
public Bestuuring() {
        DirectInputEnvironmentPlugin diep = new DirectInputEnvironmentPlugin();
        /* This throws an Internal Exception:
         *   java.lang.NoSuchMethodError: addAxis
         *       at net.java.games.input.DirectInputEnvironmentPlugin.directInputCreate(Native Method)
         *       at net.java.games.input.DirectInputEnvironmentPlugin.<init>(DirectInputEnvironmentPlugin.java:114)
         */
       
        // retrieve the available controllers   
        net.java.games.input.Controller[] controllers = diep.getControllers();
        gp = null;
        if (controllers.length > 0) {//error is caught in the run methode
            net.java.games.input.Controller c;
            for (int i = 0; i < controllers.length; i++) {
                c = controllers;
                if(c.getType() ==  net.java.games.input.Controller.Type.GAMEPAD) { // c is a gamepad
                    gp = controllers;
                }
            }
        }
    }
11  Java Game APIs & Engines / JInput / getControllers() gives an empty array on: 2005-05-31 13:13:37
I'm having much trouble running JInput with a gamepad. When I call getControllers() it returns an empty array

following is my code:
Quote
/*
* Bestuuring.java
*
* Created on 12 mei 2005, 10:14
*/

package idp1;

import net.java.games.input.*;
import net.java.games.util.plugins.*;

/**
*
* @author Groep15
*/
public class Bestuuring extends Thread {
   private net.java.games.input.Controller gp;
   
   public Bestuuring() {
       System.out.println("bestuuring online");
           ControllerEnvironment ce = DirectInputEnvironmentPlugin.getDefaultEnvironment();      
           // retrieve the available controllers      
           net.java.games.input.Controller[] controllers = ce.getControllers(); //this gives an empty array
           if (controllers.length == 0) {
               System.out.println("controllers == null");
           } else {
               System.out.println("controllers found");
           }
           net.java.games.input.Controller c;
           gp = null;
           for (int i = 0; i < controllers.length; i++) {
               c = controllers;
               if(c.getType() ==  net.java.games.input.Controller.Type.GAMEPAD) { // c is a gamepad
                   gp = controllers;
               }
           }
   }
   
   public void run() {
           //not yet coded, no need because the constructor doesn't work
   }
   
   private void errorHandler(String message) {
       Main.stuur.append("e" + message); //works fine
   }
}

I'm running on Windows XP with NetBeans 4 and J2sdk1.4.2

Could someone please give me some advice?

Grtz, Foppie
Pages: [1]
 

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

The first screenshot will be displayed as a thumbnail.

CogWheelz (18 views)
2014-07-30 21:08:39

Riven (23 views)
2014-07-29 18:09:19

Riven (15 views)
2014-07-29 18:08:52

Dwinin (12 views)
2014-07-29 10:59:34

E.R. Fleming (33 views)
2014-07-29 03:07:13

E.R. Fleming (12 views)
2014-07-29 03:06:25

pw (43 views)
2014-07-24 01:59:36

Riven (43 views)
2014-07-23 21:16:32

Riven (30 views)
2014-07-23 21:07:15

Riven (31 views)
2014-07-23 20:56:16
List of Learning Resources
by SilverTiger
2014-07-31 18:29:50

List of Learning Resources
by SilverTiger
2014-07-31 18:26:06

List of Learning Resources
by SilverTiger
2014-07-31 13:54:12

HotSpot Options
by dleskov
2014-07-08 03:59:08

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:58:24

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:47:22

How do I start Java Game Development?
by ra4king
2014-05-17 11:13:37

HotSpot Options
by Roquen
2014-05-15 09:59:54
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!