Thanks for the information endolf,
That explains why I couldn’t find any calls to the methods firing events.
However, I wonder in which thread the events are dispatched, if implemented by a pulgin? (It’s in the API so, you probably have though about this)
IMO it should be consistent for all plug-ins, since one almost never uses them directly.
Beside removing the add/remove listener methods, the two solutions are:
-
A dispatch method should be added to the abstract ControllerEvironment class, which dispatches the events in the caller thread (compare to SWT). Of course the implementation should be thread safe, so it can be used from different ones.
-
A dedicated JInput Thread should run in the background, and the should be similiar synchronized static methods like provided by the java.awt.EventQueue. As a result, every Jinput code must be executed in this Thread (compare to AWT).
The latter one is clearly easier to implement, but more difficult to use. E.g. the user has to synchronize everything with the AWT-Event-Thread if using this window toolkit. Same with SWT, unless all SWT code is executed in the JInput-Event-Thread via the invokeXXX methods.
[update]
just read the previous post: dispatching in the poll method is similiar to the first and I good point is that when the polled controller removing is checked anyway for this one. On the other side, checking for all controller adds and removes within a poll, which is probaly done for each controller in each frame, is probably an overhead compared to a single call to dispatch, isn’t it?
An idea would be adding a callback interface to a newly added ControlEnvironment.dispatch method, which allows to poll the connected invidual controllers and optinally remove the method from the Control class.
[/update]
Just thoughts, I don’t need the events atm.
And I kow that such things are difficult to implement correctly regarding threading, since I had to implment a firewire cameras, inclding listening to changes the bus…