Java-Gaming.org Hi !
Featured games (90)
games approved by the League of Dukes
Games in Showcase (741)
Games in Android Showcase (225)
games submitted by our members
Games in WIP (823)
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  
  JInput does not generate events for semicolon and apostrophe  (Read 8166 times)
0 Members and 1 Guest are viewing this topic.
Offline Elf7of9

Senior Newbie


Exp: 16 years


Java games rock!


« Posted 2016-02-21 03:33:33 »

Under Win7, JInput does not appear to generate events for the semicolon and apostrophe keys among several others.  Is there a work-around?
Offline Hydroque

JGO Coder


Medals: 25
Exp: 5 years


I'm always inspiring a good time.


« Reply #1 - Posted 2016-02-21 03:57:59 »


Update to the latest version or a previous version.

Unless it is open source, which you would then check if they disabled those keys, it should be registered as a problem.

You think I haven't been monitoring the chat? http://pastebin.java-gaming.org/c47d35366491fHere is a compilation <3
Offline Elf7of9

Senior Newbie


Exp: 16 years


Java games rock!


« Reply #2 - Posted 2016-02-21 04:09:41 »

My project uses the JInput resources exclusively.  It doesn't seem to have access to the LWJGL classes in your test code.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Elf7of9

Senior Newbie


Exp: 16 years


Java games rock!


« Reply #3 - Posted 2016-02-21 22:03:51 »

I upgraded to the latest nightly JInput build and the problem still persists.  Can someone else check on their Win7 box if JInput is capable to receiving events for semicolor or apostrophe?  Thanks.

Edit: I can get it to work if I add these VM arguments:

1  
-Djinput.useDefaultPlugin=false -Djinput.plugins=net.java.games.input.DirectInputEnvironmentPlugin


Is there any issue to using them? Is there a way to set that directly from the running app?
Offline Elf7of9

Senior Newbie


Exp: 16 years


Java games rock!


« Reply #4 - Posted 2016-02-22 15:09:23 »

From the source:

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
            //Check the properties for specified controller classes
            String pluginClasses = getPrivilegedProperty("jinput.plugins", "") + " " + getPrivilegedProperty("net.java.games.input.plugins", "");
         if(!getPrivilegedProperty("jinput.useDefaultPlugin", "true").toLowerCase().trim().equals("false") && !getPrivilegedProperty("net.java.games.input.useDefaultPlugin", "true").toLowerCase().trim().equals("false")) {
            String osName = getPrivilegedProperty("os.name", "").trim();
            if(osName.equals("Linux")) {
               pluginClasses = pluginClasses + " net.java.games.input.LinuxEnvironmentPlugin";
            } else if(osName.equals("Mac OS X")) {
               pluginClasses = pluginClasses + " net.java.games.input.OSXEnvironmentPlugin";
            } else  if(osName.equals("Windows XP") || osName.equals("Windows Vista") || osName.equals("Windows 7") || osName.equals("Windows 8") || osName.equals("Windows 8.1") || osName.equals("Windows 10")) {
               pluginClasses = pluginClasses + " net.java.games.input.DirectAndRawInputEnvironmentPlugin";
            } else if(osName.equals("Windows 98") || osName.equals("Windows 2000")) {
               pluginClasses = pluginClasses + " net.java.games.input.DirectInputEnvironmentPlugin";
            } else if (osName.startsWith("Windows")) {
               log.warning("Found unknown Windows version: " + osName);
               log.warning("Attempting to use default windows plug-in.");
               pluginClasses = pluginClasses + " net.java.games.input.DirectAndRawInputEnvironmentPlugin";
            } else {
               log.warning("Trying to use default plugin, OS name " + osName +" not recognised");
            }
         }


Windows XP and above gets:

1  
net.java.games.input.DirectAndRawInputEnvironmentPlugin


Older versions of windows gets:

1  
net.java.games.input.DirectInputEnvironmentPlugin


I don't know what the difference is between these plugins, but the newer one is not able to pick up some keyboard buttons at least under Windows 7.

Can anyone shed some light on this?
Offline thedanisaur

JGO Knight


Medals: 59



« Reply #5 - Posted 2016-02-22 18:42:25 »

Not sure why it's not picking up those keys (potential bug), anyway this thread sheds some light on it:

http://www.java-gaming.org/index.php?topic=21528.0

The raw plugin is so that you can use multiple (of the same) input devices, this might also affect console controllers (meaning that connecting a controller might cause unintended side-effects).

Every village needs an idiot Cool
Offline Elf7of9

Senior Newbie


Exp: 16 years


Java games rock!


« Reply #6 - Posted 2016-02-22 19:00:16 »

That link suggests that only the keyboards and mice are combined, which is sensible; rarely if ever do you attach multiple keyboards or mice to the same machine. 

If it is a bug, it could be specific to my keyboard since it relies on the low level keyboard events (it's a typical Logitech keyboard from about 2 years ago, nothing special or unusual about it).  It's more likely something to do with box:

Windows 7 Professional
Service Pack 1
Dell
5.1 Windows Experience Index
Intel Core i5-2400 CPU @ 3.10GHz
8 GB RAM
64-bit OS

I would appreciate if others could test out those key events if they are running on a similar platform.

In the meantime, I think I'll force it to use the non-raw plugin.
Offline thedanisaur

JGO Knight


Medals: 59



« Reply #7 - Posted 2016-02-22 19:16:04 »

If you aren't worried about people using multiple mice/keyboards/controllers then you're fine to just use the old plugin (which was my point).

I'm not sure why you think it's your machine that has the issue, update your keyboard driver. I also don't see anything for anybody to run to test this.

Every village needs an idiot Cool
Offline Elf7of9

Senior Newbie


Exp: 16 years


Java games rock!


« Reply #8 - Posted 2016-02-22 21:49:54 »

Here's a simple JInput test program.  Most keys works for me.  Semicolon and apostrophe do not generate any events.

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  
import java.awt.*;
import javax.swing.*;
import net.java.games.input.*;

public class Main {

  private final net.java.games.input.Event event
      = new net.java.games.input.Event();
 
  private Controller keyboard;  
  private JLabel label;
 
  public void launch() {
    createFrame();    
    initKeyboard();
    initTimer();  
  }
 
  private void createFrame() {
    final JFrame frame = new JFrame("Test Frame");
    frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    frame.setPreferredSize(new Dimension(640, 480));
    label = new JLabel("Press some keys.", SwingConstants.CENTER);
    label.setAlignmentY(0.5f);
    frame.setContentPane(label);
    frame.pack();
    frame.setLocationRelativeTo(null);
    frame.setVisible(true);
  }
 
  private void initKeyboard() {
    for(final Controller controller : ControllerEnvironment
        .getDefaultEnvironment().getControllers()) {
      if (controller.getType() == Controller.Type.KEYBOARD) {
        keyboard = controller;
        break;
      }
    }
  }
 
  private void initTimer() {
    final Timer timer = new Timer(25, e -> pollControllers());
    timer.start();
  }
 
  private void pollControllers() {
    if (keyboard != null) {
      if (keyboard.poll()) {
        final net.java.games.input.EventQueue queue = keyboard.getEventQueue();
        while(queue.getNextEvent(event)) {          
          label.setText(String.format("%s %d%n",
              event.getComponent().getIdentifier().getName(),
                  (int)event.getValue()));
        }
      } else {
        keyboard = null;
      }
    }
  }
 
  public static void main(final String... args) throws Throwable {
    java.awt.EventQueue.invokeLater(new Main()::launch);
  }  
}
Offline bitbytebytes

Junior Devvie


Medals: 2



« Reply #9 - Posted 2016-02-23 02:38:14 »

Just tested your code.  Not getting / ; ' \ = - I am getting / from the num pad though. win 7 64, latest jinput build.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Elf7of9

Senior Newbie


Exp: 16 years


Java games rock!


« Reply #10 - Posted 2016-02-23 03:07:41 »

Thanks for testing.  The same keys fail here.  Maybe it is some limitation of Windows Raw Input API.
Offline Elf7of9

Senior Newbie


Exp: 16 years


Java games rock!


« Reply #11 - Posted 2016-02-23 16:13:14 »

Here's my work-around for now:

1  
2  
3  
4  
5  
6  
7  
8  
    final String osName = System.getProperty("os.name");
    if (osName != null && osName.trim().toLowerCase().startsWith("win")) {
      System.setProperty("jinput.useDefaultPlugin", "false");
      System.setProperty("net.java.games.input.useDefaultPlugin", "false");
      System.setProperty("jinput.plugins", "");
      System.setProperty("net.java.games.input.plugins",
          "net.java.games.input.DirectInputEnvironmentPlugin");
    }


I'll verify, but I think this has no effect on the number of supported game controllers.  It only consolidates keyboards and mice, similar to Swing's keyboard and mouse events.
Offline thedanisaur

JGO Knight


Medals: 59



« Reply #12 - Posted 2016-02-23 20:05:15 »

Interesting, I'm having the same problem in windows 7 64bit (I don't have a 32bit machine to test on)

Controllers seem fine though and I don't have this issue on windows 8.1 64bit.

Every village needs an idiot Cool
Pages: [1]
  ignore  |  Print  
 
 

 
Ecumene (108 views)
2017-09-30 02:57:34

theagentd (135 views)
2017-09-26 18:23:31

cybrmynd (245 views)
2017-08-02 12:28:51

cybrmynd (239 views)
2017-08-02 12:19:43

cybrmynd (238 views)
2017-08-02 12:18:09

Sralse (252 views)
2017-07-25 17:13:48

Archive (864 views)
2017-04-27 17:45:51

buddyBro (1007 views)
2017-04-05 03:38:00

CopyableCougar4 (1566 views)
2017-03-24 15:39:42

theagentd (1373 views)
2017-03-24 15:32:08
List of Learning Resources
by elect
2017-03-13 14:05:44

List of Learning Resources
by elect
2017-03-13 14:04:45

SF/X Libraries
by philfrei
2017-03-02 08:45:19

SF/X Libraries
by philfrei
2017-03-02 08:44:05

SF/X Libraries
by SkyAphid
2017-03-02 06:38:56

SF/X Libraries
by SkyAphid
2017-03-02 06:38:32

SF/X Libraries
by SkyAphid
2017-03-02 06:38:05

SF/X Libraries
by SkyAphid
2017-03-02 06:37:51
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!