diff --git a/.gitignore b/.gitignore index 9b807bffd0..345ed1795c 100644 --- a/.gitignore +++ b/.gitignore @@ -39,6 +39,8 @@ pcsx2.snapshot_* svnrev.h /build +/build_dev +/build_dbg /obj-* .DS_Store @@ -47,6 +49,8 @@ Thumbs.db Debug.txt install_log.txt padLog.txt +GSdx_opengl_debug_hw.txt +GSdx_opengl_debug_sw.txt Debug Release @@ -70,6 +74,7 @@ oprofile_data/ /bin/**/*.lib /bin/**/*.pdb /bin/PCSX2 +/bin/PCSX2-linux.sh /bin/*ReplayLoader /bin/PCSX2-linux.sh /bin/GSdx*.txt diff --git a/common/include/Utilities/mt_queue.h b/common/include/Utilities/mt_queue.h index 3fc7937129..ebe38b35b2 100644 --- a/common/include/Utilities/mt_queue.h +++ b/common/include/Utilities/mt_queue.h @@ -48,6 +48,14 @@ public: return m_queue.size(); } + T dequeue() + { + std::lock_guard guard(m_mtx); + T item = m_queue.front(); + m_queue.pop(); + return item; + } + template void consume_all(F f) { diff --git a/pcsx2/Recording/NewRecordingFrame.cpp b/pcsx2/Recording/NewRecordingFrame.cpp index 39de5a7857..b44ca33223 100644 --- a/pcsx2/Recording/NewRecordingFrame.cpp +++ b/pcsx2/Recording/NewRecordingFrame.cpp @@ -1,5 +1,5 @@ /* PCSX2 - PS2 Emulator for PCs - * Copyright (C) 2002-2019 PCSX2 Dev Team + * Copyright (C) 2002-2020 PCSX2 Dev Team * * PCSX2 is free software: you can redistribute it and/or modify it under the terms * of the GNU Lesser General Public License as published by the Free Software Found- @@ -62,7 +62,13 @@ NewRecordingFrame::NewRecordingFrame(wxWindow *parent) wxString NewRecordingFrame::GetFile() const { - return m_filePicker->GetPath(); + wxString path = m_filePicker->GetPath(); + // wxWidget's removes the extension if it contains wildcards + // on wxGTK https://trac.wxwidgets.org/ticket/15285 + if (!path.EndsWith(".p2m2")) { + return wxString::Format("%s.p2m2", path); + } + return path; } wxString NewRecordingFrame::GetAuthor() const diff --git a/pcsx2/Recording/RecordingControls.cpp b/pcsx2/Recording/RecordingControls.cpp index 782a672684..c86e346465 100644 --- a/pcsx2/Recording/RecordingControls.cpp +++ b/pcsx2/Recording/RecordingControls.cpp @@ -1,5 +1,5 @@ /* PCSX2 - PS2 Emulator for PCs - * Copyright (C) 2002-2019 PCSX2 Dev Team + * Copyright (C) 2002-2020 PCSX2 Dev Team * * PCSX2 is free software: you can redistribute it and/or modify it under the terms * of the GNU Lesser General Public License as published by the Free Software Found- @@ -17,6 +17,7 @@ #include "App.h" #include "Counters.h" +#include "Common.h" #include "GSFrame.h" #include "MemoryTypes.h" @@ -27,11 +28,13 @@ RecordingControls g_RecordingControls; //----------------------------------------------- -// Status on whether or not the current recording is stopped +// Current recording status, returns true if: +// - Recording is Paused +// - GSFrame CoreThread is both running AND paused //----------------------------------------------- -bool RecordingControls::HasRecordingStopped() +bool RecordingControls::IsEmulationAndRecordingPaused() { - return (fPauseState && CoreThread.IsOpen() && CoreThread.IsPaused()); + return fPauseState && CoreThread.IsOpen() && CoreThread.IsPaused(); } //----------------------------------------------- diff --git a/pcsx2/Recording/RecordingControls.h b/pcsx2/Recording/RecordingControls.h index c0b52aa37e..f9e60a633d 100644 --- a/pcsx2/Recording/RecordingControls.h +++ b/pcsx2/Recording/RecordingControls.h @@ -1,5 +1,5 @@ /* PCSX2 - PS2 Emulator for PCs - * Copyright (C) 2002-2019 PCSX2 Dev Team + * Copyright (C) 2002-2020 PCSX2 Dev Team * * PCSX2 is free software: you can redistribute it and/or modify it under the terms * of the GNU Lesser General Public License as published by the Free Software Found- @@ -21,7 +21,7 @@ class RecordingControls public: // Movie controls main functions - bool HasRecordingStopped(); + bool IsEmulationAndRecordingPaused(); void ResumeCoreThreadIfStarted(); void HandleFrameAdvanceAndStop(); diff --git a/pcsx2/gui/App.h b/pcsx2/gui/App.h index 1086d07650..4348c5e24f 100644 --- a/pcsx2/gui/App.h +++ b/pcsx2/gui/App.h @@ -664,11 +664,6 @@ protected: void OpenWizardConsole(); void PadKeyDispatch( const keyEvent& ev ); -#ifndef DISABLE_RECORDING -public: - void Recording_PadKeyDispatch(const keyEvent& ev) { PadKeyDispatch(ev); } -#endif - protected: void HandleEvent(wxEvtHandler* handler, wxEventFunction func, wxEvent& event) const; void HandleEvent(wxEvtHandler* handler, wxEventFunction func, wxEvent& event); diff --git a/pcsx2/gui/AppMain.cpp b/pcsx2/gui/AppMain.cpp index 9ba3860d73..610c58574c 100644 --- a/pcsx2/gui/AppMain.cpp +++ b/pcsx2/gui/AppMain.cpp @@ -620,17 +620,16 @@ void Pcsx2App::HandleEvent(wxEvtHandler* handler, wxEventFunction func, wxEvent& #ifndef DISABLE_RECORDING if (g_Conf->EmuOptions.EnableRecordingTools) { - if (g_RecordingControls.HasRecordingStopped()) + if (g_RecordingControls.IsEmulationAndRecordingPaused()) { - // While stopping, GSFrame key event also stops, so get key input from here - // Along with that, you can not use the shortcut keys set in GSFrame - if (PADkeyEvent != NULL) + // When the GSFrame CoreThread is paused, so is the logical VSync + // Meaning that we have to grab the user-input through here to potentially + // resume emulation. + if (const keyEvent* ev = PADkeyEvent() ) { - // Acquire key information, possibly calling it only once per frame - const keyEvent* ev = PADkeyEvent(); - if (ev != NULL) + if( ev->key != 0 ) { - sApp.Recording_PadKeyDispatch(*ev); + PadKeyDispatch( *ev ); } } } diff --git a/pcsx2/gui/FrameForGS.cpp b/pcsx2/gui/FrameForGS.cpp index fa625be96e..136ea8f1f5 100644 --- a/pcsx2/gui/FrameForGS.cpp +++ b/pcsx2/gui/FrameForGS.cpp @@ -102,6 +102,12 @@ void GSPanel::InitRecordingAccelerators() m_Accels->Map(AAC(WXK_SPACE), "FrameAdvance"); m_Accels->Map(AAC(wxKeyCode('p')).Shift(), "TogglePause"); m_Accels->Map(AAC(wxKeyCode('r')).Shift(), "InputRecordingModeToggle"); +#if defined(__unix__) + // Shift+P (80) and Shift+p (112) have two completely different codes + // On Linux the former is sometimes fired so define bindings for both + m_Accels->Map(AAC(wxKeyCode('P')).Shift(), "TogglePause"); + m_Accels->Map(AAC(wxKeyCode('R')).Shift(), "InputRecordingModeToggle"); +#endif m_Accels->Map(AAC(WXK_NUMPAD0).Shift(), "States_SaveSlot0"); m_Accels->Map(AAC(WXK_NUMPAD1).Shift(), "States_SaveSlot1"); @@ -123,6 +129,8 @@ void GSPanel::InitRecordingAccelerators() m_Accels->Map(AAC(WXK_NUMPAD7), "States_LoadSlot7"); m_Accels->Map(AAC(WXK_NUMPAD8), "States_LoadSlot8"); m_Accels->Map(AAC(WXK_NUMPAD9), "States_LoadSlot9"); + + recordingConLog(L"Initialized Recording Key Bindings\n"); } #endif diff --git a/plugins/onepad/keyboard.cpp b/plugins/onepad/keyboard.cpp index 75cc3d318e..81c962b969 100644 --- a/plugins/onepad/keyboard.cpp +++ b/plugins/onepad/keyboard.cpp @@ -117,7 +117,7 @@ static bool s_Shift = false; static unsigned int s_previous_mouse_x = 0; static unsigned int s_previous_mouse_y = 0; -static void AnalyzeKeyEvent(keyEvent &evt) +void AnalyzeKeyEvent(keyEvent &evt) { KeySym key = (KeySym)evt.key; int pad = 0; diff --git a/plugins/onepad/keyboard.h b/plugins/onepad/keyboard.h index a6e0681e55..3a4d4a7f77 100644 --- a/plugins/onepad/keyboard.h +++ b/plugins/onepad/keyboard.h @@ -26,6 +26,7 @@ #if defined(__unix__) || defined(__APPLE__) +extern void AnalyzeKeyEvent(keyEvent &evt); extern void UpdateKeyboardInput(); extern bool PollForNewKeyboardKeys(u32 &pkey); #ifndef __APPLE__ diff --git a/plugins/onepad/onepad.cpp b/plugins/onepad/onepad.cpp index 003157b38b..3375472808 100644 --- a/plugins/onepad/onepad.cpp +++ b/plugins/onepad/onepad.cpp @@ -25,6 +25,7 @@ #include #include +#include "keyboard.h" #include "onepad.h" #include "svnrev.h" #include "state_management.h" @@ -332,10 +333,16 @@ PADkeyEvent() } } #endif - - s_event = event; - event.evt = 0; - event.key = 0; + if (g_ev_fifo.size() == 0) { + // PAD_LOG("No events in queue, returning empty event\n"); + s_event = event; + event.evt = 0; + event.key = 0; + return &s_event; + } + s_event = g_ev_fifo.dequeue(); + AnalyzeKeyEvent(s_event); + // PAD_LOG("Returning Event. Event Type: %d, Key: %d\n", s_event.evt, s_event.key); return &s_event; } @@ -343,6 +350,9 @@ PADkeyEvent() EXPORT_C_(void) PADWriteEvent(keyEvent &evt) { + // if (evt.evt != 6) { // Skip mouse move events for logging + // PAD_LOG("Pushing Event. Event Type: %d, Key: %d\n", evt.evt, evt.key); + // } g_ev_fifo.push(evt); } #endif diff --git a/plugins/onepad_legacy/keyboard.h b/plugins/onepad_legacy/keyboard.h index 5c1690d8b3..13482c52a4 100644 --- a/plugins/onepad_legacy/keyboard.h +++ b/plugins/onepad_legacy/keyboard.h @@ -29,6 +29,7 @@ #include "Linux/linux.h" extern Display *GSdsp; +extern void AnalyzeKeyEvent(keyEvent &evt); extern void PollForX11KeyboardInput(); extern bool PollX11KeyboardMouseEvent(u32 &pkey); extern Window GSwin; diff --git a/plugins/onepad_legacy/onepad.cpp b/plugins/onepad_legacy/onepad.cpp index 212bdf3948..fd7524d4d7 100644 --- a/plugins/onepad_legacy/onepad.cpp +++ b/plugins/onepad_legacy/onepad.cpp @@ -25,6 +25,7 @@ #include #include +#include "keyboard.h" #include "onepad.h" #include "svnrev.h" #include "state_management.h" @@ -329,15 +330,25 @@ EXPORT_C_(u8) PADpoll(u8 value) // PADkeyEvent is called every vsync (return NULL if no event) EXPORT_C_(keyEvent *) PADkeyEvent() { - s_event = event; - event.evt = 0; - event.key = 0; + if (g_ev_fifo.size() == 0) { + // PAD_LOG("No events in queue, returning empty event\n"); + s_event = event; + event.evt = 0; + event.key = 0; + return &s_event; + } + s_event = g_ev_fifo.dequeue(); + AnalyzeKeyEvent(s_event); + // PAD_LOG("Returning Event. Event Type: %d, Key: %d\n", s_event.evt, s_event.key); return &s_event; } #if defined(__unix__) EXPORT_C_(void) PADWriteEvent(keyEvent &evt) { + // if (evt.evt != 6) { // Skip mouse move events for logging + // PAD_LOG("Pushing Event. Event Type: %d, Key: %d\n", evt.evt, evt.key); + // } g_ev_fifo.push(evt); } #endif