1 // Copyright (C) 2003 Dolphin Project.
3 // This program is free software: you can redistribute it and/or modify
4 // it under the terms of the GNU General Public License as published by
5 // the Free Software Foundation, version 2.0.
7 // This program is distributed in the hope that it will be useful,
8 // but WITHOUT ANY WARRANTY; without even the implied warranty of
9 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 // GNU General Public License 2.0 for more details.
12 // A copy of the GPL 2.0 should have been included with the program.
13 // If not, see http://www.gnu.org/licenses/
15 // Official SVN repository and contact information can be found at
16 // http://code.google.com/p/dolphin-emu/
19 // CFrame is the main parent window. Inside CFrame there is an m_Panel that is
20 // the parent for the rendering window (when we render to the main window). In
21 // Windows the rendering window is created by giving CreateWindow()
22 // m_Panel->GetHandle() as parent window and creating a new child window to
23 // m_Panel. The new child window handle that is returned by CreateWindow() can
24 // be accessed from Core::GetWindowHandle().
26 #include "Common.h" // Common
31 #include "Globals.h" // Local
33 #include "ConfigMain.h"
34 #include "PluginManager.h"
35 #include "MemcardManager.h"
36 #include "CheatsWindow.h"
37 #include "AboutDolphin.h"
38 #include "GameListCtrl.h"
39 #include "BootManager.h"
40 #include "ConsoleListener.h"
42 #include "ConfigManager.h" // Core
44 #include "HW/DVDInterface.h"
46 #include "IPC_HLE/WII_IPC_HLE_Device_usb.h"
48 #include "VolumeHandler.h"
50 #include <wx/datetime.h> // wxWidgets
55 #include "../resources/Dolphin.c" // Dolphin icon
56 #include "../resources/toolbar_browse.c"
57 #include "../resources/toolbar_file_open.c"
58 #include "../resources/toolbar_fullscreen.c"
59 #include "../resources/toolbar_help.c"
60 #include "../resources/toolbar_pause.c"
61 #include "../resources/toolbar_play.c"
62 #include "../resources/toolbar_plugin_dsp.c"
63 #include "../resources/toolbar_plugin_gfx.c"
64 #include "../resources/toolbar_plugin_options.c"
65 #include "../resources/toolbar_plugin_pad.c"
66 #include "../resources/toolbar_refresh.c"
67 #include "../resources/toolbar_stop.c"
68 #include "../resources/Boomy.h" // Theme packages
69 #include "../resources/Vista.h"
70 #include "../resources/X-Plastik.h"
71 #include "../resources/KDE.h"
75 // Windows functions. Setting the cursor with wxSetCursor() did not work in
76 // this instance. Probably because it's somehow reset from the WndProc() in
79 // Declare a blank icon and one that will be the normal cursor
80 HCURSOR hCursor
= NULL
, hCursorBlank
= NULL
;
82 // Create the default cursor
85 hCursor
= LoadCursor( NULL
, IDC_ARROW
);
88 void MSWSetCursor(bool Show
)
94 SetCursor(hCursorBlank
);
95 //wxSetCursor(wxCursor(wxNullCursor));
99 // I could not use FindItemByHWND() instead of this, it crashed on that occation I used it */
100 HWND
MSWGetParent_(HWND Parent
)
102 return GetParent(Parent
);
107 // The CPanel class to receive MSWWindowProc messages from the video plugin.
109 extern CFrame
* main_frame
;
112 BEGIN_EVENT_TABLE(CPanel
, wxPanel
)
119 : wxPanel(parent
, id
)
124 WXLRESULT
CPanel::MSWWindowProc(WXUINT nMsg
, WXWPARAM wParam
, WXLPARAM lParam
)
133 main_frame
->DoPause();
138 main_frame
->DoStop();
144 case WM_USER_SETCURSOR
:
145 if (SConfig::GetInstance().m_LocalCoreStartupParameter
.bHideCursor
&&
146 main_frame
->RendererHasFocus() && Core::GetState() == Core::CORE_RUN
)
147 MSWSetCursor(!SConfig::GetInstance().m_LocalCoreStartupParameter
.bHideCursor
);
152 case WIIMOTE_DISCONNECT
:
153 if (SConfig::GetInstance().m_LocalCoreStartupParameter
.bWii
)
155 if (main_frame
->bNoWiimoteMsg
)
156 main_frame
->bNoWiimoteMsg
= false;
159 int wiimote_idx
= lParam
;
160 int wiimote_num
= wiimote_idx
+ 1;
161 //Auto reconnect if option is turned on.
162 //TODO: Make this only auto reconnect wiimotes that have the option activated.
163 SConfig::GetInstance().LoadSettingsWii();//Make sure we are using the newest settings.
164 if (SConfig::GetInstance().m_WiiAutoReconnect
[wiimote_idx
])
166 GetUsbPointer()->AccessWiiMote(wiimote_idx
| 0x100)->Activate(true);
167 NOTICE_LOG(WIIMOTE
, "Wiimote %i has been auto-reconnected...", wiimote_num
);
171 // The Wiimote has been disconnected, we offer reconnect here.
172 wxMessageDialog
*dlg
= new wxMessageDialog(
174 wxString::Format(wxT("Wiimote %i has been disconnected by system.\n")
175 wxT("Maybe this game doesn't support multi-wiimote,\n")
176 wxT("or maybe it is due to idle time out or other reason.\n\n")
177 wxT("Do you want to reconnect immediately?"), wiimote_num
),
178 wxT("Reconnect Wiimote Confirm"),
179 wxYES_NO
| wxSTAY_ON_TOP
| wxICON_INFORMATION
, //wxICON_QUESTION,
182 if (dlg
->ShowModal() == wxID_YES
)
183 GetUsbPointer()->AccessWiiMote(wiimote_idx
| 0x100)->Activate(true);
192 // By default let wxWidgets do what it normally does with this event
193 return wxPanel::MSWWindowProc(nMsg
, wParam
, lParam
);
199 CRenderFrame::CRenderFrame(wxFrame
* parent
, wxWindowID id
, const wxString
& title
,
200 const wxPoint
& pos
, const wxSize
& size
, long style
)
201 : wxFrame(parent
, id
, title
, pos
, size
, style
)
206 WXLRESULT
CRenderFrame::MSWWindowProc(WXUINT nMsg
, WXWPARAM wParam
, WXLPARAM lParam
)
214 case SC_MONITORPOWER
:
215 if (Core::GetState() == Core::CORE_RUN
)
218 return wxFrame::MSWWindowProc(nMsg
, wParam
, lParam
);
222 // By default let wxWidgets do what it normally does with this event
223 return wxFrame::MSWWindowProc(nMsg
, wParam
, lParam
);
230 // Notice that wxID_HELP will be processed for the 'About' menu and the toolbar
233 const wxEventType wxEVT_HOST_COMMAND
= wxNewEventType();
235 BEGIN_EVENT_TABLE(CFrame
, CRenderFrame
)
238 EVT_MENU(wxID_OPEN
, CFrame::OnOpen
)
239 EVT_MENU(wxID_EXIT
, CFrame::OnQuit
)
240 EVT_MENU(IDM_HELPWEBSITE
, CFrame::OnHelp
)
241 EVT_MENU(IDM_HELPGOOGLECODE
, CFrame::OnHelp
)
242 EVT_MENU(wxID_ABOUT
, CFrame::OnHelp
)
243 EVT_MENU(wxID_REFRESH
, CFrame::OnRefresh
)
244 EVT_MENU(IDM_PLAY
, CFrame::OnPlay
)
245 EVT_MENU(IDM_STOP
, CFrame::OnStop
)
246 EVT_MENU(IDM_RESET
, CFrame::OnReset
)
247 EVT_MENU(IDM_RECORD
, CFrame::OnRecord
)
248 EVT_MENU(IDM_PLAYRECORD
, CFrame::OnPlayRecording
)
249 EVT_MENU(IDM_FRAMESTEP
, CFrame::OnFrameStep
)
250 EVT_MENU(IDM_LUA
, CFrame::OnOpenLuaWindow
)
251 EVT_MENU(IDM_SCREENSHOT
, CFrame::OnScreenshot
)
252 EVT_MENU(wxID_PREFERENCES
, CFrame::OnConfigMain
)
253 EVT_MENU(IDM_CONFIG_GFX_PLUGIN
, CFrame::OnPluginGFX
)
254 EVT_MENU(IDM_CONFIG_DSP_PLUGIN
, CFrame::OnPluginDSP
)
255 EVT_MENU(IDM_CONFIG_PAD_PLUGIN
, CFrame::OnPluginPAD
)
256 EVT_MENU(IDM_CONFIG_WIIMOTE_PLUGIN
, CFrame::OnPluginWiimote
)
258 EVT_MENU(IDM_SAVE_PERSPECTIVE
, CFrame::OnToolBar
)
259 EVT_AUITOOLBAR_TOOL_DROPDOWN(IDM_SAVE_PERSPECTIVE
, CFrame::OnDropDownToolbarItem
)
260 EVT_MENU(IDM_EDIT_PERSPECTIVES
, CFrame::OnToolBar
)
261 EVT_AUITOOLBAR_TOOL_DROPDOWN(IDM_EDIT_PERSPECTIVES
, CFrame::OnDropDownSettingsToolbar
)
263 EVT_MENU(IDM_PERSPECTIVES_ADD_PANE
, CFrame::OnToolBar
)
264 EVT_MENU_RANGE(IDM_PERSPECTIVES_0
, IDM_PERSPECTIVES_100
, CFrame::OnSelectPerspective
)
265 EVT_MENU(IDM_ADD_PERSPECTIVE
, CFrame::OnDropDownToolbarSelect
)
266 EVT_MENU(IDM_TAB_SPLIT
, CFrame::OnDropDownToolbarSelect
)
267 EVT_MENU(IDM_NO_DOCKING
, CFrame::OnDropDownToolbarSelect
)
269 EVT_MENU_RANGE(IDM_FLOAT_LOGWINDOW
, IDM_FLOAT_CODEWINDOW
, CFrame::OnFloatWindow
)
271 EVT_MENU(IDM_NETPLAY
, CFrame::OnNetPlay
)
272 EVT_MENU(IDM_BROWSE
, CFrame::OnBrowse
)
273 EVT_MENU(IDM_MEMCARD
, CFrame::OnMemcard
)
274 EVT_MENU(IDM_IMPORTSAVE
, CFrame::OnImportSave
)
275 EVT_MENU(IDM_CHEATS
, CFrame::OnShow_CheatsWindow
)
276 EVT_MENU(IDM_CHANGEDISC
, CFrame::OnChangeDisc
)
277 EVT_MENU(IDM_INSTALL_WII_MENU
, CFrame::OnLoadWiiMenu
)
278 EVT_MENU(IDM_LOAD_WII_MENU
, CFrame::OnLoadWiiMenu
)
280 EVT_MENU(IDM_TOGGLE_FULLSCREEN
, CFrame::OnToggleFullscreen
)
281 EVT_MENU(IDM_TOGGLE_DUALCORE
, CFrame::OnToggleDualCore
)
282 EVT_MENU(IDM_TOGGLE_SKIPIDLE
, CFrame::OnToggleSkipIdle
)
283 EVT_MENU(IDM_TOGGLE_TOOLBAR
, CFrame::OnToggleToolbar
)
284 EVT_MENU(IDM_TOGGLE_STATUSBAR
, CFrame::OnToggleStatusbar
)
285 EVT_MENU_RANGE(IDM_LOGWINDOW
, IDM_VIDEOWINDOW
, CFrame::OnToggleWindow
)
287 EVT_MENU(IDM_PURGECACHE
, CFrame::GameListChanged
)
289 EVT_MENU(IDM_LOADLASTSTATE
, CFrame::OnLoadLastState
)
290 EVT_MENU(IDM_UNDOLOADSTATE
, CFrame::OnUndoLoadState
)
291 EVT_MENU(IDM_UNDOSAVESTATE
, CFrame::OnUndoSaveState
)
292 EVT_MENU(IDM_LOADSTATEFILE
, CFrame::OnLoadStateFromFile
)
293 EVT_MENU(IDM_SAVESTATEFILE
, CFrame::OnSaveStateToFile
)
295 EVT_MENU_RANGE(IDM_LOADSLOT1
, IDM_LOADSLOT8
, CFrame::OnLoadState
)
296 EVT_MENU_RANGE(IDM_SAVESLOT1
, IDM_SAVESLOT8
, CFrame::OnSaveState
)
297 EVT_MENU_RANGE(IDM_FRAMESKIP0
, IDM_FRAMESKIP9
, CFrame::OnFrameSkip
)
298 EVT_MENU_RANGE(IDM_DRIVE1
, IDM_DRIVE24
, CFrame::OnBootDrive
)
299 EVT_MENU_RANGE(IDM_CONNECT_WIIMOTE1
, IDM_CONNECT_WIIMOTE4
, CFrame::OnConnectWiimote
)
300 EVT_MENU_RANGE(IDM_LISTWAD
, IDM_LISTDRIVES
, CFrame::GameListChanged
)
303 EVT_ACTIVATE(CFrame::OnActive
)
304 EVT_CLOSE(CFrame::OnClose
)
305 EVT_SIZE(CFrame::OnResize
)
306 EVT_MOVE(CFrame::OnMove
)
307 EVT_LIST_ITEM_ACTIVATED(LIST_CTRL
, CFrame::OnGameListCtrl_ItemActivated
)
308 EVT_HOST_COMMAND(wxID_ANY
, CFrame::OnHostMessage
)
310 EVT_TIMER(wxID_ANY
, CFrame::OnTimer
)
313 EVT_AUI_PANE_CLOSE(CFrame::OnPaneClose
)
314 EVT_AUINOTEBOOK_PAGE_CLOSE(wxID_ANY
, CFrame::OnNotebookPageClose
)
315 EVT_AUINOTEBOOK_ALLOW_DND(wxID_ANY
, CFrame::OnAllowNotebookDnD
)
316 EVT_AUINOTEBOOK_PAGE_CHANGED(wxID_ANY
, CFrame::OnNotebookPageChanged
)
317 EVT_AUINOTEBOOK_TAB_RIGHT_UP(wxID_ANY
, CFrame::OnTab
)
319 // Post events to child panels
320 EVT_MENU_RANGE(IDM_INTERPRETER
, IDM_ADDRBOX
, CFrame::PostEvent
)
321 EVT_TEXT(IDM_ADDRBOX
, CFrame::PostEvent
)
326 // Creation and close, quit functions
328 CFrame::CFrame(wxFrame
* parent
,
330 const wxString
& title
,
337 : CRenderFrame(parent
, id
, title
, pos
, size
, style
)
338 , g_pCodeWindow(NULL
)
339 , bRenderToMain(false), bNoWiimoteMsg(false)
340 , m_ToolBar(NULL
), m_ToolBarDebug(NULL
), m_ToolBarAui(NULL
)
341 , m_pStatusBar(NULL
), m_GameListCtrl(NULL
), m_Panel(NULL
)
342 , m_RenderFrame(NULL
), m_RenderParent(NULL
)
343 , m_LogWindow(NULL
), UseDebugger(_UseDebugger
)
344 , m_bBatchMode(_BatchMode
), m_bEdit(false), m_bTabSplit(false), m_bNoDocking(false)
345 , m_bControlsCreated(false), m_bGameLoading(false), m_StopDlg(NULL
)
350 for (int i
= 0; i
<= IDM_CODEWINDOW
- IDM_LOGWINDOW
; i
++)
351 bFloatWindow
[i
] = false;
353 if (ShowLogWindow
) SConfig::GetInstance().m_InterfaceLogWindow
= true;
355 // Give it a console early to show potential messages from this onward
356 ConsoleListener
*Console
= LogManager::GetInstance()->getConsoleListener();
357 if (SConfig::GetInstance().m_InterfaceConsole
) Console
->Open();
358 m_LogWindow
= new CLogWindow(this, IDM_LOGWINDOW
);
360 m_LogWindow
->Disable();
362 // Start debugging mazimized
363 if (UseDebugger
) this->Maximize(true);
367 g_pCodeWindow
= new CCodeWindow(SConfig::GetInstance().m_LocalCoreStartupParameter
, this, IDM_CODEWINDOW
);
368 LoadIniPerspectives();
369 g_pCodeWindow
->Load();
370 g_pCodeWindow
->Hide();
375 int TimesPerSecond
= 10; // We don't need more than this
376 m_timer
.Start( floor((double)(1000 / TimesPerSecond
)) );
379 // Create toolbar bitmaps
384 IconTemp
.CopyFromBitmap(wxGetBitmapFromMemory(dolphin_ico32x32
));
387 // Give it a status bar
388 m_pStatusBar
= CreateStatusBar(2, wxST_SIZEGRIP
, ID_STATUSBAR
);
389 if (!SConfig::GetInstance().m_InterfaceStatusbar
)
390 m_pStatusBar
->Hide();
392 // Give it a menu bar
397 // This panel is the parent for rendering and it holds the gamelistctrl
398 m_Panel
= new CPanel(this, IDM_MPANEL
);
400 m_GameListCtrl
= new CGameListCtrl(m_Panel
, LIST_CTRL
,
401 wxDefaultPosition
, wxDefaultSize
,
402 wxLC_REPORT
| wxSUNKEN_BORDER
| wxLC_ALIGN_LEFT
);
404 wxBoxSizer
*sizerPanel
= new wxBoxSizer(wxHORIZONTAL
);
405 sizerPanel
->Add(m_GameListCtrl
, 1, wxEXPAND
| wxALL
);
406 m_Panel
->SetSizer(sizerPanel
);
410 // wxAUI_MGR_LIVE_RESIZE does not exist in the wxWidgets 2.8.9 that comes with Ubuntu 9.04
411 // Could just check for wxWidgets version if it becomes a problem.
412 m_Mgr
= new wxAuiManager(this, wxAUI_MGR_DEFAULT
| wxAUI_MGR_LIVE_RESIZE
);
416 m_Mgr
->AddPane(m_Panel
, wxAuiPaneInfo().Name(wxT("Pane 0")).Caption(wxT("Pane 0")).Show());
420 m_Mgr
->AddPane(m_Panel
, wxAuiPaneInfo().Name(wxT("Pane 0")).Caption(wxT("Pane 0")).Hide());
421 m_Mgr
->AddPane(CreateEmptyNotebook(), wxAuiPaneInfo().Name(wxT("Pane 1")).Caption(wxT("Logging")).Hide());
424 // Setup perspectives
427 m_Mgr
->GetPane(wxT("Pane 0")).CenterPane().PaneBorder(false);
428 AuiFullscreen
= m_Mgr
->SavePerspective();
429 m_Mgr
->GetPane(wxT("Pane 0")).CenterPane().PaneBorder(true);
433 m_Mgr
->GetPane(wxT("Pane 0")).Show().PaneBorder(false).CaptionVisible(false).Layer(0).Center();
434 m_Mgr
->GetPane(wxT("Pane 1")).Hide().PaneBorder(false).CaptionVisible(true).Layer(0)
435 .FloatingSize(wxSize(600, 350)).CloseButton(false);
436 AuiFullscreen
= m_Mgr
->SavePerspective();
441 if (!SConfig::GetInstance().m_InterfaceToolbar
) DoToggleToolbar(false);
443 // Create list of available plugins for the configuration window
444 CPluginManager::GetInstance().ScanForPlugins();
446 // Setup perspectives
454 if (SConfig::GetInstance().m_InterfaceLogWindow
)
455 ToggleLogWindow(true);
456 if (SConfig::GetInstance().m_InterfaceConsole
)
471 #if defined(HAVE_XRANDR) && HAVE_XRANDR
472 m_XRRConfig
= new X11Utils::XRRConfiguration(X11Utils::XDisplayFromHandle(GetHandle()),
473 X11Utils::XWindowFromHandle(GetHandle()));
476 // -------------------------
477 // Connect event handlers
479 m_Mgr
->Connect(wxID_ANY
, wxEVT_AUI_RENDER
, // Resize
480 wxAuiManagerEventHandler(CFrame::OnManagerResize
),
485 m_bControlsCreated
= true;
488 // If we are rerecording create the status bar now instead of later when a game starts
491 // It's to early for the OnHostMessage(), we will update the status when Ctrl or Space is pressed
492 //Core::WriteStatus();
498 m_bControlsCreated
= false;
501 /* The statbar sample has this so I add this to, but I guess timer will be deleted after
504 if (m_timer
.IsRunning()) m_timer
.Stop();
507 #if defined(HAVE_XRANDR) && HAVE_XRANDR
516 bool CFrame::RendererIsFullscreen()
518 if (Core::GetState() == Core::CORE_RUN
|| Core::GetState() == Core::CORE_PAUSE
)
520 return m_RenderFrame
->IsFullScreen();
525 void CFrame::OnQuit(wxCommandEvent
& WXUNUSED (event
))
532 void CFrame::OnActive(wxActivateEvent
& event
)
534 if (Core::GetState() == Core::CORE_RUN
|| Core::GetState() == Core::CORE_PAUSE
)
536 if (event
.GetActive() && event
.GetEventObject() == m_RenderFrame
)
539 ::SetFocus((HWND
)m_RenderParent
->GetHandle());
541 m_RenderParent
->SetFocus();
543 if (SConfig::GetInstance().m_LocalCoreStartupParameter
.bHideCursor
&&
544 Core::GetState() == Core::CORE_RUN
)
545 m_RenderParent
->SetCursor(wxCURSOR_BLANK
);
549 if (SConfig::GetInstance().m_LocalCoreStartupParameter
.bHideCursor
)
550 m_RenderParent
->SetCursor(wxCURSOR_ARROW
);
556 void CFrame::OnClose(wxCloseEvent
& event
)
558 //Stop Dolphin from saving the minimized Xpos and Ypos
559 if(main_frame
->IsIconized())
560 main_frame
->Iconize(false);
562 // Don't forget the skip or the window won't be destroyed
565 if (g_pCodeWindow
) SaveIniPerspectives();
567 // Close the log window now so that its settings are saved
569 m_LogWindow
->Close();
574 if (Core::GetState() != Core::CORE_UNINITIALIZED
)
583 // Warning: This may cause an endless loop if the event is propagated back to its parent
584 void CFrame::PostEvent(wxCommandEvent
& event
)
587 event
.GetId() >= IDM_INTERPRETER
&&
588 event
.GetId() <= IDM_ADDRBOX
)
590 event
.StopPropagation();
591 g_pCodeWindow
->GetEventHandler()->AddPendingEvent(event
);
597 void CFrame::OnMove(wxMoveEvent
& event
)
601 if (!IsMaximized() &&
602 !(SConfig::GetInstance().m_LocalCoreStartupParameter
.bRenderToMain
&& RendererIsFullscreen()))
604 SConfig::GetInstance().m_LocalCoreStartupParameter
.iPosX
= GetPosition().x
;
605 SConfig::GetInstance().m_LocalCoreStartupParameter
.iPosY
= GetPosition().y
;
609 void CFrame::OnResize(wxSizeEvent
& event
)
612 if (!IsMaximized() &&
613 !(SConfig::GetInstance().m_LocalCoreStartupParameter
.bRenderToMain
&& RendererIsFullscreen()))
615 SConfig::GetInstance().m_LocalCoreStartupParameter
.iWidth
= GetSize().GetWidth();
616 SConfig::GetInstance().m_LocalCoreStartupParameter
.iHeight
= GetSize().GetHeight();
623 WXLRESULT
CFrame::MSWWindowProc(WXUINT nMsg
, WXWPARAM wParam
, WXLPARAM lParam
)
628 switch (wParam
& 0xFFF0)
631 case SC_MONITORPOWER
:
634 return wxFrame::MSWWindowProc(nMsg
, wParam
, lParam
);
638 return wxFrame::MSWWindowProc(nMsg
, wParam
, lParam
);
645 void CFrame::OnTimer(wxTimerEvent
& WXUNUSED(event
))
647 // Process events. Primarily to update the statusbar text.
648 if (wxGetApp().Pending())
649 wxGetApp().ProcessPendingEvents();
653 void CFrame::OnHostMessage(wxCommandEvent
& event
)
655 switch (event
.GetId())
661 case IDM_UPDATESTATUSBAR
:
662 if (m_pStatusBar
!= NULL
)
664 m_pStatusBar
->SetStatusText(event
.GetString(), event
.GetInt());
668 case IDM_UPDATETITLE
:
669 if (!SConfig::GetInstance().m_LocalCoreStartupParameter
.bRenderToMain
&& m_RenderFrame
)
670 m_RenderFrame
->SetTitle(event
.GetString());
674 if (SConfig::GetInstance().m_LocalCoreStartupParameter
.bHideCursor
)
675 m_RenderParent
->SetCursor(wxCURSOR_BLANK
);
678 #if defined(HAVE_X11) && HAVE_X11
686 void CFrame::OnSizeRequest(int& x
, int& y
, int& width
, int& height
)
689 m_RenderParent
->GetSize(&width
, &height
);
690 m_RenderParent
->GetPosition(&x
, &y
);
694 bool CFrame::RendererHasFocus()
696 if (m_RenderParent
== NULL
)
699 if (m_RenderParent
->GetParent()->GetHWND() == GetForegroundWindow())
702 if (wxWindow::FindFocus() == NULL
)
704 // Why these different cases?
705 if (m_RenderParent
== wxWindow::FindFocus() ||
706 m_RenderParent
== wxWindow::FindFocus()->GetParent() ||
707 m_RenderParent
->GetParent() == wxWindow::FindFocus()->GetParent())
713 void CFrame::OnGameListCtrl_ItemActivated(wxListEvent
& WXUNUSED (event
))
715 // Show all platforms and regions if...
716 // 1. All platforms are set to hide
717 // 2. All Regions are set to hide
718 // Otherwise call BootGame to either...
719 // 1. Boot the selected iso
720 // 2. Boot the default or last loaded iso.
721 // 3. Call BrowseForDirectory if the gamelist is empty
722 if (!m_GameListCtrl
->GetGameNames().size() &&
723 !((SConfig::GetInstance().m_ListGC
&&
724 SConfig::GetInstance().m_ListWii
&&
725 SConfig::GetInstance().m_ListWad
) &&
726 (SConfig::GetInstance().m_ListJap
&&
727 SConfig::GetInstance().m_ListUsa
&&
728 SConfig::GetInstance().m_ListPal
&&
729 SConfig::GetInstance().m_ListFrance
&&
730 SConfig::GetInstance().m_ListItaly
&&
731 SConfig::GetInstance().m_ListKorea
&&
732 SConfig::GetInstance().m_ListTaiwan
&&
733 SConfig::GetInstance().m_ListUnknown
)))
735 SConfig::GetInstance().m_ListGC
= SConfig::GetInstance().m_ListWii
=
736 SConfig::GetInstance().m_ListWad
= SConfig::GetInstance().m_ListJap
=
737 SConfig::GetInstance().m_ListUsa
= SConfig::GetInstance().m_ListPal
=
738 SConfig::GetInstance().m_ListFrance
= SConfig::GetInstance().m_ListItaly
=
739 SConfig::GetInstance().m_ListKorea
= SConfig::GetInstance().m_ListTaiwan
=
740 SConfig::GetInstance().m_ListUnknown
= true;
742 GetMenuBar()->FindItem(IDM_LISTGC
)->Check(true);
743 GetMenuBar()->FindItem(IDM_LISTWII
)->Check(true);
744 GetMenuBar()->FindItem(IDM_LISTWAD
)->Check(true);
745 GetMenuBar()->FindItem(IDM_LISTJAP
)->Check(true);
746 GetMenuBar()->FindItem(IDM_LISTUSA
)->Check(true);
747 GetMenuBar()->FindItem(IDM_LISTPAL
)->Check(true);
748 GetMenuBar()->FindItem(IDM_LISTFRANCE
)->Check(true);
749 GetMenuBar()->FindItem(IDM_LISTITALY
)->Check(true);
750 GetMenuBar()->FindItem(IDM_LISTKOREA
)->Check(true);
751 GetMenuBar()->FindItem(IDM_LISTTAIWAN
)->Check(true);
752 GetMenuBar()->FindItem(IDM_LIST_UNK
)->Check(true);
754 m_GameListCtrl
->Update();
757 // Game started by double click
758 BootGame(std::string(""));
761 bool IsHotkey(wxKeyEvent
&event
, int Id
)
763 return (event
.GetKeyCode() == SConfig::GetInstance().m_LocalCoreStartupParameter
.iHotkey
[Id
] &&
764 event
.GetModifiers() == SConfig::GetInstance().m_LocalCoreStartupParameter
.iHotkeyModifier
[Id
]);
767 void CFrame::OnKeyDown(wxKeyEvent
& event
)
769 if(Core::GetState() != Core::CORE_UNINITIALIZED
)
773 if (IsHotkey(event
, HK_FULLSCREEN
))
774 DoFullscreen(!RendererIsFullscreen());
776 else if (IsHotkey(event
, HK_PLAY_PAUSE
))
779 else if (IsHotkey(event
, HK_STOP
))
781 // Wiimote connect and disconnect hotkeys
782 else if (IsHotkey(event
, HK_WIIMOTE1_CONNECT
))
784 else if (IsHotkey(event
, HK_WIIMOTE2_CONNECT
))
786 else if (IsHotkey(event
, HK_WIIMOTE3_CONNECT
))
788 else if (IsHotkey(event
, HK_WIIMOTE4_CONNECT
))
790 // state save and state load hotkeys
791 else if (event
.GetKeyCode() >= WXK_F1
&& event
.GetKeyCode() <= WXK_F8
)
793 int slot_number
= event
.GetKeyCode() - WXK_F1
+ 1;
794 if (event
.GetModifiers() == wxMOD_NONE
)
795 State_Load(slot_number
);
796 else if (event
.GetModifiers() == wxMOD_SHIFT
)
797 State_Save(slot_number
);
801 else if (event
.GetKeyCode() == WXK_F11
&& event
.GetModifiers() == wxMOD_NONE
)
802 State_LoadLastSaved();
803 else if (event
.GetKeyCode() == WXK_F12
)
805 if (event
.GetModifiers() == wxMOD_NONE
)
806 State_UndoSaveState();
807 else if (event
.GetModifiers() == wxMOD_SHIFT
)
808 State_UndoLoadState();
812 // screenshot hotkeys
813 else if (event
.GetKeyCode() == WXK_F9
&& event
.GetModifiers() == wxMOD_NONE
)
818 // Actually perform the wiimote connection or disconnection
821 bNoWiimoteMsg
= GetMenuBar()->IsChecked(IDM_CONNECT_WIIMOTE1
+ WiimoteId
);
822 GetMenuBar()->Check(IDM_CONNECT_WIIMOTE1
+ WiimoteId
, !bNoWiimoteMsg
);
823 GetUsbPointer()->AccessWiiMote(WiimoteId
| 0x100)->Activate(!bNoWiimoteMsg
);
824 wxString
msg(wxString::Format(wxT("Wiimote %i %s"), WiimoteId
+ 1,
825 bNoWiimoteMsg
? wxT("Disconnected") : wxT("Connected")));
826 Core::DisplayMessage(msg
.ToAscii(), 3000);
829 // Send the OSD hotkeys to the video plugin
830 if (event
.GetKeyCode() >= '3' && event
.GetKeyCode() <= '7' && event
.GetModifiers() == wxMOD_NONE
)
833 PostMessage((HWND
)Core::GetWindowHandle(), WM_USER
, WM_USER_KEYDOWN
, event
.GetKeyCode());
834 #elif defined(HAVE_X11) && HAVE_X11
835 X11Utils::SendKeyEvent(X11Utils::XDisplayFromHandle(GetHandle()), event
.GetKeyCode());
839 // Send the freelook hotkeys to the video plugin
840 if ((event
.GetKeyCode() == '0', '9', 'W', 'S', 'A', 'D', 'R')
841 && event
.GetModifiers() == wxMOD_SHIFT
)
842 PostMessage((HWND
)Core::GetWindowHandle(), WM_USER
, WM_USER_KEYDOWN
, event
.GetKeyCode());
845 // Send the keyboard status to the Input plugins
846 CPluginManager::GetInstance().GetWiimote()->Wiimote_Input(event
.GetKeyCode(), 1); // 1 = Down
852 void CFrame::OnKeyUp(wxKeyEvent
& event
)
856 if(Core::GetState() != Core::CORE_UNINITIALIZED
) {
857 CPluginManager::GetInstance().GetWiimote()->Wiimote_Input(event
.GetKeyCode(), 0); // 0 = Up
861 void CFrame::DoFullscreen(bool bF
)
863 ToggleDisplayMode(bF
);
865 m_RenderFrame
->ShowFullScreen(bF
, wxFULLSCREEN_ALL
);
866 if (SConfig::GetInstance().m_LocalCoreStartupParameter
.bRenderToMain
)
870 // Save the current mode before going to fullscreen
871 AuiCurrent
= m_Mgr
->SavePerspective();
872 m_Mgr
->LoadPerspective(AuiFullscreen
, true);
876 // Restore saved perspective
877 m_Mgr
->LoadPerspective(AuiCurrent
, true);
881 m_RenderFrame
->Raise();