Big restructuring of how the video plugin works. In linux and windows you shouldn't see a change in the functionality; however, there are changes in how render to main or not, and fullscreen modes, and such are handled. Input is largely restructured for the video plugin. It is now handled by the host. Keys for pausing and changing fullscreen are configurable. More will probably be later. This is probably classified as highly experimental.

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@5336 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
Glenn Rice 2010-04-12 01:33:10 +00:00
parent ba853e682c
commit 33a64d5db0
53 changed files with 1003 additions and 1649 deletions

View File

@ -394,6 +394,15 @@ if env['nowx']:
else:
env['HAVE_WX'] = conf.CheckWXConfig('2.8', wxmods, 0)
# check for libgtk2.0
env['HAVE_GTK2'] = 0
if sys.platform == 'linux2':
env['HAVE_GTK2'] = env['HAVE_WX'] and conf.CheckPKG('gtk+-2.0')
if env['HAVE_WX'] and not env['HAVE_GTK2']:
print "gtk+-2.0 developement headers not detected"
print "gtk+-2.0 is required to build the WX GUI"
Exit(1)
env['NOJIT'] = 0
if env['nojit']:
env['NOJIT'] = 1

View File

@ -90,6 +90,22 @@ void SConfig::SaveSettings()
ini.Set("Interface", "ShowLogWindow", m_InterfaceLogWindow);
ini.Set("Interface", "ShowConsole", m_InterfaceConsole);
// Hotkeys
ini.Set("Hotkeys", "ToggleFullscreen", m_LocalCoreStartupParameter.iHotkey[HK_FULLSCREEN]);
ini.Set("Hotkeys", "PlayPause", m_LocalCoreStartupParameter.iHotkey[HK_PLAY_PAUSE]);
ini.Set("Hotkeys", "Stop", m_LocalCoreStartupParameter.iHotkey[HK_STOP]);
ini.Set("Hotkeys", "ToggleFullscreenModifier", m_LocalCoreStartupParameter.iHotkeyModifier[HK_FULLSCREEN]);
ini.Set("Hotkeys", "PlayPauseModifier", m_LocalCoreStartupParameter.iHotkeyModifier[HK_PLAY_PAUSE]);
ini.Set("Hotkeys", "StopModifier", m_LocalCoreStartupParameter.iHotkeyModifier[HK_STOP]);
// Display
ini.Set("Display", "Fullscreen", m_LocalCoreStartupParameter.bFullscreen);
ini.Set("Display", "RenderToMain", m_LocalCoreStartupParameter.bRenderToMain);
ini.Set("Display", "RenderWindowXPos", m_LocalCoreStartupParameter.iRenderWindowXPos);
ini.Set("Display", "RenderWindowYPos", m_LocalCoreStartupParameter.iRenderWindowYPos);
ini.Set("Display", "RenderWindowWidth", m_LocalCoreStartupParameter.iRenderWindowWidth);
ini.Set("Display", "RenderWindowHeight", m_LocalCoreStartupParameter.iRenderWindowHeight);
// Game List Control
ini.Set("GameList", "ListDrives", m_ListDrives);
ini.Set("GameList", "ListWad", m_ListWad);
@ -198,6 +214,23 @@ void SConfig::LoadSettings()
ini.Get("Interface", "ShowLogWindow", &m_InterfaceLogWindow, false);
ini.Get("Interface", "ShowConsole", &m_InterfaceConsole, false);
// Hotkeys
ini.Get("Hotkeys", "ToggleFullscreen", &m_LocalCoreStartupParameter.iHotkey[HK_FULLSCREEN], 13); // WXK_RETURN
ini.Get("Hotkeys", "PlayPause", &m_LocalCoreStartupParameter.iHotkey[HK_PLAY_PAUSE], 349); // WXK_F10
ini.Get("Hotkeys", "Stop", &m_LocalCoreStartupParameter.iHotkey[HK_STOP], 27); // WXK_ESCAPE
ini.Get("Hotkeys", "ToggleFullscreenModifier", &m_LocalCoreStartupParameter.iHotkeyModifier[HK_FULLSCREEN], 0x0001); // wxMOD_ALT
ini.Get("Hotkeys", "PlayPauseModifier", &m_LocalCoreStartupParameter.iHotkeyModifier[HK_PLAY_PAUSE], 0x0000); // wxMOD_NONE
ini.Get("Hotkeys", "StopModifier", &m_LocalCoreStartupParameter.iHotkeyModifier[HK_STOP], 0x0000); // wxMOD_NONE
// Display
ini.Get("Display", "Fullscreen", &m_LocalCoreStartupParameter.bFullscreen, false);
ini.Get("Display", "RenderToMain", &m_LocalCoreStartupParameter.bRenderToMain, false);
std::string temp;
ini.Get("Display", "RenderWindowXPos", &m_LocalCoreStartupParameter.iRenderWindowXPos, 0);
ini.Get("Display", "RenderWindowYPos", &m_LocalCoreStartupParameter.iRenderWindowYPos, 0);
ini.Get("Display", "RenderWindowWidth", &m_LocalCoreStartupParameter.iRenderWindowWidth, 640);
ini.Get("Display", "RenderWindowHeight", &m_LocalCoreStartupParameter.iRenderWindowHeight, 480);
// Game List Control
ini.Get("GameList", "ListDrives", &m_ListDrives, false);
ini.Get("GameList", "ListWad", &m_ListWad, true);

View File

@ -71,7 +71,7 @@ volatile u32 DrawnFrame = 0;
u32 DrawnVideo = 0;
// Function forwarding
//void Callback_VideoRequestWindowSize(int _iWidth, int _iHeight, BOOL _bFullscreen);
void Callback_VideoRequestWindowSize(int& x, int& y, int& width, int& height);
void Callback_VideoLog(const TCHAR* _szMessage, int _bDoBreak);
void Callback_VideoCopiedToXFB(bool video_update);
void Callback_DSPLog(const TCHAR* _szMessage, int _v);
@ -80,9 +80,10 @@ void Callback_DSPInterrupt();
void Callback_PADLog(const TCHAR* _szMessage);
void Callback_WiimoteLog(const TCHAR* _szMessage, int _v);
void Callback_WiimoteInput(int _number, u16 _channelID, const void* _pData, u32 _Size);
bool Callback_RendererHasFocus(void);
// For keyboard shortcuts.
void Callback_KeyPress(int key, bool shift, bool control);
void Callback_CoreMessage(int Id);
TPeekMessages Callback_PeekMessages = NULL;
TUpdateFPSDisplay g_pUpdateFPSDisplay = NULL;
@ -322,17 +323,14 @@ THREAD_RETURN EmuThread(void *pArg)
VideoInitialize.pScheduleEvent_Threadsafe = CoreTiming::ScheduleEvent_Threadsafe;
// This is first the m_Panel handle, then it is updated to have the new window handle
VideoInitialize.pWindowHandle = _CoreParameter.hMainWindow;
#if defined(HAVE_X11) && HAVE_X11 && defined(HAVE_GTK2) && HAVE_GTK2
VideoInitialize.pPanel = _CoreParameter.hMainWindow;
#endif
VideoInitialize.pLog = Callback_VideoLog;
VideoInitialize.pSysMessage = Host_SysMessage;
VideoInitialize.pRequestWindowSize = NULL; //Callback_VideoRequestWindowSize;
VideoInitialize.pRequestWindowSize = Callback_VideoRequestWindowSize;
VideoInitialize.pCopiedToXFB = Callback_VideoCopiedToXFB;
VideoInitialize.pPeekMessages = NULL;
VideoInitialize.pUpdateFPSDisplay = NULL;
VideoInitialize.pMemoryBase = Memory::base;
VideoInitialize.pKeyPress = Callback_KeyPress;
VideoInitialize.pCoreMessage = Callback_CoreMessage;
VideoInitialize.bWii = _CoreParameter.bWii;
VideoInitialize.bOnThread = _CoreParameter.bCPUThread;
VideoInitialize.Fifo_CPUBase = &ProcessorInterface::Fifo_CPUBase;
@ -381,11 +379,9 @@ THREAD_RETURN EmuThread(void *pArg)
PADInitialize.hWnd = g_pWindowHandle;
#if defined(HAVE_X11) && HAVE_X11
PADInitialize.pXWindow = g_pXWindow;
#if defined(HAVE_GTK2) && HAVE_GTK2
PADInitialize.pPanel = VideoInitialize.pPanel;
#endif
#endif
PADInitialize.pLog = Callback_PADLog;
PADInitialize.pRendererHasFocus = Callback_RendererHasFocus;
// This is may be needed to avoid a SDL problem
//Plugins.FreeWiimote();
Plugins.GetPad(0)->Initialize(&PADInitialize);
@ -396,14 +392,12 @@ THREAD_RETURN EmuThread(void *pArg)
SWiimoteInitialize WiimoteInitialize;
WiimoteInitialize.hWnd = g_pWindowHandle;
#if defined(HAVE_X11) && HAVE_X11
#if defined(HAVE_GTK2) && HAVE_GTK2
WiimoteInitialize.pPanel = VideoInitialize.pPanel;
#endif
WiimoteInitialize.pXWindow = g_pXWindow;
#endif
WiimoteInitialize.ISOId = Ascii2Hex(_CoreParameter.m_strUniqueID);
WiimoteInitialize.pLog = Callback_WiimoteLog;
WiimoteInitialize.pWiimoteInput = Callback_WiimoteInput;
WiimoteInitialize.pRendererHasFocus = Callback_RendererHasFocus;
// Wait for Wiiuse to find the number of connected Wiimotes
Plugins.GetWiimote(0)->Initialize((void *)&WiimoteInitialize);
}
@ -711,6 +705,12 @@ void Callback_VideoCopiedToXFB(bool video_update)
Frame::FrameUpdate();
}
// Ask the host for the desired window size
void Callback_VideoRequestWindowSize(int& x, int& y, int& width, int& height)
{
Host_RequestWindowSize(x, y, width, height);
}
// Callback_DSPLog
// WARNING - THIS MAY BE EXECUTED FROM DSP THREAD
void Callback_DSPLog(const TCHAR* _szMessage, int _v)
@ -748,46 +748,10 @@ const char *Callback_ISOName()
}
// Called from ANY thread!
// The hotkey function
void Callback_KeyPress(int key, bool shift, bool control)
// Pass the message on to the host
void Callback_CoreMessage(int Id)
{
// F1 - F8: Save states
if (key >= 0x70 && key < 0x78) {
// F-key
int slot_number = key - 0x70 + 1;
if (shift)
State_Save(slot_number);
else
State_Load(slot_number);
}
// 0x78 == VK_F9
if (key == 0x78)
ScreenShot();
// 0x7a == VK_F11
if (key == 0x7a)
State_LoadLastSaved();
// 0x7b == VK_F12
if (key == 0x7b)
{
if(shift)
State_UndoSaveState();
else
State_UndoLoadState();
}
#if defined(HAVE_X11) && HAVE_X11
if (key == 0)
Host_Message(WM_USER_CREATE);
// 0x1b == VK_ESCAPE
if (key == 0x1b)
Host_Message(WM_USER_STOP);
if (key == 0x1c)
Host_Message(WM_USER_PAUSE);
if (key == 0x1d)
Host_Message(TOGGLE_FULLSCREEN);
#endif
Host_Message(Id);
}
// Callback_WiimoteLog
@ -797,4 +761,10 @@ void Callback_WiimoteLog(const TCHAR* _szMessage, int _v)
GENERIC_LOG(LogTypes::WIIMOTE, (LogTypes::LOG_LEVELS)_v, _szMessage);
}
// Check to see if the renderer window has focus
bool Callback_RendererHasFocus(void)
{
return Host_RendererHasFocus();
}
} // Core

View File

@ -50,6 +50,9 @@ SCoreStartupParameter::SCoreStartupParameter()
bWii(false),
bConfirmStop(false), bHideCursor(false),
bAutoHideCursor(false), bUsePanicHandlers(true),
bFullscreen(false), bRenderToMain(false),
iRenderWindowXPos(0), iRenderWindowYPos(0),
iRenderWindowWidth(640), iRenderWindowHeight(480),
iTheme(0),
iPosX(100), iPosY(100), iWidth(800), iHeight(600)
{

View File

@ -24,6 +24,13 @@
#define MAXPADS 1
#define MAXWIIMOTES 1
enum Hotkey {
HK_FULLSCREEN,
HK_PLAY_PAUSE,
HK_STOP,
NUM_HOTKEYS,
};
struct SCoreStartupParameter
{
void * hInstance; // HINSTANCE but we don't want to include <windows.h>
@ -77,6 +84,16 @@ struct SCoreStartupParameter
// Interface settings
bool bConfirmStop, bHideCursor, bAutoHideCursor, bUsePanicHandlers;
// Hotkeys
int iHotkey[NUM_HOTKEYS];
int iHotkeyModifier[NUM_HOTKEYS];
// Display settings
bool bFullscreen, bRenderToMain;
int iRenderWindowXPos, iRenderWindowYPos;
int iRenderWindowWidth, iRenderWindowHeight;
int iTheme;
int iPosX, iPosY, iWidth, iHeight;

View File

@ -45,6 +45,8 @@ void Host_NotifyMapLoaded();
void Host_UpdateBreakPointView();
void Host_ShowJitResults(unsigned int address);
void Host_SetDebugMode(bool enable);
void Host_RequestWindowSize(int& x, int& y, int& width, int& height);
bool Host_RendererHasFocus();
void Host_SetWaitCursor(bool enable);

View File

@ -601,7 +601,7 @@ bool CWII_IPC_HLE_Device_usb_oh1_57e_305::SendEventInquiryComplete()
SHCIEventInquiryComplete* pInquiryComplete = (SHCIEventInquiryComplete*)Event.m_buffer;
pInquiryComplete->EventType = HCI_EVENT_INQUIRY_COMPL;
pInquiryComplete->PayloadLength = sizeof(SHCIEventInquiryComplete) - 2;
pInquiryComplete->Status = 0x00;
pInquiryComplete->EventStatus = 0x00;
AddEventToQueue(Event);
@ -666,7 +666,7 @@ bool CWII_IPC_HLE_Device_usb_oh1_57e_305::SendEventConnectionComplete(const bdad
pConnectionComplete->EventType = HCI_EVENT_CON_COMPL;
pConnectionComplete->PayloadLength = sizeof(SHCIEventConnectionComplete) - 2;
pConnectionComplete->Status = 0x00;
pConnectionComplete->EventStatus = 0x00;
pConnectionComplete->Connection_Handle = pWiiMote->GetConnectionHandle();
pConnectionComplete->bdaddr = _bd;
pConnectionComplete->LinkType = HCI_LINK_ACL;
@ -745,7 +745,7 @@ bool CWII_IPC_HLE_Device_usb_oh1_57e_305::SendEventDisconnect(u16 _connectionHan
SHCIEventDisconnectCompleted* pDisconnect = (SHCIEventDisconnectCompleted*)Event.m_buffer;
pDisconnect->EventType = HCI_EVENT_DISCON_COMPL;
pDisconnect->PayloadLength = sizeof(SHCIEventDisconnectCompleted) - 2;
pDisconnect->Status = 0;
pDisconnect->EventStatus = 0;
pDisconnect->Connection_Handle = _connectionHandle;
pDisconnect->Reason = _Reason;
@ -770,7 +770,7 @@ bool CWII_IPC_HLE_Device_usb_oh1_57e_305::SendEventAuthenticationCompleted(u16 _
SHCIEventAuthenticationCompleted* pEventAuthenticationCompleted = (SHCIEventAuthenticationCompleted*)Event.m_buffer;
pEventAuthenticationCompleted->EventType = HCI_EVENT_AUTH_COMPL;
pEventAuthenticationCompleted->PayloadLength = sizeof(SHCIEventAuthenticationCompleted) - 2;
pEventAuthenticationCompleted->Status = 0;
pEventAuthenticationCompleted->EventStatus = 0;
pEventAuthenticationCompleted->Connection_Handle = _connectionHandle;
// Log
@ -794,7 +794,7 @@ bool CWII_IPC_HLE_Device_usb_oh1_57e_305::SendEventRemoteNameReq(const bdaddr_t&
pRemoteNameReq->EventType = HCI_EVENT_REMOTE_NAME_REQ_COMPL;
pRemoteNameReq->PayloadLength = sizeof(SHCIEventRemoteNameReq) - 2;
pRemoteNameReq->Status = 0x00;
pRemoteNameReq->EventStatus = 0x00;
pRemoteNameReq->bdaddr = _bd;
strcpy((char*)pRemoteNameReq->RemoteName, pWiiMote->GetName());
@ -821,7 +821,7 @@ bool CWII_IPC_HLE_Device_usb_oh1_57e_305::SendEventReadRemoteFeatures(u16 _conne
pReadRemoteFeatures->EventType = HCI_EVENT_READ_REMOTE_FEATURES_COMPL;
pReadRemoteFeatures->PayloadLength = sizeof(SHCIEventReadRemoteFeatures) - 2;
pReadRemoteFeatures->Status = 0x00;
pReadRemoteFeatures->EventStatus = 0x00;
pReadRemoteFeatures->ConnectionHandle = _connectionHandle;
pReadRemoteFeatures->features[0] = pWiiMote->GetFeatures()[0];
pReadRemoteFeatures->features[1] = pWiiMote->GetFeatures()[1];
@ -856,7 +856,7 @@ bool CWII_IPC_HLE_Device_usb_oh1_57e_305::SendEventReadRemoteVerInfo(u16 _connec
SHCIEventReadRemoteVerInfo* pReadRemoteVerInfo = (SHCIEventReadRemoteVerInfo*)Event.m_buffer;
pReadRemoteVerInfo->EventType = HCI_EVENT_READ_REMOTE_VER_INFO_COMPL;
pReadRemoteVerInfo->PayloadLength = sizeof(SHCIEventReadRemoteVerInfo) - 2;
pReadRemoteVerInfo->Status = 0x00;
pReadRemoteVerInfo->EventStatus = 0x00;
pReadRemoteVerInfo->ConnectionHandle = _connectionHandle;
pReadRemoteVerInfo->lmp_version = pWiiMote->GetLMPVersion();
pReadRemoteVerInfo->manufacturer = pWiiMote->GetManufactorID();
@ -914,7 +914,7 @@ bool CWII_IPC_HLE_Device_usb_oh1_57e_305::SendEventCommandStatus(u16 _Opcode)
SHCIEventStatus* pHCIEvent = (SHCIEventStatus*)Event.m_buffer;
pHCIEvent->EventType = HCI_EVENT_COMMAND_STATUS;
pHCIEvent->PayloadLength = sizeof(SHCIEventStatus) - 2;
pHCIEvent->Status = 0x0;
pHCIEvent->EventStatus = 0x0;
pHCIEvent->PacketIndicator = 0x01;
pHCIEvent->Opcode = _Opcode;
@ -947,7 +947,7 @@ bool CWII_IPC_HLE_Device_usb_oh1_57e_305::SendEventRoleChange(bdaddr_t _bd, bool
pRoleChange->EventType = HCI_EVENT_ROLE_CHANGE;
pRoleChange->PayloadLength = sizeof(SHCIEventRoleChange) - 2;
pRoleChange->Status = 0x00;
pRoleChange->EventStatus = 0x00;
pRoleChange->bdaddr = _bd;
pRoleChange->NewRole = _master ? 0x00 : 0x01;
@ -1002,7 +1002,7 @@ bool CWII_IPC_HLE_Device_usb_oh1_57e_305::SendEventModeChange(u16 _connectionHan
SHCIEventModeChange* pModeChange = (SHCIEventModeChange*)Event.m_buffer;
pModeChange->EventType = HCI_EVENT_MODE_CHANGE;
pModeChange->PayloadLength = sizeof(SHCIEventModeChange) - 2;
pModeChange->Status = 0;
pModeChange->EventStatus = 0;
pModeChange->Connection_Handle = _connectionHandle;
pModeChange->CurrentMode = _mode;
pModeChange->Value = _value;
@ -1074,7 +1074,7 @@ bool CWII_IPC_HLE_Device_usb_oh1_57e_305::SendEventReadClockOffsetComplete(u16 _
SHCIEventReadClockOffsetComplete* pReadClockOffsetComplete = (SHCIEventReadClockOffsetComplete*)Event.m_buffer;
pReadClockOffsetComplete->EventType = HCI_EVENT_READ_CLOCK_OFFSET_COMPL;
pReadClockOffsetComplete->PayloadLength = sizeof(SHCIEventReadClockOffsetComplete) - 2;
pReadClockOffsetComplete->Status = 0x00;
pReadClockOffsetComplete->EventStatus = 0x00;
pReadClockOffsetComplete->ConnectionHandle = _connectionHandle;
pReadClockOffsetComplete->ClockOffset = 0x3818;
@ -1099,7 +1099,7 @@ bool CWII_IPC_HLE_Device_usb_oh1_57e_305::SendEventConPacketTypeChange(u16 _conn
SHCIEventConPacketTypeChange* pChangeConPacketType = (SHCIEventConPacketTypeChange*)Event.m_buffer;
pChangeConPacketType->EventType = HCI_EVENT_CON_PKT_TYPE_CHANGED;
pChangeConPacketType->PayloadLength = sizeof(SHCIEventConPacketTypeChange) - 2;
pChangeConPacketType->Status = 0x00;
pChangeConPacketType->EventStatus = 0x00;
pChangeConPacketType->ConnectionHandle = _connectionHandle;
pChangeConPacketType->PacketType = _packetType;

View File

@ -2407,7 +2407,7 @@ struct SHCIEventStatus
{
u8 EventType;
u8 PayloadLength;
u8 Status;
u8 EventStatus;
u8 PacketIndicator;
u16 Opcode;
};
@ -2423,14 +2423,14 @@ struct SHCIEventInquiryComplete
{
u8 EventType;
u8 PayloadLength;
u8 Status;
u8 EventStatus;
};
struct SHCIEventReadClockOffsetComplete
{
u8 EventType;
u8 PayloadLength;
u8 Status;
u8 EventStatus;
u16 ConnectionHandle;
u16 ClockOffset;
};
@ -2439,7 +2439,7 @@ struct SHCIEventConPacketTypeChange
{
u8 EventType;
u8 PayloadLength;
u8 Status;
u8 EventStatus;
u16 ConnectionHandle;
u16 PacketType;
};
@ -2448,7 +2448,7 @@ struct SHCIEventReadRemoteVerInfo
{
u8 EventType;
u8 PayloadLength;
u8 Status;
u8 EventStatus;
u16 ConnectionHandle;
u8 lmp_version;
u16 manufacturer;
@ -2459,7 +2459,7 @@ struct SHCIEventReadRemoteFeatures
{
u8 EventType;
u8 PayloadLength;
u8 Status;
u8 EventStatus;
u16 ConnectionHandle;
u8 features[HCI_FEATURES_SIZE];
};
@ -2468,7 +2468,7 @@ struct SHCIEventRemoteNameReq
{
u8 EventType;
u8 PayloadLength;
u8 Status;
u8 EventStatus;
bdaddr_t bdaddr;
u8 RemoteName[248];
};
@ -2486,7 +2486,7 @@ struct SHCIEventConnectionComplete
{
u8 EventType;
u8 PayloadLength;
u8 Status;
u8 EventStatus;
u16 Connection_Handle;
bdaddr_t bdaddr;
u8 LinkType;
@ -2497,7 +2497,7 @@ struct SHCIEventRoleChange
{
u8 EventType;
u8 PayloadLength;
u8 Status;
u8 EventStatus;
bdaddr_t bdaddr;
u8 NewRole;
};
@ -2515,7 +2515,7 @@ struct SHCIEventAuthenticationCompleted
{
u8 EventType;
u8 PayloadLength;
u8 Status;
u8 EventStatus;
u16 Connection_Handle;
};
@ -2524,7 +2524,7 @@ struct SHCIEventModeChange
{
u8 EventType;
u8 PayloadLength;
u8 Status;
u8 EventStatus;
u16 Connection_Handle;
u8 CurrentMode;
u16 Value;
@ -2535,7 +2535,7 @@ struct SHCIEventDisconnectCompleted
{
u8 EventType;
u8 PayloadLength;
u8 Status;
u8 EventStatus;
u16 Connection_Handle;
u8 Reason;
};

View File

@ -871,6 +871,14 @@
RelativePath=".\src\Globals.h"
>
</File>
<File
RelativePath=".\Src\HotkeyDlg.cpp"
>
</File>
<File
RelativePath=".\Src\HotkeyDlg.h"
>
</File>
<File
RelativePath=".\Src\ISOProperties.cpp"
>

View File

@ -28,6 +28,7 @@
#include "ConfigManager.h"
#include "SysConf.h"
#include "Frame.h"
#include "HotkeyDlg.h"
extern CFrame* main_frame;
@ -51,12 +52,12 @@ EVT_BUTTON(wxID_CLOSE, CConfigMain::CloseClick)
EVT_CHECKBOX(ID_INTERFACE_CONFIRMSTOP, CConfigMain::CoreSettingsChanged)
EVT_CHECKBOX(ID_INTERFACE_USEPANICHANDLERS, CConfigMain::CoreSettingsChanged)
#if wxUSE_TIMER && defined _WIN32
EVT_CHECKBOX(ID_INTERFACE_HIDECURSOR, CConfigMain::CoreSettingsChanged)
EVT_CHECKBOX(ID_INTERFACE_AUTOHIDECURSOR, CConfigMain::CoreSettingsChanged)
#endif
EVT_CHECKBOX(ID_DISPLAY_HIDECURSOR, CConfigMain::CoreSettingsChanged)
EVT_CHECKBOX(ID_DISPLAY_FULLSCREEN, CConfigMain::CoreSettingsChanged)
EVT_CHECKBOX(ID_DISPLAY_RENDERTOMAIN, CConfigMain::CoreSettingsChanged)
EVT_RADIOBOX(ID_INTERFACE_THEME, CConfigMain::CoreSettingsChanged)
EVT_CHOICE(ID_INTERFACE_LANG, CConfigMain::CoreSettingsChanged)
EVT_BUTTON(ID_HOTKEY_CONFIG, CConfigMain::CoreSettingsChanged)
EVT_CHECKBOX(ID_ALWAYS_HLE_BS2, CConfigMain::CoreSettingsChanged)
EVT_RADIOBUTTON(ID_RADIOJIT, CConfigMain::CoreSettingsChanged)
@ -142,6 +143,7 @@ void CConfigMain::UpdateGUI()
LockThreads->Disable();
SkipIdle->Disable();
EnableCheats->Disable();
RenderToMain->Disable();
GCSystemLang->Disable();
@ -223,14 +225,15 @@ void CConfigMain::InitializeGUIValues()
// General - Interface
ConfirmStop->SetValue(SConfig::GetInstance().m_LocalCoreStartupParameter.bConfirmStop);
UsePanicHandlers->SetValue(SConfig::GetInstance().m_LocalCoreStartupParameter.bUsePanicHandlers);
#if wxUSE_TIMER && defined _WIN32
AutoHideCursor->SetValue(SConfig::GetInstance().m_LocalCoreStartupParameter.bAutoHideCursor);
HideCursor->SetValue(SConfig::GetInstance().m_LocalCoreStartupParameter.bHideCursor);
#endif
Theme->SetSelection(SConfig::GetInstance().m_LocalCoreStartupParameter.iTheme);
// need redesign
InterfaceLang->SetSelection(SConfig::GetInstance().m_InterfaceLanguage);
// General - Display
Fullscreen->SetValue(SConfig::GetInstance().m_LocalCoreStartupParameter.bFullscreen);
HideCursor->SetValue(SConfig::GetInstance().m_LocalCoreStartupParameter.bHideCursor);
RenderToMain->SetValue(SConfig::GetInstance().m_LocalCoreStartupParameter.bRenderToMain);
// Gamecube - IPL
GCSystemLang->SetSelection(SConfig::GetInstance().m_LocalCoreStartupParameter.SelectedLanguage);
@ -280,19 +283,23 @@ void CConfigMain::InitializeGUITooltips()
UsePanicHandlers->SetToolTip(wxT("Show a message box when a potentially serious error has occured.")
wxT(" Disabling this may avoid annoying and non-fatal messages, but it may also mean that Dolphin")
wxT(" suddenly crashes without any explanation at all."));
#if wxUSE_TIMER && defined _WIN32
AutoHideCursor->SetToolTip(wxT("This will auto hide the cursor in fullscreen mode."));
HideCursor->SetToolTip(wxT("This will always hide the cursor when it's over the rendering window.")
wxT("\nIt can be convenient in a Wii game that already has a cursor."));
#endif
InterfaceLang->SetToolTip(wxT("For the time being this will only change the text shown in")
wxT("\nthe game list of PAL GC games."));
// Themes: Copyright notice
Theme->SetItemToolTip(0, wxT("Created by Milosz Wlazlo [miloszwl@miloszwl.com, miloszwl.deviantart.com]"));
Theme->SetItemToolTip(1, wxT("Created by VistaIcons.com"));
Theme->SetItemToolTip(2, wxT("Created by black_rider and published on ForumW.org > Web Developments"));
Theme->SetItemToolTip(3, wxT("Created by KDE-Look.org"));
// General - Display
Fullscreen->SetToolTip(
wxT("Start the rendering window in fullscreen mode.")
wxT(" Press Alt+Enter to switch between Fullscreen and Windowed mode."));
HideCursor->SetToolTip(wxT("Hide the cursor when it is over the rendering window")
wxT("\n and the rendering window has focus."));
RenderToMain->SetToolTip(wxT("Render to main window."));
// Wii
WiiKeyboard->SetToolTip(wxT("This could cause slow down in Wii Menu and some games."));
}
@ -318,6 +325,7 @@ void CConfigMain::CreateGUIControls()
sbBasic = new wxStaticBoxSizer(wxVERTICAL, GeneralPage, wxT("Basic Settings"));
sbAdvanced = new wxStaticBoxSizer(wxVERTICAL, GeneralPage, wxT("Advanced Settings"));
sbInterface = new wxStaticBoxSizer(wxVERTICAL, GeneralPage, wxT("Interface Settings"));
sbDisplay = new wxStaticBoxSizer(wxVERTICAL, GeneralPage, wxT("Emulator Display Settings"));
// Core Settings - Basic
CPUThread = new wxCheckBox(GeneralPage, ID_CPUTHREAD, wxT("Enable Dual Core (speedup)"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator);
SkipIdle = new wxCheckBox(GeneralPage, ID_IDLESKIP, wxT("Enable Idle Skipping (speedup)"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator);
@ -340,21 +348,23 @@ void CConfigMain::CreateGUIControls()
ConfirmStop = new wxCheckBox(GeneralPage, ID_INTERFACE_CONFIRMSTOP, wxT("Confirm On Stop"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator);
UsePanicHandlers = new wxCheckBox(GeneralPage, ID_INTERFACE_USEPANICHANDLERS, wxT("Use Panic Handlers"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator);
#if wxUSE_TIMER && defined _WIN32
// Hide Cursor
wxStaticText *HideCursorText = new wxStaticText(GeneralPage, ID_INTERFACE_HIDECURSOR_TEXT, wxT("Hide Cursor:"), wxDefaultPosition, wxDefaultSize);
AutoHideCursor = new wxCheckBox(GeneralPage, ID_INTERFACE_AUTOHIDECURSOR, wxT("Auto"));
HideCursor = new wxCheckBox(GeneralPage, ID_INTERFACE_HIDECURSOR, wxT("Always"));
#endif
// Interface Language
// At the moment this only changes the language displayed in m_gamelistctrl
// If someone wants to control the whole GUI's language, it should be set here too
wxStaticText *InterfaceLangText = new wxStaticText(GeneralPage, ID_INTERFACE_LANG_TEXT, wxT("Game List Language:"), wxDefaultPosition, wxDefaultSize);
InterfaceLang = new wxChoice(GeneralPage, ID_INTERFACE_LANG, wxDefaultPosition, wxDefaultSize, arrayStringFor_InterfaceLang, 0, wxDefaultValidator);
// Hotkey configuration
HotkeyConfig = new wxButton(GeneralPage, ID_HOTKEY_CONFIG, wxT("Hotkeys"), wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT, wxDefaultValidator);
// Themes - this should really be a wxChoice...
Theme = new wxRadioBox(GeneralPage, ID_INTERFACE_THEME, wxT("Theme"),wxDefaultPosition, wxDefaultSize, arrayStringFor_Themes, 1, wxRA_SPECIFY_ROWS);
// General display settings
Fullscreen = new wxCheckBox(GeneralPage, ID_DISPLAY_FULLSCREEN, wxT("Start Renderer in Fullscreen"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator);
HideCursor = new wxCheckBox(GeneralPage, ID_DISPLAY_HIDECURSOR, wxT("Hide Mouse Cursor"));
RenderToMain = new wxCheckBox(GeneralPage, ID_DISPLAY_RENDERTOMAIN, wxT("Render to Main Window"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator);
// Populate the settings
sCore = new wxBoxSizer(wxHORIZONTAL);
sbBasic->Add(CPUThread, 0, wxALL, 5);
@ -378,23 +388,23 @@ void CConfigMain::CreateGUIControls()
sbInterface->Add(ConfirmStop, 0, wxALL, 5);
sbInterface->Add(UsePanicHandlers, 0, wxALL, 5);
#if wxUSE_TIMER && defined _WIN32
wxBoxSizer *sHideCursor = new wxBoxSizer(wxHORIZONTAL);
sHideCursor->Add(HideCursorText);
sHideCursor->Add(AutoHideCursor, 0, wxLEFT, 5);
sHideCursor->Add(HideCursor, 0, wxLEFT, 5);
sbInterface->Add(sHideCursor, 0, wxALL, 5);
#endif
sbInterface->Add(Theme, 0, wxEXPAND | wxALL, 5);
wxBoxSizer *sInterfaceLanguage = new wxBoxSizer(wxHORIZONTAL);
sInterfaceLanguage->Add(InterfaceLangText, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5);
sInterfaceLanguage->Add(InterfaceLang, 0, wxEXPAND | wxALL, 5);
sbInterface->Add(sInterfaceLanguage, 0, wxEXPAND | wxALL, 5);
wxBoxSizer *sInterface = new wxBoxSizer(wxHORIZONTAL);
sInterface->Add(InterfaceLangText, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5);
sInterface->Add(InterfaceLang, 0, wxEXPAND | wxALL, 5);
sInterface->AddStretchSpacer();
sInterface->Add(HotkeyConfig, 0, wxALIGN_RIGHT | wxALL, 5);
sbInterface->Add(sInterface, 0, wxEXPAND | wxALL, 5);
sbDisplay->Add(Fullscreen, 0, wxEXPAND | wxALL, 5);
sbDisplay->Add(HideCursor, 0, wxALL, 5);
sbDisplay->Add(RenderToMain, 0, wxEXPAND | wxALL, 5);
// Populate the entire page
sGeneralPage = new wxBoxSizer(wxVERTICAL);
sGeneralPage->Add(sCore, 0, wxEXPAND | wxALL, 5);
sGeneralPage->Add(sbInterface, 0, wxEXPAND | wxALL, 5);
sGeneralPage->Add(sbDisplay, 0, wxEXPAND | wxALL, 5);
GeneralPage->SetSizer(sGeneralPage);
sGeneralPage->Layout();
@ -699,18 +709,6 @@ void CConfigMain::CoreSettingsChanged(wxCommandEvent& event)
SConfig::GetInstance().m_LocalCoreStartupParameter.bUsePanicHandlers = UsePanicHandlers->IsChecked();
SetEnableAlert(UsePanicHandlers->IsChecked());
break;
#if wxUSE_TIMER && defined _WIN32
case ID_INTERFACE_AUTOHIDECURSOR:
if (AutoHideCursor->IsChecked()) HideCursor->SetValue(!AutoHideCursor->IsChecked()); // Update the other one
SConfig::GetInstance().m_LocalCoreStartupParameter.bAutoHideCursor = AutoHideCursor->IsChecked();
SConfig::GetInstance().m_LocalCoreStartupParameter.bHideCursor = HideCursor->IsChecked();
break;
case ID_INTERFACE_HIDECURSOR:
if (HideCursor->IsChecked()) AutoHideCursor->SetValue(!HideCursor->IsChecked()); // Update the other one
SConfig::GetInstance().m_LocalCoreStartupParameter.bAutoHideCursor = AutoHideCursor->IsChecked();
SConfig::GetInstance().m_LocalCoreStartupParameter.bHideCursor = HideCursor->IsChecked();
break;
#endif
case ID_INTERFACE_THEME:
SConfig::GetInstance().m_LocalCoreStartupParameter.iTheme = Theme->GetSelection();
main_frame->InitBitmaps();
@ -719,6 +717,15 @@ void CConfigMain::CoreSettingsChanged(wxCommandEvent& event)
SConfig::GetInstance().m_InterfaceLanguage = (INTERFACE_LANGUAGE)InterfaceLang->GetSelection();
bRefreshList = true;
break;
case ID_HOTKEY_CONFIG:
{
HotkeyConfigDialog *m_HotkeyDialog = new HotkeyConfigDialog(this);
m_HotkeyDialog->ShowModal();
m_HotkeyDialog->Destroy();
// Update the GUI in case menu accelerators were changed
main_frame->UpdateGUI();
}
break;
case ID_FRAMELIMIT:
SConfig::GetInstance().m_Framelimit = (u32)Framelimit->GetSelection();
break;
@ -752,6 +759,15 @@ void CConfigMain::CoreSettingsChanged(wxCommandEvent& event)
case ID_ENABLECHEATS:
SConfig::GetInstance().m_LocalCoreStartupParameter.bEnableCheats = EnableCheats->IsChecked();
break;
case ID_DISPLAY_FULLSCREEN: // Display
SConfig::GetInstance().m_LocalCoreStartupParameter.bFullscreen = Fullscreen->IsChecked();
break;
case ID_DISPLAY_HIDECURSOR:
SConfig::GetInstance().m_LocalCoreStartupParameter.bHideCursor = HideCursor->IsChecked();
break;
case ID_DISPLAY_RENDERTOMAIN:
SConfig::GetInstance().m_LocalCoreStartupParameter.bRenderToMain = RenderToMain->IsChecked();
break;
}
}

View File

@ -49,15 +49,16 @@ private:
wxBoxSizer* sGeneralPage; // General Settings
wxCheckBox* ConfirmStop, *UsePanicHandlers;
#if wxUSE_TIMER && defined _WIN32
wxCheckBox* HideCursor, *AutoHideCursor;
#endif
wxCheckBox* HideCursor;
wxChoice* InterfaceLang;
wxChoice* Framelimit;
wxRadioBox* Theme;
wxCheckBox* Fullscreen;
wxCheckBox* RenderToMain;
wxButton* HotkeyConfig;
wxBoxSizer* sCore;
wxStaticBoxSizer* sbBasic, *sbAdvanced, *sbInterface;
wxStaticBoxSizer* sbBasic, *sbAdvanced, *sbInterface, *sbDisplay;
wxCheckBox* AlwaysHLE_BS2;
wxRadioButton* m_RadioInt;
wxRadioButton* m_RadioJIT;
@ -171,9 +172,10 @@ private:
ID_INTERFACE_CONFIRMSTOP, // Interface settings
ID_INTERFACE_USEPANICHANDLERS,
#if wxUSE_TIMER && defined _WIN32
ID_INTERFACE_HIDECURSOR_TEXT, ID_INTERFACE_HIDECURSOR, ID_INTERFACE_AUTOHIDECURSOR,
#endif
ID_DISPLAY_FULLSCREEN,
ID_DISPLAY_HIDECURSOR,
ID_DISPLAY_RENDERTOMAIN,
ID_HOTKEY_CONFIG,
ID_INTERFACE_LANG_TEXT, ID_INTERFACE_LANG,
ID_INTERFACE_THEME,
ID_FRAMELIMIT_TEXT, ID_FRAMELIMIT,

View File

@ -111,22 +111,6 @@ HWND MSWGetParent_(HWND Parent)
extern CFrame* main_frame;
class CPanel : public wxPanel
{
public:
CPanel(
wxWindow* parent,
wxWindowID id = wxID_ANY
);
private:
DECLARE_EVENT_TABLE();
#ifdef _WIN32
// Receive WndProc messages
WXLRESULT MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam);
#endif
};
BEGIN_EVENT_TABLE(CPanel, wxPanel)
END_EVENT_TABLE()
@ -158,12 +142,15 @@ CPanel::CPanel(
break;
case WM_USER_CREATE:
// We don't have a local setting for bRenderToMain but we can detect it this way instead
//PanicAlert("main call %i %i %i %i", lParam, (HWND)Core::GetWindowHandle(), MSWGetParent_((HWND)Core::GetWindowHandle()), (HWND)this->GetHWND());
if (lParam == NULL)
main_frame->bRenderToMain = false;
main_frame->DoFullscreen(SConfig::GetInstance().m_LocalCoreStartupParameter.bFullscreen);
break;
case WM_USER_SETCURSOR:
if (SConfig::GetInstance().m_LocalCoreStartupParameter.bHideCursor &&
main_frame->RendererHasFocus() && Core::GetState() == Core::CORE_RUN)
MSWSetCursor(!SConfig::GetInstance().m_LocalCoreStartupParameter.bHideCursor);
else
main_frame->bRenderToMain = true;
MSWSetCursor(true);
break;
case WIIMOTE_DISCONNECT:
@ -341,9 +328,6 @@ CFrame::CFrame(wxFrame* parent,
, UseDebugger(_UseDebugger), m_bEdit(false), m_bTabSplit(false), m_bNoDocking(false)
, m_bControlsCreated(false), m_StopDlg(NULL)
#if wxUSE_TIMER
#ifdef _WIN32
, m_fLastClickTime(0), m_iLastMotionTime(0), LastMouseX(0), LastMouseY(0)
#endif
, m_timer(this)
#endif
@ -473,10 +457,6 @@ CFrame::CFrame(wxFrame* parent,
// -------------------------
// Connect event handlers
wxTheApp->Connect(wxID_ANY, wxEVT_SIZE, // Keyboard
wxSizeEventHandler(CFrame::OnResizeAll),
(wxObject*)0, this);
wxTheApp->Connect(wxID_ANY, wxEVT_KEY_DOWN, // Keyboard
wxKeyEventHandler(CFrame::OnKeyDown),
(wxObject*)0, this);
@ -491,11 +471,6 @@ CFrame::CFrame(wxFrame* parent,
wxTheApp->Connect(wxID_ANY, wxEVT_LEFT_DCLICK,
wxMouseEventHandler(CFrame::OnDoubleClick),
(wxObject*)0, this);
#ifdef _WIN32
wxTheApp->Connect(wxID_ANY, wxEVT_MOTION,
wxMouseEventHandler(CFrame::OnMotion),
(wxObject*)0, this);
#endif
// ----------
// Update controls
@ -530,13 +505,23 @@ CFrame::~CFrame()
delete m_Mgr;
}
bool CFrame::RendererIsFullscreen()
{
if (Core::GetState() == Core::CORE_RUN || Core::GetState() == Core::CORE_PAUSE)
{
return m_RenderFrame->IsFullScreen();
}
return false;
}
void CFrame::OnQuit(wxCommandEvent& WXUNUSED (event))
{
Close(true);
}
#if defined HAVE_X11 && HAVE_X11
void CFrame::X11_SendClientEvent(const char *message)
void CFrame::X11_SendClientEvent(const char *message,
int data1, int data2, int data3, int data4)
{
XEvent event;
Display *dpy = (Display *)Core::GetWindowHandle();
@ -546,6 +531,10 @@ void CFrame::X11_SendClientEvent(const char *message)
event.xclient.type = ClientMessage;
event.xclient.format = 32;
event.xclient.data.l[0] = XInternAtom(dpy, message, False);
event.xclient.data.l[1] = data1;
event.xclient.data.l[2] = data2;
event.xclient.data.l[3] = data3;
event.xclient.data.l[4] = data4;
// Send the event
if (!XSendEvent(dpy, win, False, False, &event))
@ -560,7 +549,7 @@ void X11_SendKeyEvent(int key)
// Init X event structure for key press event
event.xkey.type = KeyPress;
// WARNING: This works for '3' to '7'. If in the future other keys are needed
// WARNING: This works for ASCII keys. If in the future other keys are needed
// convert with InputCommon::wxCharCodeWXToX from X11InputBase.cpp.
event.xkey.keycode = XKeysymToKeycode(dpy, key);
@ -574,15 +563,25 @@ void X11_SendKeyEvent(int key)
// Events
void CFrame::OnActive(wxActivateEvent& event)
{
#if defined(HAVE_X11) && HAVE_X11 && defined(HAVE_GTK2) && HAVE_GTK2 && defined(wxGTK)
if (Core::GetState() == Core::CORE_RUN || Core::GetState() == Core::CORE_PAUSE)
{
if (event.GetActive())
X11_SendClientEvent("FOCUSIN");
else
X11_SendClientEvent("FOCUSOUT");
}
if (event.GetActive() && event.GetEventObject() == m_RenderFrame)
{
#ifdef _WIN32
::SetFocus((HWND)m_RenderParent->GetHandle());
#else
m_RenderParent->SetFocus();
#endif
if (SConfig::GetInstance().m_LocalCoreStartupParameter.bHideCursor &&
Core::GetState() == Core::CORE_RUN)
m_RenderParent->SetCursor(wxCURSOR_BLANK);
}
else
{
if (SConfig::GetInstance().m_LocalCoreStartupParameter.bHideCursor)
m_RenderParent->SetCursor(wxCURSOR_ARROW);
}
}
event.Skip();
}
@ -601,7 +600,7 @@ void CFrame::OnClose(wxCloseEvent& event)
if (Core::GetState() != Core::CORE_UNINITIALIZED)
{
Core::Stop();
DoStop();
UpdateGUI();
}
}
@ -635,26 +634,23 @@ void CFrame::OnMove(wxMoveEvent& event)
{
event.Skip();
if (!IsMaximized() &&
!(SConfig::GetInstance().m_LocalCoreStartupParameter.bRenderToMain && RendererIsFullscreen()))
{
SConfig::GetInstance().m_LocalCoreStartupParameter.iPosX = GetPosition().x;
SConfig::GetInstance().m_LocalCoreStartupParameter.iPosY = GetPosition().y;
}
}
void CFrame::OnResize(wxSizeEvent& event)
{
event.Skip();
if (!IsMaximized() &&
!(SConfig::GetInstance().m_LocalCoreStartupParameter.bRenderToMain && RendererIsFullscreen()))
{
SConfig::GetInstance().m_LocalCoreStartupParameter.iWidth = GetSize().GetWidth();
SConfig::GetInstance().m_LocalCoreStartupParameter.iHeight = GetSize().GetHeight();
}
void CFrame::OnResizeAll(wxSizeEvent& event)
{
event.Skip();
#if defined(HAVE_X11) && HAVE_X11 && defined(HAVE_GTK2) && HAVE_GTK2 && defined(wxGTK)
if (Core::GetState() == Core::CORE_RUN || Core::GetState() == Core::CORE_PAUSE)
X11_SendClientEvent("RESIZE");
#endif
//wxWindow * Win = (wxWindow*)event.GetEventObject();
//NOTICE_LOG(CONSOLE, "OnResizeAll: %i", (HWND)Win->GetHWND());
}
}
// Host messages
@ -681,17 +677,14 @@ WXLRESULT CFrame::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam)
}
#endif
#if wxUSE_TIMER
void CFrame::OnTimer(wxTimerEvent& WXUNUSED(event))
{
#ifdef _WIN32
Update();
#else
// Process events in linux. Primarily to update the statusbar text.
// This should be unnecessary if we ever get WXGL and render to main working
// Process events. Primarily to update the statusbar text.
if (wxGetApp().Pending())
wxGetApp().ProcessPendingEvents();
#endif
}
#endif
void CFrame::OnHostMessage(wxCommandEvent& event)
{
@ -707,19 +700,16 @@ void CFrame::OnHostMessage(wxCommandEvent& event)
m_pStatusBar->SetStatusText(event.GetString(), event.GetInt());
}
break;
#if defined(HAVE_X11) && HAVE_X11
case WM_USER_CREATE:
bRenderToMain = true;
break;
case TOGGLE_FULLSCREEN:
DoFullscreen(!IsFullScreen());
DoFullscreen(SConfig::GetInstance().m_LocalCoreStartupParameter.bFullscreen);
if (SConfig::GetInstance().m_LocalCoreStartupParameter.bHideCursor)
m_RenderParent->SetCursor(wxCURSOR_BLANK);
break;
#if defined(HAVE_X11) && HAVE_X11
case WM_USER_STOP:
DoStop();
break;
case WM_USER_PAUSE:
DoPause();
break;
#endif
}
}
@ -755,6 +745,24 @@ void CFrame::OnCustomHostMessage(int Id)
}
}
void CFrame::OnSizeRequest(int& x, int& y, int& width, int& height)
{
m_RenderParent->GetSize(&width, &height);
m_RenderParent->GetPosition(&x, &y);
}
bool CFrame::RendererHasFocus()
{
#ifdef _WIN32
// Why doesn't the "else" method below work in windows when called from
// Host_RendererHasFocus()?
bRendererHasFocus = (m_RenderParent == wxWindow::FindFocus());
return bRendererHasFocus;
#else
return m_RenderParent == wxWindow::FindFocus();
#endif
}
void CFrame::OnGameListCtrl_ItemActivated(wxListEvent& WXUNUSED (event))
{
// Show all platforms and regions if...
@ -803,38 +811,68 @@ void CFrame::OnGameListCtrl_ItemActivated(wxListEvent& WXUNUSED (event))
StartGame(std::string(""));
}
bool IsHotkey(wxKeyEvent &event, int Id)
{
return (event.GetKeyCode() == SConfig::GetInstance().m_LocalCoreStartupParameter.iHotkey[Id] &&
event.GetModifiers() == SConfig::GetInstance().m_LocalCoreStartupParameter.iHotkeyModifier[Id]);
}
void CFrame::OnKeyDown(wxKeyEvent& event)
{
if(Core::GetState() != Core::CORE_UNINITIALIZED)
{
// Toggle fullscreen
if (event.GetKeyCode() == WXK_RETURN && event.GetModifiers() == wxMOD_ALT)
{
DoFullscreen(!IsFullScreen());
if (IsHotkey(event, HK_FULLSCREEN))
DoFullscreen(!RendererIsFullscreen());
// Pause and Unpause
else if (IsHotkey(event, HK_PLAY_PAUSE))
DoPause();
// Stop
else if (IsHotkey(event, HK_STOP))
DoStop();
// We do that to avoid the event to be double processed (which would cause the window to be stuck in fullscreen)
event.StopPropagation();
}
else if(event.GetKeyCode() == WXK_ESCAPE)
{
main_frame->DoPause();
}
// event.Skip() allows the event to propagate to the gamelist for example
else if (! (Core::GetState() == Core::CORE_RUN && bRenderToMain && event.GetEventObject() == this))
event.Skip();
if (event.GetKeyCode() >= '3' && event.GetKeyCode() <= '7') // Send this to the video plugin
// Send the OSD hotkeys to the video plugin
if (event.GetKeyCode() >= '3' && event.GetKeyCode() <= '7' && event.GetModifiers() == wxMOD_NONE)
{
#ifdef _WIN32
PostMessage((HWND)Core::GetWindowHandle(), WM_USER, WM_USER_KEYDOWN, event.GetKeyCode());
#elif defined(HAVE_X11) && HAVE_X11 && defined(HAVE_GTK2) && HAVE_GTK2 && defined(wxGTK)
#elif defined(HAVE_X11) && HAVE_X11
X11_SendKeyEvent(event.GetKeyCode());
#endif
}
#ifdef _WIN32
// Send the freelook hotkeys to the video plugin
if ((event.GetKeyCode() == '0', '9', 'W', 'S', 'A', 'D', 'R')
&& event.GetModifiers() == wxMOD_SHIFT)
PostMessage((HWND)Core::GetWindowHandle(), WM_USER, WM_USER_KEYDOWN, event.GetKeyCode());
#endif
// state save and state load hotkeys
if (event.GetKeyCode() >= WXK_F1 && event.GetKeyCode() <= WXK_F8)
{
int slot_number = event.GetKeyCode() - WXK_F1 + 1;
if (event.GetModifiers() == wxMOD_NONE)
State_Load(slot_number);
else if (event.GetModifiers() == wxMOD_SHIFT)
State_Save(slot_number);
}
if (event.GetKeyCode() == WXK_F11 && event.GetModifiers() == wxMOD_NONE)
State_LoadLastSaved();
if (event.GetKeyCode() == WXK_F12)
{
if (event.GetModifiers() == wxMOD_NONE)
State_UndoSaveState();
else if (event.GetModifiers() == wxMOD_SHIFT)
State_UndoLoadState();
}
// screenshot hotkeys
if (event.GetKeyCode() == WXK_F9 && event.GetModifiers() == wxMOD_NONE)
Core::ScreenShot();
// Send the keyboard status to the Input plugin
CPluginManager::GetInstance().GetPad(0)->PAD_Input(event.GetKeyCode(), 1); // 1 = Down
}
else
event.Skip();
}
void CFrame::OnKeyUp(wxKeyEvent& event)
@ -857,84 +895,12 @@ void CFrame::OnDoubleClick(wxMouseEvent& event)
if (SConfig::GetInstance().m_LocalCoreStartupParameter.bWii) return;
// Only detect double clicks in the rendering window, and only use this when a game is running
if (! (Core::GetState() == Core::CORE_RUN && bRenderToMain && event.GetEventObject() == m_Panel)) return;
if (! (Core::GetState() == Core::CORE_RUN && event.GetEventObject() == m_RenderParent)) return;
DoFullscreen(!IsFullScreen());
DoFullscreen(!RendererIsFullscreen());
}
// Check for mouse motion. Here we process the bHideCursor setting.
#if wxUSE_TIMER && defined _WIN32
void CFrame::OnMotion(wxMouseEvent& event)
{
event.Skip();
// The following is only interesting when a game is running
if(Core::GetState() == Core::CORE_UNINITIALIZED) return;
/* For some reason WM_MOUSEMOVE events are sent from the plugin even when there is no movement
so we have to check that the cursor position has actually changed */
if(bRenderToMain) //
{
bool PositionIdentical = false;
if (event.GetX() == LastMouseX && event.GetY() == LastMouseY) PositionIdentical = true;
LastMouseX = event.GetX(); LastMouseY = event.GetY();
if(PositionIdentical) return;
}
// Now we know that we have an actual mouse movement event
// Update motion for the auto hide option and return
if(IsFullScreen() && SConfig::GetInstance().m_LocalCoreStartupParameter.bAutoHideCursor)
{
m_iLastMotionTime = Common::Timer::GetDoubleTime();
MSWSetCursor(true);
return;
}
if(SConfig::GetInstance().m_LocalCoreStartupParameter.bHideCursor && event.GetId() == IDM_MPANEL)
{
if(bRenderToMain) MSWSetCursor(false);
/* We only need to use this if we are rendering to a separate window. It does work
for rendering to the main window to, but in that case our MSWSetCursor() works to
so we can use that instead. If we one day determine that the separate window
rendering is superfluous we could do without this */
else PostMessage((HWND)Core::GetWindowHandle(), WM_USER, 10, 0);
}
// For some reason we need this to, otherwise the cursor can get stuck with the resizing arrows
else
{
if(bRenderToMain) MSWSetCursor(true);
else PostMessage((HWND)Core::GetWindowHandle(), WM_USER, 10, 1);
}
}
#endif
// Check for mouse status a couple of times per second for the auto hide option
#if wxUSE_TIMER && defined _WIN32
void CFrame::Update()
{
// Check if auto hide is on, or if we are already hiding the cursor all the time
if(!SConfig::GetInstance().m_LocalCoreStartupParameter.bAutoHideCursor
|| SConfig::GetInstance().m_LocalCoreStartupParameter.bHideCursor) return;
if(IsFullScreen())
{
int HideDelay = 1; // Wait 1 second to hide the cursor, just like Windows Media Player
double TmpSeconds = Common::Timer::GetDoubleTime(); // Get timestamp
double CompareTime = TmpSeconds - HideDelay; // Compare it
if(m_iLastMotionTime < CompareTime) // Update cursor
MSWSetCursor(false);
}
}
#endif
// --------
// Functions
@ -986,10 +952,14 @@ void CFrame::DoFullscreen(bool bF)
// the main window to become unresponsive, so we have to avoid that.
if ((Core::GetState() == Core::CORE_RUN) || (Core::GetState() == Core::CORE_PAUSE))
{
if (bRenderToMain)
#if defined(HAVE_X11) && HAVE_X11
X11_SendClientEvent("TOGGLE_DISPLAYMODE", bF);
#elif defined(_WIN32)
PostMessage((HWND)Core::GetWindowHandle(), WM_USER, TOGGLE_DISPLAYMODE, bF);
#endif
m_RenderFrame->ShowFullScreen(bF);
if (SConfig::GetInstance().m_LocalCoreStartupParameter.bRenderToMain)
{
ShowFullScreen(bF);
if (bF)
{
// Save the current mode before going to fullscreen
@ -1001,25 +971,9 @@ void CFrame::DoFullscreen(bool bF)
// Restore saved perspective
m_Mgr->LoadPerspective(AuiCurrent, true);
}
#ifdef _WIN32
// Show the cursor again, in case it was hidden
if (IsFullScreen())
{
MSWSetCursor(true);
}
#endif
}
#ifdef _WIN32
else // Post the message to the separate rendering window which will then handle it.
{
BringWindowToTop((HWND)Core::GetWindowHandle());
PostMessage((HWND)Core::GetWindowHandle(), WM_USER, TOGGLE_FULLSCREEN, 0);
}
#elif defined HAVE_X11 && HAVE_X11
else // Send the event to the separate rendering window which will then handle it.
X11_SendClientEvent("TOGGLE_FULLSCREEN");
#endif
else
m_RenderFrame->Raise();
}
}

View File

@ -35,6 +35,10 @@
#include "CDUtils.h"
#include "CodeWindow.h"
#include "LogWindow.h"
#if defined(HAVE_X11) && HAVE_X11
#include <gtk/gtk.h>
#include <gdk/gdkx.h>
#endif
// A shortcut to access the bitmaps
#define wxGetBitmapFromMemory(name) _wxGetBitmapFromMemory(name, sizeof(name))
@ -48,6 +52,24 @@ inline wxBitmap _wxGetBitmapFromMemory(const unsigned char* data, int length)
class CGameListCtrl;
class CLogWindow;
// The CPanel class to receive MSWWindowProc messages from the video plugin.
class CPanel : public wxPanel
{
public:
CPanel(
wxWindow* parent,
wxWindowID id = wxID_ANY
);
private:
DECLARE_EVENT_TABLE();
#ifdef _WIN32
// Receive WndProc messages
WXLRESULT MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam);
#endif
};
class CFrame : public wxFrame
{
public:
@ -63,11 +85,11 @@ class CFrame : public wxFrame
void* GetRenderHandle()
{
#ifdef _WIN32
return(m_Panel->GetHandle());
return (void *)m_RenderParent->GetHandle();
#elif defined(HAVE_X11) && HAVE_X11
return m_Panel;
return (void *)GDK_WINDOW_XID(GTK_WIDGET(m_RenderParent->GetHandle())->window);
#else
return this;
return m_RenderParent;
#endif
}
@ -81,6 +103,9 @@ class CFrame : public wxFrame
void DoPause();
void DoStop();
bool bRenderToMain;
#ifdef _WIN32
bool bRendererHasFocus;
#endif
bool bNoWiimoteMsg;
void UpdateGUI();
void ToggleLogWindow(bool, int i = -1);
@ -91,7 +116,12 @@ class CFrame : public wxFrame
void StatusBarMessage(const char * Text, ...);
void ClearStatusBar();
void OnCustomHostMessage(int Id);
void OnSizeRequest(int& x, int& y, int& width, int& height);
void StartGame(const std::string& filename);
void OnRenderParentClose(wxCloseEvent& event);
void OnRenderParentMove(wxMoveEvent& event);
bool RendererHasFocus();
void DoFullscreen(bool _F);
// AUI
wxAuiManager *m_Mgr;
@ -118,6 +148,7 @@ class CFrame : public wxFrame
int PixelsToPercentage(int,int);
void ListChildren();
void ListTopWindows();
const wxChar * GetMenuLabel(int Id);
// Perspectives
void AddRemoveBlankPage();
@ -178,6 +209,8 @@ class CFrame : public wxFrame
wxBoxSizer* sizerFrame;
CGameListCtrl* m_GameListCtrl;
wxPanel* m_Panel;
wxFrame* m_RenderFrame;
wxPanel* m_RenderParent;
wxToolBarToolBase* m_ToolPlay;
CLogWindow* m_LogWindow;
bool UseDebugger;
@ -277,7 +310,6 @@ class CFrame : public wxFrame
void OnManagerResize(wxAuiManagerEvent& event);
void OnMove(wxMoveEvent& event);
void OnResize(wxSizeEvent& event);
void OnResizeAll(wxSizeEvent& event);
void OnToggleToolbar(wxCommandEvent& event);
void DoToggleToolbar(bool);
void OnToggleStatusbar(wxCommandEvent& event);
@ -286,7 +318,6 @@ class CFrame : public wxFrame
void OnKeyDown(wxKeyEvent& event);
void OnKeyUp(wxKeyEvent& event);
void OnDoubleClick(wxMouseEvent& event);
void OnMotion(wxMouseEvent& event);
void OnHostMessage(wxCommandEvent& event);
@ -302,9 +333,11 @@ class CFrame : public wxFrame
void GameListChanged(wxCommandEvent& event);
void OnGameListCtrl_ItemActivated(wxListEvent& event);
void DoFullscreen(bool _F);
void OnRenderParentResize(wxSizeEvent& event);
bool RendererIsFullscreen();
#if defined HAVE_X11 && HAVE_X11
void X11_SendClientEvent(const char *message);
void X11_SendClientEvent(const char *message,
int data1 = 0, int data2 = 0, int data3 = 0, int data4 = 0);
#endif
// MenuBar
@ -318,15 +351,8 @@ class CFrame : public wxFrame
void BootGame(const std::string& filename);
// Double click and mouse move options
#if wxUSE_TIMER
#ifdef _WIN32
double m_fLastClickTime, m_iLastMotionTime;
int LastMouseX, LastMouseY;
void Update();
#endif
// Used in linux to process command events
// Used to process command events
void OnTimer(wxTimerEvent& WXUNUSED(event));
wxTimer m_timer;
#endif

View File

@ -60,6 +60,7 @@ Core::GetWindowHandle().
#include "State.h"
#include "VolumeHandler.h"
#include "NANDContentLoader.h"
#include "WXInputBase.h"
#include <wx/datetime.h> // wxWidgets
@ -122,10 +123,12 @@ void CFrame::CreateMenu()
// Emulation menu
wxMenu* emulationMenu = new wxMenu;
emulationMenu->Append(IDM_PLAY, _T("&Play\tF10"));
emulationMenu->Append(IDM_STOP, _T("&Stop"));
emulationMenu->Append(IDM_PLAY, GetMenuLabel(HK_PLAY_PAUSE));
emulationMenu->Append(IDM_STOP, GetMenuLabel(HK_STOP));
emulationMenu->Append(IDM_RESET, _T("&Reset"));
emulationMenu->AppendSeparator();
emulationMenu->Append(IDM_TOGGLE_FULLSCREEN, GetMenuLabel(HK_FULLSCREEN));
emulationMenu->AppendSeparator();
emulationMenu->Append(IDM_RECORD, _T("Start Re&cording..."));
emulationMenu->Append(IDM_PLAYRECORD, _T("P&lay Recording..."));
emulationMenu->AppendSeparator();
@ -169,8 +172,6 @@ void CFrame::CreateMenu()
pOptionsMenu->Append(IDM_CONFIG_DSP_PLUGIN, _T("&DSP Settings"));
pOptionsMenu->Append(IDM_CONFIG_PAD_PLUGIN, _T("&Gamecube Pad Settings"));
pOptionsMenu->Append(IDM_CONFIG_WIIMOTE_PLUGIN, _T("&Wiimote Settings"));
pOptionsMenu->AppendSeparator();
pOptionsMenu->Append(IDM_TOGGLE_FULLSCREEN, _T("&Fullscreen\tAlt+Enter"));
if (g_pCodeWindow)
{
pOptionsMenu->AppendSeparator();
@ -269,7 +270,31 @@ void CFrame::CreateMenu()
SetMenuBar(m_MenuBar);
}
const wxChar * CFrame::GetMenuLabel(int Id)
{
wxString Label;
switch (Id)
{
case HK_FULLSCREEN:
Label = _T("&Fullscreen\t");
break;
case HK_PLAY_PAUSE:
if (Core::GetState() == Core::CORE_UNINITIALIZED)
Label = _T("&Play\t");
else
Label = _T("&Play\t");
break;
case HK_STOP:
Label = _T("&Stop\t");
}
wxString Modifier = InputCommon::WXKeymodToString
(SConfig::GetInstance().m_LocalCoreStartupParameter.iHotkeyModifier[Id]);
wxString Hotkey = InputCommon::WXKeyToString
(SConfig::GetInstance().m_LocalCoreStartupParameter.iHotkey[Id]);
return Label + Modifier + (Modifier.Len() ? _T("+") : _T("")) + Hotkey;
}
// Create toolbar items
@ -500,6 +525,8 @@ void CFrame::BootGame(const std::string& filename)
}
else
{
if (!SConfig::GetInstance().m_LocalCoreStartupParameter.bRenderToMain)
m_RenderFrame->Destroy();
m_GameListCtrl->BrowseForDirectory();
game_loading = false;
m_GameListCtrl->Enable();
@ -509,6 +536,8 @@ void CFrame::BootGame(const std::string& filename)
}
if (!success)
{
if (!SConfig::GetInstance().m_LocalCoreStartupParameter.bRenderToMain)
m_RenderFrame->Destroy();
game_loading = false;
m_GameListCtrl->Enable();
m_GameListCtrl->Show();
@ -641,6 +670,43 @@ void CFrame::OnPlay(wxCommandEvent& WXUNUSED (event))
StartGame(std::string(""));
}
void CFrame::OnRenderParentClose(wxCloseEvent& event)
{
if ((Core::GetState() == Core::CORE_RUN) || (Core::GetState() == Core::CORE_PAUSE))
DoStop();
event.Skip();
}
void CFrame::OnRenderParentMove(wxMoveEvent& event)
{
if (!RendererIsFullscreen() && !m_RenderFrame->IsMaximized())
{
SConfig::GetInstance().m_LocalCoreStartupParameter.iRenderWindowXPos = m_RenderFrame->GetPosition().x;
SConfig::GetInstance().m_LocalCoreStartupParameter.iRenderWindowYPos = m_RenderFrame->GetPosition().y;
}
event.Skip();
}
void CFrame::OnRenderParentResize(wxSizeEvent& event)
{
event.Skip();
if (Core::GetState() == Core::CORE_RUN || Core::GetState() == Core::CORE_PAUSE)
{
int x, y, width, height;
m_RenderParent->GetSize(&width, &height);
m_RenderParent->GetPosition(&x, &y);
if (!SConfig::GetInstance().m_LocalCoreStartupParameter.bRenderToMain &&
!RendererIsFullscreen() && !m_RenderFrame->IsMaximized())
{
SConfig::GetInstance().m_LocalCoreStartupParameter.iRenderWindowWidth = width;
SConfig::GetInstance().m_LocalCoreStartupParameter.iRenderWindowHeight = height;
}
#if defined(HAVE_X11) && HAVE_X11
X11_SendClientEvent("RESIZE", x, y, width, height);
#endif
}
}
// Prepare the GUI to start the game.
void CFrame::StartGame(const std::string& filename)
{
@ -657,6 +723,42 @@ void CFrame::StartGame(const std::string& filename)
m_GameListCtrl->Hide();
}
if (SConfig::GetInstance().m_LocalCoreStartupParameter.bRenderToMain)
{
m_RenderParent = m_Panel;
m_RenderFrame = this;
}
else
{
wxPoint position(SConfig::GetInstance().m_LocalCoreStartupParameter.iRenderWindowXPos,
SConfig::GetInstance().m_LocalCoreStartupParameter.iRenderWindowYPos);
wxSize size(SConfig::GetInstance().m_LocalCoreStartupParameter.iRenderWindowWidth,
SConfig::GetInstance().m_LocalCoreStartupParameter.iRenderWindowHeight);
m_RenderFrame = new wxFrame((wxWindow *)NULL, wxID_ANY, _("Dolphin"), position, size);
m_RenderFrame->Connect(wxID_ANY, wxEVT_CLOSE_WINDOW,
wxCloseEventHandler(CFrame::OnRenderParentClose),
(wxObject*)0, this);
m_RenderFrame->Connect(wxID_ANY, wxEVT_ACTIVATE,
wxActivateEventHandler(CFrame::OnActive),
(wxObject*)0, this);
m_RenderFrame->Connect(wxID_ANY, wxEVT_MOVE,
wxMoveEventHandler(CFrame::OnRenderParentMove),
(wxObject*)0, this);
m_RenderFrame->Connect(wxID_ANY, wxEVT_KEY_DOWN, // Keyboard
wxKeyEventHandler(CFrame::OnKeyDown),
(wxObject*)0, this);
m_RenderParent = new CPanel(m_RenderFrame, wxID_ANY);
m_RenderFrame->Show();
}
m_RenderFrame->Connect(wxID_ANY, wxEVT_SIZE,
wxSizeEventHandler(CFrame::OnRenderParentResize),
(wxObject*)0, this);
#ifdef _WIN32
::SetFocus((HWND)m_RenderParent->GetHandle());
#else
m_RenderParent->SetFocus();
#endif
BootGame(filename);
}
@ -689,17 +791,16 @@ void CFrame::DoPause()
{
if (Core::GetState() == Core::CORE_RUN)
{
#if defined(HAVE_X11) && HAVE_X11
X11_SendClientEvent("PAUSE");
#endif
Core::SetState(Core::CORE_PAUSE);
if (SConfig::GetInstance().m_LocalCoreStartupParameter.bHideCursor)
m_RenderParent->SetCursor(wxCURSOR_ARROW);
}
else
{
#if defined(HAVE_X11) && HAVE_X11
X11_SendClientEvent("RESUME");
#endif
Core::SetState(Core::CORE_RUN);
if (SConfig::GetInstance().m_LocalCoreStartupParameter.bHideCursor &&
RendererHasFocus())
m_RenderParent->SetCursor(wxCURSOR_BLANK);
}
UpdateGUI();
}
@ -739,6 +840,12 @@ void CFrame::DoStop()
Core::Stop();
UpdateGUI();
// Destroy the renderer frame when not rendering to main
if (SConfig::GetInstance().m_LocalCoreStartupParameter.bHideCursor)
m_RenderParent->SetCursor(wxCURSOR_ARROW);
if (!SConfig::GetInstance().m_LocalCoreStartupParameter.bRenderToMain)
m_RenderFrame->Destroy();
// Clean framerate indications from the status bar.
m_pStatusBar->SetStatusText(wxT(" "), 0);
}
@ -902,7 +1009,7 @@ void CFrame::OnConnectWiimote(wxCommandEvent& event)
// the entire screen (when we render to the main window).
void CFrame::OnToggleFullscreen(wxCommandEvent& WXUNUSED (event))
{
DoFullscreen(!IsFullScreen());
DoFullscreen(!RendererIsFullscreen());
}
void CFrame::OnToggleDualCore(wxCommandEvent& WXUNUSED (event))
@ -1014,6 +1121,7 @@ void CFrame::UpdateGUI()
m_ToolBar->EnableTool(wxID_OPEN, !Initialized);
m_ToolBar->EnableTool(wxID_REFRESH, !Initialized); // Don't allow refresh when we don't show the list
m_ToolBar->EnableTool(IDM_STOP, Running || Paused);
m_ToolBar->EnableTool(IDM_TOGGLE_FULLSCREEN, Running || Paused);
m_ToolBar->EnableTool(IDM_SCREENSHOT, Running || Paused);
}
@ -1030,6 +1138,12 @@ void CFrame::UpdateGUI()
GetMenuBar()->FindItem(IDM_PLAYRECORD)->Enable(!Initialized);
GetMenuBar()->FindItem(IDM_FRAMESTEP)->Enable(Running || Paused);
GetMenuBar()->FindItem(IDM_SCREENSHOT)->Enable(Running || Paused);
GetMenuBar()->FindItem(IDM_TOGGLE_FULLSCREEN)->Enable(Running || Paused);
// Update Menu Accelerators
GetMenuBar()->FindItem(IDM_TOGGLE_FULLSCREEN)->SetItemLabel(GetMenuLabel(HK_FULLSCREEN));
GetMenuBar()->FindItem(IDM_PLAY)->SetItemLabel(GetMenuLabel(HK_PLAY_PAUSE));
GetMenuBar()->FindItem(IDM_STOP)->SetItemLabel(GetMenuLabel(HK_STOP));
m_pSubMenuLoad->Enable(Initialized);
m_pSubMenuSave->Enable(Initialized);
@ -1059,7 +1173,6 @@ void CFrame::UpdateGUI()
m_ToolBar->SetToolShortHelp(IDM_PLAY, _("Pause"));
m_ToolBar->SetToolLabel(IDM_PLAY, _("Pause"));
}
GetMenuBar()->FindItem(IDM_PLAY)->SetText(_("&Pause\tF10"));
}
else
{
@ -1069,7 +1182,6 @@ void CFrame::UpdateGUI()
m_ToolBar->SetToolShortHelp(IDM_PLAY, _("Play"));
m_ToolBar->SetToolLabel(IDM_PLAY, wxT(" Play "));
}
GetMenuBar()->FindItem(IDM_PLAY)->SetText(_("&Play\tF10"));
}
if (!Initialized)

View File

@ -79,6 +79,7 @@ enum
IDM_PLAY,
IDM_STOP,
IDM_RESET,
IDM_TOGGLE_FULLSCREEN,
IDM_RECORD,
IDM_PLAYRECORD,
IDM_FRAMESTEP,
@ -123,7 +124,6 @@ enum
IDM_CONFIG_DSP_PLUGIN,
IDM_CONFIG_PAD_PLUGIN,
IDM_CONFIG_WIIMOTE_PLUGIN,
IDM_TOGGLE_FULLSCREEN,
// --------------------------------------------------------------
// Debugger Menu Entries

View File

@ -540,13 +540,13 @@ CFrame* DolphinApp::GetCFrame()
void Host_Message(int Id)
{
#if defined(HAVE_X11) && HAVE_X11
switch(Id)
{
case WM_USER_CREATE:
case TOGGLE_FULLSCREEN:
#if defined(HAVE_X11) && HAVE_X11
case WM_USER_STOP:
case WM_USER_PAUSE:
#endif
case WM_USER_CREATE:
{
wxCommandEvent event(wxEVT_HOST_COMMAND, Id);
main_frame->GetEventHandler()->AddPendingEvent(event);
@ -555,9 +555,6 @@ void Host_Message(int Id)
default:
main_frame->OnCustomHostMessage(Id);
}
#else
main_frame->OnCustomHostMessage(Id);
#endif
}
// OK, this thread boundary is DANGEROUS on linux
@ -631,18 +628,17 @@ void Host_UpdateMemoryView()
void Host_SetDebugMode(bool)
{}
void Host_RequestWindowSize(int& x, int& y, int& width, int& height)
{
main_frame->OnSizeRequest(x, y, width, height);
}
void Host_SetWaitCursor(bool enable)
{
#ifdef _WIN32
if (enable)
{
SetCursor(LoadCursor(NULL, IDC_WAIT));
}
wxBeginBusyCursor();
else
{
SetCursor(LoadCursor(NULL, IDC_ARROW));
}
#endif
wxEndBusyCursor();
}
void Host_UpdateStatusBar(const char* _pText, int Field)
@ -656,9 +652,6 @@ void Host_UpdateStatusBar(const char* _pText, int Field)
// TODO : this has been said to cause hang (??) how is that even possible ? :d
event.StopPropagation();
main_frame->GetEventHandler()->AddPendingEvent(event);
// Process the event before continue
if (wxGetApp().Pending())
wxGetApp().ProcessPendingEvents();
}
void Host_SetWiiMoteConnectionState(int _State)
@ -681,3 +674,12 @@ void Host_SetWiiMoteConnectionState(int _State)
main_frame->GetEventHandler()->AddPendingEvent(event);
}
bool Host_RendererHasFocus()
{
#ifdef _WIN32
return main_frame->bRendererHasFocus;
#else
return main_frame->RendererHasFocus();
#endif
}

View File

@ -34,6 +34,14 @@
#if defined HAVE_X11 && HAVE_X11
#include <X11/Xlib.h>
#include <X11/keysym.h>
#include "X11InputBase.h"
#include "State.h"
// EWMH state actions, see
// http://freedesktop.org/wiki/Specifications/wm-spec?action=show&redirect=Standards%2Fwm-spec
#define _NET_WM_STATE_REMOVE 0 /* remove/unset property */
#define _NET_WM_STATE_ADD 1 /* add/set property */
#define _NET_WM_STATE_TOGGLE 2 /* toggle property */
#endif
#if defined(HAVE_COCOA) && HAVE_COCOA
@ -54,12 +62,18 @@
#include "LogManager.h"
#include "BootManager.h"
#if defined HAVE_X11 && HAVE_X11
bool running = true;
bool rendererHasFocus = true;
#endif
void Host_NotifyMapLoaded(){}
void Host_ShowJitResults(unsigned int address){}
#if defined(HAVE_X11) && HAVE_X11
void X11_SendClientEvent(const char *message)
void X11_SendClientEvent(const char *message,
int data1 = 0, int data2 = 0, int data3 = 0, int data4 = 0)
{
XEvent event;
Display *dpy = (Display *)Core::GetWindowHandle();
@ -69,11 +83,38 @@ void X11_SendClientEvent(const char *message)
event.xclient.type = ClientMessage;
event.xclient.format = 32;
event.xclient.data.l[0] = XInternAtom(dpy, message, False);
event.xclient.data.l[1] = data1;
event.xclient.data.l[2] = data2;
event.xclient.data.l[3] = data3;
event.xclient.data.l[4] = data4;
// Send the event
if (!XSendEvent(dpy, win, False, False, &event))
ERROR_LOG(VIDEO, "Failed to send message %s to the emulator window.\n", message);
}
void X11_EWMH_Fullscreen(int action)
{
_assert_(action == _NET_WM_STATE_REMOVE || action == _NET_WM_STATE_ADD
|| action == _NET_WM_STATE_TOGGLE);
Display *dpy = (Display *)Core::GetWindowHandle();
Window win = *(Window *)Core::GetXWindow();
// Init X event structure for _NET_WM_STATE_FULLSCREEN client message
XEvent event;
event.xclient.type = ClientMessage;
event.xclient.message_type = XInternAtom(dpy, "_NET_WM_STATE", False);
event.xclient.window = win;
event.xclient.format = 32;
event.xclient.data.l[0] = action;
event.xclient.data.l[1] = XInternAtom(dpy, "_NET_WM_STATE_FULLSCREEN", False);
// Send the event
if (!XSendEvent(dpy, DefaultRootWindow(dpy), False,
SubstructureRedirectMask | SubstructureNotifyMask, &event))
ERROR_LOG(VIDEO, "Failed to switch fullscreen/windowed mode.\n");
}
#endif
Common::Event updateMainFrameEvent;
@ -83,19 +124,7 @@ void Host_Message(int Id)
switch (Id)
{
case WM_USER_STOP:
updateMainFrameEvent.Set();
break;
case WM_USER_PAUSE:
if (Core::GetState() == Core::CORE_RUN)
{
X11_SendClientEvent("PAUSE");
Core::SetState(Core::CORE_PAUSE);
}
else
{
X11_SendClientEvent("RESUME");
Core::SetState(Core::CORE_RUN);
}
running = false;
break;
}
#endif
@ -120,6 +149,18 @@ void Host_UpdateMemoryView(){}
void Host_SetDebugMode(bool){}
void Host_RequestWindowSize(int& x, int& y, int& width, int& height)
{
x = SConfig::GetInstance().m_LocalCoreStartupParameter.iRenderWindowXPos;
y = SConfig::GetInstance().m_LocalCoreStartupParameter.iRenderWindowYPos;
width = SConfig::GetInstance().m_LocalCoreStartupParameter.iRenderWindowWidth;
height = SConfig::GetInstance().m_LocalCoreStartupParameter.iRenderWindowHeight;
}
bool Host_RendererHasFocus()
{
return rendererHasFocus;
}
void Host_SetWaitCursor(bool enable){}
@ -279,9 +320,111 @@ int main(int argc, char* argv[])
if (BootManager::BootCore(bootFile)) //no use running the loop when booting fails
{
#if defined(HAVE_X11) && HAVE_X11
bool fullscreen = SConfig::GetInstance().m_LocalCoreStartupParameter.bFullscreen;
printf("gopt here\n");
while (Core::GetState() == Core::CORE_UNINITIALIZED)
updateMainFrameEvent.Wait();
updateMainFrameEvent.Wait();
Display *dpy = XOpenDisplay(0);
Window win = *(Window *)Core::GetXWindow();
XSelectInput(dpy, win, KeyPressMask | KeyReleaseMask | FocusChangeMask);
Cursor blankCursor = NULL;
if (SConfig::GetInstance().m_LocalCoreStartupParameter.bHideCursor)
{
// make a blank cursor
Pixmap Blank;
XColor DummyColor;
char ZeroData[1] = {0};
Blank = XCreateBitmapFromData (dpy, win, ZeroData, 1, 1);
blankCursor = XCreatePixmapCursor(dpy, Blank, Blank, &DummyColor, &DummyColor, 0, 0);
XFreePixmap (dpy, Blank);
XDefineCursor(dpy, win, blankCursor);
}
if (fullscreen)
{
X11_SendClientEvent("TOGGLE_DISPLAYMODE", fullscreen);
X11_EWMH_Fullscreen(_NET_WM_STATE_TOGGLE);
}
while (running)
{
XEvent event;
KeySym key;
for (int num_events = XPending(dpy); num_events > 0; num_events--)
{
XNextEvent(dpy, &event);
switch(event.type)
{
case KeyPress:
key = XLookupKeysym((XKeyEvent*)&event, 0);
if (key == XK_Escape)
{
if (Core::GetState() == Core::CORE_RUN)
{
if (SConfig::GetInstance().m_LocalCoreStartupParameter.bHideCursor)
XUndefineCursor(dpy, win);
Core::SetState(Core::CORE_PAUSE);
}
else
{
if (SConfig::GetInstance().m_LocalCoreStartupParameter.bHideCursor)
XDefineCursor(dpy, win, blankCursor);
Core::SetState(Core::CORE_RUN);
}
}
else if ((key == XK_Return) && (event.xkey.state & Mod1Mask))
{
fullscreen = !fullscreen;
X11_SendClientEvent("TOGGLE_DISPLAYMODE", fullscreen);
X11_EWMH_Fullscreen(_NET_WM_STATE_TOGGLE);
}
else if (key >= XK_F1 && key <= XK_F8)
{
int slot_number = key - XK_F1 + 1;
if (event.xkey.state & ShiftMask)
State_Save(slot_number);
else
State_Load(slot_number);
}
else if (key == XK_F9)
Core::ScreenShot();
else if (key == XK_F11)
State_LoadLastSaved();
else if (key == XK_F12)
{
if (event.xkey.state & ShiftMask)
State_UndoLoadState();
else
State_UndoSaveState();
}
break;
case FocusIn:
rendererHasFocus = true;
if (SConfig::GetInstance().m_LocalCoreStartupParameter.bHideCursor &&
Core::GetState() != Core::CORE_PAUSE)
XDefineCursor(dpy, win, blankCursor);
break;
case FocusOut:
rendererHasFocus = false;
if (SConfig::GetInstance().m_LocalCoreStartupParameter.bHideCursor)
XUndefineCursor(dpy, win);
break;
}
}
if (!fullscreen)
{
Window winDummy;
unsigned int borderDummy, depthDummy;
XGetGeometry(dpy, win, &winDummy,
&SConfig::GetInstance().m_LocalCoreStartupParameter.iRenderWindowXPos,
&SConfig::GetInstance().m_LocalCoreStartupParameter.iRenderWindowYPos,
(unsigned int *)&SConfig::GetInstance().m_LocalCoreStartupParameter.iRenderWindowWidth,
(unsigned int *)&SConfig::GetInstance().m_LocalCoreStartupParameter.iRenderWindowHeight,
&borderDummy, &depthDummy);
}
usleep(100000);
}
if (SConfig::GetInstance().m_LocalCoreStartupParameter.bHideCursor)
XFreeCursor(dpy, blankCursor);
XCloseDisplay(dpy);
Core::Stop();
#else
while (PowerPC::GetState() != PowerPC::CPU_POWERDOWN)

View File

@ -27,6 +27,7 @@ if wxenv['HAVE_WX']:
'LogWindow.cpp',
'GameListCtrl.cpp',
'Globals.cpp',
'HotkeyDlg.cpp',
'ISOFile.cpp',
'ISOProperties.cpp',
'MemcardManager.cpp',

View File

@ -448,6 +448,14 @@
RelativePath=".\Src\SDL_Util.h"
>
</File>
<File
RelativePath=".\Src\WXInputBase.cpp"
>
</File>
<File
RelativePath=".\Src\WXInputBase.h"
>
</File>
<File
RelativePath=".\Src\XInput_Util.cpp"
>

View File

@ -14,6 +14,11 @@ if env['HAVE_X11']:
"X11InputBase.cpp",
]
if env['HAVE_WX']:
files += [
"WXInputBase.cpp",
]
env_inputcommon = env.Clone()
env_inputcommon.Append(CXXFLAGS = [ '-fPIC' ])
env_inputcommon.StaticLibrary(env['local_libs'] + "inputcommon", files)

View File

@ -112,10 +112,16 @@ KeySym wxCharCodeWXToX(int id)
return keySym;
}
#else
KeySym wxCharCodeWXToX(int id)
int wxKeyModWXToX(int modstate)
{
return NULL;
int xstate = 0;
if (modstate & wxMOD_ALT)
xstate |= 8;
if (modstate & wxMOD_SHIFT)
xstate |= 1;
if (modstate & wxMOD_CONTROL)
xstate |= 4;
return xstate;
}
#endif
void XKeyToString(unsigned int keycode, char *keyStr) {

View File

@ -26,7 +26,10 @@
#endif
namespace InputCommon
{
#if defined(HAVE_WX) && HAVE_WX
KeySym wxCharCodeWXToX(int id);
int wxKeyModWXToX(int modstate);
#endif
void XKeyToString(unsigned int keycode, char *keyStr);
}
#endif

View File

@ -48,20 +48,15 @@ void VideoConfig::Load(const char *ini_file)
iniFile.Load(ini_file);
// get resolution
iniFile.Get("Hardware", "WindowedRes", &temp, "640x480");
strncpy(cInternalRes, temp.c_str(), 16);
iniFile.Get("Hardware", "FullscreenRes", &temp, "640x480");
strncpy(cFSResolution, temp.c_str(), 16);
iniFile.Get("Hardware", "Fullscreen", &bFullscreen, 0); // Hardware
iniFile.Get("Hardware", "VSync", &bVSync, 0); // Hardware
iniFile.Get("Hardware", "RenderToMainframe", &RenderToMainframe, false);
iniFile.Get("Settings", "StretchToFit", &bNativeResolution, true);
iniFile.Get("Settings", "2xResolution", &b2xResolution, false);
iniFile.Get("Settings", "wideScreenHack", &bWidescreenHack, false);
iniFile.Get("Settings", "AspectRatio", &iAspectRatio, (int)ASPECT_AUTO);
iniFile.Get("Settings", "Crop", &bCrop, false);
iniFile.Get("Settings", "HideCursor", &bHideCursor, false);
iniFile.Get("Settings", "UseXFB", &bUseXFB, 0);
iniFile.Get("Settings", "UseRealXFB", &bUseRealXFB, 0);
iniFile.Get("Settings", "AutoScale", &bAutoScale, true);
@ -156,17 +151,13 @@ void VideoConfig::Save(const char *ini_file)
{
IniFile iniFile;
iniFile.Load(ini_file);
iniFile.Set("Hardware", "WindowedRes", cInternalRes);
iniFile.Set("Hardware", "FullscreenRes", cFSResolution);
iniFile.Set("Hardware", "Fullscreen", bFullscreen);
iniFile.Set("Hardware", "VSync", bVSync);
iniFile.Set("Hardware", "RenderToMainframe", RenderToMainframe);
iniFile.Set("Settings", "StretchToFit", bNativeResolution);
iniFile.Set("Settings", "2xResolution", b2xResolution);
iniFile.Set("Settings", "AspectRatio", iAspectRatio);
iniFile.Set("Settings", "Crop", bCrop);
iniFile.Set("Settings", "wideScreenHack", bWidescreenHack);
iniFile.Set("Settings", "HideCursor", bHideCursor);
iniFile.Set("Settings", "UseXFB", bUseXFB);
iniFile.Set("Settings", "UseRealXFB", bUseRealXFB);
iniFile.Set("Settings", "AutoScale", bAutoScale);

View File

@ -67,14 +67,10 @@ struct VideoConfig
void UpdateProjectionHack();
// General
bool bFullscreen;
bool bHideCursor;
bool RenderToMainframe;
bool bVSync;
// Resolution control
char cFSResolution[16];
char cInternalRes[16];
bool bNativeResolution, b2xResolution, bRunning; // Should possibly be augmented with 2x, 4x native.
bool bWidescreenHack;

View File

@ -21,8 +21,10 @@ enum PLUGIN_COMM
WM_USER_PAUSE = 10,
WM_USER_STOP,
WM_USER_CREATE,
WM_USER_SETCURSOR,
WM_USER_KEYDOWN,
WM_USER_VIDEO_STOP,
TOGGLE_DISPLAYMODE,
TOGGLE_FULLSCREEN,
VIDEO_DESTROY, // The video debugging window was destroyed
AUDIO_DESTROY, // The audio debugging window was destroyed

View File

@ -30,17 +30,16 @@
#define PAD_BUTTON_START 0x1000
typedef void (*TLog)(const char* _pMessage);
typedef bool (*TRendererHasFocus)(void);
typedef struct
{
HWND hWnd;
#if defined HAVE_X11 && HAVE_X11
#if defined(HAVE_GTK2) && HAVE_GTK2
void *pPanel;
#endif
void *pXWindow;
#endif
TLog pLog;
TRendererHasFocus pRendererHasFocus;
} SPADInitialize;
typedef struct

View File

@ -18,11 +18,11 @@ typedef void (*TScheduleEvent_Threadsafe)(int cyclesIntoFuture, int e
typedef unsigned char* (*TGetMemoryPointer)(const unsigned int _iAddress);
typedef void (*TVideoLog)(const char* _pMessage, int _bBreak);
typedef void (*TSysMessage)(const char *fmt, ...);
typedef void (*TRequestWindowSize)(int _iWidth, int _iHeight, bool _bFullscreen);
typedef void (*TRequestWindowSize)(int& x, int& y, int& width, int& height);
typedef void (*TCopiedToXFB)(bool video_update);
typedef unsigned int (*TPeekMessages)(void);
typedef void (*TUpdateFPSDisplay)(const char* text); // sets the window title
typedef void (*TKeyPressed)(int keycode, bool shift, bool control); // passes keys to the hotkey function
typedef void (*TCoreMessage)(int Id); // passes message to the core
enum FieldType
{
@ -72,9 +72,6 @@ typedef struct
{
void *pWindowHandle;
#if defined(HAVE_X11) && HAVE_X11
#if defined(HAVE_GTK2) && HAVE_GTK2
void *pPanel;
#endif
void *pXWindow;
#endif
@ -88,7 +85,7 @@ typedef struct
TCopiedToXFB pCopiedToXFB;
TPeekMessages pPeekMessages;
TUpdateFPSDisplay pUpdateFPSDisplay;
TKeyPressed pKeyPress;
TCoreMessage pCoreMessage;
void *pMemoryBase;
bool bWii;
bool bOnThread;

View File

@ -14,20 +14,19 @@ typedef void (*TLogv)(const char* _pMessage, int _v);
// This is called when the Wiimote sends input reports to the Core.
// Payload: an L2CAP packet.
typedef void (*TWiimoteInput)(int _number, u16 _channelID, const void* _pData, u32 _Size);
typedef bool (*TRendererHasFocus)(void);
// This data is passed from the core on initialization.
typedef struct
{
HWND hWnd;
#if defined HAVE_X11 && HAVE_X11
#if defined(HAVE_GTK2) && HAVE_GTK2
void *pPanel;
#endif
void *pXWindow;
#endif
u32 ISOId;
TLogv pLog;
TWiimoteInput pWiimoteInput;
TRendererHasFocus pRendererHasFocus;
} SWiimoteInitialize;

View File

@ -647,26 +647,5 @@ bool IsKey(int Key)
// ----------------
bool IsFocus()
{
#ifdef _WIN32
HWND RenderingWindow = (g_PADInitialize) ? g_PADInitialize->hWnd : NULL;
HWND Parent = GetParent(RenderingWindow);
HWND TopLevel = GetParent(Parent);
if (GetForegroundWindow() == TopLevel || GetForegroundWindow() == RenderingWindow)
return true;
else
return false;
#elif defined HAVE_X11 && HAVE_X11
Window GLWin = *(Window *)g_PADInitialize->pXWindow;
bool bFocus = False;
#if defined(HAVE_GTK2) && HAVE_GTK2 && defined(wxGTK)
bFocus = (wxPanel *)g_PADInitialize->pPanel == wxWindow::FindFocus();
#endif
Window FocusWin;
int Revert;
XGetInputFocus(GCdisplay, &FocusWin, &Revert);
return (GLWin == FocusWin || bFocus);
#else
return true;
#endif
return g_PADInitialize->pRendererHasFocus();
}

View File

@ -148,7 +148,7 @@ extern std::vector<InputCommon::CONTROLLER_INFO> joyinfo;
extern HWND m_hWnd; // Handle to window
#endif
#if defined(HAVE_X11) && HAVE_X11
extern Display* WMdisplay;
extern Display* GCdisplay;
#endif

View File

@ -44,29 +44,7 @@ SPADInitialize *g_PADInitialize = NULL;
// ----------------
bool IsFocus()
{
#ifdef _WIN32
HWND RenderingWindow = (g_PADInitialize) ? g_PADInitialize->hWnd : NULL;
HWND Parent = GetParent(RenderingWindow);
HWND TopLevel = GetParent(Parent);
if (GetForegroundWindow() == TopLevel || GetForegroundWindow() == RenderingWindow)
return true;
else
return false;
#elif defined HAVE_X11 && HAVE_X11
Display* GCdisplay = (Display*)g_PADInitialize->hWnd;
Window GLWin = *(Window *)g_PADInitialize->pXWindow;
bool bFocus = False;
#if defined(HAVE_GTK2) && HAVE_GTK2 && defined(wxGTK)
bFocus = (wxPanel *)g_PADInitialize->pPanel == wxWindow::FindFocus();
#endif
Window FocusWin;
int Revert;
XGetInputFocus(GCdisplay, &FocusWin, &Revert);
return (GLWin == FocusWin || bFocus);
#else
return true;
#endif
return g_PADInitialize->pRendererHasFocus();
}
// copied from GCPad

View File

@ -30,8 +30,6 @@ LPDIRECT3DSURFACE9 back_buffer_z;
D3DCAPS9 caps;
HWND hWnd;
static bool fullScreen = false;
static bool nextFullScreen = false;
static int multisample;
static int resolution;
static int xres, yres;
@ -130,15 +128,7 @@ void InitPP(int adapter, int f, int aa_mode, D3DPRESENT_PARAMETERS *pp)
pp->MultiSampleQuality = adapters[adapter].aa_levels[aa_mode].qual_setting;
pp->Flags = auto_depth_stencil ? D3DPRESENTFLAG_DISCARD_DEPTHSTENCIL : 0;
if (fullScreen)
{
xres = pp->BackBufferWidth = FSResX;
yres = pp->BackBufferHeight = FSResY;
pp->SwapEffect = D3DSWAPEFFECT_DISCARD;
pp->Windowed = FALSE;
}
else
{
RECT client;
GetClientRect(hWnd, &client);
xres = pp->BackBufferWidth = client.right - client.left;
@ -146,7 +136,6 @@ void InitPP(int adapter, int f, int aa_mode, D3DPRESENT_PARAMETERS *pp)
pp->SwapEffect = D3DSWAPEFFECT_DISCARD;
pp->PresentationInterval = g_Config.bVSync ? D3DPRESENT_INTERVAL_DEFAULT : D3DPRESENT_INTERVAL_IMMEDIATE;
pp->Windowed = TRUE;
}
}
void Enumerate()
@ -265,11 +254,9 @@ void Enumerate()
}
}
HRESULT Create(int adapter, HWND wnd, bool _fullscreen, int _resolution, int aa_mode, bool auto_depth)
HRESULT Create(int adapter, HWND wnd, int _resolution, int aa_mode, bool auto_depth)
{
hWnd = wnd;
fullScreen = _fullscreen;
nextFullScreen = _fullscreen;
multisample = aa_mode;
resolution = _resolution;
auto_depth_stencil = auto_depth;
@ -401,11 +388,6 @@ void Reset()
}
}
bool IsFullscreen()
{
return fullScreen;
}
int GetBackBufferWidth()
{
return xres;
@ -416,11 +398,6 @@ int GetBackBufferHeight()
return yres;
}
void SwitchFullscreen(bool fullscreen)
{
nextFullScreen = fullscreen;
}
bool BeginFrame()
{
if (bFrameInProgress)
@ -455,12 +432,6 @@ void Present()
{
dev->Present(NULL, NULL, NULL, NULL);
}
if (fullScreen != nextFullScreen)
{
fullScreen = nextFullScreen;
Reset();
}
}
void ApplyCachedState()

View File

@ -46,7 +46,7 @@ namespace D3D
bool IsATIDevice();
HRESULT Init();
HRESULT Create(int adapter, HWND wnd, bool fullscreen, int resolution, int aa_mode, bool auto_depth);
HRESULT Create(int adapter, HWND wnd, int resolution, int aa_mode, bool auto_depth);
void Close();
void Shutdown();
@ -58,8 +58,6 @@ void Reset();
bool BeginFrame();
void EndFrame();
void Present();
void SwitchFullscreen(bool fullscreen);
bool IsFullscreen();
bool CanUseINTZ();
int GetBackBufferWidth();

View File

@ -77,7 +77,6 @@ struct TabDirect3D : public W32Util::Tab
const D3D::Resolution &r = adapter.resolutions[i];
MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, r.name, -1, tempwstr, 2000);
ComboBox_AddString(GetDlgItem(hDlg, IDC_RESOLUTION), tempwstr);
ComboBox_AddString(GetDlgItem(hDlg, IDC_RESOLUTIONWINDOWED),tempwstr);
}
for (int i = 0; i < 16; i++) {
@ -85,14 +84,7 @@ struct TabDirect3D : public W32Util::Tab
}
ComboBox_SelectString(GetDlgItem(hDlg,IDC_RESOLUTION), -1, tempwstr);
for (int i = 0; i < 16; i++) {
tempwstr[i] = g_Config.cInternalRes[i];
}
ComboBox_SelectString(GetDlgItem(hDlg,IDC_RESOLUTIONWINDOWED), -1, tempwstr);
Button_SetCheck(GetDlgItem(hDlg, IDC_FULLSCREENENABLE), g_Config.bFullscreen);
Button_SetCheck(GetDlgItem(hDlg, IDC_VSYNC), g_Config.bVSync);
Button_SetCheck(GetDlgItem(hDlg, IDC_RENDER_TO_MAINWINDOW), g_Config.RenderToMainframe);
Button_SetCheck(GetDlgItem(hDlg, IDC_WIDESCREEN_HACK), g_Config.bWidescreenHack);
Button_SetCheck(GetDlgItem(hDlg, IDC_SAFE_TEXTURE_CACHE), g_Config.bSafeTextureCache);
@ -116,7 +108,6 @@ struct TabDirect3D : public W32Util::Tab
Button_Enable(GetDlgItem(hDlg, IDC_SAFE_TEXTURE_CACHE_FAST),g_Config.bSafeTextureCache);
Button_SetCheck(GetDlgItem(hDlg, IDC_EFB_ACCESS_ENABLE), g_Config.bEFBAccessEnable);
Button_GetCheck(GetDlgItem(hDlg,IDC_RENDER_TO_MAINWINDOW)) ? Button_Enable(GetDlgItem(hDlg,IDC_FULLSCREENENABLE), false) : Button_Enable(GetDlgItem(hDlg,IDC_FULLSCREENENABLE), true);
}
void Command(HWND hDlg,WPARAM wParam)
@ -138,11 +129,6 @@ struct TabDirect3D : public W32Util::Tab
case IDC_EFB_ACCESS_ENABLE:
g_Config.bEFBAccessEnable = Button_GetCheck(GetDlgItem(hDlg, IDC_EFB_ACCESS_ENABLE)) == 0 ? false : true;
break;
case IDC_RENDER_TO_MAINWINDOW:
Button_Enable(GetDlgItem(hDlg, IDC_FULLSCREENENABLE), !Button_GetCheck(GetDlgItem(hDlg, IDC_RENDER_TO_MAINWINDOW)));
if (Button_GetCheck(GetDlgItem(hDlg, IDC_RENDER_TO_MAINWINDOW)))
Button_SetCheck(GetDlgItem(hDlg, IDC_FULLSCREENENABLE), false);
break;
default:
break;
}
@ -150,14 +136,11 @@ struct TabDirect3D : public W32Util::Tab
void Apply(HWND hDlg)
{
ComboBox_GetTextA(GetDlgItem(hDlg, IDC_RESOLUTIONWINDOWED), g_Config.cInternalRes, 16);
ComboBox_GetTextA(GetDlgItem(hDlg, IDC_RESOLUTION), g_Config.cFSResolution, 16);
g_Config.iAdapter = ComboBox_GetCurSel(GetDlgItem(hDlg, IDC_ADAPTER));
g_Config.iMultisampleMode = ComboBox_GetCurSel(GetDlgItem(hDlg, IDC_ANTIALIASMODE));
g_Config.bFullscreen = Button_GetCheck(GetDlgItem(hDlg, IDC_FULLSCREENENABLE)) ? true : false;
g_Config.bVSync = Button_GetCheck(GetDlgItem(hDlg, IDC_VSYNC)) ? true : false;
g_Config.RenderToMainframe = Button_GetCheck(GetDlgItem(hDlg, IDC_RENDER_TO_MAINWINDOW)) ? true : false;
if(Button_GetCheck(GetDlgItem(hDlg, IDC_SAFE_TEXTURE_CACHE_SAFE)))
{
g_Config.iSafeTextureCache_ColorSamples = 0;

View File

@ -29,7 +29,6 @@ int OSDChoice = 0 , OSDTime = 0, OSDInternalW = 0, OSDInternalH = 0;
namespace EmuWindow
{
HWND m_hWnd = NULL;
HWND m_hMain = NULL;
HWND m_hParent = NULL;
HINSTANCE m_hInstance = NULL;
WNDCLASSEX wndClass;
@ -37,20 +36,6 @@ const TCHAR m_szClassName[] = _T("DolphinEmuWnd");
int g_winstyle;
static volatile bool s_sizing;
// ---------------------------------------------------------------------
/* Invisible cursor option. In the lack of a predefined IDC_BLANK we make
an empty transparent cursor */
// ------------------
HCURSOR hCursor = NULL, hCursorBlank = NULL;
void CreateCursors(HINSTANCE hInstance)
{
BYTE ANDmaskCursor[] = { 0xff };
BYTE XORmaskCursor[] = { 0x00 };
hCursorBlank = CreateCursor(hInstance, 0,0, 1,1, ANDmaskCursor,XORmaskCursor);
hCursor = LoadCursor(NULL, IDC_ARROW);
}
bool IsSizing()
{
return s_sizing;
@ -66,13 +51,50 @@ HWND GetParentWnd()
return m_hParent;
}
// ---------------------------------------------------------------------
// KeyDown events
// -------------
void OnKeyDown(WPARAM wParam)
{
switch (LOWORD( wParam ))
{
case '3': // OSD keys
case '4':
case '5':
case '6':
case '7':
if (g_Config.bOSDHotKey)
OSDMenu(wParam);
break;
}
}
// ---------------------------------------------------------------------
void ToggleDisplayMode (int bFullscreen)
{
if (bFullscreen)
{
DEVMODE dmScreenSettings;
memset(&dmScreenSettings,0,sizeof(dmScreenSettings));
dmScreenSettings.dmSize = sizeof(dmScreenSettings);
sscanf(g_Config.cFSResolution, "%dx%d", &dmScreenSettings.dmPelsWidth, &dmScreenSettings.dmPelsHeight);
dmScreenSettings.dmBitsPerPel = 32;
dmScreenSettings.dmFields = DM_BITSPERPEL|DM_PELSWIDTH|DM_PELSHEIGHT;
// Try To Set Selected Mode And Get Results. NOTE: CDS_FULLSCREEN Gets Rid Of Start Bar.
ChangeDisplaySettings(&dmScreenSettings, CDS_FULLSCREEN);
}
else
{
// Change to default resolution
ChangeDisplaySettings(NULL, CDS_FULLSCREEN);
}
}
LRESULT CALLBACK WndProc( HWND hWnd, UINT iMsg, WPARAM wParam, LPARAM lParam )
{
switch( iMsg )
{
case WM_CREATE:
PostMessage( m_hMain, WM_USER, WM_USER_CREATE, g_Config.RenderToMainframe );
break;
case WM_PAINT:
{
HDC hdc;
@ -90,51 +112,6 @@ LRESULT CALLBACK WndProc( HWND hWnd, UINT iMsg, WPARAM wParam, LPARAM lParam )
s_sizing = false;
break;
case WM_KEYDOWN:
switch (LOWORD(wParam))
{
case VK_ESCAPE:
if(!g_Config.RenderToMainframe)
{
if (g_Config.bFullscreen)
{
// Pressing Esc switches to Windowed mode from Fullscreen mode
ToggleFullscreen(hWnd);
}
// And pauses the emulation when already in Windowed mode
PostMessage(m_hMain, WM_USER, WM_USER_PAUSE, 0);
}
break;
case '3': // OSD keys
case '4':
case '5':
case '6':
case '7':
if (g_Config.bOSDHotKey)
OSDMenu(wParam);
break;
}
// Tell the hotkey function that this key was pressed
g_VideoInitialize.pKeyPress(LOWORD(wParam), GetAsyncKeyState(VK_SHIFT) != 0, GetAsyncKeyState(VK_CONTROL) != 0);
break;
case WM_SYSKEYDOWN:
switch (LOWORD( wParam ))
{
case VK_RETURN: // Pressing Alt+Enter switch FullScreen/Windowed
if (m_hParent == NULL && !g_Config.RenderToMainframe)
{
ToggleFullscreen(hWnd);
}
break;
case VK_F5: case VK_F6: case VK_F7: case VK_F8:
PostMessage(m_hMain, WM_SYSKEYDOWN, wParam, lParam);
break;
default:
return DefWindowProc(hWnd, iMsg, wParam, lParam);
}
break;
/* Post thes mouse events to the main window, it's nessesary because in difference to the
keyboard inputs these events only appear here, not in the parent window or any other WndProc()*/
case WM_LBUTTONDOWN:
@ -146,25 +123,17 @@ LRESULT CALLBACK WndProc( HWND hWnd, UINT iMsg, WPARAM wParam, LPARAM lParam )
case WM_CLOSE:
// When the user closes the window, we post an event to the main window to call Stop()
// Which then handles all the necessary steps to Shutdown the core + the plugins
if (!g_Config.RenderToMainframe)
{
PostMessage(m_hMain, WM_USER, WM_USER_STOP, 0);
}
if (m_hParent == NULL)
PostMessage(m_hParent, WM_USER, WM_USER_STOP, 0);
break;
case WM_USER:
if (wParam == WM_USER_STOP)
{
SetCursor((lParam) ? hCursor : hCursorBlank);
}
else if (wParam == TOGGLE_FULLSCREEN)
{
ToggleFullscreen(hWnd);
}
if (wParam == WM_USER_KEYDOWN)
OnKeyDown(lParam);
else if (wParam == WIIMOTE_DISCONNECT)
{
PostMessage(m_hMain, WM_USER, wParam, lParam);
}
PostMessage(m_hParent, WM_USER, wParam, lParam);
else if (wParam == TOGGLE_DISPLAYMODE)
ToggleDisplayMode(lParam);
break;
case WM_SYSCOMMAND:
@ -177,6 +146,10 @@ LRESULT CALLBACK WndProc( HWND hWnd, UINT iMsg, WPARAM wParam, LPARAM lParam )
return DefWindowProc(hWnd, iMsg, wParam, lParam);
}
break;
case WM_SETCURSOR:
PostMessage(m_hParent, WM_USER, WM_USER_SETCURSOR, 0);
return true;
break;
default:
return DefWindowProc(hWnd, iMsg, wParam, lParam);
}
@ -244,8 +217,6 @@ HWND OpenWindow(HWND parent, HINSTANCE hInstance, int width, int height, const T
wndClass.cbWndExtra = 0;
wndClass.hInstance = hInstance;
wndClass.hIcon = LoadIcon( NULL, IDI_APPLICATION );
// To interfer less with SetCursor() later we set this to NULL
//wndClass.hCursor = LoadCursor( NULL, IDC_ARROW );
wndClass.hCursor = NULL;
wndClass.hbrBackground = (HBRUSH)GetStockObject( BLACK_BRUSH );
wndClass.lpszMenuName = NULL;
@ -255,35 +226,10 @@ HWND OpenWindow(HWND parent, HINSTANCE hInstance, int width, int height, const T
m_hInstance = hInstance;
RegisterClassEx( &wndClass );
CreateCursors(m_hInstance);
if (g_Config.RenderToMainframe)
{
m_hParent = m_hMain = parent;
m_hParent = parent;
m_hWnd = CreateWindow(m_szClassName, title, WS_CHILD,
0, 0, width, height, m_hParent, NULL, hInstance, NULL);
}
else
{
m_hMain = parent;
m_hParent = NULL;
DWORD style = WS_OVERLAPPEDWINDOW;
RECT rc = {0, 0, width, height};
AdjustWindowRect(&rc, style, false);
RECT rcdesktop;
GetWindowRect(GetDesktopWindow(), &rcdesktop);
int X = (rcdesktop.right-rcdesktop.left)/2 - (rc.right-rc.left)/2;
int Y = (rcdesktop.bottom-rcdesktop.top)/2 - (rc.bottom-rc.top)/2;
m_hWnd = CreateWindow(m_szClassName, title, style,
X, Y, rc.right-rc.left, rc.bottom-rc.top,
NULL, NULL, hInstance, NULL);
}
return m_hWnd;
}
@ -293,6 +239,7 @@ void Show()
ShowWindow(m_hWnd, SW_SHOW);
BringWindowToTop(m_hWnd);
UpdateWindow(m_hWnd);
SetFocus(m_hParent);
}
HWND Create(HWND hParent, HINSTANCE hInstance, const TCHAR *title)
@ -301,16 +248,13 @@ HWND Create(HWND hParent, HINSTANCE hInstance, const TCHAR *title)
// 1. Remove redundant window manipulation,
// 2. Make DX9 in fullscreen can be overlapped by other dialogs
HWND Ret;
int width=640, height=480;
sscanf(g_Config.cInternalRes, "%dx%d", &width, &height );
int x=0, y=0, width=640, height=480;
g_VideoInitialize.pRequestWindowSize(x, y, width, height);
Ret = OpenWindow(hParent, hInstance, width, height, title);
if (Ret)
{
if (g_Config.bFullscreen)
ToggleFullscreen(Ret, true);
else
Show();
}
return Ret;
@ -318,11 +262,9 @@ HWND Create(HWND hParent, HINSTANCE hInstance, const TCHAR *title)
void Close()
{
if (m_hWnd && !g_Config.RenderToMainframe)
{
if (m_hParent == NULL)
DestroyWindow(m_hWnd);
UnregisterClass(m_szClassName, m_hInstance);
}
}
void SetSize(int width, int height)
@ -341,77 +283,4 @@ void SetSize(int width, int height)
MoveWindow(m_hWnd, rc.left, rc.top, rc.right-rc.left, rc.bottom-rc.top, TRUE);
}
void ToggleFullscreen(HWND hParent, bool bForceFull)
{
if (m_hParent == NULL)
{
if (D3D::IsFullscreen())
{
PostMessage( m_hMain, WM_USER, WM_USER_STOP, 0 );
return;
}
int w_fs = 640, h_fs = 480;
if (!g_Config.bFullscreen || bForceFull)
{
if (strlen(g_Config.cFSResolution) > 1)
sscanf(g_Config.cFSResolution, "%dx%d", &w_fs, &h_fs);
// Get into fullscreen
DEVMODE dmScreenSettings;
memset(&dmScreenSettings, 0, sizeof(dmScreenSettings));
// Desktop -> FullScreen
dmScreenSettings.dmSize = sizeof(dmScreenSettings);
dmScreenSettings.dmPelsWidth = w_fs;
dmScreenSettings.dmPelsHeight = h_fs;
dmScreenSettings.dmFields = DM_PELSWIDTH|DM_PELSHEIGHT;
if (ChangeDisplaySettings(&dmScreenSettings, CDS_FULLSCREEN) != DISP_CHANGE_SUCCESSFUL)
return;
// Set new window style -> PopUp
SetWindowLong(hParent, GWL_STYLE, WS_POPUP);
// SetWindowPos to the upper-left corner of the screen
SetWindowPos(hParent, HWND_TOP, 0, 0, w_fs, h_fs, SWP_NOREPOSITION);
// Disable the cursor
ShowCursor(FALSE);
g_Config.bFullscreen = true;
// Eventually show the window!
EmuWindow::Show();
}
else
{
if (strlen(g_Config.cInternalRes) > 1)
sscanf(g_Config.cInternalRes, "%dx%d", &w_fs, &h_fs);
// FullScreen - > Desktop
ChangeDisplaySettings(NULL, 0);
DWORD style = WS_OVERLAPPEDWINDOW;
RECT rc = {0, 0, w_fs, h_fs};
AdjustWindowRect(&rc, style, false);
RECT rcdesktop;
GetWindowRect(GetDesktopWindow(), &rcdesktop);
// SetWindowPos to the center of the screen
int X = (rcdesktop.right-rcdesktop.left)/2 - (rc.right-rc.left)/2;
int Y = (rcdesktop.bottom-rcdesktop.top)/2 - (rc.bottom-rc.top)/2;
SetWindowPos(hParent, NULL, X, Y, rc.right-rc.left, rc.bottom-rc.top, SWP_NOREPOSITION | SWP_NOZORDER);
// Set new window style FS -> Windowed
SetWindowLong(hParent, GWL_STYLE, style);
// Re-Enable the cursor
ShowCursor(TRUE);
g_Config.bFullscreen = false;
// Eventually show the window!
EmuWindow::Show();
}
}
}
}

View File

@ -12,9 +12,9 @@ HWND Create(HWND hParent, HINSTANCE hInstance, const TCHAR *title);
void Show();
void Close();
void SetSize(int displayWidth, int displayHeight);
void ToggleFullscreen(HWND hParent, bool bForceFull = false);
bool IsSizing();
void OSDMenu(WPARAM wParam);
void ToggleDisplayMode (int bFullscreen);
}

View File

@ -280,7 +280,7 @@ bool Renderer::Init()
if (fullScreenRes == D3D::GetAdapter(g_ActiveConfig.iAdapter).resolutions.size())
fullScreenRes = 0;
D3D::Create(g_ActiveConfig.iAdapter, EmuWindow::GetWnd(), false,
D3D::Create(g_ActiveConfig.iAdapter, EmuWindow::GetWnd(),
fullScreenRes, backbuffer_ms_mode, false);
IS_AMD = D3D::IsATIDevice();

View File

@ -284,6 +284,7 @@ void Shutdown()
OpcodeDecoder_Shutdown();
Renderer::Shutdown();
D3D::Shutdown();
EmuWindow::ToggleDisplayMode(false);
EmuWindow::Close();
s_PluginInitialized = false;
}

View File

@ -9,10 +9,7 @@
#define IDC_ADAPTER 1001
#define IDC_ANTIALIASMODE 1002
#define IDC_RESOLUTION 1003
#define IDC_RESOLUTIONWINDOWED 1004
#define IDC_FULLSCREENENABLE 1005
#define IDC_VSYNC 1006
#define IDC_RENDER_TO_MAINWINDOW 1007
#define IDC_ASPECT_16_9 1008
#define IDC_ASPECT_4_3 1009
#define IDC_WIDESCREEN_HACK 1010

View File

@ -42,25 +42,20 @@ FONT 8, "MS Shell Dlg", 0, 0, 0x0
BEGIN
LTEXT "&Graphics card:",IDC_STATIC,9,9,49,8
COMBOBOX IDC_ADAPTER,68,7,162,48,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
CONTROL "&Fullscreen",IDC_FULLSCREENENABLE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,68,25,44,8
CONTROL "&V-Sync",IDC_VSYNC,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,114,25,36,8
CONTROL "&Render to main window",IDC_RENDER_TO_MAINWINDOW,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,150,25,87,8
LTEXT "&Windowed",IDC_STATIC,14,89,40,8
COMBOBOX IDC_RESOLUTIONWINDOWED,68,87,162,73,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
LTEXT "&Anti-alias mode:",IDC_STATIC,9,113,51,8
COMBOBOX IDC_ANTIALIASMODE,68,111,162,73,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
CONTROL "&V-Sync",IDC_VSYNC,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,68,25,36,8
CONTROL "&Widescreen Hack",IDC_WIDESCREEN_HACK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,161,25,67,10
LTEXT "&Aspect Ratio:",IDC_STATIC,9,40,48,8
CONTROL "&Widescreen Hack",IDC_WIDESCREEN_HACK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,161,40,67,10
CONTROL "&Safe Texture Cache",IDC_SAFE_TEXTURE_CACHE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,157,80,11
CONTROL "&Enable CPU->EFB access ",IDC_EFB_ACCESS_ENABLE,"Button",BS_AUTOCHECKBOX | BS_MULTILINE | WS_TABSTOP,7,136,94,11
COMBOBOX IDC_ASPECTRATIO,68,39,89,57,CBS_DROPDOWNLIST | CBS_SORT | WS_VSCROLL | WS_TABSTOP
GROUPBOX "Safe Texture Cache Mode",IDC_STATIC,109,147,125,27
GROUPBOX "Resolutions",IDC_STATIC,7,56,230,50
LTEXT "Full&screen:",IDC_STATIC,14,68,36,8
LTEXT "Full&screen Resolution:",IDC_STATIC,9,56,230,8
COMBOBOX IDC_RESOLUTION,68,67,162,73,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
CONTROL "Safe",IDC_SAFE_TEXTURE_CACHE_SAFE,"Button",BS_AUTORADIOBUTTON,117,158,27,10
CONTROL "Normal",IDC_SAFE_TEXTURE_CACHE_NORMAL,"Button",BS_AUTORADIOBUTTON,154,158,38,10
CONTROL "Fast",IDC_SAFE_TEXTURE_CACHE_FAST,"Button",BS_AUTORADIOBUTTON,198,158,30,10
LTEXT "&Anti-alias mode:",IDC_STATIC,9,87,51,8
COMBOBOX IDC_ANTIALIASMODE,68,85,162,73,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
CONTROL "&Enable CPU->EFB access ",IDC_EFB_ACCESS_ENABLE,"Button",BS_AUTOCHECKBOX | BS_MULTILINE | WS_TABSTOP,7,103,94,11
GROUPBOX "Safe Texture Cache Mode",IDC_STATIC,109,119,125,27
CONTROL "&Safe Texture Cache",IDC_SAFE_TEXTURE_CACHE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,129,80,11
CONTROL "Safe",IDC_SAFE_TEXTURE_CACHE_SAFE,"Button",BS_AUTORADIOBUTTON,117,130,27,10
CONTROL "Normal",IDC_SAFE_TEXTURE_CACHE_NORMAL,"Button",BS_AUTORADIOBUTTON,154,130,38,10
CONTROL "Fast",IDC_SAFE_TEXTURE_CACHE_FAST,"Button",BS_AUTORADIOBUTTON,198,130,30,10
END
IDD_ADVANCED DIALOGEX 0, 0, 244, 200

View File

@ -77,7 +77,7 @@ u32 OpenGL_GetBackbufferHeight()
void OpenGL_SetWindowText(const char *text)
{
#if defined(USE_WX) && USE_WX
GLWin.frame->SetTitle(wxString::FromAscii(text));
// GLWin.frame->SetTitle(wxString::FromAscii(text));
#elif defined(HAVE_COCOA) && HAVE_COCOA
cocoaGLSetTitle(GLWin.cocoaWin, text);
#elif defined(_WIN32)
@ -120,143 +120,105 @@ void UpdateFPSDisplay(const char *text)
#if defined(HAVE_X11) && HAVE_X11
THREAD_RETURN XEventThread(void *pArg);
void X11_EWMH_Fullscreen(int action)
{
_assert_(action == _NET_WM_STATE_REMOVE || action == _NET_WM_STATE_ADD
|| action == _NET_WM_STATE_TOGGLE);
// Init X event structure for _NET_WM_STATE_FULLSCREEN client message
XEvent event;
event.xclient.type = ClientMessage;
event.xclient.message_type = XInternAtom(GLWin.dpy, "_NET_WM_STATE", False);
event.xclient.window = GLWin.win;
event.xclient.format = 32;
event.xclient.data.l[0] = action;
event.xclient.data.l[1] = XInternAtom(GLWin.dpy, "_NET_WM_STATE_FULLSCREEN", False);
// Send the event
if (!XSendEvent(GLWin.dpy, DefaultRootWindow(GLWin.dpy), False,
SubstructureRedirectMask | SubstructureNotifyMask, &event))
ERROR_LOG(VIDEO, "Failed to switch fullscreen/windowed mode.\n");
}
void CreateXWindow (void)
{
Atom wmProtocols[3];
Window parent;
#if defined(HAVE_GTK2) && HAVE_GTK2 && defined(wxGTK)
wxMutexGuiEnter();
#endif
#if defined(HAVE_XRANDR) && HAVE_XRANDR
if (GLWin.fs && !GLWin.renderToMain)
XRRSetScreenConfig(GLWin.dpy, GLWin.screenConfig, RootWindow(GLWin.dpy, GLWin.screen),
GLWin.fullSize, GLWin.screenRotation, CurrentTime);
#endif
#if defined(HAVE_GTK2) && HAVE_GTK2 && defined(wxGTK)
if (GLWin.renderToMain)
{
GLWin.panel->GetSize((int *)&GLWin.width, (int *)&GLWin.height);
GLWin.panel->GetPosition(&GLWin.x, &GLWin.y);
parent = GDK_WINDOW_XID(GTK_WIDGET(GLWin.panel->GetHandle())->window);
GLWin.panel->SetFocus();
// Get the resolution setings for fullscreen mode
int fullWidth, fullHeight;
sscanf(g_Config.cFSResolution, "%dx%d", &fullWidth, &fullHeight);
int vidModeMajorVersion, vidModeMinorVersion;
XRRScreenSize *sizes;
int numSizes;
XRRQueryVersion(GLWin.dpy, &vidModeMajorVersion, &vidModeMinorVersion);
NOTICE_LOG(VIDEO, "XRRExtension-Version %d.%d", vidModeMajorVersion, vidModeMinorVersion);
GLWin.screenConfig = XRRGetScreenInfo(GLWin.dpy, GLWin.parent);
/* save desktop resolution */
GLWin.deskSize = XRRConfigCurrentConfiguration(GLWin.screenConfig, &GLWin.screenRotation);
/* Set the desktop resolution as the default */
GLWin.fullSize = GLWin.deskSize;
/* Find the index of the fullscreen resolution from config */
sizes = XRRConfigSizes(GLWin.screenConfig, &numSizes);
if (numSizes > 0 && sizes != NULL) {
for (int i = 0; i < numSizes; i++) {
if ((sizes[i].width == fullWidth) && (sizes[i].height == fullHeight)) {
GLWin.fullSize = i;
}
else
#endif
{
GLWin.x = 0;
GLWin.y = 0;
GLWin.width = GLWin.winWidth;
GLWin.height = GLWin.winHeight;
parent = RootWindow(GLWin.dpy, GLWin.vi->screen);
}
NOTICE_LOG(VIDEO, "Fullscreen Resolution %dx%d", sizes[GLWin.fullSize].width, sizes[GLWin.fullSize].height);
}
else {
ERROR_LOG(VIDEO, "Failed to obtain fullscreen sizes.\n"
"Using current desktop resolution for fullscreen.\n");
}
#endif
Atom wmProtocols[1];
g_VideoInitialize.pRequestWindowSize(GLWin.x, GLWin.y, (int&)GLWin.width, (int&)GLWin.height);
// Control window size and picture scaling
s_backbuffer_width = GLWin.width;
s_backbuffer_height = GLWin.height;
// create the window
GLWin.win = XCreateWindow(GLWin.dpy, parent,
// Setup window attributes
GLWin.attr.colormap = XCreateColormap(GLWin.dpy,
GLWin.parent, GLWin.vi->visual, AllocNone);
GLWin.attr.event_mask = ExposureMask | KeyPressMask | KeyReleaseMask |
StructureNotifyMask | ResizeRedirectMask;
GLWin.attr.background_pixel = BlackPixel(GLWin.dpy, GLWin.screen);
GLWin.attr.border_pixel = 0;
// Create the window
GLWin.win = XCreateWindow(GLWin.dpy, GLWin.parent,
GLWin.x, GLWin.y, GLWin.width, GLWin.height, 0, GLWin.vi->depth, InputOutput, GLWin.vi->visual,
CWBorderPixel | CWBackPixel | CWColormap | CWEventMask, &GLWin.attr);
wmProtocols[0] = XInternAtom(GLWin.dpy, "WM_DELETE_WINDOW", True);
wmProtocols[1] = XInternAtom(GLWin.dpy, "_NET_WM_STATE", False);
wmProtocols[2] = XInternAtom(GLWin.dpy, "_NET_WM_STATE_FULLSCREEN", False);
XSetWMProtocols(GLWin.dpy, GLWin.win, wmProtocols, 3);
XSetWMProtocols(GLWin.dpy, GLWin.win, wmProtocols, 1);
XSetStandardProperties(GLWin.dpy, GLWin.win, "GPU", "GPU", None, NULL, 0, NULL);
XSelectInput(GLWin.dpy, GLWin.win, ExposureMask | KeyPressMask | KeyReleaseMask |
StructureNotifyMask | EnterWindowMask | LeaveWindowMask | FocusChangeMask );
XMapRaised(GLWin.dpy, GLWin.win);
XSync(GLWin.dpy, True);
#if defined(HAVE_GTK2) && HAVE_GTK2 && defined(wxGTK)
wxMutexGuiLeave();
#endif
if (g_Config.bHideCursor)
{
// make a blank cursor
Pixmap Blank;
XColor DummyColor;
char ZeroData[1] = {0};
Blank = XCreateBitmapFromData (GLWin.dpy, GLWin.win, ZeroData, 1, 1);
GLWin.blankCursor = XCreatePixmapCursor(GLWin.dpy, Blank, Blank, &DummyColor, &DummyColor, 0, 0);
XFreePixmap (GLWin.dpy, Blank);
}
GLWin.xEventThread = new Common::Thread(XEventThread, NULL);
}
void DestroyXWindow(void)
void ToggleDisplayMode (bool bFullscreen)
{
if( GLWin.ctx )
{
if( !glXMakeCurrent(GLWin.dpy, None, NULL))
{
printf("Could not release drawing context.\n");
}
}
/* switch back to original desktop resolution if we were in fullscreen */
if( GLWin.fs )
{
#if defined(HAVE_XRANDR) && HAVE_XRANDR
XRRSetScreenConfig(GLWin.dpy, GLWin.screenConfig, RootWindow(GLWin.dpy, GLWin.screen),
GLWin.deskSize, GLWin.screenRotation, CurrentTime);
#if defined(HAVE_GTK2) && HAVE_GTK2 && defined(wxGTK)
if (!GLWin.renderToMain)
#endif
X11_EWMH_Fullscreen(_NET_WM_STATE_REMOVE);
#endif
}
XUndefineCursor(GLWin.dpy, GLWin.win);
XUnmapWindow(GLWin.dpy, GLWin.win);
GLWin.win = 0;
}
void ToggleFullscreenMode (void)
{
GLWin.fs = !GLWin.fs;
#if defined(HAVE_XRANDR) && HAVE_XRANDR
if (GLWin.fs)
XRRSetScreenConfig(GLWin.dpy, GLWin.screenConfig, RootWindow(GLWin.dpy, GLWin.screen),
if (bFullscreen)
XRRSetScreenConfig(GLWin.dpy, GLWin.screenConfig, GLWin.parent,
GLWin.fullSize, GLWin.screenRotation, CurrentTime);
else
XRRSetScreenConfig(GLWin.dpy, GLWin.screenConfig, RootWindow(GLWin.dpy, GLWin.screen),
XRRSetScreenConfig(GLWin.dpy, GLWin.screenConfig, GLWin.parent,
GLWin.deskSize, GLWin.screenRotation, CurrentTime);
#endif
#if defined(HAVE_GTK2) && HAVE_GTK2 && defined(wxGTK)
if (!GLWin.renderToMain)
}
void DestroyXWindow(void)
{
/* switch back to original desktop resolution if we were in fullscreen */
#if defined(HAVE_XRANDR) && HAVE_XRANDR
ToggleDisplayMode(False);
#endif
XUnmapWindow(GLWin.dpy, GLWin.win);
GLWin.win = 0;
XFreeColormap(GLWin.dpy, GLWin.attr.colormap);
if (GLWin.xEventThread)
GLWin.xEventThread->WaitForDeath();
GLWin.xEventThread = NULL;
#if defined(HAVE_XRANDR) && HAVE_XRANDR
XRRFreeScreenConfigInfo(GLWin.screenConfig);
#endif
{
X11_EWMH_Fullscreen(_NET_WM_STATE_TOGGLE);
XRaiseWindow(GLWin.dpy, GLWin.win);
XSetInputFocus(GLWin.dpy, GLWin.win, RevertToPointerRoot, CurrentTime);
}
XSync(GLWin.dpy, False);
}
THREAD_RETURN XEventThread(void *pArg)
{
bool bPaused = False;
while (GLWin.win)
{
XEvent event;
@ -268,31 +230,17 @@ THREAD_RETURN XEventThread(void *pArg)
key = XLookupKeysym((XKeyEvent*)&event, 0);
switch (key)
{
case XK_F1: case XK_F2: case XK_F3: case XK_F4: case XK_F5: case XK_F6:
case XK_F7: case XK_F8: case XK_F9: case XK_F11: case XK_F12:
g_VideoInitialize.pKeyPress(key - 0xff4e,
event.xkey.state & ShiftMask,
event.xkey.state & ControlMask);
break;
case XK_Escape:
if (GLWin.fs && !bPaused)
{
printf("toggling fullscreen\n");
ToggleFullscreenMode();
}
g_VideoInitialize.pKeyPress(0x1c, False, False);
break;
case XK_Return:
if (event.xkey.state & Mod1Mask)
ToggleFullscreenMode();
break;
case XK_3:
OSDChoice = 1;
// Toggle native resolution
if (!(g_Config.bNativeResolution || g_Config.b2xResolution))
g_Config.bNativeResolution = true;
else if (g_Config.bNativeResolution && Renderer::AllowCustom())
{ g_Config.bNativeResolution = false; if (Renderer::Allow2x()) {g_Config.b2xResolution = true;} }
{
g_Config.bNativeResolution = false;
if (Renderer::Allow2x())
g_Config.b2xResolution = true;
}
else if (Renderer::AllowCustom())
g_Config.b2xResolution = false;
break;
@ -326,64 +274,22 @@ THREAD_RETURN XEventThread(void *pArg)
break;
}
break;
case FocusIn:
if (g_Config.bHideCursor && !bPaused && !GLWin.renderToMain)
XDefineCursor(GLWin.dpy, GLWin.win, GLWin.blankCursor);
break;
case FocusOut:
if (g_Config.bHideCursor && !bPaused && !GLWin.renderToMain)
XUndefineCursor(GLWin.dpy, GLWin.win);
break;
case ConfigureNotify:
Window winDummy;
unsigned int borderDummy;
unsigned int borderDummy, depthDummy;
XGetGeometry(GLWin.dpy, GLWin.win, &winDummy, &GLWin.x, &GLWin.y,
&GLWin.width, &GLWin.height, &borderDummy, &GLWin.depth);
&GLWin.width, &GLWin.height, &borderDummy, &depthDummy);
s_backbuffer_width = GLWin.width;
s_backbuffer_height = GLWin.height;
// Save windowed mode size for return from fullscreen
if (!GLWin.fs)
{
GLWin.winWidth = GLWin.width;
GLWin.winHeight = GLWin.height;
}
break;
case ClientMessage:
if ((ulong) event.xclient.data.l[0] == XInternAtom(GLWin.dpy, "WM_DELETE_WINDOW", False))
g_VideoInitialize.pKeyPress(0x1b, False, False);
if ((ulong) event.xclient.data.l[0] == XInternAtom(GLWin.dpy, "TOGGLE_FULLSCREEN", False))
ToggleFullscreenMode();
if (g_Config.bHideCursor &&
(ulong) event.xclient.data.l[0] == XInternAtom(GLWin.dpy, "PAUSE", False))
{
bPaused = True;
XUndefineCursor(GLWin.dpy, GLWin.win);
}
if (g_Config.bHideCursor &&
(ulong) event.xclient.data.l[0] == XInternAtom(GLWin.dpy, "RESUME", False))
{
bPaused = False;
XDefineCursor(GLWin.dpy, GLWin.win, GLWin.blankCursor);
}
#if defined(HAVE_GTK2) && HAVE_GTK2 && defined(wxGTK)
if (GLWin.renderToMain &&
(ulong) event.xclient.data.l[0] == XInternAtom(GLWin.dpy, "RESIZE", False))
{
GLWin.panel->GetSize((int *)&GLWin.width, (int *)&GLWin.height);
GLWin.panel->GetPosition(&GLWin.x, &GLWin.y);
XMoveResizeWindow(GLWin.dpy, GLWin.win, GLWin.x, GLWin.y, GLWin.width, GLWin.height);
}
if (GLWin.renderToMain &&
(ulong) event.xclient.data.l[0] == XInternAtom(GLWin.dpy, "FOCUSIN", False))
{
GLWin.panel->SetFocus();
if (g_Config.bHideCursor)
XDefineCursor(GLWin.dpy, GLWin.win, GLWin.blankCursor);
}
if (GLWin.renderToMain && g_Config.bHideCursor &&
(ulong) event.xclient.data.l[0] == XInternAtom(GLWin.dpy, "FOCUSOUT", False))
XUndefineCursor(GLWin.dpy, GLWin.win);
#endif
g_VideoInitialize.pCoreMessage(WM_USER_STOP);
if ((ulong) event.xclient.data.l[0] == XInternAtom(GLWin.dpy, "TOGGLE_DISPLAYMODE", False))
ToggleDisplayMode(event.xclient.data.l[1]);
if ((ulong) event.xclient.data.l[0] == XInternAtom(GLWin.dpy, "RESIZE", False))
XMoveResizeWindow(GLWin.dpy, GLWin.win, event.xclient.data.l[1],
event.xclient.data.l[2], event.xclient.data.l[3], event.xclient.data.l[4]);
break;
default:
break;
@ -399,33 +305,9 @@ THREAD_RETURN XEventThread(void *pArg)
// Call browser: Core.cpp:EmuThread() > main.cpp:Video_Initialize()
bool OpenGL_Create(SVideoInitialize &_VideoInitialize, int _iwidth, int _iheight)
{
#if !defined(HAVE_X11) || !HAVE_X11
// Check for fullscreen mode
int _twidth, _theight;
if (g_Config.bFullscreen)
{
if (strlen(g_Config.cFSResolution) > 1)
{
sscanf(g_Config.cFSResolution, "%dx%d", &_twidth, &_theight);
}
else // No full screen reso set, fall back to default reso
{
_twidth = _iwidth;
_theight = _iheight;
}
}
else // Going Windowed
{
if (strlen(g_Config.cInternalRes) > 1)
{
sscanf(g_Config.cInternalRes, "%dx%d", &_twidth, &_theight);
}
else // No Window resolution set, fall back to default
{
_twidth = _iwidth;
_theight = _iheight;
}
}
#if (!defined(HAVE_X11) || !HAVE_X11)
int _tx, _ty, _twidth, _theight;
g_VideoInitialize.pRequestWindowSize(_tx, _ty, _twidth, _theight);
// Control window size and picture scaling
s_backbuffer_width = _twidth;
@ -439,19 +321,12 @@ bool OpenGL_Create(SVideoInitialize &_VideoInitialize, int _iwidth, int _iheight
int args[] = {WX_GL_RGBA, WX_GL_DOUBLEBUFFER, WX_GL_DEPTH_SIZE, 16, 0};
wxSize size(_iwidth, _iheight);
if (!g_Config.RenderToMainframe ||
g_VideoInitialize.pWindowHandle == NULL) {
GLWin.frame = new wxFrame((wxWindow *)NULL,
-1, _("Dolphin"), wxPoint(50,50), size);
} else {
GLWin.frame = new wxFrame((wxWindow *)g_VideoInitialize.pWindowHandle,
-1, _("Dolphin"), wxPoint(50,50), size);
}
GLWin.glCanvas = new wxGLCanvas(GLWin.frame, wxID_ANY, args,
GLWin.panel = (wxPanel *)g_VideoInitialize.pWindowHandle;
GLWin.glCanvas = new wxGLCanvas(GLWin.panel, wxID_ANY, args,
wxPoint(0,0), size, wxSUNKEN_BORDER);
GLWin.glCtxt = new wxGLContext(GLWin.glCanvas);
GLWin.frame->Show(TRUE);
GLWin.glCanvas->Show(TRUE);
GLWin.glCanvas->SetCurrent(*GLWin.glCtxt);
@ -470,36 +345,6 @@ bool OpenGL_Create(SVideoInitialize &_VideoInitialize, int _iwidth, int _iheight
return false;
}
if (g_Config.bFullscreen)
{
DEVMODE dmScreenSettings;
memset(&dmScreenSettings,0,sizeof(dmScreenSettings));
dmScreenSettings.dmSize = sizeof(dmScreenSettings);
dmScreenSettings.dmPelsWidth = s_backbuffer_width;
dmScreenSettings.dmPelsHeight = s_backbuffer_height;
dmScreenSettings.dmBitsPerPel = 32;
dmScreenSettings.dmFields = DM_BITSPERPEL|DM_PELSWIDTH|DM_PELSHEIGHT;
// Try To Set Selected Mode And Get Results. NOTE: CDS_FULLSCREEN Gets Rid Of Start Bar.
if (ChangeDisplaySettings(&dmScreenSettings, CDS_FULLSCREEN) != DISP_CHANGE_SUCCESSFUL)
{
if (MessageBox(NULL, _T("The Requested Fullscreen Mode Is Not Supported By\nYour Video Card. Use Windowed Mode Instead?"), _T("NeHe GL"),MB_YESNO|MB_ICONEXCLAMATION)==IDYES)
EmuWindow::ToggleFullscreen(EmuWindow::GetWnd());
else
return false;
}
else
{
// SetWindowPos to the upper-left corner of the screen
SetWindowPos(EmuWindow::GetWnd(), HWND_TOP, 0, 0, _twidth, _theight, SWP_NOREPOSITION | SWP_NOZORDER);
}
}
else
{
// Change to default resolution
ChangeDisplaySettings(NULL, 0);
}
// Show the window
EmuWindow::Show();
@ -547,7 +392,6 @@ bool OpenGL_Create(SVideoInitialize &_VideoInitialize, int _iwidth, int _iheight
#elif defined(HAVE_X11) && HAVE_X11
int glxMajorVersion, glxMinorVersion;
int vidModeMajorVersion, vidModeMinorVersion;
// attributes for a single buffered visual in RGBA format with at least
// 8 bits per color and a 24 bit depth buffer
@ -568,110 +412,35 @@ bool OpenGL_Create(SVideoInitialize &_VideoInitialize, int _iwidth, int _iheight
GLWin.dpy = XOpenDisplay(0);
#if defined(HAVE_GTK2) && HAVE_GTK2 && defined(wxGTK)
GLWin.panel = (wxPanel *)g_VideoInitialize.pPanel;
#endif
GLWin.parent = (Window)g_VideoInitialize.pWindowHandle;
g_VideoInitialize.pWindowHandle = (Display *)GLWin.dpy;
GLWin.screen = DefaultScreen(GLWin.dpy);
if (GLWin.parent == 0)
GLWin.parent = RootWindow(GLWin.dpy, GLWin.screen);
XkbSetDetectableAutoRepeat(GLWin.dpy, True, NULL);
// Fullscreen option.
GLWin.fs = g_Config.bFullscreen; //Set to setting in Options
// Render to main option.
#if defined(HAVE_GTK2) && HAVE_GTK2 && defined(wxGTK)
GLWin.renderToMain = g_Config.RenderToMainframe;
#else
GLWin.renderToMain = False;
#endif
glXQueryVersion(GLWin.dpy, &glxMajorVersion, &glxMinorVersion);
NOTICE_LOG(VIDEO, "glX-Version %d.%d", glxMajorVersion, glxMinorVersion);
/* get an appropriate visual */
GLWin.vi = glXChooseVisual(GLWin.dpy, GLWin.screen, attrListDbl);
if (GLWin.vi == NULL) {
GLWin.vi = glXChooseVisual(GLWin.dpy, GLWin.screen, attrListSgl);
GLWin.doubleBuffered = False;
ERROR_LOG(VIDEO, "Only Singlebuffered Visual!");
}
else {
GLWin.doubleBuffered = True;
else
NOTICE_LOG(VIDEO, "Got Doublebuffered Visual!");
}
glXQueryVersion(GLWin.dpy, &glxMajorVersion, &glxMinorVersion);
NOTICE_LOG(VIDEO, "glX-Version %d.%d", glxMajorVersion, glxMinorVersion);
// Create a GLX context.
GLWin.ctx = glXCreateContext(GLWin.dpy, GLWin.vi, 0, GL_TRUE);
if(!GLWin.ctx)
if (!GLWin.ctx)
{
PanicAlert("Couldn't Create GLX context.Quit");
exit(0); // TODO: Don't bring down entire Emu
}
// Create a color map and set the event masks
GLWin.attr.colormap = XCreateColormap(GLWin.dpy,
RootWindow(GLWin.dpy, GLWin.vi->screen), GLWin.vi->visual, AllocNone);
GLWin.attr.event_mask = ExposureMask | KeyPressMask | KeyReleaseMask |
StructureNotifyMask | ResizeRedirectMask;
GLWin.attr.background_pixel = BlackPixel(GLWin.dpy, GLWin.screen);
GLWin.attr.border_pixel = 0;
XkbSetDetectableAutoRepeat(GLWin.dpy, True, NULL);
// Get the resolution setings for both fullscreen and windowed modes
if (strlen(g_Config.cFSResolution) > 1)
sscanf(g_Config.cFSResolution, "%dx%d", &GLWin.fullWidth, &GLWin.fullHeight);
else // No full screen reso set, fall back to desktop resolution
{
GLWin.fullWidth = DisplayWidth(GLWin.dpy, GLWin.screen);
GLWin.fullHeight = DisplayHeight(GLWin.dpy, GLWin.screen);
}
if (strlen(g_Config.cInternalRes) > 1)
sscanf(g_Config.cInternalRes, "%dx%d", &GLWin.winWidth, &GLWin.winHeight);
else // No Window resolution set, fall back to default
{
GLWin.winWidth = _iwidth;
GLWin.winHeight = _iheight;
}
#if defined(HAVE_XRANDR) && HAVE_XRANDR
XRRQueryVersion(GLWin.dpy, &vidModeMajorVersion, &vidModeMinorVersion);
XRRScreenSize *sizes;
int numSizes;
NOTICE_LOG(VIDEO, "XRRExtension-Version %d.%d", vidModeMajorVersion, vidModeMinorVersion);
GLWin.screenConfig = XRRGetScreenInfo(GLWin.dpy, RootWindow(GLWin.dpy, GLWin.screen));
/* save desktop resolution */
GLWin.deskSize = XRRConfigCurrentConfiguration(GLWin.screenConfig, &GLWin.screenRotation);
/* Set the desktop resolution as the default */
GLWin.fullSize = -1;
/* Find the index of the fullscreen resolution from config */
sizes = XRRConfigSizes(GLWin.screenConfig, &numSizes);
if (numSizes > 0 && sizes != NULL) {
for (int i = 0; i < numSizes; i++) {
if ((sizes[i].width == GLWin.fullWidth) && (sizes[i].height == GLWin.fullHeight)) {
GLWin.fullSize = i;
}
}
NOTICE_LOG(VIDEO, "Fullscreen Resolution %dx%d", sizes[GLWin.fullSize].width, sizes[GLWin.fullSize].height);
}
else {
ERROR_LOG(VIDEO, "Failed to obtain fullscreen sizes.\n"
"Using current desktop resolution for fullscreen.\n");
GLWin.fullWidth = DisplayWidth(GLWin.dpy, GLWin.screen);
GLWin.fullHeight = DisplayHeight(GLWin.dpy, GLWin.screen);
}
#else
GLWin.fullWidth = DisplayWidth(GLWin.dpy, GLWin.screen);
GLWin.fullHeight = DisplayHeight(GLWin.dpy, GLWin.screen);
#endif
#if defined(HAVE_GTK2) && HAVE_GTK2 && defined(wxGTK)
if (GLWin.renderToMain)
g_VideoInitialize.pKeyPress(0, False, False);
#endif
CreateXWindow();
g_VideoInitialize.pXWindow = (Window *) &GLWin.win;
#endif
return true;
}
@ -684,31 +453,8 @@ bool OpenGL_Initialize()
PanicAlert("Can't Activate The GL Rendering Context.");
return false;
}
#if defined(HAVE_X11) && HAVE_X11
NOTICE_LOG(VIDEO, "GLWin Depth %d", GLWin.depth)
if (glXIsDirect(GLWin.dpy, GLWin.ctx)) {
NOTICE_LOG(VIDEO, "detected direct rendering");
} else {
ERROR_LOG(VIDEO, "no Direct Rendering possible!");
}
if (GLWin.fs)
{
#if defined(HAVE_GTK2) && HAVE_GTK2 && defined(wxGTK)
if (GLWin.renderToMain)
{
GLWin.fs = False;
g_VideoInitialize.pKeyPress(0x1d, False, False);
}
else
#endif
X11_EWMH_Fullscreen(_NET_WM_STATE_ADD);
}
// Hide the cursor now
if (g_Config.bHideCursor)
XDefineCursor (GLWin.dpy, GLWin.win, GLWin.blankCursor);
#endif
// Notify the core that the window is current
g_VideoInitialize.pCoreMessage(WM_USER_CREATE);
return success;
}
@ -782,12 +528,12 @@ void OpenGL_Shutdown()
{
#if defined(USE_WX) && USE_WX
delete GLWin.glCanvas;
delete GLWin.frame;
#elif defined(HAVE_COCOA) && HAVE_COCOA
cocoaGLDeleteWindow(GLWin.cocoaWin);
cocoaGLDelete(GLWin.cocoaCtx);
#elif defined(_WIN32)
EmuWindow::ToggleDisplayMode(false);
if (hRC) // Do We Have A Rendering Context?
{
if (!wglMakeCurrent(NULL,NULL)) // Are We Able To Release The DC And RC Contexts?
@ -810,21 +556,14 @@ void OpenGL_Shutdown()
ERROR_LOG(VIDEO, "Release Device Context Failed.");
hDC = NULL; // Set DC To NULL
}
EmuWindow::Close();
#elif defined(HAVE_X11) && HAVE_X11
DestroyXWindow();
if (GLWin.xEventThread)
GLWin.xEventThread->WaitForDeath();
GLWin.xEventThread = NULL;
#if defined(HAVE_XRANDR) && HAVE_XRANDR
if (GLWin.fullSize >= 0)
XRRFreeScreenConfigInfo(GLWin.screenConfig);
#endif
if (g_Config.bHideCursor)
XFreeCursor(GLWin.dpy, GLWin.blankCursor);
if (GLWin.ctx && !glXMakeCurrent(GLWin.dpy, None, NULL))
NOTICE_LOG(VIDEO, "Could not release drawing context.");
if (GLWin.ctx)
{
glXDestroyContext(GLWin.dpy, GLWin.ctx);
XFreeColormap(GLWin.dpy, GLWin.attr.colormap);
XCloseDisplay(GLWin.dpy);
GLWin.ctx = NULL;
}

View File

@ -41,23 +41,12 @@
#elif defined(HAVE_X11) && HAVE_X11
#include <GL/glxew.h>
#include <X11/XKBlib.h>
#if defined(HAVE_GTK2) && HAVE_GTK2 // Needed for render to main
#include <gtk/gtk.h>
#include <gdk/gdkx.h>
#include <wx/wx.h>
#endif
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/keysym.h>
#include "Thread.h"
#if defined(HAVE_XRANDR) && HAVE_XRANDR
#include <X11/extensions/Xrandr.h>
#endif // XRANDR
// EWMH state actions, see
// http://freedesktop.org/wiki/Specifications/wm-spec?action=show&redirect=Standards%2Fwm-spec
#define _NET_WM_STATE_REMOVE 0 /* remove/unset property */
#define _NET_WM_STATE_ADD 1 /* add/set property */
#define _NET_WM_STATE_TOGGLE 2 /* toggle property */
#elif defined(USE_SDL) && USE_SDL
#include <GL/glew.h>
@ -95,20 +84,12 @@ typedef struct {
NSOpenGLContext *cocoaCtx;
#elif defined(HAVE_X11) && HAVE_X11
Window win;
#if defined(HAVE_GTK2) && HAVE_GTK2 && defined(wxGTK)
wxPanel *panel;
#endif
Window parent;
Display *dpy;
XVisualInfo *vi;
GLXContext ctx;
Cursor blankCursor;
XSetWindowAttributes attr;
Bool fs;
Bool doubleBuffered;
int fullWidth, fullHeight;
int winWidth, winHeight;
Common::Thread *xEventThread;
Bool renderToMain;
#if defined(HAVE_XRANDR) && HAVE_XRANDR
XRRScreenConfiguration *screenConfig;
Rotation screenRotation;
@ -117,12 +98,11 @@ typedef struct {
#endif // X11
#if defined(USE_WX) && USE_WX
wxGLCanvas *glCanvas;
wxFrame *frame;
wxPanel *panel;
wxGLContext *glCtxt;
#endif
int x, y;
unsigned int width, height;
unsigned int depth;
} GLWindow;
extern GLWindow GLWin;

View File

@ -36,11 +36,8 @@ BEGIN_EVENT_TABLE(GFXConfigDialogOGL,wxDialog)
EVT_CLOSE(GFXConfigDialogOGL::OnClose)
EVT_BUTTON(wxID_CLOSE, GFXConfigDialogOGL::CloseClick)
EVT_BUTTON(wxID_ABOUT, GFXConfigDialogOGL::AboutClick)
EVT_CHECKBOX(ID_FULLSCREEN, GFXConfigDialogOGL::GeneralSettingsChanged)
EVT_CHECKBOX(ID_VSYNC, GFXConfigDialogOGL::GeneralSettingsChanged)
EVT_CHECKBOX(ID_RENDERTOMAINWINDOW, GFXConfigDialogOGL::GeneralSettingsChanged)
EVT_CHOICE(ID_WINDOWRESOLUTIONCB, GFXConfigDialogOGL::GeneralSettingsChanged)
EVT_CHOICE(ID_WINDOWFSRESOLUTIONCB, GFXConfigDialogOGL::GeneralSettingsChanged)
EVT_CHOICE(ID_FULLSCREENRESOLUTION, GFXConfigDialogOGL::GeneralSettingsChanged)
EVT_CHOICE(ID_MAXANISOTROPY, GFXConfigDialogOGL::GeneralSettingsChanged)
EVT_CHOICE(ID_MSAAMODECB, GFXConfigDialogOGL::GeneralSettingsChanged)
EVT_CHECKBOX(ID_NATIVERESOLUTION, GFXConfigDialogOGL::GeneralSettingsChanged)
@ -52,9 +49,6 @@ BEGIN_EVENT_TABLE(GFXConfigDialogOGL,wxDialog)
EVT_CHECKBOX(ID_WIDESCREENHACK, GFXConfigDialogOGL::GeneralSettingsChanged)
EVT_CHOICE(ID_ASPECT, GFXConfigDialogOGL::GeneralSettingsChanged)
EVT_CHECKBOX(ID_CROP, GFXConfigDialogOGL::GeneralSettingsChanged)
#ifndef _WIN32
EVT_CHECKBOX(ID_HIDECURSOR, GFXConfigDialogOGL::GeneralSettingsChanged)
#endif
EVT_CHECKBOX(ID_WIREFRAME, GFXConfigDialogOGL::AdvancedSettingsChanged)
EVT_CHECKBOX(ID_SHOWFPS, GFXConfigDialogOGL::AdvancedSettingsChanged)
EVT_CHECKBOX(ID_STATISTICS, GFXConfigDialogOGL::AdvancedSettingsChanged)
@ -138,11 +132,6 @@ void GFXConfigDialogOGL::AddFSReso(const char *reso)
arrayStringFor_FullscreenCB.Add(wxString::FromAscii(reso));
}
void GFXConfigDialogOGL::AddWindowReso(const char *reso)
{
arrayStringFor_WindowResolutionCB.Add(wxString::FromAscii(reso));
}
// This one could be used to reload shaders while dolphin is running...
void GFXConfigDialogOGL::LoadShaders()
{
@ -172,8 +161,6 @@ void GFXConfigDialogOGL::InitializeGUILists()
// Resolutions
if (arrayStringFor_FullscreenCB.empty())
AddFSReso("<No resolutions found>");
if (arrayStringFor_WindowResolutionCB.empty())
AddWindowReso("<No resolutions found>");
// Keep Aspect Ratio
arrayStringFor_AspectRatio.Add(wxT("Auto Aspect (recommended)"));
@ -213,22 +200,14 @@ void GFXConfigDialogOGL::InitializeGUIValues()
// General Display Settings
m_NativeResolution->SetValue(g_Config.bNativeResolution);
m_2xResolution->SetValue(g_Config.b2xResolution);
m_Fullscreen->SetValue(g_Config.bFullscreen);
int num = 0;
num = m_WindowResolutionCB->FindString(wxString::FromAscii(g_Config.cInternalRes));
m_WindowResolutionCB->SetSelection(num);
num = m_WindowFSResolutionCB->FindString(wxString::FromAscii(g_Config.cFSResolution));
m_WindowFSResolutionCB->SetSelection(num);
#ifndef _WIN32
m_HideCursor->SetValue(g_Config.bHideCursor);
#endif
m_KeepAR->SetSelection(g_Config.iAspectRatio);
m_Crop->SetValue(g_Config.bCrop);
// Advanced Display Settings
m_RenderToMainWindow->SetValue(g_Config.RenderToMainframe);
m_OSDHotKey->SetValue(g_Config.bOSDHotKey);
m_VSync->SetValue(g_Config.bVSync);
m_UseXFB->SetValue(g_Config.bUseXFB);
@ -288,10 +267,6 @@ void GFXConfigDialogOGL::InitializeGUIValues()
void GFXConfigDialogOGL::InitializeGUITooltips()
{
// Tool tips
m_Fullscreen->SetToolTip(
wxT("Start the separate window in fullscreen mode.")
wxT(" Press Alt+Enter to switch between Fullscreen and Windowed mode.")
wxT("\n\nApplies instanty during gameplay: <Yes>"));
m_NativeResolution->SetToolTip(
wxT("This will use the game's native resolution and stretch it to fill the")
wxT("\nwindow instead of changing the internal display resolution. It")
@ -309,12 +284,9 @@ void GFXConfigDialogOGL::InitializeGUITooltips()
wxT("\nis of the 5:4 format if you have selected the 4:3 aspect ratio. It will assume")
wxT("\nthat your screen is of the 16:10 format if you have selected the 16:9 aspect ratio.")
wxT("\n\nApplies instanty during gameplay: <Yes>"));
m_WindowResolutionCB->SetToolTip(
wxT("Select internal resolution for the separate rendering window for windowed mode")
wxT("\n\nApplies instanty during gameplay: <No>"));
m_WindowFSResolutionCB->SetToolTip(
wxT("Select internal resolution for the separate rendering window for fullscreen mode")
wxT("\n\nApplies instanty during gameplay: <No>"));
wxT("Select resolution for fullscreen mode")
wxT("\n\nApplies instantly during gameplay: <No>"));
m_MSAAModeCB->SetToolTip(wxT(
"Applies instanty during gameplay: <No>"));
m_OSDHotKey->SetToolTip(
@ -393,17 +365,11 @@ void GFXConfigDialogOGL::CreateGUIControls()
// General Display Settings
sbBasic = new wxStaticBoxSizer(wxVERTICAL, m_PageGeneral, wxT("Basic Display Settings"));
wxStaticText *IRText = new wxStaticText(m_PageGeneral, ID_IRTEXT, wxT("Resolution:"), wxDefaultPosition, wxDefaultSize, 0);
wxStaticText *IRText = new wxStaticText(m_PageGeneral, wxID_ANY, wxT("Resolution:"), wxDefaultPosition, wxDefaultSize, 0);
m_NativeResolution = new wxCheckBox(m_PageGeneral, ID_NATIVERESOLUTION, wxT("Native"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator);
m_2xResolution = new wxCheckBox(m_PageGeneral, ID_2X_RESOLUTION, wxT("2x"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator);
wxStaticText *RText = new wxStaticText(m_PageGeneral, ID_RTEXT, wxT("Custom resolution:"), wxDefaultPosition, wxDefaultSize, 0);
wxStaticText *WMText = new wxStaticText(m_PageGeneral, ID_WMTEXT, wxT("Windowed:"), wxDefaultPosition, wxDefaultSize , 0 );
m_Fullscreen = new wxCheckBox(m_PageGeneral, ID_FULLSCREEN, wxT("Fullscreen:"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator);
m_WindowResolutionCB = new wxChoice(m_PageGeneral, ID_WINDOWRESOLUTIONCB, wxDefaultPosition, wxDefaultSize, arrayStringFor_WindowResolutionCB, 0, wxDefaultValidator, arrayStringFor_WindowResolutionCB[0]);
m_WindowFSResolutionCB = new wxChoice(m_PageGeneral, ID_WINDOWFSRESOLUTIONCB, wxDefaultPosition, wxDefaultSize, arrayStringFor_FullscreenCB, 0, wxDefaultValidator, arrayStringFor_FullscreenCB[0]);
#ifndef _WIN32
m_HideCursor = new wxCheckBox(m_PageGeneral, ID_HIDECURSOR, wxT("Hide mouse cursor"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator);
#endif
wxStaticText *RText = new wxStaticText(m_PageGeneral, wxID_ANY, wxT("Fullscreen Display Resolution:"), wxDefaultPosition, wxDefaultSize, 0);
m_WindowFSResolutionCB = new wxChoice(m_PageGeneral, ID_FULLSCREENRESOLUTION, wxDefaultPosition, wxDefaultSize, arrayStringFor_FullscreenCB, 0, wxDefaultValidator, arrayStringFor_FullscreenCB[0]);
// Aspect ratio / positioning controls
wxStaticText *KeepARText = new wxStaticText(m_PageGeneral, wxID_ANY, wxT("Keep aspect ratio:"), wxDefaultPosition, wxDefaultSize, 0);
m_KeepAR = new wxChoice(m_PageGeneral, ID_ASPECT, wxDefaultPosition, wxDefaultSize, arrayStringFor_AspectRatio);
@ -411,7 +377,6 @@ void GFXConfigDialogOGL::CreateGUIControls()
// Advanced Display Settings
sbBasicAdvanced = new wxStaticBoxSizer(wxVERTICAL, m_PageGeneral, wxT("Advanced Display Settings"));
m_RenderToMainWindow = new wxCheckBox(m_PageGeneral, ID_RENDERTOMAINWINDOW, wxT("Render to Main window"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator);
m_OSDHotKey = new wxCheckBox(m_PageGeneral, ID_OSDHOTKEY, wxT("Enable Hotkeys"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator);
#if !defined(_WIN32) && (!defined(HAVE_X11) || !HAVE_X11)
// JPeterson set the hot key to be Win32-specific
@ -445,32 +410,23 @@ void GFXConfigDialogOGL::CreateGUIControls()
sBasic->Add(m_2xResolution, wxGBPosition(0, 2), wxGBSpan(1, 1), wxALIGN_CENTER_VERTICAL | wxALL, 5);
sBasic->Add(RText, wxGBPosition(1, 0), wxGBSpan(1, 1), wxALIGN_CENTER_VERTICAL | wxALL, 5);
sBasic->Add(WMText, wxGBPosition(1, 1), wxGBSpan(1, 1), wxALIGN_CENTER_VERTICAL | wxALL, 5);
sBasic->Add(m_WindowResolutionCB, wxGBPosition(2, 1), wxGBSpan(1, 1), wxALL, 5);
sBasic->Add(m_Fullscreen, wxGBPosition(1, 2), wxGBSpan(1, 1), wxALIGN_CENTER_VERTICAL | wxALL, 5);
sBasic->Add(m_WindowFSResolutionCB, wxGBPosition(2, 2), wxGBSpan(1, 1), wxALL, 5);
sBasic->Add(m_WindowFSResolutionCB, wxGBPosition(1, 1), wxGBSpan(1, 1), wxALL, 5);
sBasic->Add(KeepARText, wxGBPosition(3, 0), wxGBSpan(1, 1), wxALIGN_CENTER_VERTICAL | wxALL, 5);
sBasic->Add(m_KeepAR, wxGBPosition(3, 1), wxGBSpan(1, 1), wxALL, 5);
sBasic->Add(m_Crop, wxGBPosition(3, 2), wxGBSpan(1, 1), wxALL | wxALIGN_CENTER_VERTICAL, 5);
// This option is configured from the main Dolphin.exe settings for _WIN32
#ifndef _WIN32
sBasic->Add(m_HideCursor, wxGBPosition(5, 0), wxGBSpan(1, 4), wxALL, 5);
#endif
sBasic->Add(KeepARText, wxGBPosition(2, 0), wxGBSpan(1, 1), wxALIGN_CENTER_VERTICAL | wxALL, 5);
sBasic->Add(m_KeepAR, wxGBPosition(2, 1), wxGBSpan(1, 1), wxALL, 5);
sBasic->Add(m_Crop, wxGBPosition(2, 2), wxGBSpan(1, 1), wxALL | wxALIGN_CENTER_VERTICAL, 5);
sbBasic->Add(sBasic);
sGeneral->Add(sbBasic, 0, wxEXPAND|wxALL, 5);
sBasicAdvanced = new wxGridBagSizer(0, 0);
sBasicAdvanced->Add(m_RenderToMainWindow, wxGBPosition(0, 0), wxGBSpan(1, 1), wxALL, 5);
sBasicAdvanced->Add(m_OSDHotKey, wxGBPosition(1, 0), wxGBSpan(1, 2), wxALL, 5);
sBasicAdvanced->Add(m_VSync, wxGBPosition(2, 0), wxGBSpan(1, 2), wxALL, 5);
sBasicAdvanced->Add(m_UseXFB, wxGBPosition(3, 0), wxGBSpan(1, 2), wxALL, 5);
sBasicAdvanced->Add(m_UseRealXFB, wxGBPosition(4, 0), wxGBSpan(1, 2), wxALL, 5);
sBasicAdvanced->Add(m_AutoScale, wxGBPosition(5, 0), wxGBSpan(1, 2), wxALL, 5);
sBasicAdvanced->Add(m_WidescreenHack, wxGBPosition(6, 0), wxGBSpan(1, 2), wxALL, 5);
sBasicAdvanced->Add(m_OSDHotKey, wxGBPosition(0, 0), wxGBSpan(1, 2), wxALL, 5);
sBasicAdvanced->Add(m_VSync, wxGBPosition(1, 0), wxGBSpan(1, 2), wxALL, 5);
sBasicAdvanced->Add(m_UseXFB, wxGBPosition(2, 0), wxGBSpan(1, 2), wxALL, 5);
sBasicAdvanced->Add(m_UseRealXFB, wxGBPosition(3, 0), wxGBSpan(1, 2), wxALL, 5);
sBasicAdvanced->Add(m_AutoScale, wxGBPosition(4, 0), wxGBSpan(1, 2), wxALL, 5);
sBasicAdvanced->Add(m_WidescreenHack, wxGBPosition(5, 0), wxGBSpan(1, 2), wxALL, 5);
sbBasicAdvanced->Add(sBasicAdvanced);
sGeneral->Add(sbBasicAdvanced, 0, wxEXPAND|wxALL, 5);
@ -638,13 +594,6 @@ void GFXConfigDialogOGL::GeneralSettingsChanged(wxCommandEvent& event)
{
switch (event.GetId())
{
case ID_FULLSCREEN:
g_Config.bFullscreen = m_Fullscreen->IsChecked();
break;
case ID_RENDERTOMAINWINDOW:
g_Config.RenderToMainframe = m_RenderToMainWindow->IsChecked();
g_Config.bFullscreen = false;
break;
case ID_NATIVERESOLUTION:
g_Config.bNativeResolution = m_NativeResolution->IsChecked();
// Don't allow 1x and 2x at the same time
@ -679,15 +628,7 @@ void GFXConfigDialogOGL::GeneralSettingsChanged(wxCommandEvent& event)
case ID_FORCEFILTERING:
g_Config.bForceFiltering = m_ForceFiltering->IsChecked();
break;
#ifndef _WIN32
case ID_HIDECURSOR:
g_Config.bHideCursor = m_HideCursor->IsChecked();
break;
#endif
case ID_WINDOWRESOLUTIONCB:
strcpy(g_Config.cInternalRes, m_WindowResolutionCB->GetStringSelection().mb_str() );
break;
case ID_WINDOWFSRESOLUTIONCB:
case ID_FULLSCREENRESOLUTION:
strcpy(g_Config.cFSResolution, m_WindowFSResolutionCB->GetStringSelection().mb_str() );
break;
case ID_MAXANISOTROPY:
@ -839,23 +780,12 @@ void GFXConfigDialogOGL::UpdateGUI()
m_AutoScale->Enable(!g_Config.bUseRealXFB);
m_UseXFB->Enable(!g_Config.bUseRealXFB);
// These options are for the separate rendering window
#if !defined(HAVE_GTK2) || !HAVE_GTK2 || !defined(wxGTK)
m_Fullscreen->Enable(!g_Config.RenderToMainframe);
if (g_Config.RenderToMainframe) m_Fullscreen->SetValue(false);
#endif
// Resolution settings
//disable native/2x choice when real xfb is on. native simply looks best, as ector noted above.
//besides, it would look odd if one disabled native, and it came back on again.
m_NativeResolution->Enable(!g_Config.bUseRealXFB);
m_2xResolution->Enable(!g_Config.bUseRealXFB && (!g_Config.bRunning || Renderer::Allow2x()));
m_WindowResolutionCB->Enable(!g_Config.bRunning);
#if defined(HAVE_GTK2) && HAVE_GTK2 && defined(wxGTK)
m_WindowFSResolutionCB->Enable(!g_Config.bRunning);
#else
m_WindowFSResolutionCB->Enable(!g_Config.bRunning && !g_Config.RenderToMainframe);
#endif
// Disable the Copy to options when EFBCopy is disabled
m_Radio_CopyEFBToRAM->Enable(!(g_Config.bEFBCopyDisable));

View File

@ -65,7 +65,6 @@ class GFXConfigDialogOGL : public wxDialog
void CloseClick(wxCommandEvent& event);
void AddFSReso(const char *reso);
void AddWindowReso(const char *reso);
void CreateGUIControls();
void GameIniLoad();
@ -95,9 +94,7 @@ class GFXConfigDialogOGL : public wxDialog
wxNotebook *m_Notebook;
wxPanel *m_PageGeneral;
wxPanel *m_PageAdvanced;
wxCheckBox *m_Fullscreen;
wxCheckBox *m_VSync;
wxCheckBox *m_RenderToMainWindow;
wxCheckBox *m_NativeResolution, *m_2xResolution;
wxCheckBox *m_WidescreenHack;
wxCheckBox *m_ForceFiltering;
@ -105,10 +102,6 @@ class GFXConfigDialogOGL : public wxDialog
wxCheckBox *m_UseXFB;
wxCheckBox *m_UseRealXFB;
wxCheckBox *m_AutoScale;
#ifndef _WIN32
wxCheckBox *m_HideCursor;
#endif
wxChoice *m_WindowResolutionCB;
wxChoice *m_WindowFSResolutionCB;
wxChoice *m_MaxAnisotropyCB;
wxChoice *m_MSAAModeCB, *m_PhackvalueCB, *m_PostShaderCB, *m_KeepAR;
@ -144,7 +137,6 @@ class GFXConfigDialogOGL : public wxDialog
wxSlider *m_SliderWidth, *m_SliderHeight, *m_SliderLeft, *m_SliderTop;
wxCheckBox *m_ScreenSize;
wxArrayString arrayStringFor_WindowResolutionCB;
wxArrayString arrayStringFor_FullscreenCB;
wxArrayString arrayStringFor_AspectRatio;
wxArrayString arrayStringFor_MaxAnisotropyCB;
@ -158,9 +150,7 @@ class GFXConfigDialogOGL : public wxDialog
ID_PAGEGENERAL,
ID_PAGEADVANCED,
ID_FULLSCREEN,
ID_VSYNC,
ID_RENDERTOMAINWINDOW,
ID_NATIVERESOLUTION, ID_2X_RESOLUTION,
ID_ASPECT,
ID_CROP,
@ -169,16 +159,7 @@ class GFXConfigDialogOGL : public wxDialog
ID_AUTOSCALE,
ID_WIDESCREENHACK,
ID_HIDECURSOR,
ID_FSTEXT,
ID_FULLSCREENCB,
ID_WMTEXT,
ID_WM2TEXT,
ID_FMTEXT,
ID_IRTEXT,
ID_RTEXT,
ID_WINDOWRESOLUTIONCB,
ID_WINDOWFSRESOLUTIONCB,
ID_FULLSCREENRESOLUTION,
ID_FORCEFILTERING,
ID_MAXANISOTROPY,
ID_MAXANISOTROPYTEXT,

View File

@ -137,27 +137,12 @@ namespace EmuWindow
HWND m_hWnd = NULL; // The new window that is created here
HWND m_hParent = NULL;
HWND m_hMain = NULL; // The main CPanel
HINSTANCE m_hInstance = NULL;
WNDCLASSEX wndClass;
const TCHAR m_szClassName[] = _T("DolphinEmuWnd");
int g_winstyle;
// ---------------------------------------------------------------------
/* Invisible cursor option. In the lack of a predefined IDC_BLANK we make
an empty transparent cursor */
// ------------------
HCURSOR hCursor = NULL, hCursorBlank = NULL;
void CreateCursors(HINSTANCE hInstance)
{
BYTE ANDmaskCursor[] = { 0xff };
BYTE XORmaskCursor[] = { 0x00 };
hCursorBlank = CreateCursor(hInstance, 0,0, 1,1, ANDmaskCursor,XORmaskCursor);
hCursor = LoadCursor(NULL, IDC_ARROW);
}
HWND GetWnd()
{
return m_hWnd;
@ -233,18 +218,6 @@ void OnKeyDown(WPARAM wParam)
{
switch (LOWORD( wParam ))
{
case VK_ESCAPE:
if (!g_Config.RenderToMainframe)
{
if (g_Config.bFullscreen)
{
// Pressing Esc switches to Windowed mode from Fullscreen mode
ToggleFullscreen(m_hWnd);
}
// then pauses the emulation if already Windowed
SendMessage(m_hMain, WM_USER, WM_USER_PAUSE, 0);
}
break;
case '3': // OSD keys
case '4':
case '5':
@ -254,10 +227,29 @@ void OnKeyDown(WPARAM wParam)
OSDMenu(wParam);
break;
}
g_VideoInitialize.pKeyPress(LOWORD(wParam), GetAsyncKeyState(VK_SHIFT) != 0, GetAsyncKeyState(VK_CONTROL) != 0);
}
// ---------------------------------------------------------------------
void ToggleDisplayMode (int bFullscreen)
{
if (bFullscreen)
{
DEVMODE dmScreenSettings;
memset(&dmScreenSettings,0,sizeof(dmScreenSettings));
dmScreenSettings.dmSize = sizeof(dmScreenSettings);
sscanf(g_Config.cFSResolution, "%dx%d", &dmScreenSettings.dmPelsWidth, &dmScreenSettings.dmPelsHeight);
dmScreenSettings.dmBitsPerPel = 32;
dmScreenSettings.dmFields = DM_BITSPERPEL|DM_PELSWIDTH|DM_PELSHEIGHT;
// Try To Set Selected Mode And Get Results. NOTE: CDS_FULLSCREEN Gets Rid Of Start Bar.
ChangeDisplaySettings(&dmScreenSettings, CDS_FULLSCREEN);
}
else
{
// Change to default resolution
ChangeDisplaySettings(NULL, CDS_FULLSCREEN);
}
}
// Should really take a look at the mouse stuff in here - some of it is weird.
LRESULT CALLBACK WndProc(HWND hWnd, UINT iMsg, WPARAM wParam, LPARAM lParam)
@ -267,10 +259,6 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT iMsg, WPARAM wParam, LPARAM lParam)
switch (iMsg)
{
case WM_CREATE:
PostMessage(m_hMain, WM_USER, WM_USER_CREATE, g_Config.RenderToMainframe);
break;
case WM_PAINT:
{
HDC hdc;
@ -280,29 +268,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT iMsg, WPARAM wParam, LPARAM lParam)
}
break;
case WM_SYSKEYDOWN:
switch (LOWORD(wParam))
{
case VK_RETURN:
// Pressing Alt+Enter switch FullScreen/Windowed
if (m_hParent == NULL && !g_Config.RenderToMainframe)
{
ToggleFullscreen(hWnd);
}
break;
case VK_F5: case VK_F6: case VK_F7: case VK_F8:
PostMessage(m_hMain, WM_SYSKEYDOWN, wParam, lParam);
break;
default:
return DefWindowProc(hWnd, iMsg, wParam, lParam);
}
break;
case WM_KEYDOWN:
// Don't process this as a child window to avoid double events
if (!g_Config.RenderToMainframe)
OnKeyDown(wParam);
break;
/* Post these mouse events to the main window, it's nessesary becase in difference to the
@ -313,53 +279,26 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT iMsg, WPARAM wParam, LPARAM lParam)
PostMessage(GetParentWnd(), iMsg, wParam, lParam);
break;
/* The reason we pick up the WM_MOUSEMOVE is to be able to change this option
during gameplay. The alternative is to load one of the cursors when the plugin
is loaded and go with that. This should only produce a minimal performance hit
because SetCursor is not supposed to actually change the cursor if it's the
same as the one before. */
case WM_MOUSEMOVE:
/* Check rendering mode; child or parent. Then post the mouse moves to the main window
it's nessesary for both the child window and separate rendering window because
moves over the rendering window do not reach the main program then. */
if (GetParentWnd() == NULL) { // Separate rendering window
PostMessage(m_hMain, iMsg, wParam, -1);
SetCursor(hCursor);
}
else
PostMessage(GetParentWnd(), iMsg, wParam, lParam);
break;
/* To support the separate window rendering we get the message back here. So we basically
only let it pass through Dolphin > Frame.cpp to determine if it should be on or off
and coordinate it with the other settings if nessesary */
case WM_USER:
if (wParam == WM_USER_STOP)
SetCursor((lParam) ? hCursor : hCursorBlank);
else if (wParam == WM_USER_KEYDOWN)
if (wParam == WM_USER_KEYDOWN)
{
OnKeyDown(lParam);
FreeLookInput(wParam, lParam);
}
else if (wParam == TOGGLE_FULLSCREEN)
{
if(!g_Config.RenderToMainframe)
ToggleFullscreen(m_hWnd);
}
else if (wParam == WIIMOTE_DISCONNECT)
{
PostMessage(m_hMain, WM_USER, wParam, lParam);
PostMessage(m_hParent, WM_USER, wParam, lParam);
}
else if (wParam == TOGGLE_DISPLAYMODE)
ToggleDisplayMode(lParam);
break;
// This is called when we close the window when we render to a separate window
case WM_CLOSE:
if (m_hParent == NULL)
{
// Take it out of fullscreen and stop the game
if( g_Config.bFullscreen )
ToggleFullscreen(m_hParent);
PostMessage(m_hMain, WM_USER, WM_USER_STOP, 0);
// Stop the game
PostMessage(m_hParent, WM_USER, WM_USER_STOP, 0);
}
break;
@ -378,6 +317,10 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT iMsg, WPARAM wParam, LPARAM lParam)
return DefWindowProc(hWnd, iMsg, wParam, lParam);
}
break;
case WM_SETCURSOR:
PostMessage(m_hParent, WM_USER, WM_USER_SETCURSOR, 0);
return true;
break;
default:
return DefWindowProc(hWnd, iMsg, wParam, lParam);
}
@ -390,14 +333,12 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT iMsg, WPARAM wParam, LPARAM lParam)
HWND OpenWindow(HWND parent, HINSTANCE hInstance, int width, int height, const TCHAR *title)
{
wndClass.cbSize = sizeof( wndClass );
wndClass.style = CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS;
wndClass.style = CS_HREDRAW | CS_VREDRAW;
wndClass.lpfnWndProc = WndProc;
wndClass.cbClsExtra = 0;
wndClass.cbWndExtra = 0;
wndClass.hInstance = hInstance;
wndClass.hIcon = LoadIcon( NULL, IDI_APPLICATION );
// To interfer less with SetCursor() later we set this to NULL
//wndClass.hCursor = LoadCursor( NULL, IDC_ARROW );
wndClass.hCursor = NULL;
wndClass.hbrBackground = (HBRUSH)GetStockObject( BLACK_BRUSH );
wndClass.lpszMenuName = NULL;
@ -407,112 +348,21 @@ HWND OpenWindow(HWND parent, HINSTANCE hInstance, int width, int height, const T
m_hInstance = hInstance;
RegisterClassEx( &wndClass );
CreateCursors(m_hInstance);
// Create child window
if (g_Config.RenderToMainframe)
{
m_hParent = m_hMain = parent;
m_hParent = parent;
m_hWnd = CreateWindow(m_szClassName, title, WS_CHILD,
0, 0, width, height, parent, NULL, hInstance, NULL);
}
// Create new separate window
else
{
// Don't forget to make it NULL, or a broken window will be created in case we
// render to main, stop, then render to separate window, as the GUI will still
// think we're rendering to main because m_hParent will still contain the old HWND
m_hParent = NULL;
m_hMain = parent;
DWORD style = g_Config.bFullscreen ? WS_POPUP : WS_OVERLAPPEDWINDOW;
RECT rc = {0, 0, width, height};
AdjustWindowRect(&rc, style, false);
RECT rcdesktop;
GetWindowRect(GetDesktopWindow(), &rcdesktop);
int X = (rcdesktop.right-rcdesktop.left)/2 - (rc.right-rc.left)/2;
int Y = (rcdesktop.bottom-rcdesktop.top)/2 - (rc.bottom-rc.top)/2;
m_hWnd = CreateWindow(m_szClassName, title, style,
X, Y, rc.right-rc.left, rc.bottom-rc.top,
NULL, NULL, hInstance, NULL);
}
return m_hWnd;
}
void ToggleFullscreen(HWND hParent, bool bForceFull)
{
if (m_hParent == NULL)
{
int w_fs = 640, h_fs = 480;
if (!g_Config.bFullscreen || bForceFull)
{
if (strlen(g_Config.cFSResolution) > 1)
sscanf(g_Config.cFSResolution, "%dx%d", &w_fs, &h_fs);
// Get into fullscreen
DEVMODE dmScreenSettings;
memset(&dmScreenSettings, 0, sizeof(dmScreenSettings));
// Desktop -> FullScreen
dmScreenSettings.dmSize = sizeof(dmScreenSettings);
dmScreenSettings.dmPelsWidth = w_fs;
dmScreenSettings.dmPelsHeight = h_fs;
dmScreenSettings.dmFields = DM_PELSWIDTH|DM_PELSHEIGHT;
if (ChangeDisplaySettings(&dmScreenSettings, CDS_FULLSCREEN) != DISP_CHANGE_SUCCESSFUL)
return;
// Set new window style -> PopUp
SetWindowLongPtr(hParent, GWL_STYLE, WS_POPUP);
// SetWindowPos to the upper-left corner of the screen
SetWindowPos(hParent, HWND_TOP, 0, 0, w_fs, h_fs, SWP_NOREPOSITION);
ShowCursor(FALSE);
g_Config.bFullscreen = true;
// Eventually show the window!
EmuWindow::Show();
}
else
{
if (strlen(g_Config.cInternalRes) > 1)
sscanf(g_Config.cInternalRes, "%dx%d", &w_fs, &h_fs);
// FullScreen -> Desktop
ChangeDisplaySettings(NULL, CDS_FULLSCREEN);
DWORD style = WS_OVERLAPPEDWINDOW;
RECT rc = {0, 0, w_fs, h_fs};
AdjustWindowRect(&rc, style, false);
RECT rcdesktop;
GetWindowRect(GetDesktopWindow(), &rcdesktop);
// SetWindowPos to the center of the screen
int X = (rcdesktop.right-rcdesktop.left)/2 - (rc.right-rc.left)/2;
int Y = (rcdesktop.bottom-rcdesktop.top)/2 - (rc.bottom-rc.top)/2;
SetWindowPos(hParent, NULL, X, Y, rc.right-rc.left, rc.bottom-rc.top, SWP_NOREPOSITION | SWP_NOZORDER);
// Set new window style FS -> Windowed
SetWindowLongPtr(hParent, GWL_STYLE, style);
// Re-Enable the cursor
ShowCursor(TRUE);
g_Config.bFullscreen = false;
// Eventually show the window!
EmuWindow::Show();
}
}
}
void Show()
{
ShowWindow(m_hWnd, SW_SHOW);
BringWindowToTop(m_hWnd);
UpdateWindow(m_hWnd);
SetFocus(m_hParent);
// gShowDebugger from main.cpp is forgotten between the Dolphin-Debugger is opened and a game is
// started so we have to use an ini file setting here
@ -527,13 +377,14 @@ void Show()
HWND Create(HWND hParent, HINSTANCE hInstance, const TCHAR *title)
{
int width=640, height=480;
sscanf( g_Config.bFullscreen ? g_Config.cFSResolution : g_Config.cInternalRes, "%dx%d", &width, &height );
int x=0, y=0, width=640, height=480;
g_VideoInitialize.pRequestWindowSize(x, y, width, height);
return OpenWindow(hParent, hInstance, width, height, title);
}
void Close()
{
if (m_hParent == NULL)
DestroyWindow(m_hWnd);
UnregisterClass(m_szClassName, m_hInstance);
}

View File

@ -31,8 +31,8 @@ namespace EmuWindow
HWND Create(HWND hParent, HINSTANCE hInstance, const TCHAR *title);
void Show();
void Close();
void ToggleFullscreen(HWND hParent, bool bForceFull = false);
void SetSize(int displayWidth, int displayHeight);
void ToggleDisplayMode (int bFullscreen);
}
#endif // _WIN32_H_

View File

@ -82,8 +82,6 @@ CGprofile g_cgfProf;
RasterFont* s_pfont = NULL;
static bool s_bFullscreen = false;
static bool s_bLastFrameDumped = false;
#ifdef _WIN32
static bool s_bAVIDumping = false;
@ -241,8 +239,6 @@ bool Renderer::Init()
(const char*)glGetString(GL_RENDERER),
(const char*)glGetString(GL_VERSION)).c_str(), 5000);
s_bFullscreen = g_ActiveConfig.bFullscreen;
glGetIntegerv(GL_MAX_VERTEX_ATTRIBS, &numvertexattribs);
if (numvertexattribs < 11) {
ERROR_LOG(VIDEO, "*********\nGPU: OGL ERROR: Number of attributes %d not enough\nGPU: *********Does your video card support OpenGL 2.x?", numvertexattribs);
@ -847,7 +843,7 @@ void Renderer::Swap(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight)
// care of disabling it in that case. It returns false in case of no post processing.
bool applyShader = PostProcessing::ApplyShader();
const XFBSource* xfbSource;
const XFBSource* xfbSource = NULL;
// draw each xfb source
for (u32 i = 0; i < xfbCount; ++i)
@ -1227,7 +1223,8 @@ void Renderer::DrawDebugText()
std::vector<std::string> T0;
int W, H;
sscanf(g_ActiveConfig.cInternalRes, "%dx%d", &W, &H);
W = OpenGL_GetBackbufferWidth();
H = OpenGL_GetBackbufferHeight();
std::string OSDM1 =
g_ActiveConfig.bNativeResolution || g_ActiveConfig.b2xResolution ?

View File

@ -99,16 +99,11 @@ if sys.platform == 'win32':
]
gfxenv['CPPPATH'] += libs
# check for Xrandr
gfxenv['HAVE_XRANDR'] = gfxenv['HAVE_X11'] and conf.CheckPKG('xrandr')
conf.Define('HAVE_XRANDR', gfxenv['HAVE_XRANDR'])
# check for libgtk2.0
gfxenv['HAVE_GTK2'] = gfxenv['HAVE_WX'] and conf.CheckPKG('gtk+-2.0')
conf.Define('HAVE_GTK2', gfxenv['HAVE_GTK2'])
conf.Finish()
# Sanity check

View File

@ -167,7 +167,7 @@ void DllDebugger(HWND _hParent, bool Show)
}
#ifdef _WIN32
void Win32AddResolutions()
void AddResolutions()
{
// Search for avaliable resolutions
@ -201,13 +201,12 @@ void Win32AddResolutions()
resos.push_back(strBuffer);
i++;
m_ConfigFrame->AddFSReso(szBuffer);
m_ConfigFrame->AddWindowReso(szBuffer);
}
ZeroMemory(&dmi, sizeof(dmi));
}
}
#elif defined(HAVE_X11) && HAVE_X11 && defined(HAVE_XRANDR) && HAVE_XRANDR
void X11AddResolutions() {
void AddResolutions() {
// Don't modify GLWin.dpy here.
// If the emulator is running that is bad.
Display *dpy;
@ -229,15 +228,12 @@ void X11AddResolutions() {
#if defined(HAVE_WX) && HAVE_WX
m_ConfigFrame->AddFSReso(temp);
//Add same to window resolutions, since
//they should be nearly all that's needed
m_ConfigFrame->AddWindowReso(temp);
#endif
}
}
}
#elif defined(HAVE_COCOA) && HAVE_COCOA
void CocoaAddResolutions() {
void AddResolutions() {
CFArrayRef modes;
CFRange range;
@ -269,7 +265,6 @@ void CocoaAddResolutions() {
sprintf(temp,"%dx%d", modeWidth, modeHeight);
#if defined(HAVE_WX) && HAVE_WX
m_ConfigFrame->AddFSReso(temp);
m_ConfigFrame->AddWindowReso(temp);//Add same to Window ones, since they should be nearly all that's needed
#endif
px = modeWidth;
py = modeHeight;
@ -288,13 +283,7 @@ void DllConfig(HWND _hParent)
wxWindow *frame = GetParentedWxWindow(_hParent);
m_ConfigFrame = new GFXConfigDialogOGL(frame);
#if defined(_WIN32)
Win32AddResolutions();
#elif defined(HAVE_X11) && HAVE_X11 && defined(HAVE_XRANDR) && HAVE_XRANDR
X11AddResolutions();
#elif defined(HAVE_COCOA) && HAVE_COCOA
CocoaAddResolutions();
#endif
AddResolutions();
// Prevent user to show more than 1 config window at same time
#ifdef _WIN32

View File

@ -129,6 +129,9 @@ void UpdateFPSDisplay(const char *text)
// ------------------
bool OpenGL_Create(SVideoInitialize &_VideoInitialize, int _twidth, int _theight)
{
int xPos, yPos;
g_VideoInitialize.pRequestWindowSize(xPos, yPos, _twidth, _theight);
#if defined(_WIN32)
EmuWindow::SetSize(_twidth, _theight);
#endif
@ -173,12 +176,6 @@ bool OpenGL_Create(SVideoInitialize &_VideoInitialize, int _twidth, int _theight
// ---------------------------------------------------------------------------------------
// Create rendering window in Windows
// ----------------------
// Create a separate window
if (!g_Config.renderToMainframe || g_VideoInitialize.pWindowHandle == NULL)
g_VideoInitialize.pWindowHandle = (void*)EmuWindow::Create(NULL, g_hInstance, _T("Please wait..."));
// Create a child window
else
g_VideoInitialize.pWindowHandle = (void*)EmuWindow::Create((HWND)g_VideoInitialize.pWindowHandle, g_hInstance, _T("Please wait..."));
// Show the window
@ -197,43 +194,8 @@ bool OpenGL_Create(SVideoInitialize &_VideoInitialize, int _twidth, int _theight
RECT rcdesktop;
GetWindowRect(GetDesktopWindow(), &rcdesktop);
if (g_Config.bFullscreen) {
//s_backbuffer_width = rcdesktop.right - rcdesktop.left;
//s_backbuffer_height = rcdesktop.bottom - rcdesktop.top;
DEVMODE dmScreenSettings;
memset(&dmScreenSettings,0,sizeof(dmScreenSettings));
dmScreenSettings.dmSize=sizeof(dmScreenSettings);
dmScreenSettings.dmPelsWidth = s_backbuffer_width;
dmScreenSettings.dmPelsHeight = s_backbuffer_height;
dmScreenSettings.dmBitsPerPel = 32;
dmScreenSettings.dmFields = DM_BITSPERPEL|DM_PELSWIDTH|DM_PELSHEIGHT;
// Try To Set Selected Mode And Get Results. NOTE: CDS_FULLSCREEN Gets Rid Of Start Bar.
if (ChangeDisplaySettings(&dmScreenSettings, CDS_FULLSCREEN) != DISP_CHANGE_SUCCESSFUL)
{
if (MessageBox(NULL,_T("The Requested Fullscreen Mode Is Not Supported By\nYour Video Card. Use Windowed Mode Instead?"),_T("NeHe GL"),MB_YESNO|MB_ICONEXCLAMATION)==IDYES)
g_Config.bFullscreen = false;
else
return false;
}
}
else
{
// Change to default resolution
ChangeDisplaySettings(NULL, 0);
}
if (g_Config.bFullscreen && !g_Config.renderToMainframe)
{
// Hide the cursor
ShowCursor(FALSE);
}
else
{
dwExStyle = WS_EX_APPWINDOW | WS_EX_WINDOWEDGE;
dwStyle = WS_OVERLAPPEDWINDOW;
}
RECT rc = {0, 0, s_backbuffer_width, s_backbuffer_height};
AdjustWindowRectEx(&rc, dwStyle, FALSE, dwExStyle);
@ -242,10 +204,6 @@ bool OpenGL_Create(SVideoInitialize &_VideoInitialize, int _twidth, int _theight
int Y = (rcdesktop.bottom-rcdesktop.top)/2 - (rc.bottom-rc.top)/2;
// EmuWindow::GetWnd() is either the new child window or the new separate window
if (g_Config.bFullscreen)
// We put the window at the upper left corner of the screen, so x = y = 0
SetWindowPos(EmuWindow::GetWnd(), NULL, 0, 0, rc.right-rc.left, rc.bottom-rc.top, SWP_NOREPOSITION | SWP_NOZORDER);
else
SetWindowPos(EmuWindow::GetWnd(), NULL, X, Y, rc.right-rc.left, rc.bottom-rc.top, SWP_NOREPOSITION | SWP_NOZORDER);
PIXELFORMATDESCRIPTOR pfd = // pfd Tells Windows How We Want Things To Be
@ -294,9 +252,7 @@ bool OpenGL_Create(SVideoInitialize &_VideoInitialize, int _twidth, int _theight
#elif defined(HAVE_X11) && HAVE_X11
XVisualInfo *vi;
Colormap cmap;
int dpyWidth, dpyHeight;
int glxMajorVersion, glxMinorVersion;
int vidModeMajorVersion, vidModeMinorVersion;
Atom wmDelete;
// attributes for a single buffered visual in RGBA format with at least
@ -316,23 +272,18 @@ bool OpenGL_Create(SVideoInitialize &_VideoInitialize, int _twidth, int _theight
GLX_DEPTH_SIZE, 24,
GLX_SAMPLE_BUFFERS_ARB, GLX_SAMPLES_ARB, 1, None };
GLWin.dpy = XOpenDisplay(0);
GLWin.parent = (Window)g_VideoInitialize.pWindowHandle;
g_VideoInitialize.pWindowHandle = (HWND)GLWin.dpy;
GLWin.screen = DefaultScreen(GLWin.dpy);
// Fullscreen option.
GLWin.fs = g_Config.bFullscreen; //Set to setting in Options
/* get an appropriate visual */
vi = glXChooseVisual(GLWin.dpy, GLWin.screen, attrListDbl);
if (vi == NULL) {
vi = glXChooseVisual(GLWin.dpy, GLWin.screen, attrListSgl);
GLWin.doubleBuffered = False;
ERROR_LOG(VIDEO, "Only Singlebuffered Visual!");
}
else {
GLWin.doubleBuffered = True;
else
NOTICE_LOG(VIDEO, "Got Doublebuffered Visual!");
}
glXQueryVersion(GLWin.dpy, &glxMajorVersion, &glxMinorVersion);
NOTICE_LOG(VIDEO, "glX-Version %d.%d", glxMajorVersion, glxMinorVersion);
@ -343,80 +294,20 @@ bool OpenGL_Create(SVideoInitialize &_VideoInitialize, int _twidth, int _theight
PanicAlert("Couldn't Create GLX context.Quit");
exit(0); // TODO: Don't bring down entire Emu
}
if (GLWin.parent == 0)
GLWin.parent = RootWindow(GLWin.dpy, vi->screen);
// Create a color map.
cmap = XCreateColormap(GLWin.dpy, RootWindow(GLWin.dpy, vi->screen), vi->visual, AllocNone);
cmap = XCreateColormap(GLWin.dpy, GLWin.parent, vi->visual, AllocNone);
GLWin.attr.colormap = cmap;
GLWin.attr.border_pixel = 0;
XkbSetDetectableAutoRepeat(GLWin.dpy, True, NULL);
#if defined(HAVE_XRANDR) && HAVE_XRANDR
// get a connection
XRRQueryVersion(GLWin.dpy, &vidModeMajorVersion, &vidModeMinorVersion);
if (GLWin.fs) {
XRRScreenSize *sizes;
int numSizes;
int bestSize;
NOTICE_LOG(VIDEO, "XRRExtension-Version %d.%d", vidModeMajorVersion, vidModeMinorVersion);
GLWin.screenConfig = XRRGetScreenInfo(GLWin.dpy, RootWindow(GLWin.dpy, GLWin.screen));
/* save desktop-resolution before switching modes */
GLWin.deskSize = XRRConfigCurrentConfiguration(GLWin.screenConfig, &GLWin.screenRotation);
bestSize = GLWin.deskSize;
sizes = XRRConfigSizes(GLWin.screenConfig, &numSizes);
if (numSizes > 0 && sizes != NULL) {
/* look for mode with requested resolution */
for (int i = 0; i < numSizes; i++) {
if ((sizes[i].width == _twidth) && (sizes[i].height == _theight)) {
bestSize = i;
}
}
XRRSetScreenConfig(GLWin.dpy, GLWin.screenConfig, RootWindow(GLWin.dpy, GLWin.screen),
bestSize, GLWin.screenRotation, CurrentTime);
dpyWidth = sizes[bestSize].width;
dpyHeight = sizes[bestSize].height;
NOTICE_LOG(VIDEO, "Resolution %dx%d", dpyWidth, dpyHeight);
/* create a fullscreen window */
GLWin.attr.override_redirect = True;
GLWin.attr.event_mask = ExposureMask | KeyPressMask | KeyReleaseMask | StructureNotifyMask;
GLWin.win = XCreateWindow(GLWin.dpy, RootWindow(GLWin.dpy, vi->screen),
0, 0, dpyWidth, dpyHeight, 0, vi->depth, InputOutput, vi->visual,
CWBorderPixel | CWColormap | CWEventMask | CWOverrideRedirect,
&GLWin.attr);
XWarpPointer(GLWin.dpy, None, GLWin.win, 0, 0, 0, 0, 0, 0);
XMapRaised(GLWin.dpy, GLWin.win);
XGrabKeyboard(GLWin.dpy, GLWin.win, True, GrabModeAsync, GrabModeAsync, CurrentTime);
XGrabPointer(GLWin.dpy, GLWin.win, True, NULL,
GrabModeAsync, GrabModeAsync, GLWin.win, None, CurrentTime);
}
else {
ERROR_LOG(VIDEO, "Failed to start fullscreen. If you received the "
"\"XFree86-VidModeExtension\" extension is missing, add\n"
"Load \"extmod\"\n"
"to your X configuration file (under the Module Section)\n");
GLWin.fs = 0;
}
}
#endif
if (!GLWin.fs) {
//XRootWindow(dpy,screen)
//int X = (rcdesktop.right-rcdesktop.left)/2 - (rc.right-rc.left)/2;
//int Y = (rcdesktop.bottom-rcdesktop.top)/2 - (rc.bottom-rc.top)/2;
// create a window in window mode
GLWin.attr.event_mask = ExposureMask | KeyPressMask | KeyReleaseMask |
StructureNotifyMask | ResizeRedirectMask;
GLWin.win = XCreateWindow(GLWin.dpy, RootWindow(GLWin.dpy, vi->screen),
0, 0, _twidth, _theight, 0, vi->depth, InputOutput, vi->visual,
GLWin.win = XCreateWindow(GLWin.dpy, GLWin.parent,
xPos, yPos, _twidth, _theight, 0, vi->depth, InputOutput, vi->visual,
CWBorderPixel | CWColormap | CWEventMask, &GLWin.attr);
// only set window title and handle wm_delete_events if in windowed mode
wmDelete = XInternAtom(GLWin.dpy, "WM_DELETE_WINDOW", True);
@ -424,7 +315,7 @@ bool OpenGL_Create(SVideoInitialize &_VideoInitialize, int _twidth, int _theight
XSetStandardProperties(GLWin.dpy, GLWin.win, "GPU",
"GPU", None, NULL, 0, NULL);
XMapRaised(GLWin.dpy, GLWin.win);
}
g_VideoInitialize.pXWindow = (Window *) &GLWin.win;
#endif
return true;
@ -507,40 +398,10 @@ void OpenGL_Update()
#elif defined(HAVE_X11) && HAVE_X11
// We just check all of our events here
XEvent event;
KeySym key;
static bool ShiftPressed = false;
static bool ControlPressed = false;
static int FKeyPressed = -1;
int num_events;
for (num_events = XPending(GLWin.dpy);num_events > 0;num_events--) {
XNextEvent(GLWin.dpy, &event);
switch(event.type) {
case KeyRelease:
key = XLookupKeysym((XKeyEvent*)&event, 0);
if(key >= XK_F1 && key <= XK_F9) {
g_VideoInitialize.pKeyPress(FKeyPressed, ShiftPressed, ControlPressed);
FKeyPressed = -1;
} else {
if(key == XK_Shift_L || key == XK_Shift_R)
ShiftPressed = false;
else if(key == XK_Control_L || key == XK_Control_R)
ControlPressed = false;
}
break;
case KeyPress:
key = XLookupKeysym((XKeyEvent*)&event, 0);
if(key >= XK_F1 && key <= XK_F9)
FKeyPressed = key - 0xff4e;
else {
if(key == XK_Shift_L || key == XK_Shift_R)
ShiftPressed = true;
else if(key == XK_Control_L || key == XK_Control_R)
ControlPressed = true;
}
break;
case ButtonPress:
case ButtonRelease:
break;
case ConfigureNotify:
Window winDummy;
unsigned int borderDummy;
@ -551,7 +412,10 @@ void OpenGL_Update()
break;
case ClientMessage:
if ((ulong) event.xclient.data.l[0] == XInternAtom(GLWin.dpy, "WM_DELETE_WINDOW", False))
g_VideoInitialize.pKeyPress(0x1b, False, False);
g_VideoInitialize.pCoreMessage(WM_USER_STOP);
if ((ulong) event.xclient.data.l[0] == XInternAtom(GLWin.dpy, "RESIZE", False))
XMoveResizeWindow(GLWin.dpy, GLWin.win, event.xclient.data.l[1],
event.xclient.data.l[2], event.xclient.data.l[3], event.xclient.data.l[4]);
return;
break;
default:
@ -597,16 +461,6 @@ void OpenGL_Shutdown()
hDC = NULL; // Set DC To NULL
}
#elif defined(HAVE_X11) && HAVE_X11
#if defined(HAVE_XRANDR) && HAVE_XRANDR
/* switch back to original desktop resolution if we were in fs */
if ((GLWin.dpy != NULL) && GLWin.fs) {
XUngrabKeyboard (GLWin.dpy, CurrentTime);
XUngrabPointer (GLWin.dpy, CurrentTime);
XRRSetScreenConfig(GLWin.dpy, GLWin.screenConfig, RootWindow(GLWin.dpy, GLWin.screen),
GLWin.deskSize, GLWin.screenRotation, CurrentTime);
XRRFreeScreenConfigInfo(GLWin.screenConfig);
}
#endif
printf ("Unmapping window\n");
if (GLWin.ctx)
{

View File

@ -75,9 +75,6 @@
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/keysym.h>
#if defined(HAVE_XRANDR) && HAVE_XRANDR
#include <X11/extensions/Xrandr.h>
#endif // XRANDR
#endif // X11
#include <sys/stat.h>
@ -90,16 +87,10 @@ typedef struct {
NSOpenGLContext *cocoaCtx;
#elif defined(HAVE_X11) && HAVE_X11
Window win;
Window parent;
Display *dpy;
GLXContext ctx;
XSetWindowAttributes attr;
Bool fs;
Bool doubleBuffered;
#if defined(HAVE_XRANDR) && HAVE_XRANDR
XRRScreenConfiguration *screenConfig;
Rotation screenRotation;
int deskSize;
#endif // XRANDR
#endif // X11
#if defined(USE_WX) && USE_WX
wxGLCanvas *glCanvas;

View File

@ -79,7 +79,6 @@ namespace EmuWindow
HWND m_hWnd = NULL; // The new window that is created here
HWND m_hParent = NULL;
HWND m_hMain = NULL; // The main CPanel
HINSTANCE m_hInstance = NULL;
WNDCLASSEX wndClass;
@ -110,11 +109,6 @@ HWND GetParentWnd()
return m_hParent;
}
HWND GetChildParentWnd()
{
return m_hMain;
}
LRESULT CALLBACK WndProc( HWND hWnd, UINT iMsg, WPARAM wParam, LPARAM lParam )
{
HDC hdc;
@ -122,7 +116,7 @@ LRESULT CALLBACK WndProc( HWND hWnd, UINT iMsg, WPARAM wParam, LPARAM lParam )
switch( iMsg )
{
case WM_CREATE:
PostMessage(m_hMain, WM_USER, WM_USER_CREATE, (int)m_hParent);
PostMessage(m_hParent, WM_USER, WM_USER_CREATE, (int)m_hParent);
break;
case WM_PAINT:
@ -141,7 +135,7 @@ LRESULT CALLBACK WndProc( HWND hWnd, UINT iMsg, WPARAM wParam, LPARAM lParam )
}
break;
case VK_F5: case VK_F6: case VK_F7: case VK_F8:
PostMessage(m_hMain, WM_SYSKEYDOWN, wParam, lParam);
PostMessage(m_hParent, WM_SYSKEYDOWN, wParam, lParam);
break;
default:
return DefWindowProc(hWnd, iMsg, wParam, lParam);
@ -158,10 +152,9 @@ LRESULT CALLBACK WndProc( HWND hWnd, UINT iMsg, WPARAM wParam, LPARAM lParam )
ToggleFullscreen(hWnd);
}
// And pause the emulation when already in Windowed mode
PostMessage(m_hMain, WM_USER, WM_USER_PAUSE, 0);
PostMessage(m_hParent, WM_USER, WM_USER_PAUSE, 0);
break;
}
g_VideoInitialize.pKeyPress(LOWORD(wParam), GetAsyncKeyState(VK_SHIFT) != 0, GetAsyncKeyState(VK_CONTROL) != 0);
break;
/* The reason we pick up the WM_MOUSEMOVE is to be able to change this option
@ -174,7 +167,7 @@ LRESULT CALLBACK WndProc( HWND hWnd, UINT iMsg, WPARAM wParam, LPARAM lParam )
it's nessesary for both the chil dwindow and separate rendering window because
moves over the rendering window do not reach the main program then. */
if (GetParentWnd() == NULL) // Separate rendering window
PostMessage(m_hMain, iMsg, wParam, -1);
PostMessage(m_hParent, iMsg, wParam, -1);
else
PostMessage(GetParentWnd(), iMsg, wParam, lParam);
break;
@ -186,7 +179,7 @@ LRESULT CALLBACK WndProc( HWND hWnd, UINT iMsg, WPARAM wParam, LPARAM lParam )
if (wParam == WM_USER_STOP)
SetCursor((lParam) ? hCursor : hCursorBlank);
else if (wParam == WIIMOTE_DISCONNECT)
PostMessage(m_hMain, WM_USER, wParam, lParam);
PostMessage(m_hParent, WM_USER, wParam, lParam);
break;
/* Post these mouse events to the main window, it's nessesary becase in difference to the
@ -204,7 +197,7 @@ LRESULT CALLBACK WndProc( HWND hWnd, UINT iMsg, WPARAM wParam, LPARAM lParam )
// Take it out of fullscreen and stop the game
if( g_Config.bFullscreen )
ToggleFullscreen(m_hParent);
PostMessage(m_hMain, WM_USER, WM_USER_STOP, 0);
PostMessage(m_hParent, WM_USER, WM_USER_STOP, 0);
}
break;
@ -256,7 +249,7 @@ HWND OpenWindow(HWND parent, HINSTANCE hInstance, int width, int height, const T
// Create child window
if (parent)
{
m_hParent = m_hMain = parent;
m_hParent = parent;
m_hWnd = CreateWindow(m_szClassName, title,
WS_CHILD,
@ -282,8 +275,7 @@ HWND OpenWindow(HWND parent, HINSTANCE hInstance, int width, int height, const T
rc.top = (1024 - h)/2;
rc.bottom = rc.top + h;
// I save this to m_hMain instead of m_hParent because it casused problems otherwise
m_hMain = (HWND)g_VideoInitialize.pWindowHandle;
m_hParent = (HWND)g_VideoInitialize.pWindowHandle;
m_hWnd = CreateWindow(m_szClassName, title,
style,
@ -370,6 +362,7 @@ HWND Create(HWND hParent, HINSTANCE hInstance, const TCHAR *title)
void Close()
{
if (!m_hParent)
DestroyWindow(m_hWnd);
UnregisterClass(m_szClassName, m_hInstance);
}

View File

@ -382,32 +382,11 @@ unsigned int Wiimote_GetAttachedControllers()
// Supporting functions
// Check if Dolphin is in focus
// Check if the render window is in focus
bool IsFocus()
{
#ifdef _WIN32
HWND RenderingWindow = g_WiimoteInitialize.hWnd;
HWND Parent = GetParent(RenderingWindow);
HWND TopLevel = GetParent(Parent);
// Support both rendering to main window and not
if (GetForegroundWindow() == TopLevel || GetForegroundWindow() == RenderingWindow)
return true;
else
return false;
#elif defined HAVE_X11 && HAVE_X11
Window GLWin = *(Window *)g_WiimoteInitialize.pXWindow;
bool bFocus = False;
#if defined(HAVE_GTK2) && HAVE_GTK2 && defined(wxGTK)
bFocus = (wxPanel *)g_WiimoteInitialize.pPanel == wxWindow::FindFocus();
#endif
Window FocusWin;
int Revert;
XGetInputFocus(WMdisplay, &FocusWin, &Revert);
return (GLWin == FocusWin || bFocus);
#else
return true;
#endif
return g_WiimoteInitialize.pRendererHasFocus();
}
/* Returns a timestamp with three decimals for precise time comparisons. The return format is