windy54
Posts: 86
Joined: Sat Dec 29, 2012 3:37 pm

cant detect Logitech WIngman joystick in PYGAME

Wed Jan 23, 2013 3:54 pm

Hi,

I have been trying to use my old Logitech Wingman controller to control a maplins robotic arm.

After lots of searches on the web I came across a reference to PYGAME and some example programs .

I have simplified a program Event echoer which I found on the web to just print out joystick events, see code at end of file. ( I tried to attach the file but could not, I have replaced all of my "tab" indents with a space because the format got messed up. hope it is legible!)

jcount, the number of detected joysticks is zero.

If I use lsusb then the controller is listed.

Do I need a PYGAME dirver or is there something wrong with the code?

I have got plenty of programming experience but not with PYTHON or Linux.

I am using the Raspbian Wheezey OS with a powered USB hub.

thanks in advance

Steve


#! /usr/bin/env python
#written by alex@nyrpnz.com
"Event echoer in Pygame"

import pygame.locals

def main():
"opens a window and prints events to the terminal. Closes on ESC or QUIT"
pygame.init()
screen = pygame.display.set_mode((640,480))
pygame.display.set_caption("JOYTEST")
clock = pygame.time.Clock()
joysticks = []
jcount = pygame.joystick.get_count()
print "detected ",jcount," joysticks"
for i in range(0,jcount):
joysticks.append(pygame.joystick.Joystick(i))
joysticks[-1].init()
print "Detected joystick '",joysticks[-1].get_name(),"'"
while 1:
clock.tick(60)
for event in pygame.event.get():
if event.type == pygame.QUIT:
print "Received event 'QUIT', exiting."
sys.exit(0)

elif event.type == pygame.JOYAXISMOTION:
print "Joystick '",joysticks[event.joy].get_name(),"' axis",event.axis,"motion."
elif event.type == pygame.JOYBUTTONDOWN:
print "Joystick '",joysticks[event.joy].get_name(),"' axis",event.button," down."
elif event.type == pygame.JOYBUTTONUP:
print "Joystick '",joysticks[event.joy].get_name(),"' axis",event.button," up."
elif event.type == pygame.JOYHATMOTION:
print "Joystick '",joysticks[event.joy].get_name(),"' axis",event.hat," moved."

if __name__ =="__main__":
main()
main()

Return to “Python”