Java-Gaming.org
Play Revenge of the Titans! The situation is critical. We need fancy commanders to defend Earth, the moon, Mars!
Featured games (78)
games approved by the League of Dukes
Games in Showcase (408)
games submitted by our members
Games in WIP (293)
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 20: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 18: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 18: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 11: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 10: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 19: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]
Play Revenge of the Titans! The situation is critical. We need fancy commanders to defend Earth, the moon, Mars!
 
Get high quality music tracks for your game!

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

The invasion has landed! On Mars! And you're there to beat 'em!
cubemaster21 (143 views)
2013-05-17 21:29:12

alaslipknot (151 views)
2013-05-16 21:24:48

gouessej (182 views)
2013-05-16 00:53:38

gouessej (175 views)
2013-05-16 00:17:58

theagentd (184 views)
2013-05-15 15:01:13

theagentd (169 views)
2013-05-15 15:00:54

StreetDoggy (214 views)
2013-05-14 15:56:26

kutucuk (239 views)
2013-05-12 17:10:36

kutucuk (237 views)
2013-05-12 15:36:09

UnluckyDevil (242 views)
2013-05-12 05:09:57
Complex number cookbook
by Roquen
2013-04-24 12:47:31

2D Dynamic Lighting
by Oskuro
2013-04-17 16:46:12

2D Dynamic Lighting
by Oskuro
2013-04-17 16:45:57

2D Dynamic Lighting
by Oskuro
2013-04-17 16:23:20

Noise (bandpassed white)
by Roquen
2013-04-05 17:36:01

Noise (bandpassed white)
by Roquen
2013-04-03 16:17:38

Java Data structures
by Roquen
2013-03-29 13:21:12

Topic Request
by kutucuk
2013-03-22 21:42:01
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!
Page created in 0.091 seconds with 21 queries.