Introduce extended button handler

This commit is contained in:
jpirnay
2026-04-26 12:26:29 +02:00
parent 499702a754
commit a1d0ddec49
19 changed files with 833 additions and 33 deletions
+8 -1
View File
@@ -8,6 +8,7 @@
#include "ActivityManager.h" // for using the ActivityManager singleton
#include "ActivityResult.h"
#include "ButtonEventManager.h"
#include "GfxRenderer.h"
#include "MappedInputManager.h"
#include "RenderLock.h"
@@ -19,13 +20,14 @@ class Activity {
std::string name;
GfxRenderer& renderer;
MappedInputManager& mappedInput;
ButtonEventManager& buttonEvents;
ActivityResultHandler resultHandler;
ActivityResult result;
public:
explicit Activity(std::string name, GfxRenderer& renderer, MappedInputManager& mappedInput)
: name(std::move(name)), renderer(renderer), mappedInput(mappedInput) {}
: name(std::move(name)), renderer(renderer), mappedInput(mappedInput), buttonEvents(globalButtonEvents()) {}
virtual ~Activity() = default;
const std::string& getName() const { return name; }
virtual void onEnter();
@@ -45,6 +47,11 @@ class Activity {
virtual bool preventAutoSleep() { return false; }
virtual bool isReaderActivity() const { return false; }
// Called by ActivityManager when a globally-configured button action targets the
// current activity. Override in reader activities to handle reader-specific actions.
// Non-reader activities can ignore this (default is no-op).
virtual void onButtonAction(CrossPointSettings::BUTTON_ACTION) {}
// Start a new activity without destroying the current one
// Note: requestUpdate() will be invoked automatically once resultHandler finishes
void startActivityForResult(std::unique_ptr<Activity>&& activity, ActivityResultHandler resultHandler);