inputs icon indicating copy to clipboard operation
inputs copied to clipboard

Max CPU usage on gamepad.read()

Open Benhgift opened this issue 7 years ago • 2 comments

from inputs import devices
gamepad = devices.gamepads[0]
while True:
    print(gamepad.read())

^ with a 360 controller plugged in that uses 100% of 1 core.

Benhgift avatar Apr 04 '17 01:04 Benhgift

And I found the offending line: https://github.com/zeth/inputs/blob/master/inputs.py#L2191

I don't know enough about how device input is handled to fix it beyond here, but I think it shouldn't loop forever and continually check state.

Benhgift avatar Apr 04 '17 02:04 Benhgift

Man I cannot believe this is not higher up. That method was wrecking my CPU usage and all it needed was a single time.sleep(0.01)

SkylerHektner avatar Jul 08 '18 02:07 SkylerHektner