Toggling a every 10 frames. Not super happy about having to put code in renderer_opengl...

This commit is contained in:
danzel 2017-08-11 21:54:39 +12:00
parent 1eb6af61fd
commit cd10c543c3
6 changed files with 40 additions and 4 deletions

View File

@ -33,6 +33,8 @@ int IndexOfButton(const std::string& button) {
return -1; //home
}
int frame = 0;
namespace ScriptedInput {
class ScriptedButton final : public Input::ButtonDevice {
@ -61,8 +63,24 @@ std::unique_ptr<Input::ButtonDevice> ScriptedButtons::Create(const Common::Param
int index = IndexOfButton(button_str);
if (index >= 0) {
scripted_button_list.get()->buttons[index] = button.get();
is_in_use = true;
}
return std::move(button);
}
bool ScriptedButtons::IsInUse() {
return is_in_use;
}
void ScriptedButtons::NotifyFrameFinished() {
frame++;
if (frame >= 10) {
printf("TOGGLING\r\n");
frame = 0;
auto button = scripted_button_list.get()->buttons[0];
button->status.store(!button->GetStatus());
}
}
}

View File

@ -25,8 +25,15 @@ public:
*/
std::unique_ptr<Input::ButtonDevice> Create(const Common::ParamPackage& params) override;
/**
* True if any button is being controlled
*/
bool IsInUse();
void NotifyFrameFinished();
private:
std::shared_ptr<ScriptedButtonList> scripted_button_list;
bool is_in_use {false};
};
} // namespace InputCommon

View File

@ -21,8 +21,12 @@ void Shutdown() {
Input::UnregisterFactory<Input::ButtonDevice>("scripted");
}
ScriptedButtons* GetScriptedButtons() {
return scripted_buttons.get();
bool IsInUse() {
return scripted_buttons.get()->IsInUse();
}
void NotifyFrameFinished() {
scripted_buttons.get()->NotifyFrameFinished();
}
} // namespace ScriptedInput

View File

@ -16,6 +16,8 @@ void Shutdown();
class ScriptedButtons;
ScriptedButtons* GetScriptedButtons();
bool IsInUse();
void NotifyFrameFinished();
} // namespace InputCommon

View File

@ -81,7 +81,7 @@ endif()
create_directory_groups(${SRCS} ${HEADERS})
add_library(video_core STATIC ${SRCS} ${HEADERS})
target_link_libraries(video_core PUBLIC common core)
target_link_libraries(video_core PUBLIC common core scripted_input)
target_link_libraries(video_core PRIVATE glad nihstro-headers)
if (ARCHITECTURE_x86_64)

View File

@ -19,6 +19,7 @@
#include "core/memory.h"
#include "core/settings.h"
#include "core/tracer/recorder.h"
#include "scripted_input/scripted_input.h"
#include "video_core/debug_utils/debug_utils.h"
#include "video_core/rasterizer_interface.h"
#include "video_core/renderer_opengl/renderer_opengl.h"
@ -151,6 +152,10 @@ void RendererOpenGL::SwapBuffers() {
prev_state.Apply();
RefreshRasterizerSetting();
if (ScriptedInput::IsInUse()) {
ScriptedInput::NotifyFrameFinished();
}
if (Pica::g_debug_context && Pica::g_debug_context->recorder) {
Pica::g_debug_context->recorder->FrameFinished();
}