Greetings fellow developers. I have been searching this topic only to find that one has succeeded and failed to provide their results because they like proprietary bullshit.
I have been looking to make a push to talk handset for a project I am doing with the United States Air Force. I found it necessary that I must be able to find a device that I plug/unplug during the program running.
I come to find that the immediate issue was that "ControllerEnvironment.getDefaultEnvironment().getControllers()" never changed the list of Controllers while the program is running. So why is that?
Well lets start with the the call "ControllerEnvironment.getDefaultEnvironment().getControllers()". This class does not have a protected Constructor. so in order to have access to the constructor you have to be part of the package it is contained in. This is not practical. So I made this public, but only to find that I still could not call construction on it. so I undid that.
The next thing I notice is the getDefaultEnvironment(). Ths actually uses a constructor. Once again, this is protected. So I made it public.
Next, for testing purpose I programmed a button like so in my GUI;
ce = new DefaultControllerEnviornment();
Controller controller = ce.getControllers();
for(int i = 0; i < controller.length; i++)
every time i press this button, it reconstructs the list of controllers and prints them out.
so i removed and added devices while pressing this button. Viola!! it worked, the list was updating the devices.
so for the next part you basically want to created a TimerTask that runs this code every so often to update the list. How often is up to the use of your software and how important an updated list of controllers is.
I have yet to test how this effects the rest of my code polling the controllers, but this is a start, and it is far easier than try to understand and edit the native code.
I hope this helps all of you out, i have spent a couple weeks researching this, and I solved it in a matter of half an hour just mucking through the code.