joy select, button map

This commit is contained in:
Frank DeMarco 2013-04-26 23:54:21 +09:00
parent 02c5a5a6b7
commit 157e6fde4d
3 changed files with 11 additions and 11 deletions

4
README
View File

@ -2,7 +2,7 @@
Pygame Framework
----------------
Classes that facilitate the creation of Pygame projects
Classes to facilitate creation of Pygame projects
Example
@ -54,4 +54,4 @@ Contact
=======
frank dot s dot demarco at gmail
http://usethematrixze.us
http://a-o.in

View File

@ -105,6 +105,7 @@ class Configuration(RawConfigParser):
add_section(section)
set_option(section, "advance", "7")
set_option(section, "pause", "7")
set_option(section, "select", "6")
section = "event"
add_section(section)
set_option(section, "user-event-id", "USEREVENT")
@ -281,7 +282,7 @@ class TypeDeclarations(dict):
"keys": {"list": ["up", "right", "down", "left"]},
"joy": {"int": ["advance", "pause"]},
"joy": {"int": ["advance", "pause", "select"]},
"audio": {"path": "sfx-path"},

View File

@ -17,13 +17,11 @@ class Input(GameChild):
self.unsuppress()
self.subscribe_to_events()
self.build_key_map()
self.build_joy_button_map()
def load_configuration(self):
self.release_suffix = self.get_configuration("input", "release-suffix")
self.key_commands = self.get_configuration().items("keys")
joy = self.get_configuration("joy")
self.joy_advance_button_id = joy["advance"]
self.joy_pause_button_id = joy["pause"]
self.double_click_time_limit = self.get_configuration(
"mouse", "double-click-time-limit")
@ -51,6 +49,9 @@ class Input(GameChild):
key_map[command].append(globals()[key])
self.key_map = key_map
def build_joy_button_map(self):
self.joy_button_map = self.get_configuration("joy")
def translate_key_press(self, event):
if not self.suppressed:
key = event.key
@ -70,11 +71,9 @@ class Input(GameChild):
def translate_joy_press(self, event):
if not self.suppressed:
button = event.button
if button == self.joy_advance_button_id:
self.post_command("advance")
if button == self.joy_pause_button_id:
self.post_command("pause")
for command, button in self.joy_button_map.iteritems():
if button == event.button:
self.post_command(command)
def translate_axis_motion(self, event):
if not self.suppressed: