Gamepad question

I’m randomly looking through the code base and I have a question about Gamepad. From what I can see, the main loop for the program is run() in Winodow.

On line 357 in run() gamepad::step(); is called. I’m familiar with OO (Java), though not with C++. Is this a static call? It doesn’t seem like it should be, but I don’t seen where an instance of gamepad would have been created so I’m assuming at this point it is…

step() polls the state of any connected controller and generates MIDI events for any changes in state. Does this mean that the controller is being polled when connected even if it’s not being used as a Driver for any of the Core MIDI modules? I doubt it’s a taking up many CPU cycles, but it seems like it shouldn’t be?

It looks like if the device id isn’t set for Gamepad then nothing is polled? At least that’s my current theory. Not quite sure how it’s set, but I’m imaging that’s how it works…

Most, if not all higher languages use the same reserved Keywords. It is a void call void step() (non-value return) if it was static it would be static void step() {...} just like Java.

Window calls the method in gamepad called step()… Was the question?..

in gamepad::step()

if (!driver)  
    return;

If the static object of driver is neither true or false return. Static being a pointer across any instance of the program. In other words if the driver is not initialised break from the statement.

1 Like

Thanks, I see my problem. I was looking at struct InputDevice : midi::InputDevice's step() and not the top level step() of gamepad :man_facepalming:. I’m such an idiot. Thanks for the clarification.