I bought a Logitech Gamepad F310 to remotely control robotics. I am using Pygame (version 1.9.1, Python version 2.7.11+) on Linux Mint (release 18, Sarah).
As a simple test to check the joystick's functionality, I wrote this short script that outputs the values for the different axes:
import pygame
pygame.display.init()
pygame.joystick.init()
pygame.joystick.Joystick(0).init()
# Get the name of the joystick and print it
JoyName = pygame.joystick.Joystick(0).get_name()
print "Name of the joystick:"
print JoyName
# Get the number of axes
JoyAx = pygame.joystick.Joystick(0).get_numaxes()
print "Number of axis:"
print JoyAx
# Print the values for the axes
pygame.event.pump()
print pygame.joystick.Joystick(0).get_axis(0)
print pygame.joystick.Joystick(0).get_axis(1)
print pygame.joystick.Joystick(0).get_axis(2)
print pygame.joystick.Joystick(0).get_axis(3)
Regardless of the position the axes are in when I run the script, I always get the following output:
Name of the joystick:
Logitech Gamepad F310
Number of axis:
6
SDL_JoystickGetAxis value:0:
0.0
SDL_JoystickGetAxis value:0:
0.0
SDL_JoystickGetAxis value:0:
0.0
SDL_JoystickGetAxis value:0:
0.0
I understand that the output "SDL_joystick.Joystick(0).getAxis value" is due to the fact that the developers kept the debug flag when compiling the source code. But I don't understand why the script returns 0 for all axis values while they're not in the 0 position.
I have tested the joystick with the jstest-gtk package. Using this package, it works smoothly. Is there an error in my code?
I ran the code in windows, there it works smoothly. Any idea why it doesn't work under the Linux distro?