Samuel
Samuel

Reputation: 405

Slick2D Mouse Click not working in Windows 10

I created a simple mouse listener example using Slick2D in Windows 10 environment in Intellij. It is not reporting the correct coordinates or not working at all:

State class:

import org.lwjgl.input.Mouse;
import org.newdawn.slick.GameContainer;
import org.newdawn.slick.Graphics;
import org.newdawn.slick.SlickException;
import org.newdawn.slick.state.BasicGameState;
import org.newdawn.slick.state.StateBasedGame;
public class StateMain extends BasicGameState
{
@Override
public int getID() {return 0;}
@Override
public void init(GameContainer container, StateBasedGame game) throws SlickException {}
@Override
public void render(GameContainer container, StateBasedGame game, Graphics g) throws SlickException {}
@Override
public void update(GameContainer container, StateBasedGame game, int delta) throws SlickException
    {
    System.out.printf("Position: %d,%d\n", Mouse.getX(), Mouse.getY()); // Only reports position (-1,-1)
    }
@Override
public void mouseClicked(int button, int x, int y, int clickCount)
    {
    System.out.printf("Clicked: %d,%d\n", x, y); // Doesn't report
    }
@Override
public void mousePressed(int button, int x, int y)
    {
    System.out.printf("Pressed: %d,%d\n", x, y); // Only reports (-1,501)
    }
}

I have the following files in my libs folder:

jinput-dx8.dll jinput-dx8_64.dll jinput-raw.dll jinput-raw_64.dll lwjgl.dll lwjgl64.dll OpenAL32.dll OpenAL64.dll

The following are my VM arguments:

-Djava.library.path=libs/ -Dorg.lwjgl.opengl.Display.allowSoftwareOpenGL=true

I always get the following error when running the code:

Oct 05, 2017 11:26:30 AM net.java.games.input.DefaultControllerEnvironment getControllers WARNING: Found unknown Windows version: Windows 10 Oct 05, 2017 11:26:30 AM net.java.games.input.DefaultControllerEnvironment getControllers INFO: Attempting to use default windows plug-in. Oct 05, 2017 11:26:30 AM net.java.games.input.DefaultControllerEnvironment getControllers INFO: Loading: net.java.games.input.DirectAndRawInputEnvironmentPlugin

I suspect that the input environment plugin it is loading is causing the weird mouse position errors?

Upvotes: 0

Views: 191

Answers (1)

LOLWTFasdasd asdad
LOLWTFasdasd asdad

Reputation: 2943

It's working for me. Could you try lwjgl 2.9.1 and put this in your init method: System.setProperty("org.lwjgl.input.Mouse.allowNegativeMouse‌​Coords", "false");

Upvotes: 1

Related Questions