initiual GUI for gamepad config (currently only works with keyboards, joystick support to come)

This commit is contained in:
punkrockguy318 2008-12-02 20:40:23 +00:00
parent ab899d720e
commit b0d4eb7035
4 changed files with 231 additions and 218 deletions

View File

@ -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

26
gfceux
View File

@ -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,

View File

@ -1,8 +1,11 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE glade-interface SYSTEM "glade-2.0.dtd">
<!--Generated with glade3 3.4.5 on Mon Sep 22 04:14:45 2008 -->
<!--Generated with glade3 3.4.5 on Tue Dec 2 15:32:04 2008 -->
<glade-interface>
<widget class="GtkWindow" id="gamepad_config_window">
<signal name="destroy" handler="gamepad_window_close"/>
<signal name="delete_event" handler="gamepad_window_close"/>
<signal name="destroy_event" handler="gamepad_window_close"/>
<child>
<widget class="GtkHBox" id="hbox3">
<property name="visible">True</property>
@ -36,17 +39,29 @@
<placeholder/>
</child>
<child>
<widget class="GtkButton" id="right_button">
<widget class="GtkButton" id="up_button">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="label" translatable="yes">Right</property>
<property name="label" translatable="yes">Up</property>
<property name="response_id">0</property>
<signal name="clicked" handler="button_clicked"/>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
</packing>
</child>
<child>
<widget class="GtkButton" id="left_button">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="label" translatable="yes">Left</property>
<property name="response_id">0</property>
<signal name="clicked" handler="button_clicked"/>
</widget>
<packing>
<property name="left_attach">2</property>
<property name="right_attach">3</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
</packing>
@ -68,33 +83,21 @@
</packing>
</child>
<child>
<widget class="GtkButton" id="left_button">
<widget class="GtkButton" id="right_button">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="label" translatable="yes">Left</property>
<property name="label" translatable="yes">Right</property>
<property name="response_id">0</property>
<signal name="clicked" handler="button_clicked"/>
</widget>
<packing>
<property name="left_attach">2</property>
<property name="right_attach">3</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
</packing>
</child>
<child>
<widget class="GtkButton" id="up_button">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="label" translatable="yes">Up</property>
<property name="response_id">0</property>
<signal name="clicked" handler="button_clicked"/>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
</packing>
</child>
</widget>
</child>
</widget>
@ -446,30 +449,17 @@
<property name="column_spacing">5</property>
<property name="row_spacing">5</property>
<child>
<widget class="GtkButton" id="gp1_button">
<widget class="GtkButton" id="gp3_button">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">Gamepad _1</property>
<property name="label" translatable="yes">Gamepad _3</property>
<property name="use_underline">True</property>
<property name="response_id">0</property>
<signal name="clicked" handler="gamepad_clicked" after="yes"/>
</widget>
<packing>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkButton" id="gp2_button">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">Gamepad _2</property>
<property name="use_underline">True</property>
<property name="response_id">0</property>
<signal name="clicked" handler="gamepad_clicked" after="yes"/>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="y_options"></property>
</packing>
</child>
@ -491,17 +481,30 @@
</packing>
</child>
<child>
<widget class="GtkButton" id="gp3_button">
<widget class="GtkButton" id="gp2_button">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">Gamepad _3</property>
<property name="label" translatable="yes">Gamepad _2</property>
<property name="use_underline">True</property>
<property name="response_id">0</property>
<signal name="clicked" handler="gamepad_clicked_new" after="yes"/>
<signal name="clicked" handler="gamepad_clicked" after="yes"/>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkButton" id="gp1_button">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">Gamepad _1</property>
<property name="use_underline">True</property>
<property name="response_id">0</property>
<signal name="clicked" handler="gamepad_clicked" after="yes"/>
</widget>
<packing>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="y_options"></property>
</packing>
</child>
@ -995,26 +998,15 @@ Invalid options may cause GFCE UltraX to behave incorrectly.
<property name="column_spacing">5</property>
<property name="row_spacing">5</property>
<child>
<widget class="GtkLabel" id="label19">
<widget class="GtkEntry" id="host_pass">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Port:</property>
</widget>
<packing>
<property name="x_options">GTK_FILL</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label20">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Password:</property>
<property name="can_focus">True</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options"></property>
</packing>
</child>
@ -1032,15 +1024,26 @@ Invalid options may cause GFCE UltraX to behave incorrectly.
</packing>
</child>
<child>
<widget class="GtkEntry" id="host_pass">
<widget class="GtkLabel" id="label20">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Password:</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label19">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Port:</property>
</widget>
<packing>
<property name="x_options">GTK_FILL</property>
<property name="y_options"></property>
</packing>
</child>
@ -1091,13 +1094,54 @@ Invalid options may cause GFCE UltraX to behave incorrectly.
<property name="column_spacing">3</property>
<property name="row_spacing">5</property>
<child>
<widget class="GtkEntry" id="join_add">
<widget class="GtkSpinButton" id="join_port">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="adjustment">4046 1 65536 1 10 10</property>
<property name="climb_rate">1</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label17">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Password:</property>
</widget>
<packing>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label16">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Server Port:</property>
</widget>
<packing>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label15">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Server Address:</property>
</widget>
<packing>
<property name="x_options">GTK_FILL</property>
<property name="y_options"></property>
</packing>
</child>
@ -1117,54 +1161,13 @@ Invalid options may cause GFCE UltraX to behave incorrectly.
</packing>
</child>
<child>
<widget class="GtkLabel" id="label15">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Server Address:</property>
</widget>
<packing>
<property name="x_options">GTK_FILL</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label16">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Server Port:</property>
</widget>
<packing>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label17">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Password:</property>
</widget>
<packing>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkSpinButton" id="join_port">
<widget class="GtkEntry" id="join_add">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="adjustment">4046 1 65536 1 10 10</property>
<property name="climb_rate">1</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="y_options"></property>
</packing>
</child>

View File

@ -1,5 +1,5 @@
<?xml version="1.0"?>
<!--Generated with glade3 3.4.5 on Mon Sep 22 04:14:45 2008 -->
<!--Generated with glade3 3.4.5 on Tue Dec 2 15:32:04 2008 -->
<interface>
<object class="GtkAdjustment" id="adjustment1">
<property name="upper">5</property>
@ -34,6 +34,9 @@
<property name="value">4046</property>
</object>
<object class="GtkWindow" id="gamepad_config_window">
<signal handler="gamepad_window_close" name="destroy"/>
<signal handler="gamepad_window_close" name="delete_event"/>
<signal handler="gamepad_window_close" name="destroy_event"/>
<child>
<object class="GtkHBox" id="hbox3">
<property name="visible">True</property>
@ -67,16 +70,27 @@
<placeholder/>
</child>
<child>
<object class="GtkButton" id="right_button">
<object class="GtkButton" id="up_button">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="label" translatable="yes">Right</property>
<property name="label" translatable="yes">Up</property>
<signal handler="button_clicked" name="clicked"/>
</object>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
</packing>
</child>
<child>
<object class="GtkButton" id="left_button">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="label" translatable="yes">Left</property>
<signal handler="button_clicked" name="clicked"/>
</object>
<packing>
<property name="left_attach">2</property>
<property name="right_attach">3</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
</packing>
@ -97,31 +111,20 @@
</packing>
</child>
<child>
<object class="GtkButton" id="left_button">
<object class="GtkButton" id="right_button">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="label" translatable="yes">Left</property>
<property name="label" translatable="yes">Right</property>
<signal handler="button_clicked" name="clicked"/>
</object>
<packing>
<property name="left_attach">2</property>
<property name="right_attach">3</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
</packing>
</child>
<child>
<object class="GtkButton" id="up_button">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="label" translatable="yes">Up</property>
<signal handler="button_clicked" name="clicked"/>
</object>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
</packing>
</child>
</object>
</child>
</object>
@ -456,28 +459,16 @@
<property name="column_spacing">5</property>
<property name="row_spacing">5</property>
<child>
<object class="GtkButton" id="gp1_button">
<object class="GtkButton" id="gp3_button">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">Gamepad _1</property>
<property name="label" translatable="yes">Gamepad _3</property>
<property name="use_underline">True</property>
<signal after="yes" handler="gamepad_clicked" name="clicked"/>
</object>
<packing>
<property name="y_options"/>
</packing>
</child>
<child>
<object class="GtkButton" id="gp2_button">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">Gamepad _2</property>
<property name="use_underline">True</property>
<signal after="yes" handler="gamepad_clicked" name="clicked"/>
</object>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="y_options"/>
</packing>
</child>
@ -498,16 +489,28 @@
</packing>
</child>
<child>
<object class="GtkButton" id="gp3_button">
<object class="GtkButton" id="gp2_button">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">Gamepad _3</property>
<property name="label" translatable="yes">Gamepad _2</property>
<property name="use_underline">True</property>
<signal after="yes" handler="gamepad_clicked_new" name="clicked"/>
<signal after="yes" handler="gamepad_clicked" name="clicked"/>
</object>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="y_options"/>
</packing>
</child>
<child>
<object class="GtkButton" id="gp1_button">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">Gamepad _1</property>
<property name="use_underline">True</property>
<signal after="yes" handler="gamepad_clicked" name="clicked"/>
</object>
<packing>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="y_options"/>
</packing>
</child>
@ -978,26 +981,15 @@ Invalid options may cause GFCE UltraX to behave incorrectly.
<property name="column_spacing">5</property>
<property name="row_spacing">5</property>
<child>
<object class="GtkLabel" id="label19">
<object class="GtkEntry" id="host_pass">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Port:</property>
</object>
<packing>
<property name="x_options">GTK_FILL</property>
<property name="y_options"/>
</packing>
</child>
<child>
<object class="GtkLabel" id="label20">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Password:</property>
<property name="can_focus">True</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options"/>
</packing>
</child>
@ -1015,15 +1007,26 @@ Invalid options may cause GFCE UltraX to behave incorrectly.
</packing>
</child>
<child>
<object class="GtkEntry" id="host_pass">
<object class="GtkLabel" id="label20">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Password:</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options"/>
</packing>
</child>
<child>
<object class="GtkLabel" id="label19">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Port:</property>
</object>
<packing>
<property name="x_options">GTK_FILL</property>
<property name="y_options"/>
</packing>
</child>
@ -1073,13 +1076,54 @@ Invalid options may cause GFCE UltraX to behave incorrectly.
<property name="column_spacing">3</property>
<property name="row_spacing">5</property>
<child>
<object class="GtkEntry" id="join_add">
<object class="GtkSpinButton" id="join_port">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="adjustment">adjustment4</property>
<property name="climb_rate">1</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="y_options"/>
</packing>
</child>
<child>
<object class="GtkLabel" id="label17">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Password:</property>
</object>
<packing>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options"/>
</packing>
</child>
<child>
<object class="GtkLabel" id="label16">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Server Port:</property>
</object>
<packing>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options"/>
</packing>
</child>
<child>
<object class="GtkLabel" id="label15">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Server Address:</property>
</object>
<packing>
<property name="x_options">GTK_FILL</property>
<property name="y_options"/>
</packing>
</child>
@ -1099,54 +1143,13 @@ Invalid options may cause GFCE UltraX to behave incorrectly.
</packing>
</child>
<child>
<object class="GtkLabel" id="label15">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Server Address:</property>
</object>
<packing>
<property name="x_options">GTK_FILL</property>
<property name="y_options"/>
</packing>
</child>
<child>
<object class="GtkLabel" id="label16">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Server Port:</property>
</object>
<packing>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options"/>
</packing>
</child>
<child>
<object class="GtkLabel" id="label17">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Password:</property>
</object>
<packing>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options"/>
</packing>
</child>
<child>
<object class="GtkSpinButton" id="join_port">
<object class="GtkEntry" id="join_add">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="adjustment">adjustment4</property>
<property name="climb_rate">1</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="y_options"/>
</packing>
</child>