shut up some glade warnings and also made pygame optional, but recommended. Pygame is required for the GUI of the gamepads. if pygame is not found, the old --inputcfg method is used.

This commit is contained in:
punkrockguy318 2008-12-05 08:18:29 +00:00
parent 1fdb739619
commit 78a310ba09
6 changed files with 68 additions and 49 deletions

View File

@ -1,3 +1,5 @@
* Cleaned up glade file to silence warnings
* Pygame is no longer required for gfceux to run, just for the input GUI
* Turbo A and Turbo B support for gamepad GUI
* Added initial support for a graphical UI for configuring gamepads
* Moved gfceu options data file into .fceux instead of .fceultra

17
INSTALL
View File

@ -2,12 +2,21 @@ You can install gfceux with setup.py:
$ sudo python setup.py install --prefix=/usr/local
TODO: 12/5/2008 - Work out build system with new modules.
You can change the prefix to whatever you like.
Requirements:
Python (tested with 2.5); (Ubuntu package name: python)
PyGTK, and GTK; (Ubuntu package name: (python-gtk2 libgtk2.0-0)
FceuX 2.0
Python (tested with 2.5); (Ubuntu package name: python)
NOTE: gfceux is not yet compatible with python 3.x
PyGTK and GTK; (Ubuntu package name: (python-gtk2 libgtk2.0-0)
Fceux 2.x
Recommended dependencies
Pygame (Ubuntu package name: python-pygame) - This will allow graphical conifguraion of input
NOTE: fceu 1.x is no longer supported in the gfceu 2.x series.
If you still want/need a front-end for gfceu use gfceu 0.x
NOTE: fceu 1.x is no longer supported in the gfceu 2.x series. if you still want/need a front-end for gfceu use gfceu .7

View File

@ -1,25 +1,27 @@
#!/usr/bin/env python
import pygame
#!/usr/bin/env python
import sys
from pygame.locals import *
try:
import pygame
from pygame.locals import *
has_pygame = True
except ImportError:
self.has_pygame = False
class KeyGrabber:
""" KeyGrabber is a wrapper that gets an SDL key from the user using pygame """
def __init__(self, width=300, height=100):
pygame.init()
screen = pygame.display.set_mode((width, height))
pygame.display.set_caption("Press any key. . .")
""" KeyGrabber is a wrapper that gets an SDL key from the user using pygame """
def __init__(self, width=300, height=100):
pygame.init()
screen = pygame.display.set_mode((width, height))
pygame.display.set_caption("Press any key. . .")
def get_key(self):
while 1:
for event in pygame.event.get():
if event.type == KEYDOWN:
#print event.key
pygame.display.quit()
return event.key
def get_key(self):
while 1:
for event in pygame.event.get():
if event.type == KEYDOWN:
pygame.display.quit()
return event.key
if __name__ == "__main__":
kg = KeyGrabber()
print kg.get_key()
kg = KeyGrabber()
print kg.get_key()

36
gfceux
View File

@ -30,7 +30,7 @@ import pickle
import shutil
from optparse import OptionParser
from config_parse import FceuxConfigParser
from get_key import KeyGrabber
import get_key
#from subprocess import Popen
try:
@ -551,20 +551,21 @@ class GfceuxApp:
options.romfile = x
# fix this global its ugly
gamepad_config = "0"
# specifies which NES gamepad we are configuring
gamepad_config_no = "0"
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]
d = {'gp1_button' : "1",
'gp2_button' : "2",
'gp3_button' : "3",
'gp4_button' : "4"}
self.gamepad_config_no = d[widget.name]
def button_clicked(self, widget, data=None):
prefix = "SDL.Input.GamePad" + self.gamepad_config
prefix = "SDL.Input.GamePad" + self.gamepad_config_no
d = {'right_button' : prefix + "Right",
'left_button' : prefix + "Left",
'up_button' : prefix + "Up",
@ -575,17 +576,18 @@ class GfceuxApp:
'b_button' : prefix + "B",
'turbo_a_button' : prefix + "TurboA",
'turbo_b_button' : prefix + "TurboB"}
kg = KeyGrabber()
key = kg.get_key()
cp = FceuxConfigParser(configfile)
cp.writeKey(d[widget.name], key)
if get_key.has_pygame == False:
self.msg("Pygame could not be found on this system. Gfceux will revert to the old configuration routine.", True)
self.gamepad_clicked_old(widget)
else:
kg = get_key.KeyGrabber()
key = kg.get_key()
cp = FceuxConfigParser(configfile)
cp.writeKey(d[widget.name], key)
def gamepad_clicked_old(self, widget, data=None):
d = {'gp1_button' : '1',
'gp2_button' : '2',
'gp3_button' : '3',
'gp4_button' : '4'}
command = '-inputcfg gamepad' + d[widget.name] + ' /dev/null'
command = '--inputcfg gamepad' + self.gamepad_config_no
self.launch(command, True)
def gamepad_window_close(self, widget, data=None):

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE glade-interface SYSTEM "glade-2.0.dtd">
<!--Generated with glade3 3.4.5 on Fri Dec 5 02:36:02 2008 -->
<!--Generated with glade3 3.4.5 on Fri Dec 5 03:16:36 2008 -->
<glade-interface>
<widget class="GtkWindow" id="gamepad_config_window">
<signal name="destroy" handler="gamepad_window_close"/>
@ -676,7 +676,8 @@
<widget class="GtkSpinButton" id="xscale_spin">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="adjustment">2 1 5 0.5 1 10</property>
<property name="adjustment">2 1 5 0.5 1 0</property>
<property name="climb_rate">0.099999999776482579</property>
<property name="digits">1</property>
<property name="numeric">True</property>
</widget>
@ -707,7 +708,8 @@
<widget class="GtkSpinButton" id="yscale_spin">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="adjustment">2 1 10 0.5 1 10</property>
<property name="adjustment">2 1 10 0.5 1 0</property>
<property name="climb_rate">0.10000000000000001</property>
<property name="digits">1</property>
<property name="numeric">True</property>
<property name="update_policy">GTK_UPDATE_IF_VALID</property>
@ -1050,7 +1052,7 @@ Invalid options may cause GFCE UltraX to behave incorrectly.
<widget class="GtkSpinButton" id="host_port">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="adjustment">4046 1 65536 1 10 10</property>
<property name="adjustment">4046 1 65536 1 10 0</property>
<property name="climb_rate">1</property>
</widget>
<packing>
@ -1133,7 +1135,7 @@ Invalid options may cause GFCE UltraX to behave incorrectly.
<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="adjustment">4046 1 65536 1 10 0</property>
<property name="climb_rate">1</property>
</widget>
<packing>

View File

@ -1,12 +1,12 @@
<?xml version="1.0"?>
<!--Generated with glade3 3.4.5 on Fri Dec 5 02:36:02 2008 -->
<!--Generated with glade3 3.4.5 on Fri Dec 5 03:16:36 2008 -->
<interface>
<object class="GtkAdjustment" id="adjustment1">
<property name="upper">5</property>
<property name="lower">1</property>
<property name="page_increment">1</property>
<property name="step_increment">0.5</property>
<property name="page_size">10</property>
<property name="page_size">0</property>
<property name="value">2</property>
</object>
<object class="GtkAdjustment" id="adjustment2">
@ -14,7 +14,7 @@
<property name="lower">1</property>
<property name="page_increment">1</property>
<property name="step_increment">0.5</property>
<property name="page_size">10</property>
<property name="page_size">0</property>
<property name="value">2</property>
</object>
<object class="GtkAdjustment" id="adjustment3">
@ -22,7 +22,7 @@
<property name="lower">1</property>
<property name="page_increment">10</property>
<property name="step_increment">1</property>
<property name="page_size">10</property>
<property name="page_size">0</property>
<property name="value">4046</property>
</object>
<object class="GtkAdjustment" id="adjustment4">
@ -30,7 +30,7 @@
<property name="lower">1</property>
<property name="page_increment">10</property>
<property name="step_increment">1</property>
<property name="page_size">10</property>
<property name="page_size">0</property>
<property name="value">4046</property>
</object>
<object class="GtkWindow" id="gamepad_config_window">
@ -673,6 +673,7 @@
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="adjustment">adjustment1</property>
<property name="climb_rate">0.099999999776482579</property>
<property name="digits">1</property>
<property name="numeric">True</property>
</object>
@ -704,6 +705,7 @@
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="adjustment">adjustment2</property>
<property name="climb_rate">0.10000000000000001</property>
<property name="digits">1</property>
<property name="numeric">True</property>
<property name="update_policy">GTK_UPDATE_IF_VALID</property>