473,379 Members | 1,423 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,379 software developers and data experts.

pyGame - Logitech rumble pad input OS X (10.3.9)

kjm
Hi everyone,

I have recently acquired a Logitech Rumble pad to use as an input
device. I have been having trouble getting the event que to respond
that a button or hat arrow has been pressed. This is on a system
running OS 10.3.9.

I have modified/written a small piece of code that initializes the
joystick, and pygame does recognize it. I was wondering if someone has
a small snippet of code to get me going? I have posted the code I'm
using to initialize the joystick, plus it's output below.

Versions are:

Version checklist:

Python version 2.3 (OK)
extra Python info: (#1, Sep 13 2003, 00:49:11) [GCC 3.3 20030304 (Apple
Computer, Inc. build 1495)]
Numeric version 24.0b1 (OK)
PyOpenGL (package "OpenGL") version 2.0.2.01 (OK)
pygame version 1.7.0 (OK)
Python Imaging Library (package "Image") version 1.1.5 (OK)

any help is appreciated.

Cheers,
kjm

[begin code]
-------------------------------------------------
import pygame
import pygame.display
import pygame.joystick
from pygame.locals import *

pygame.display.init()

pygame.joystick.init() #initialize joystick module
pygame.joystick.get_init() #verify initialization (boolean)

joystick_count = pygame.joystick.get_count()#get number of joysticks
print('%d joystick(s) connected' %joystick_count)#print number

joystick_object = pygame.joystick.Joystick(0)
#create an instance of a joystick
#first joystick is [0] in the list
#haven't had much luck with multiple joysticks

joystick_object.get_name()
print joystick_object.get_name()
#grab joystick name - flightstick, gravis...
#can (and is in this case) be done before initialization

joystick_object.init()

joystick_object.get_init()
#verify initialization (maybe cool to do some
#error trapping with this so game doesn't crash

num_axes = joystick_object.get_numaxes()
num_buttons = joystick_object.get_numbuttons()

print 'Joystick has %d axes and %d buttons' %(num_axes,num_buttons)

pygame.event.pump()
#necessary for os to pass joystick events

xaxis = joystick_object.get_axis(0)
yaxis = joystick_object.get_axis(1)
wheel = joystick_object.get_axis(2)
trigger = joystick_object.get_button(0)
top = joystick_object.get_button(1)
#from above, you have number of axes and buttons
#could assign more if your joystick has more

print '%f %f %f %d %d' %(xaxis, yaxis, wheel, trigger, top)
#print values to console for debugging
#analog channels (axes) range -1 to 1
#digital channels (buttons) are 1 or 0


joystick_object.quit()
#destroy objects and clean up
pygame.joystick.quit()

[/code]
------------------------------------------------------------------
[begin output]

[XXXXXXX@viridian 16:10:26]$ python testjoy.py
1 joystick(s) connected
Logitech Cordless RumblePad 2
Joystick has 4 axes and 12 buttons
-1.000000 -1.000000 -1.000000 0 0
[XXXXX@viridian 16:10:32]$

[/output]

Aug 30 '05 #1
1 3204
On Tuesday 30 August 2005 03:17 pm, kjm wrote:
I have modified/written a small piece of code that initializes the
joystick, and pygame does recognize it. I was wondering if someone has
a small snippet of code to get me going? I have posted the code I'm
using to initialize the joystick, plus it's output below.
First of all, you'd be much better off asking this question on
the pygame mailing list ( py**********@seul.org ).

But ...
pygame.event.pump()
#necessary for os to pass joystick events


You understand, you have to call pygame.event.pump()
ONCE PER EVENT LOOP?

The code you posted doesn't do that. "pump" doesn't
start a separate thread or anything, it just polls the
event queue and runs some pygame code to update state.

You must repeatedly call it to check for events.

Pygame tries to be very straightforward and explicit.
There isn't much hidden "magic" going on (although
movie and sound objects *do* process things in background
threads).

Cheers,
Terry

--
Terry Hancock ( hancock at anansispaceworks.com )
Anansi Spaceworks http://www.anansispaceworks.com

Aug 30 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
by: Marian Aldenhövel | last post by:
Hi, I am trying to make pygame play music on windows. This simple program: import pygame,time pygame.init() print "Mixer settings", pygame.mixer.get_init() print "Mixer channels",...
3
by: Tim Knauf | last post by:
Hi everyone, I'm glad to have found this list. I've written a small script for my own use which, amongst other things, captures mouse click information from a window containing an image. I used...
2
by: Brent W. Hughes | last post by:
I'm just starting to learn pygame. I write what I think is just about the simplest program that should display a window and then quit. #----------------------------------------------- import sys...
5
by: Gregory Piñero | last post by:
Hi guys, I was just idley curious on what it would take to make a web plug-in for Pygame. I'm picturing it working the way my browser currently shows flash games. Is such an idea even...
1
by: liuliuliu | last post by:
hi -- sorry if this is trivial -- but how do you make a screenshot of a pygame display? i have a surface which is basically the entire visible screen -- how do you write this surface as an image...
4
by: jedi200581 | last post by:
Hi, I'm trying to retreive mouse event in a python thread using pygame. It's not working and I don't know why! Here is the code: <snippet on> import pygame, sys, os, threading from...
11
by: dynamo | last post by:
Hi guys i have come again with more problems.This time it has to do with pygame.The following code does not give any error messages but it does not do what it is supposed to do either.the code is a...
3
by: globalrev | last post by:
im doing this : http://www.learningpython.com/2006/03/12/creating-a-game-in-python-using-pygame-part-one/ and when closing the program the window stays up and doesnt respond. i tried adding...
11
by: globalrev | last post by:
http://www.pygame.org/docs/ref/mixer.html import pygame #pygame.mixer.init(frequency=22050, size=-16, channels=2, buffer=3072) //it complained abiout words= so i guess its only the nbrs...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.