fixed indentation error in gfceux
This commit is contained in:
parent
adefbb3069
commit
d7812c852a
19
get_key.py
19
get_key.py
|
@ -1,4 +1,11 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
# get_key.py - an sdl keygrabber for gfceux
|
||||||
|
# Lukas Sabota
|
||||||
|
# December 2008
|
||||||
|
#
|
||||||
|
# Licensed under the GPL
|
||||||
|
#
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
try:
|
try:
|
||||||
import pygame
|
import pygame
|
||||||
|
@ -13,28 +20,28 @@ class KeyGrabber:
|
||||||
pygame.init()
|
pygame.init()
|
||||||
pygame.joystick.init()
|
pygame.joystick.init()
|
||||||
if pygame.joystick.get_count() > 0:
|
if pygame.joystick.get_count() > 0:
|
||||||
print "Joystick found!"
|
|
||||||
for x in range(0, pygame.joystick.get_count()):
|
for x in range(0, pygame.joystick.get_count()):
|
||||||
joy = pygame.joystick.Joystick(x)
|
joy = pygame.joystick.Joystick(x)
|
||||||
joy.init()
|
joy.init()
|
||||||
print "joy " + str(x) + " initialized."
|
print "joystick " + str(x) + " initialized."
|
||||||
screen = pygame.display.set_mode((width, height))
|
screen = pygame.display.set_mode((width, height))
|
||||||
pygame.display.set_caption("Press any key. . .")
|
pygame.display.set_caption("Press any key. . .")
|
||||||
|
|
||||||
|
|
||||||
def get_key(self):
|
def get_key(self):
|
||||||
|
""" returns a tuple with information about the key pressed
|
||||||
|
(device_string, key_number, joy_number) """
|
||||||
while 1:
|
while 1:
|
||||||
for event in pygame.event.get():
|
for event in pygame.event.get():
|
||||||
if event.type == KEYDOWN:
|
if event.type == KEYDOWN:
|
||||||
pygame.display.quit()
|
pygame.display.quit()
|
||||||
return ("Keyboard", event.key)
|
return ("Keyboard", event.key)
|
||||||
# TODO: Make work with joystick. Do buttons first.
|
|
||||||
if event.type == JOYBUTTONDOWN:
|
if event.type == JOYBUTTONDOWN:
|
||||||
pygame.display.quit()
|
pygame.display.quit()
|
||||||
# TODO: Make sure we're returning the data we need
|
|
||||||
# for config file here. I'm not sure if this is
|
|
||||||
# the correct data.
|
|
||||||
return ("Joystick", event.button, event.joy)
|
return ("Joystick", event.button, event.joy)
|
||||||
|
# TODO: figure out how fceux saves axes and hat movements and implement
|
||||||
|
# this might even be easier if we just make the C++ fceux code more modular
|
||||||
|
# and use a C++ snippet based off code in drivers/sdl/input.cpp and drivers/sdl/sdl-joystick.cpp
|
||||||
#if event.type == JOYAXISMOTION:
|
#if event.type == JOYAXISMOTION:
|
||||||
# pygame.display.quit()
|
# pygame.display.quit()
|
||||||
# return event.joy, event.axis, event.value
|
# return event.joy, event.axis, event.value
|
||||||
|
|
Loading…
Reference in New Issue