Skip to content

Deleting (unplugging) vController object causes application hanging #13

@ghost

Description

I use Python 3.6 64-bit on 64bit machine.
This project looks really cool, and I was able to use some different inputs to test and it was working. But now I have a problem.
Whenever I run virtual_controller.py the code hangs in this place:
print('Done, disconnecting controllers.')
del cons

def main():
    import time
    cons = []

    print('Testings multiple connections')
    while True:
        print('Connecting Controller:')
        try:
            cons.append(vController())
        except MaxInputsReachedError:
            break
        else:
            print('Available:', vController.available_ids())
            print('This ID:', cons[-1].id)

        # time.sleep(1)

    print('Done, disconnecting controllers.')
    del cons
    print('Available:', vController.available_ids())
    time.sleep(2)

I see the sentence and then I wait a few minutes and nothing happens. When I comment code above and use only this part...

    print('Testing Value setting')
    print('Connecting Controller:')
    try:
        con = vController()
    except MaxInputsReachedError:
        print('Unable to connect controller for testing.')
    else:
        print('This ID:', con.id)
        print('Available:', vController.available_ids())
        print('Setting TriggerR and AxisLx:')
        for x in range(11):
            val = x / 10
            print(val)
            con.set_value('TriggerR', val)
            con.set_value('AxisLx', val)
            time.sleep(0.5)

        print('Done, disconnecting controller.')
        del con
        print('Available:', vController.available_ids())
        time.sleep(2)

... it also hangs after printing: "Done, disconnecting controller."

When I stop process and then run again I have MaxInputsReachedError and I see:
"Unable to connect controller for testing."

So stopping the process is not a good idea because the virtual controller is not plugged off. And it causes that I cannot run the program correctly again. Also uninstalling the controller from device manager doesn't work. It also hangs.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions