LWJGL Forum

Programming => Lightweight Java Gaming Library => Topic started by: sirantonycartwright on February 02, 2007, 15:37:05

Title: LWJGL noobie wanting to get joypad input - where do i start?
Post by: sirantonycartwright on February 02, 2007, 15:37:05
Ok, Ive installed the package and i can now import it in Netbeans 5.5.
I have no idea where to start and i cant get javadoc to work in Netbeans.

Im trying to get input from a joypad/ joystick/ gamepad or whatever its called!

Where do i start?

Thanks, Ant...

(ps. It might be a good idea to make a sticky called "where do i start" for noobies" - that would be cool!)
Title: Re: LWJGL noobie wanting to get joypad input - where do i start?
Post by: sirantonycartwright on February 02, 2007, 15:42:41
oh, yeah.
I found a good one here but i think its only snippets. Is there a tutorial so i can see whats going on and whats happening?

http://lwjgl.org/wiki/doku.php/lwjgl/tutorials/input/basiccontroller
I dont know where the Controllers class is coming from.

By the way, good choice, i prefer doku too!
Ant...
Title: Re: LWJGL noobie wanting to get joypad input - where do i start?
Post by: Fool Running on February 02, 2007, 18:35:08
QuoteI dont know where the Controllers class is coming from.
The Controllers class is a part of LWJGL. http://www.lwjgl.org/javadoc/
QuoteIs there a tutorial so i can see whats going on and whats happening?
What kind of tutorial are you looking for? That one seemed to show how to use the Controllers class pretty well.
Title: Re: LWJGL noobie wanting to get joypad input - where do i start?
Post by: sirantonycartwright on February 02, 2007, 19:50:36
well, i gave that one a try but i had an error straight away..
Title: Re: LWJGL noobie wanting to get joypad input - where do i start?
Post by: sirantonycartwright on February 02, 2007, 19:57:23
This is my class - well as far as it went:

/*
* Emulator.java
*
* Created on 02 February 2007, 19:51
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
import org.lwjgl.*;
/**
*
* @author Antonio
*/
public class Emulator {
   
    /** Creates a new instance of Emulator */
    public Emulator() {
    }
   
    Controllers.create(); //create the class
    int numberOfControllers = Controllers.getControllerCount();
   
    String playerChosenController = "MyJoystick";
    Controller playerControl;
   
    for (int i = 0; i < numberOfControllers; i++ ) {
        Controller c = Controllers.getController(i);
        if (c.getName().equals(playerChosenController)) {
            playerControl = c;
        }
    }
   
}


My java might be wrong.
Title: Re: LWJGL noobie wanting to get joypad input - where do i start?
Post by: sirantonycartwright on February 02, 2007, 19:58:50
Error: Controllers.create(); Identifier expected
Can you help?
Ant...
Title: Re: LWJGL noobie wanting to get joypad input - where do i start?
Post by: Matzon on February 03, 2007, 00:18:58
uhm, import the Controller ?
Title: Re: LWJGL noobie wanting to get joypad input - where do i start?
Post by: sirantonycartwright on February 04, 2007, 15:34:05
how do i import Controller?

import org.lwjgl.input.Controllers.*;

???
Title: Re: LWJGL noobie wanting to get joypad input - where do i start?
Post by: sirantonycartwright on February 04, 2007, 15:41:01
the "input" folder isnt there!

i can type import org.lwjgl. then all thats there is a folder called "test".

What have i done wrong?
Or have i done anything wrong?

Ant...
Title: Re: LWJGL noobie wanting to get joypad input - where do i start?
Post by: aldacron on February 04, 2007, 15:46:35
Quote from: sirantonycartwright on February 04, 2007, 15:34:05
how do i import Controller?

Drop the .* after Controllers:

import org.lwjgl.input.Controllers;

This imports the Controllers class only.

It seems you may have a misunderstanding of how imports work. I see that in your code you use this:

import org.lwjgl.*;

All this does is import all the classes in the lwjgl package (of which there are five) -- it does not import classes from subpackages. If you want to get to those, you have to either import each class specifically, or all classes in the subpackage via the * syntax:

import org.lwjgl.input.*;    // all classes from the input subpackage
import org.lwjgl.opengl.*;  // all classes from the opengl subpackage




Title: Re: LWJGL noobie wanting to get joypad input - where do i start?
Post by: aldacron on February 04, 2007, 15:48:50
Quote from: sirantonycartwright on February 04, 2007, 15:41:01
the "input" folder isnt there!

i can type import org.lwjgl. then all thats there is a folder called "test".

What have i done wrong?
Or have i done anything wrong?

It seems you have put lwjgl_test.jar on the classpath and not lwjgl.jar. Update your project properties in your IDE with the path to lwjgl.jar.
Title: Re: LWJGL noobie wanting to get joypad input - where do i start?
Post by: sirantonycartwright on February 05, 2007, 12:39:03
Hello,
I have a "lwjgl" library in Netbeans which has four classpaths, for jinput.jar, lwjgl.jar, lwjgl_util.jar and lwjgl_util_applet.jar. I have added the "lwjgl" library to the project. It seems right so im unsure what to do.
I didnt update because i think this is already right, i removed the test jar though.

It still doesnt work.

Ant...

ps. Thanks for clearing up my import misunderstanding.
Title: Re: LWJGL noobie wanting to get joypad input - where do i start?
Post by: aldacron on February 05, 2007, 16:16:24
Quote from: sirantonycartwright on February 05, 2007, 12:39:03
Hello,
I have a "lwjgl" library in Netbeans which has four classpaths, for jinput.jar, lwjgl.jar, lwjgl_util.jar and lwjgl_util_applet.jar.

There is only one classpath. It can contain multiple entries.

Quote
I have added the "lwjgl" library to the project. It seems right so im unsure what to do.
I didnt update because i think this is already right, i removed the test jar though.

Don't add the jars to the project. You need to modify the project classpath via the project properties. You also need to tell Netbeans to pass the path of the native libraries (the DLLs) to the VM when it runs your program. Read this Wiki entry (http://lwjgl.org/wiki/doku.php/lwjgl/install/ide/netbeans) for step-by-step instructions.