Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Clearing _DEVICES
#1
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
DIM Fcount AS INTEGER
DIM d AS INTEGER
DIM DeviceName AS STRING

Devices = _DEVICES
Fcount = 0

DO
    CLS
    _LIMIT 30
    Fcount = Fcount + 1
    IF Fcount = 30 THEN '                                        check for new devices once per second
        Fcount = 1
        IF _DEVICES <> Devices THEN Devices = _DEVICES '         if number of devices changes get new count
    END IF
    PRINT
    FOR d = 1 TO Devices '                                       print found devices
        COLOR 14, 1
        DeviceName = _DEVICE$(d)
        IF INSTR(DeviceName, "[DISCONNECTED]") THEN COLOR 7, 0 ' change color if disconnected
        PRINT " Found: "; _DEVICE$(d)
        COLOR 7, 0
    NEXT d
    _DISPLAY
LOOP UNTIL _KEYDOWN(27) '                                        press ESC to exit
New to QB64pe? Visit the QB64 tutorial to get started.
QB64 Tutorial
Reply


Messages In This Thread
Clearing _DEVICES - by TerryRitchie - 05-14-2023, 05:12 AM
RE: Clearing _DEVICES - by madscijr - 05-18-2023, 08:36 PM
RE: Clearing _DEVICES - by TerryRitchie - 05-19-2023, 12:31 AM
RE: Clearing _DEVICES - by Ultraman - 05-19-2023, 11:03 AM
RE: Clearing _DEVICES - by TerryRitchie - 05-19-2023, 02:51 PM
RE: Clearing _DEVICES - by TempodiBasic - 05-24-2023, 07:36 AM
RE: Clearing _DEVICES - by Ultraman - 05-24-2023, 12:01 PM
RE: Clearing _DEVICES - by TempodiBasic - 05-25-2023, 02:47 PM



Users browsing this thread: 3 Guest(s)