mirror of
https://github.com/citra-emu/citra.git
synced 2024-11-30 06:20:05 +00:00
Toggling a every 10 frames. Not super happy about having to put code in renderer_opengl...
This commit is contained in:
parent
1eb6af61fd
commit
cd10c543c3
@ -33,6 +33,8 @@ int IndexOfButton(const std::string& button) {
|
|||||||
return -1; //home
|
return -1; //home
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int frame = 0;
|
||||||
|
|
||||||
namespace ScriptedInput {
|
namespace ScriptedInput {
|
||||||
|
|
||||||
class ScriptedButton final : public Input::ButtonDevice {
|
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);
|
int index = IndexOfButton(button_str);
|
||||||
if (index >= 0) {
|
if (index >= 0) {
|
||||||
scripted_button_list.get()->buttons[index] = button.get();
|
scripted_button_list.get()->buttons[index] = button.get();
|
||||||
|
is_in_use = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return std::move(button);
|
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());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
@ -25,8 +25,15 @@ public:
|
|||||||
*/
|
*/
|
||||||
std::unique_ptr<Input::ButtonDevice> Create(const Common::ParamPackage& params) override;
|
std::unique_ptr<Input::ButtonDevice> Create(const Common::ParamPackage& params) override;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* True if any button is being controlled
|
||||||
|
*/
|
||||||
|
bool IsInUse();
|
||||||
|
|
||||||
|
void NotifyFrameFinished();
|
||||||
private:
|
private:
|
||||||
std::shared_ptr<ScriptedButtonList> scripted_button_list;
|
std::shared_ptr<ScriptedButtonList> scripted_button_list;
|
||||||
|
bool is_in_use {false};
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace InputCommon
|
} // namespace InputCommon
|
||||||
|
@ -21,8 +21,12 @@ void Shutdown() {
|
|||||||
Input::UnregisterFactory<Input::ButtonDevice>("scripted");
|
Input::UnregisterFactory<Input::ButtonDevice>("scripted");
|
||||||
}
|
}
|
||||||
|
|
||||||
ScriptedButtons* GetScriptedButtons() {
|
bool IsInUse() {
|
||||||
return scripted_buttons.get();
|
return scripted_buttons.get()->IsInUse();
|
||||||
|
}
|
||||||
|
|
||||||
|
void NotifyFrameFinished() {
|
||||||
|
scripted_buttons.get()->NotifyFrameFinished();
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace ScriptedInput
|
} // namespace ScriptedInput
|
||||||
|
@ -16,6 +16,8 @@ void Shutdown();
|
|||||||
|
|
||||||
class ScriptedButtons;
|
class ScriptedButtons;
|
||||||
|
|
||||||
ScriptedButtons* GetScriptedButtons();
|
bool IsInUse();
|
||||||
|
|
||||||
|
void NotifyFrameFinished();
|
||||||
|
|
||||||
} // namespace InputCommon
|
} // namespace InputCommon
|
||||||
|
@ -81,7 +81,7 @@ endif()
|
|||||||
create_directory_groups(${SRCS} ${HEADERS})
|
create_directory_groups(${SRCS} ${HEADERS})
|
||||||
|
|
||||||
add_library(video_core STATIC ${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)
|
target_link_libraries(video_core PRIVATE glad nihstro-headers)
|
||||||
|
|
||||||
if (ARCHITECTURE_x86_64)
|
if (ARCHITECTURE_x86_64)
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
#include "core/memory.h"
|
#include "core/memory.h"
|
||||||
#include "core/settings.h"
|
#include "core/settings.h"
|
||||||
#include "core/tracer/recorder.h"
|
#include "core/tracer/recorder.h"
|
||||||
|
#include "scripted_input/scripted_input.h"
|
||||||
#include "video_core/debug_utils/debug_utils.h"
|
#include "video_core/debug_utils/debug_utils.h"
|
||||||
#include "video_core/rasterizer_interface.h"
|
#include "video_core/rasterizer_interface.h"
|
||||||
#include "video_core/renderer_opengl/renderer_opengl.h"
|
#include "video_core/renderer_opengl/renderer_opengl.h"
|
||||||
@ -151,6 +152,10 @@ void RendererOpenGL::SwapBuffers() {
|
|||||||
prev_state.Apply();
|
prev_state.Apply();
|
||||||
RefreshRasterizerSetting();
|
RefreshRasterizerSetting();
|
||||||
|
|
||||||
|
if (ScriptedInput::IsInUse()) {
|
||||||
|
ScriptedInput::NotifyFrameFinished();
|
||||||
|
}
|
||||||
|
|
||||||
if (Pica::g_debug_context && Pica::g_debug_context->recorder) {
|
if (Pica::g_debug_context && Pica::g_debug_context->recorder) {
|
||||||
Pica::g_debug_context->recorder->FrameFinished();
|
Pica::g_debug_context->recorder->FrameFinished();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user