Created
July 27, 2020 00:55
-
-
Save Marcin648/efb9c4f9f421e91023590d066214aed4 to your computer and use it in GitHub Desktop.
Simple code check resolution of joystick analog input
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pygame | |
import math | |
pygame.init() | |
pygame.joystick.init() | |
values = set() | |
j = pygame.joystick.Joystick(0) | |
print(j.get_name()) | |
j.init() | |
last_count = 0 | |
while True: | |
pygame.event.get() | |
value = j.get_axis(0) | |
values.add(value) | |
count = len(values) | |
if last_count != count: | |
print("Values: %s Bits: %s" % (count, math.ceil(math.log2(count+1)))) | |
last_count = count | |
pygame.quit() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment