Add an option to eject the disc

This commit is contained in:
JosJuice 2017-09-17 11:35:26 +02:00
parent 3c770693a2
commit e4faabb763
9 changed files with 24 additions and 3 deletions

View File

@ -468,6 +468,12 @@ static void InsertDiscCallback(u64 userdata, s64 cyclesLate)
s_disc_path_to_insert.clear();
}
// Must only be called on the CPU thread
void EjectDisc()
{
CoreTiming::ScheduleEvent(0, s_eject_disc);
}
// Must only be called on the CPU thread
void ChangeDisc(const std::string& new_path)
{
@ -477,10 +483,10 @@ void ChangeDisc(const std::string& new_path)
return;
}
s_disc_path_to_insert = new_path;
CoreTiming::ScheduleEvent(0, s_eject_disc);
CoreTiming::ScheduleEvent(SystemTimers::GetTicksPerSecond(), s_insert_disc);
EjectDisc();
s_disc_path_to_insert = new_path;
CoreTiming::ScheduleEvent(SystemTimers::GetTicksPerSecond(), s_insert_disc);
Movie::SignalDiscChange(new_path);
}

View File

@ -113,6 +113,7 @@ void RegisterMMIO(MMIO::Mapping* mmio, u32 base);
void SetDisc(std::unique_ptr<DiscIO::Volume> disc);
bool IsDiscInside();
void EjectDisc(); // Must only be called on the CPU thread
void ChangeDisc(const std::string& new_path); // Must only be called on the CPU thread
// This function returns true and calls SConfig::SetRunningGameMetadata(Volume&, Partition&)

View File

@ -23,6 +23,7 @@
const std::string hotkey_labels[] = {
_trans("Open"),
_trans("Change Disc"),
_trans("Eject Disc"),
_trans("Refresh List"),
_trans("Toggle Pause"),
_trans("Stop"),

View File

@ -21,6 +21,7 @@ enum Hotkey
{
HK_OPEN,
HK_CHANGE_DISC,
HK_EJECT_DISC,
HK_REFRESH_LIST,
HK_PLAY_PAUSE,
HK_STOP,

View File

@ -961,6 +961,8 @@ static int GetMenuIDFromHotkey(unsigned int key)
return wxID_OPEN;
case HK_CHANGE_DISC:
return IDM_CHANGE_DISC;
case HK_EJECT_DISC:
return IDM_EJECT_DISC;
case HK_REFRESH_LIST:
return wxID_REFRESH;
case HK_PLAY_PAUSE:
@ -1305,6 +1307,7 @@ void CFrame::ParseHotkeys()
{
case HK_OPEN:
case HK_CHANGE_DISC:
case HK_EJECT_DISC:
case HK_REFRESH_LIST:
case HK_RESET:
case HK_START_RECORDING:

View File

@ -299,6 +299,7 @@ private:
void OnShowInputDisplay(wxCommandEvent& event);
void OnShowRTCDisplay(wxCommandEvent& event);
void OnChangeDisc(wxCommandEvent& event);
void OnEjectDisc(wxCommandEvent& event);
void OnScreenshot(wxCommandEvent& event);
void OnActive(wxActivateEvent& event);
void OnClose(wxCloseEvent& event);

View File

@ -127,6 +127,7 @@ void CFrame::BindMenuBarEvents()
// File menu
Bind(wxEVT_MENU, &CFrame::OnOpen, this, wxID_OPEN);
Bind(wxEVT_MENU, &CFrame::OnChangeDisc, this, IDM_CHANGE_DISC);
Bind(wxEVT_MENU, &CFrame::OnEjectDisc, this, IDM_EJECT_DISC);
Bind(wxEVT_MENU, &CFrame::OnBootDrive, this, IDM_DRIVE1, IDM_DRIVE24);
Bind(wxEVT_MENU, &CFrame::OnRefresh, this, wxID_REFRESH);
Bind(wxEVT_MENU, &CFrame::OnQuit, this, wxID_EXIT);
@ -459,6 +460,11 @@ void CFrame::OnChangeDisc(wxCommandEvent& WXUNUSED(event))
DoOpen(false);
}
void CFrame::OnEjectDisc(wxCommandEvent& WXUNUSED(event))
{
Core::RunAsCPUThread(DVDInterface::EjectDisc);
}
void CFrame::OnRecord(wxCommandEvent& WXUNUSED(event))
{
if ((!Core::IsRunningAndStarted() && Core::IsRunning()) || Movie::IsRecordingInput() ||

View File

@ -94,6 +94,7 @@ enum
IDM_CHEATS,
IDM_NETPLAY,
IDM_RESTART,
IDM_EJECT_DISC,
IDM_CHANGE_DISC,
IDM_LIST_CHANGE_DISC,
IDM_PROPERTIES,

View File

@ -79,6 +79,7 @@ wxMenu* MainMenuBar::CreateFileMenu() const
auto* const file_menu = new wxMenu;
file_menu->Append(wxID_OPEN, _("&Open..."));
file_menu->Append(IDM_CHANGE_DISC, _("Change &Disc..."));
file_menu->Append(IDM_EJECT_DISC, _("Eject Disc"));
file_menu->Append(IDM_DRIVES, _("&Boot from DVD Backup"), external_drive_menu);
file_menu->AppendSeparator();
file_menu->Append(wxID_REFRESH, _("&Refresh Game List"));