Page 1 of 1

How to determine the maximum number of a joystick?

Posted: Tue Jul 21, 2020 10:58 am
by John Smith
Hello. There are several joysticks in the system. It is necessary to poll their status in a loop. To do this, we need to know the maximum number of the joystick. How to define it?

Re: How to determine the maximum number of a joystick?

Posted: Fri Jul 24, 2020 6:20 am
by John Smith
I answer my own question. This is the script I use at this time. I can't think of a better option yet. Useless forum.

Code: Select all

if starting:
    joyMax = 100

    for i in range(joyMax):
        try:
             joystick[i].setRange(-1000, 1000)
        except ValueError:
            joyMax = i - 1
            break


diagnostics.watch(joyMax)