I have a question relative with that issue (this is all about version 
1.2alpha1 and Linux).

In pyglet/window/__init__py I see event handlers for keyboard, mouse, 
window, but not for joystick. Should I use code like below for handling 
joystick event  instead of defining those handlers in Window object?

import pyglet                
                   
from pyglet.input.evdev_constants import EV_ABS, EV_KEY, ABS_X, ABS_Y, 
BTN_JOYSTICK, BTN_GAMEPAD
                        
                                   
class JoystickInputHandler(pyglet.input.base.Joystick):                   
                          
    def __init__(self, device):                                             
        super(JoystickInputHandler, self).__init__(device)
        self.open()                              
                                                                   
    def on_joybutton_press(self, joystick, button):
        print self, joystick, button
                                          
                     
def _can_be_joystick(device):
    have_x = False
    have_y = False
    have_button = False
    for control in device.controls:
        if control._event_type == EV_ABS and control._event_code == ABS_X:
            have_x = True       
        elif control._event_type == EV_ABS and control._event_code == ABS_Y:
            have_y = True
        elif control._event_type == EV_KEY and \
                control._event_code in (BTN_JOYSTICK, BTN_GAMEPAD):
            have_button = 
True                                                                  
                                        
    if have_x and have_y and have_button 
:                                                      
        return device  
                       
    return None             
                                       
                                                                              

joysticks = []                
for device in 
pyglet.input.evdev.get_devices():                                 
    if _can_be_joystick(device):
        joysticks.append(JoystickInputHandler(device))
                                                                    
pyglet.window.Window()             
pyglet.app.run()

-- 
You received this message because you are subscribed to the Google Groups 
"pyglet-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/pyglet-users.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to