Jump to content

View more

Image of the Day

The night is still, but the invasion brings chaos. #screenshotsaturday #hanako #indiegame #gameart #ue4 #samurai https://t.co/cgILXuokoS
IOTD | Top Screenshots

The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.


Sign up now

pygame: is there a way to get input from xbox controller?

4: Adsense

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.


  • You cannot reply to this topic
3 replies to this topic

#1 nickme   Members   

253
Like
0Likes
Like

Posted 24 February 2013 - 05:34 AM

thanks



#2 Toothpix   Members   

810
Like
0Likes
Like

Posted 24 February 2013 - 08:02 AM

Yes. Write a python module in C using DirectInput, and use that module in your python program. I don't think there is another way, unless somebody already has done that and is offering their library up for free.


C dominates the world of linear procedural computing, which won't advance. The future lies in MASSIVE parallelism.


#3 nickme   Members   

253
Like
0Likes
Like

Posted 24 February 2013 - 02:53 PM

hi

 

i found a small script on the net:

 

 

 

#!/usr/bin/env python

# Written by alex@nyrpnz.com March 14 2012
"Event echoer in Pygame."
 
import pygame
from pygame.locals import *
 
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 = []
        for i in range(0, pygame.joystick.get_count()):
                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 == QUIT:
                                print "Received event 'Quit', exiting."
                                return
                        elif event.type == KEYDOWN and event.key == K_ESCAPE:
                                print "Escape key pressed, exiting."
                                return
                        elif event.type == KEYDOWN:
                                print "Keydown,",event.key
                        elif event.type == KEYUP:
                                print "Keyup,",event.key
                        elif event.type == MOUSEMOTION:
                                print "Mouse movement detected."
                        elif event.type == MOUSEBUTTONDOWN:
                                print "Mouse button",event.button,"down at",pygame.mouse.get_pos()
                        elif event.type == MOUSEBUTTONUP:
                                print "Mouse button",event.button,"up at",pygame.mouse.get_pos()
                        elif event.type == JOYAXISMOTION:
                                print "Joystick '",joysticks[event.joy].get_name(),"' axis",event.axis,"motion."
                                if event.axis == 4:
                                        print ' axis 4', event.value
                                elif event.axis == 3:
                                        print ' axis 3', event.value
                        elif event.type == JOYBUTTONDOWN:
                                print ("Joystick '",joysticks[event.joy].get_name(),
                                    "' button",event.button,"down.")
                        elif event.type == JOYBUTTONUP:
                                print "Joystick '",joysticks[event.joy].get_name(),"' button",event.button,"up."
                        elif event.type == JOYHATMOTION:
                                print "Joystick '",joysticks[event.joy].get_name(),"' hat",event.hat," moved."
 
if __name__ == "__main__":
        main()

Edited by nickme, 24 February 2013 - 02:54 PM.


#4 nobodynews   Members   

3094
Like
0Likes
Like

Posted 24 February 2013 - 03:21 PM

You'd probably want to use XInput http://msdn.microsoft.com/en-us/library/windows/desktop/hh405053%28v=vs.85%29.aspx


C++: A Dialog | C++0x Features: Part1 (lambdas, auto, static_assert) , Part 2 (rvalue references) , Part 3 (decltype) | Write Games | Fix Your Timestep!





Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.