- Autofire is now configurable using the Joypad config dialog.
- This allowed simplifying the Joypad menu to a single item.
This commit is contained in:
bgk 2008-09-20 13:11:13 +00:00
parent be21f833ec
commit 6bac5170fc
5 changed files with 40 additions and 142 deletions

View File

@ -38,7 +38,9 @@ const JoypadConfigDialog::SJoypadKey JoypadConfigDialog::m_astKeys[] =
{ KEY_BUTTON_SELECT, "Select :" }, { KEY_BUTTON_SELECT, "Select :" },
{ KEY_BUTTON_START, "Start :" }, { KEY_BUTTON_START, "Start :" },
{ KEY_BUTTON_SPEED, "Speed :" }, { KEY_BUTTON_SPEED, "Speed :" },
{ KEY_BUTTON_CAPTURE, "Capture :" } { KEY_BUTTON_CAPTURE, "Capture :" },
{ KEY_BUTTON_AUTO_A, "Autofire A :" },
{ KEY_BUTTON_AUTO_B, "Autofire B :" }
}; };
JoypadConfigDialog::JoypadConfigDialog() : JoypadConfigDialog::JoypadConfigDialog() :
@ -93,6 +95,7 @@ JoypadConfigDialog::JoypadConfigDialog() :
&JoypadConfigDialog::vOnDefaultJoypadSelect) ); &JoypadConfigDialog::vOnDefaultJoypadSelect) );
m_oTitleCombo.signal_changed().connect(sigc::mem_fun(*this, m_oTitleCombo.signal_changed().connect(sigc::mem_fun(*this,
&JoypadConfigDialog::vOnJoypadSelect) ); &JoypadConfigDialog::vOnJoypadSelect) );
m_oTitleCombo.set_active_text("1"); m_oTitleCombo.set_active_text("1");
show_all_children(); show_all_children();
@ -222,10 +225,10 @@ bool JoypadConfigDialog::bOnConfigIdle()
{ {
case SDL_JOYAXISMOTION: case SDL_JOYAXISMOTION:
if (abs(event.jaxis.value) < 16384) continue; if (abs(event.jaxis.value) < 16384) continue;
if (event.jaxis.which != m_oPreviousEvent.jaxis.which || if (event.jaxis.which != m_oPreviousEvent.jaxis.which
event.jaxis.axis != m_oPreviousEvent.jaxis.axis || || event.jaxis.axis != m_oPreviousEvent.jaxis.axis
(event.jaxis.value > 0 && m_oPreviousEvent.jaxis.value < 0) || || (event.jaxis.value > 0 && m_oPreviousEvent.jaxis.value < 0)
(event.jaxis.value < 0 && m_oPreviousEvent.jaxis.value > 0)) || (event.jaxis.value < 0 && m_oPreviousEvent.jaxis.value > 0))
{ {
vOnInputEvent(event); vOnInputEvent(event);
m_oPreviousEvent = event; m_oPreviousEvent = event;

View File

@ -1030,67 +1030,13 @@
</child> </child>
</widget> </widget>
</child> </child>
<child>
<widget class="GtkMenuItem" id="JoypadMenu">
<property name="visible">True</property>
<property name="label" translatable="yes">_Joypad</property>
<property name="use_underline">True</property>
<child>
<widget class="GtkMenu" id="JoypadMenu_menu">
<child> <child>
<widget class="GtkMenuItem" id="JoypadConfigure"> <widget class="GtkMenuItem" id="JoypadConfigure">
<property name="visible">True</property> <property name="visible">True</property>
<property name="label" translatable="yes">_Configure ...</property> <property name="label" translatable="yes">_Joypads ...</property>
<property name="use_underline">True</property> <property name="use_underline">True</property>
</widget> </widget>
</child> </child>
<child>
<widget class="GtkMenuItem" id="AutofireMenu">
<property name="visible">True</property>
<property name="label" translatable="yes">_Autofire</property>
<property name="use_underline">True</property>
<child>
<widget class="GtkMenu" id="AutofireMenu_menu">
<child>
<widget class="GtkCheckMenuItem" id="AutofireA">
<property name="visible">True</property>
<property name="label" translatable="yes">_A</property>
<property name="use_underline">True</property>
<accelerator key="1" modifiers="GDK_MOD1_MASK" signal="activate"/>
</widget>
</child>
<child>
<widget class="GtkCheckMenuItem" id="AutofireB">
<property name="visible">True</property>
<property name="label" translatable="yes">_B</property>
<property name="use_underline">True</property>
<accelerator key="2" modifiers="GDK_MOD1_MASK" signal="activate"/>
</widget>
</child>
<child>
<widget class="GtkCheckMenuItem" id="AutofireL">
<property name="visible">True</property>
<property name="label" translatable="yes">_L</property>
<property name="use_underline">True</property>
<accelerator key="3" modifiers="GDK_MOD1_MASK" signal="activate"/>
</widget>
</child>
<child>
<widget class="GtkCheckMenuItem" id="AutofireR">
<property name="visible">True</property>
<property name="label" translatable="yes">_R</property>
<property name="use_underline">True</property>
<accelerator key="4" modifiers="GDK_MOD1_MASK" signal="activate"/>
</widget>
</child>
</widget>
</child>
</widget>
</child>
</widget>
</child>
</widget>
</child>
</widget> </widget>
</child> </child>
</widget> </widget>

View File

@ -70,7 +70,9 @@ const Window::SJoypadKey Window::m_astJoypad[] =
{ "speed", KEY_BUTTON_SPEED }, { "speed", KEY_BUTTON_SPEED },
{ "capture", KEY_BUTTON_CAPTURE }, { "capture", KEY_BUTTON_CAPTURE },
{ "speed", KEY_BUTTON_SPEED }, { "speed", KEY_BUTTON_SPEED },
{ "capture", KEY_BUTTON_CAPTURE } { "capture", KEY_BUTTON_CAPTURE },
{ "autoA", KEY_BUTTON_AUTO_A },
{ "autoB", KEY_BUTTON_AUTO_B }
}; };
Window::Window(GtkWindow * _pstWindow, const Glib::RefPtr<Xml> & _poXml) : Window::Window(GtkWindow * _pstWindow, const Glib::RefPtr<Xml> & _poXml) :
@ -618,31 +620,6 @@ Window::Window(GtkWindow * _pstWindow, const Glib::RefPtr<Xml> & _poXml) :
EPad eDefaultJoypad = (EPad)m_poInputConfig->oGetKey<int>("active_joypad"); EPad eDefaultJoypad = (EPad)m_poInputConfig->oGetKey<int>("active_joypad");
inputSetDefaultJoypad(eDefaultJoypad); inputSetDefaultJoypad(eDefaultJoypad);
// Autofire menu
//
struct
{
const char * m_csName;
const char * m_csKey;
const EKey m_eKey;
}
astAutofire[] =
{
{ "AutofireA", "autofire_A", KEY_BUTTON_A },
{ "AutofireB", "autofire_B", KEY_BUTTON_B },
{ "AutofireL", "autofire_L", KEY_BUTTON_L },
{ "AutofireR", "autofire_R", KEY_BUTTON_R }
};
for (guint i = 0; i < G_N_ELEMENTS(astAutofire); i++)
{
poCMI = dynamic_cast<Gtk::CheckMenuItem *>(_poXml->get_widget(astAutofire[i].m_csName));
poCMI->set_active(m_poInputConfig->oGetKey<bool>(astAutofire[i].m_csKey));
vOnAutofireToggled(poCMI, astAutofire[i].m_eKey);
poCMI->signal_toggled().connect(sigc::bind(
sigc::mem_fun(*this, &Window::vOnAutofireToggled),
poCMI, astAutofire[i].m_eKey));
}
// Fullscreen menu // Fullscreen menu
// //
poMI = dynamic_cast<Gtk::MenuItem *>(_poXml->get_widget("VideoFullscreen")); poMI = dynamic_cast<Gtk::MenuItem *>(_poXml->get_widget("VideoFullscreen"));
@ -767,7 +744,7 @@ void Window::vInitScreenArea(EVideoOutput _eVideoOutput)
} }
catch (std::exception e) catch (std::exception e)
{ {
fprintf(stderr, "Unable to initialise output, falling back to Cairo\n"); fprintf(stderr, "Unable to initialize output, falling back to Cairo\n");
m_poScreenArea = Gtk::manage(new ScreenAreaCairo(m_iScreenWidth, m_iScreenHeight)); m_poScreenArea = Gtk::manage(new ScreenAreaCairo(m_iScreenWidth, m_iScreenHeight));
} }

View File

@ -163,7 +163,6 @@ protected:
virtual void vOnFilter2xToggled(Gtk::CheckMenuItem * _poCMI, int _iFilter2x); virtual void vOnFilter2xToggled(Gtk::CheckMenuItem * _poCMI, int _iFilter2x);
virtual void vOnFilterIBToggled(Gtk::CheckMenuItem * _poCMI, int _iFilterIB); virtual void vOnFilterIBToggled(Gtk::CheckMenuItem * _poCMI, int _iFilterIB);
virtual void vOnJoypadConfigure(); virtual void vOnJoypadConfigure();
virtual void vOnAutofireToggled(Gtk::CheckMenuItem * _poCMI, EKey _eKey);
virtual void vOnHelpAbout(); virtual void vOnHelpAbout();
virtual bool bOnEmuIdle(); virtual bool bOnEmuIdle();

View File

@ -645,33 +645,6 @@ void Window::vOnJoypadConfigure()
m_poInputConfig->vSetKey("active_joypad", inputGetDefaultJoypad()); m_poInputConfig->vSetKey("active_joypad", inputGetDefaultJoypad());
} }
void Window::vOnAutofireToggled(Gtk::CheckMenuItem * _poCMI, EKey _eKey)
{
if (_poCMI->get_active() == inputGetAutoFire(_eKey))
{
inputToggleAutoFire(_eKey);
}
std::string sKey;
if (_eKey == KEY_BUTTON_A)
{
sKey = "autofire_A";
}
else if (_eKey == KEY_BUTTON_B)
{
sKey = "autofire_B";
}
else if (_eKey == KEY_BUTTON_L)
{
sKey = "autofire_L";
}
else if (_eKey == KEY_BUTTON_R)
{
sKey = "autofire_R";
}
m_poInputConfig->vSetKey(sKey, _poCMI->get_active());
}
void Window::vOnHelpAbout() void Window::vOnHelpAbout()
{ {
Gtk::AboutDialog oAboutDialog; Gtk::AboutDialog oAboutDialog;