diff --git a/ChangeLog b/ChangeLog index 6cf928f2..fe068a12 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,4 @@ +* Added initial support for a graphical UI for configuring gamepads * Moved gfceu options data file into .fceux instead of .fceultra ================= version 2.0.3 ================================= * Updated UI slightly. Moved sound and advanced tabs; made autoscaling diff --git a/gfceux b/gfceux index 26515ab7..9253f8fd 100755 --- a/gfceux +++ b/gfceux @@ -29,6 +29,8 @@ import os import pickle import shutil from optparse import OptionParser +from config_parse import FceuxConfigParser +from get_key import KeyGrabber #from subprocess import Popen try: @@ -210,6 +212,7 @@ def find_binary(file): # # # # # # # # # # # # # # # # # # Globals options = None +configfile = os.getenv('HOME') + '/.fceux/fceux.cfg' optionsfile = os.getenv('HOME') + '/.fceux/gfceux_options.dat' widgets = None @@ -291,6 +294,7 @@ class GfceuxApp: self.print_error("Couldn't load the UI data.", 24) widgets.get_object("main_window").show_all() + def launch(self, rom_name, local=False): global options @@ -546,22 +550,16 @@ class GfceuxApp: # fix this global its ugly gamepad_config = "0" - def gamepad_clicked_new(self, widget, data=None): + def gamepad_clicked(self, widget, data=None): widgets.get_object("gamepad_config_window").show_all() + d = {'gp1_button' : "0", 'gp2_button' : "1", 'gp3_button' : "2", 'gp4_button' : "3"} self.gamepad_config = d[widget.name] - def right_button_clicked(self, widget, data=None): - print "right!" - def left_button_clicked(self, widget, data=None): - print "left!" - def down_button_clicked(self, widget, data=None): - print "down!" - def up_button_clicked(self, widget, data=None): - print "up!" + def button_clicked(self, widget, data=None): d = {'right_button' : "SDL.Input.GamePad." + self.gamepad_config + "Right", 'left_button' : "SDL.Input.GamePad." + self.gamepad_config + "Left", @@ -571,10 +569,14 @@ class GfceuxApp: 'start_button' : "SDL.Input.GamePad." + self.gamepad_config + "Start", 'a_button' : "SDL.Input.GamePad." + self.gamepad_config + "A", 'b_button' : "SDL.Input.GamePad." + self.gamepad_config + "B"} + kg = KeyGrabber() + key = kg.get_key() + cp = FceuxConfigParser(configfile) + cp.writeKey(d[widget.name], key) print d[widget.name] - def gamepad_clicked(self, widget, data=None): + def gamepad_clicked_old(self, widget, data=None): d = {'gp1_button' : '1', 'gp2_button' : '2', @@ -582,6 +584,10 @@ class GfceuxApp: 'gp4_button' : '4'} command = '-inputcfg gamepad' + d[widget.name] + ' /dev/null' self.launch(command, True) + + def gamepad_window_close(self, widget, data=None): + widgets.get_object("gamepad_config_window").hide() + return True def config_help_button_clicked(self, menuitem, data=None): msgbox = gtk.MessageDialog(parent=None, flags=0, diff --git a/gfceux.glade b/gfceux.glade index fd6c5fc0..f97cf66e 100644 --- a/gfceux.glade +++ b/gfceux.glade @@ -1,8 +1,11 @@ - + + + + True @@ -36,17 +39,29 @@ - + True True True - Right + Up + 0 + + + + 1 + 2 + + + + + True + True + True + Left 0 - 2 - 3 1 2 @@ -68,33 +83,21 @@ - + True True True - Left + Right 0 + 2 + 3 1 2 - - - True - True - True - Up - 0 - - - - 1 - 2 - - @@ -446,30 +449,17 @@ 5 5 - + True True - Gamepad _1 + Gamepad _3 True 0 - - - - - - True - True - Gamepad _2 - True - 0 - - - - 1 - 2 + 1 + 2 @@ -491,17 +481,30 @@ - + True True - Gamepad _3 + Gamepad _2 True 0 - + + + + 1 + 2 + + + + + + True + True + Gamepad _1 + True + 0 + - 1 - 2 @@ -995,26 +998,15 @@ Invalid options may cause GFCE UltraX to behave incorrectly. 5 5 - + True - 0 - Port: - - - GTK_FILL - - - - - - True - 0 - Password: + True + 1 + 2 1 2 - GTK_FILL @@ -1032,15 +1024,26 @@ Invalid options may cause GFCE UltraX to behave incorrectly. - + True - True + 0 + Password: - 1 - 2 1 2 + GTK_FILL + + + + + + True + 0 + Port: + + + GTK_FILL @@ -1091,13 +1094,54 @@ Invalid options may cause GFCE UltraX to behave incorrectly. 3 5 - + True True + 4046 1 65536 1 10 10 + 1 1 2 + 1 + 2 + + + + + + True + 0 + Password: + + + 2 + 3 + GTK_FILL + + + + + + True + 0 + Server Port: + + + 1 + 2 + GTK_FILL + + + + + + True + 0 + Server Address: + + + GTK_FILL @@ -1117,54 +1161,13 @@ Invalid options may cause GFCE UltraX to behave incorrectly. - - True - 0 - Server Address: - - - GTK_FILL - - - - - - True - 0 - Server Port: - - - 1 - 2 - GTK_FILL - - - - - - True - 0 - Password: - - - 2 - 3 - GTK_FILL - - - - - + True True - 4046 1 65536 1 10 10 - 1 1 2 - 1 - 2 diff --git a/gfceux.xml b/gfceux.xml index b6be8ccd..c8ff013e 100644 --- a/gfceux.xml +++ b/gfceux.xml @@ -1,5 +1,5 @@ - + 5 @@ -34,6 +34,9 @@ 4046 + + + True @@ -67,16 +70,27 @@ - + True True True - Right + Up + + + + 1 + 2 + + + + + True + True + True + Left - 2 - 3 1 2 @@ -97,31 +111,20 @@ - + True True True - Left + Right + 2 + 3 1 2 - - - True - True - True - Up - - - - 1 - 2 - - @@ -456,28 +459,16 @@ 5 5 - + True True - Gamepad _1 + Gamepad _3 True - - - - - - True - True - Gamepad _2 - True - - - - 1 - 2 + 1 + 2 @@ -498,16 +489,28 @@ - + True True - Gamepad _3 + Gamepad _2 True - + + + + 1 + 2 + + + + + + True + True + Gamepad _1 + True + - 1 - 2 @@ -978,26 +981,15 @@ Invalid options may cause GFCE UltraX to behave incorrectly. 5 5 - + True - 0 - Port: - - - GTK_FILL - - - - - - True - 0 - Password: + True + 1 + 2 1 2 - GTK_FILL @@ -1015,15 +1007,26 @@ Invalid options may cause GFCE UltraX to behave incorrectly. - + True - True + 0 + Password: - 1 - 2 1 2 + GTK_FILL + + + + + + True + 0 + Port: + + + GTK_FILL @@ -1073,13 +1076,54 @@ Invalid options may cause GFCE UltraX to behave incorrectly. 3 5 - + True True + adjustment4 + 1 1 2 + 1 + 2 + + + + + + True + 0 + Password: + + + 2 + 3 + GTK_FILL + + + + + + True + 0 + Server Port: + + + 1 + 2 + GTK_FILL + + + + + + True + 0 + Server Address: + + + GTK_FILL @@ -1099,54 +1143,13 @@ Invalid options may cause GFCE UltraX to behave incorrectly. - - True - 0 - Server Address: - - - GTK_FILL - - - - - - True - 0 - Server Port: - - - 1 - 2 - GTK_FILL - - - - - - True - 0 - Password: - - - 2 - 3 - GTK_FILL - - - - - + True True - adjustment4 - 1 1 2 - 1 - 2