Clearing _DEVICES - Printable Version +- QB64 Phoenix Edition (https://staging.qb64phoenix.com) +-- Forum: QB64 Rising (https://staging.qb64phoenix.com/forumdisplay.php?fid=1) +--- Forum: Code and Stuff (https://staging.qb64phoenix.com/forumdisplay.php?fid=3) +---- Forum: Help Me! (https://staging.qb64phoenix.com/forumdisplay.php?fid=10) +---- Thread: Clearing _DEVICES (/showthread.php?tid=1685) |
Clearing _DEVICES - TerryRitchie - 05-14-2023 Is there a way to force controller _DEVICES to be cleared and re-detected? For instance, when _DEVICES is first used in a running program the detected number of controllers will be returned. If one or more of the detected controllers is then disconnected the _DEVICE$ for the disconnected controllers will add "[DISCONNECTED]" to the string returned but still occupy a place in _DEVICES. If a user were to start plugging in random controllers after program startup the _DEVICES value will just keep growing with each new unique controller connected. The program listed below will show this in action. I would like to clear the _DEVICES list when a controller is listed as "[DISCONNECTED]" so _DEVICES can recount the actual number of controllers still plugged in if this is possible while a program is running. Any thoughts? Code: (Select All) DIM Devices AS INTEGER RE: Clearing _DEVICES - madscijr - 05-18-2023 I added this to the top of the loop: Code: (Select All) While _DeviceInput(1): Wend and your code seems to be working (full program below). step 1: no game controller plugged in yet Step 2: after plugging in a game controller Step 3: after unplugging game controller Step 4: after plugging the controller back in I only tried it on one computer so far (old MS Surface Pro 3 w/Windows 10) so if it's still not working for you, maybe try it on a different machine? Code: (Select All) ' Clearing _DEVICES RE: Clearing _DEVICES - TerryRitchie - 05-19-2023 Correct, you're seeing the _DEVICE$ change from having [DISCONNECTED] when the device is unplugged to having that string removed when plugged back in. I was wondering if you could have the device disappear from the list completely when disconnected. The only way to to this now is to end the program and restart. In effect what I would like to do is have _DEVICES clear the list each time it is called and redetect ONLY currently connected controllers while the program is running, refreshing the list. RE: Clearing _DEVICES - Ultraman - 05-19-2023 I hate to say this but you'd probably have to find the C code that runs the _DEVICES keyword and find whatever is used for freeing that in your OS. You may or may not be able to find the actual handle so you can free it but it might be worth checking if you really need this functionality. RE: Clearing _DEVICES - TerryRitchie - 05-19-2023 (05-19-2023, 11:03 AM)Ultraman Wrote: I hate to say this but you'd probably have to find the C code that runs the _DEVICES keyword and find whatever is used for freeing that in your OS. You may or may not be able to find the actual handle so you can free it but it might be worth checking if you really need this functionality. Yeah, I figured this may be the answer as well. I've tried every conceivable way of using the controller statements to see if I could somehow get a fresh list. I've worked around the issue in the latest version the controller library I posted. I'm not nearly comfortable enough with C to go snooping around in the code. This may be something the developers could consider in a future update if it's possible. RE: Clearing _DEVICES - TempodiBasic - 05-24-2023 Hi Terry reading now the new posts about game controller I have found this Quote:// Unique device identifier for application session, starting at 0 for the first device attached and in this path of our QB64pe folder.... Quote:qb64pe 3_7\qb64pe\internal\c\parts\input\game_controller\src\gamepad it may bring the solution... sorry I do not go on now for 2 reasons: my dusted C (I take much time to follow C code because at this time my knowledge is more theorical and less practical, because I often write something in QB64pe) and no time to use now for coding or studing the code already written. See again on this fantastic forum friends. RE: Clearing _DEVICES - Ultraman - 05-24-2023 One thing I had to do on my PC was use the Xinput library in Windows. My controller did not work properly with _DEVICES so I had to interface with Xinput and call all the different functions there. The nice thing about it was that I was able to activate the vibration mode on the controller as well. RE: Clearing _DEVICES - TempodiBasic - 05-25-2023 @Ultraman Yeah I know of its existence but I do not know where is this wonderful library! |