Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (516)
Games in Android Showcase (122)
games submitted by our members
Games in WIP (577)
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: Rescan controllers on: 2012-02-27 19:36:51
I paste you my patch here :

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  
Index: coreAPI/src/java/net/java/games/input/DefaultControllerEnvironment.java
===================================================================
--- coreAPI/src/java/net/java/games/input/DefaultControllerEnvironment.java   (revision 247)
+++ coreAPI/src/java/net/java/games/input/DefaultControllerEnvironment.java   (working copy)
-169,6 +169,21 @@
                e.printStackTrace();
             }
          }
+        } else {
+           controllers = new ArrayList();
+           for (Object ceName : loadedPlugins) {
+            try {
+               Class ceClass = Class.forName((String) ceName);
+               ControllerEnvironment ce = (ControllerEnvironment) ceClass.newInstance();
+               if (ce.isSupported()) {
+                  addControllers(ce.getControllers());
+               } else {
+                  logln(ceClass.getName() + " is not supported");
+               }
+            } catch (Exception e) {
+               e.printStackTrace();
+            }
+           }
         }
         Controller[] ret = new Controller[controllers.size()];
         Iterator it = controllers.iterator();
Index: plugins/windows/src/java/net/java/games/input/DirectInputEnvironmentPlugin.java
===================================================================
--- plugins/windows/src/java/net/java/games/input/DirectInputEnvironmentPlugin.java   (revision 247)
+++ plugins/windows/src/java/net/java/games/input/DirectInputEnvironmentPlugin.java   (working copy)
-111,28 +111,20 @@
       }
    }
 
-   private final Controller[] controllers;
+   private Controller[] controllers = new Controller[0];
    private final List active_devices = new ArrayList();
    private final DummyWindow window;
 
    /** Creates new DirectInputEnvironment */
    public DirectInputEnvironmentPlugin() {      
       DummyWindow window = null;
-      Controller[] controllers = new Controller[]{};
       if(isSupported()) {
          try {
             window = new DummyWindow();
-            try {
-               controllers = enumControllers(window);
-            } catch (IOException e) {
-               window.destroy();
-               throw e;
-            }
          } catch (IOException e) {
             logln("Failed to enumerate devices: " + e.getMessage());
          }
          this.window = window;
-         this.controllers = controllers;
          AccessController.doPrivileged(
                new PrivilegedAction() {
                   public final Object run() {
-144,12 +136,23 @@
          // These are final fields, so can't set them, then over ride
          // them if we are supported.
          this.window = null;
-         this.controllers = controllers;
       }
    }
 
    public final Controller[] getControllers() {
-      return controllers;
+      if (this.window != null) {
+         try {
+            try {
+               this.controllers = this.enumControllers(this.window);
+            } catch (IOException e) {
+               this.window.destroy();
+               throw e;
+            }
+         } catch (IOException e) {
+            logln("Failed to enumerate devices: " + e.getMessage());
+         }
+      }
+      return this.controllers;
    }
 
    private final Component[] createComponents(IDirectInputDevice device, boolean map_mouse_buttons) {


As you could see, I only upgrade DirectInputEnvironnementPlugin (and DefaultControllerEnvironnement  Roll Eyes)
May be you will need to change the implicit for-each for Java 1.4.

The patch works well for me. I suppose it could be applied to other platforms.

2  Java Game APIs & Engines / JInput / Re: Rescan controllers on: 2012-02-25 17:29:06
Yes, I succed in rescanning controller.

If I remember well, I only do it for Windows (my target platform) and in Java 6.
If you are interested in, may be I could make you a patch  Wink
3  Java Game APIs & Engines / JInput / Re: Rescan controllers on: 2011-09-20 16:03:35
The ant build script wants 1.4 java source :
1  
<javacsource="1.4" target="1.4">


And yes, Sun Oracle has release Java 7  Wink
4  Java Game APIs & Engines / JInput / Re: Rescan controllers on: 2011-09-20 09:46:52
I wonder why java API is frozen to 1.4 ?  Huh
5  Java Game APIs & Engines / JInput / Re: Rescan controllers on: 2011-09-17 08:43:31
I made some patches to net.java.games.input.DirectInputEnvironmentPlugin and net.java.games.input.DefaultControllerEnvironment classes and it seems to work. (I am on Windows for now).
I need to improve cleaning device first and test again.

I will keep this post up to date if you are interested in  Wink
6  Java Game APIs & Engines / JInput / Rescan controllers on: 2011-09-16 17:27:48
According this topic (http://www.java-gaming.org/index.php?topic=21694.0) and my own tests, the controller environnement could not rescan controllers.
I'm just getting the source and I wonder how many time it take to add this feature and if it is only java fix or I need to fix native part.

I need controller rescan so why not add it myself if you help me in explaining the main architecture  Wink
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.

TehJavaDev (31 views)
2014-10-27 03:28:38

TehJavaDev (26 views)
2014-10-27 03:27:51

DarkCart (40 views)
2014-10-26 19:37:11

Luminem (21 views)
2014-10-26 10:17:50

Luminem (26 views)
2014-10-26 10:14:04

theagentd (32 views)
2014-10-25 15:46:29

Longarmx (61 views)
2014-10-17 03:59:02

Norakomi (57 views)
2014-10-16 15:22:06

Norakomi (46 views)
2014-10-16 15:20:20

lcass (43 views)
2014-10-15 16:18:58
Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06
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!