GTK : Started hooking up the SDL input code. The events are well transmitted to the input module but the GDK code is still used. WIP.
This commit is contained in:
parent
c599c978f1
commit
63fba2be26
|
@ -206,6 +206,7 @@ SET(SRC_GTK
|
|||
src/gtk/screenarea-opengl.cpp
|
||||
src/gtk/tools.cpp
|
||||
src/gtk/window.cpp
|
||||
src/sdl/inputSDL.cpp
|
||||
src/sdl/sndSDL.cpp
|
||||
)
|
||||
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
#include "../dmg/gbPrinter.h"
|
||||
#include "../Sound.h"
|
||||
#include "../Util.h"
|
||||
#include "../sdl/inputSDL.h"
|
||||
|
||||
#include "tools.h"
|
||||
#include "intl.h"
|
||||
|
@ -517,7 +518,7 @@ Window::Window(GtkWindow * _pstWindow, const Glib::RefPtr<Xml> & _poXml) :
|
|||
poCMI->signal_toggled().connect(sigc::bind(
|
||||
sigc::mem_fun(*this, &Window::vOnSoundMuteToggled),
|
||||
poCMI));
|
||||
|
||||
|
||||
struct
|
||||
{
|
||||
const char * m_csName;
|
||||
|
@ -808,7 +809,7 @@ void Window::vInitScreenArea(EVideoOutput _eVideoOutput)
|
|||
poC = dynamic_cast<Gtk::Alignment *>(m_poXml->get_widget("ScreenContainer"));
|
||||
poC->remove();
|
||||
poC->set(Gtk::ALIGN_CENTER, Gtk::ALIGN_CENTER, 1.0, 1.0);
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
switch (_eVideoOutput)
|
||||
|
@ -882,7 +883,7 @@ void Window::vInitSystem()
|
|||
}
|
||||
|
||||
Init_2xSaI(32);
|
||||
|
||||
|
||||
soundInit();
|
||||
}
|
||||
|
||||
|
@ -898,7 +899,7 @@ void Window::vInitSDL()
|
|||
if (bDone)
|
||||
return;
|
||||
|
||||
int iFlags = (SDL_INIT_AUDIO | SDL_INIT_NOPARACHUTE);
|
||||
int iFlags = (SDL_INIT_EVERYTHING | SDL_INIT_NOPARACHUTE);
|
||||
|
||||
if (SDL_Init(iFlags) < 0)
|
||||
{
|
||||
|
@ -906,6 +907,13 @@ void Window::vInitSDL()
|
|||
abort();
|
||||
}
|
||||
|
||||
// TODO : remove
|
||||
int sdlNumDevices = SDL_NumJoysticks();
|
||||
for (int i = 0; i < sdlNumDevices; i++)
|
||||
SDL_JoystickOpen(i);
|
||||
|
||||
inputInitJoysticks();
|
||||
|
||||
bDone = true;
|
||||
}
|
||||
|
||||
|
@ -1788,4 +1796,23 @@ void Window::vToggleFullscreen()
|
|||
}
|
||||
}
|
||||
|
||||
void Window::vSDLPollEvents()
|
||||
{
|
||||
SDL_Event event;
|
||||
while(SDL_PollEvent(&event))
|
||||
{
|
||||
switch(event.type)
|
||||
{
|
||||
case SDL_JOYHATMOTION:
|
||||
case SDL_JOYBUTTONDOWN:
|
||||
case SDL_JOYBUTTONUP:
|
||||
case SDL_JOYAXISMOTION:
|
||||
case SDL_KEYDOWN:
|
||||
case SDL_KEYUP:
|
||||
inputProcessSDLEvent(event);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} // VBA namespace
|
||||
|
|
|
@ -295,6 +295,7 @@ private:
|
|||
void vSelectBestThrottleItem();
|
||||
void vUpdateGameSlots();
|
||||
void vToggleFullscreen();
|
||||
void vSDLPollEvents();
|
||||
};
|
||||
|
||||
} // namespace VBA
|
||||
|
|
|
@ -23,12 +23,15 @@
|
|||
#include <stdio.h>
|
||||
#include <time.h>
|
||||
|
||||
#include <SDL.h>
|
||||
|
||||
#include "../agb/GBA.h"
|
||||
#include "../dmg/gb.h"
|
||||
#include "../dmg/gbGlobals.h"
|
||||
#include "../dmg/gbPrinter.h"
|
||||
#include "../Sound.h"
|
||||
#include "../Util.h"
|
||||
#include "../sdl/inputSDL.h"
|
||||
|
||||
#include "tools.h"
|
||||
#include "intl.h"
|
||||
|
@ -933,7 +936,7 @@ void Window::vOnGDBWait()
|
|||
poDialog->set_transient_for(*this);
|
||||
|
||||
int iPort = 55555;
|
||||
poSpin->set_value(iPort);
|
||||
poSpin->set_value(iPort);
|
||||
|
||||
bool bOk = false;
|
||||
if (poDialog->run() == Gtk::RESPONSE_OK)
|
||||
|
@ -1027,7 +1030,7 @@ void Window::vOnGDBLoadAndWait()
|
|||
poDialog->set_transient_for(*this);
|
||||
|
||||
int iPort = 55555;
|
||||
poSpin->set_value(iPort);
|
||||
poSpin->set_value(iPort);
|
||||
|
||||
bool bOk = false;
|
||||
if (poDialog->run() == Gtk::RESPONSE_OK)
|
||||
|
@ -1078,7 +1081,7 @@ void Window::vOnGDBDisconnect()
|
|||
void Window::vOnHelpAbout()
|
||||
{
|
||||
Gtk::AboutDialog oAboutDialog;
|
||||
|
||||
|
||||
oAboutDialog.set_transient_for(*this);
|
||||
|
||||
oAboutDialog.set_name("VBA-M");
|
||||
|
@ -1099,13 +1102,13 @@ void Window::vOnHelpAbout()
|
|||
list_authors.push_back("jbo_85");
|
||||
list_authors.push_back("bgK");
|
||||
oAboutDialog.set_authors(list_authors);
|
||||
|
||||
|
||||
std::list<Glib::ustring> list_artists;
|
||||
list_artists.push_back("Matteo Drera");
|
||||
list_artists.push_back("Jakub Steiner");
|
||||
list_artists.push_back("Jones Lee");
|
||||
oAboutDialog.set_artists(list_artists);
|
||||
|
||||
|
||||
oAboutDialog.run();
|
||||
}
|
||||
|
||||
|
@ -1121,7 +1124,7 @@ bool Window::bOnEmuIdle()
|
|||
{
|
||||
Glib::TimeVal uiTime;
|
||||
uiTime.assign_current_time();
|
||||
|
||||
|
||||
if (uiTime - m_uiThrottleLastTime >= m_uiThrottleDelay)
|
||||
{
|
||||
m_uiThrottleDelay = Glib::TimeVal(0, 0);
|
||||
|
@ -1133,6 +1136,8 @@ bool Window::bOnEmuIdle()
|
|||
}
|
||||
}
|
||||
|
||||
vSDLPollEvents();
|
||||
|
||||
m_stEmulator.emuMain(m_stEmulator.emuCount);
|
||||
return true;
|
||||
}
|
||||
|
@ -1172,6 +1177,12 @@ bool Window::on_key_press_event(GdkEventKey * _pstEvent)
|
|||
return true;
|
||||
}
|
||||
|
||||
// Forward the keyboard event to the input module by faking a SDL event
|
||||
SDL_Event event;
|
||||
event.type = SDL_KEYDOWN;
|
||||
event.key.keysym.sym = (SDLKey)_pstEvent->keyval;
|
||||
inputProcessSDLEvent(event);
|
||||
|
||||
if ((_pstEvent->state & Gtk::AccelGroup::get_default_mod_mask())
|
||||
|| (eKey = m_oKeymap[_pstEvent->hardware_keycode]) == KeyNone)
|
||||
{
|
||||
|
@ -1228,6 +1239,12 @@ bool Window::on_key_press_event(GdkEventKey * _pstEvent)
|
|||
|
||||
bool Window::on_key_release_event(GdkEventKey * _pstEvent)
|
||||
{
|
||||
// Forward the keyboard event to the input module by faking a SDL event
|
||||
SDL_Event event;
|
||||
event.type = SDL_KEYDOWN;
|
||||
event.key.keysym.sym = (SDLKey)_pstEvent->keyval;
|
||||
inputProcessSDLEvent(event);
|
||||
|
||||
EKey eKey;
|
||||
|
||||
if ((_pstEvent->state & Gtk::AccelGroup::get_default_mod_mask())
|
||||
|
@ -1286,7 +1303,7 @@ bool Window::on_window_state_event(GdkEventWindowState* _pstEvent)
|
|||
{
|
||||
m_bFullscreen = _pstEvent->new_window_state & GDK_WINDOW_STATE_FULLSCREEN;
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue