LWJGL noobie wanting to get joypad input - where do i start?

Started by sirantonycartwright, February 02, 2007, 15:37:05

Previous topic - Next topic

sirantonycartwright

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!)

sirantonycartwright

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...

Fool Running

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.
Programmers will, one day, rule the world... and the world won't notice until its too late.Just testing the marquee option ;D

sirantonycartwright

well, i gave that one a try but i had an error straight away..

sirantonycartwright

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.

sirantonycartwright

Error: Controllers.create(); Identifier expected
Can you help?
Ant...

Matzon


sirantonycartwright

how do i import Controller?

import org.lwjgl.input.Controllers.*;

???

sirantonycartwright

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...

aldacron

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





aldacron

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.

sirantonycartwright

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.

aldacron

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 for step-by-step instructions.