Bind Win32 tablet state in runtime shell
This commit is contained in:
@@ -20,6 +20,7 @@ namespace {
|
||||
struct RetainedWindowsRuntimeState final {
|
||||
App* app = nullptr;
|
||||
AppRuntime* runtime = nullptr;
|
||||
WacomTablet* tablet = nullptr;
|
||||
};
|
||||
|
||||
[[nodiscard]] RetainedWindowsRuntimeState& retained_runtime_state()
|
||||
@@ -56,10 +57,12 @@ void install_debug_gl_callbacks()
|
||||
|
||||
void initialize_wintab(HWND hWnd, bool sandboxed)
|
||||
{
|
||||
auto* tablet = bound_wacom_tablet();
|
||||
assert(tablet);
|
||||
if (!sandboxed)
|
||||
{
|
||||
LOG("init WinTab");
|
||||
WacomTablet::I.init(hWnd);
|
||||
tablet->init(hWnd);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -110,7 +113,8 @@ void run_main_message_loop()
|
||||
|
||||
void shutdown_main_window_runtime(const MainWindowStartupState& startup, HINSTANCE hInst)
|
||||
{
|
||||
WacomTablet::I.terminate();
|
||||
if (auto* tablet = retained_runtime_state().tablet)
|
||||
tablet->terminate();
|
||||
UnregisterClass(startup.window_class.lpszClassName, hInst);
|
||||
LogRemote::I.stop();
|
||||
}
|
||||
@@ -137,6 +141,16 @@ AppRuntime* bound_runtime() noexcept
|
||||
return retained_runtime_state().runtime;
|
||||
}
|
||||
|
||||
void bind_wacom_tablet(WacomTablet* tablet) noexcept
|
||||
{
|
||||
retained_runtime_state().tablet = tablet;
|
||||
}
|
||||
|
||||
WacomTablet* bound_wacom_tablet() noexcept
|
||||
{
|
||||
return retained_runtime_state().tablet;
|
||||
}
|
||||
|
||||
int run_main_application(int argc, char** argv)
|
||||
{
|
||||
auto& state = retained_state();
|
||||
@@ -146,6 +160,7 @@ int run_main_application(int argc, char** argv)
|
||||
App::I = app;
|
||||
bind_app(app);
|
||||
bind_runtime(&app->runtime());
|
||||
bind_wacom_tablet(&WacomTablet::I);
|
||||
app->set_platform_services(&pp::platform::windows::platform_services());
|
||||
app->initLog();
|
||||
|
||||
@@ -176,10 +191,12 @@ int run_main_application(int argc, char** argv)
|
||||
case pp::platform::windows::MainStartupResult::GladLoadFailure:
|
||||
bind_app(nullptr);
|
||||
bind_runtime(nullptr);
|
||||
bind_wacom_tablet(nullptr);
|
||||
return 0;
|
||||
case pp::platform::windows::MainStartupResult::MissingCoreContextSupport:
|
||||
bind_app(nullptr);
|
||||
bind_runtime(nullptr);
|
||||
bind_wacom_tablet(nullptr);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -195,6 +212,7 @@ int run_main_application(int argc, char** argv)
|
||||
app->cmd_convert(argv[2], argv[3]);
|
||||
bind_app(nullptr);
|
||||
bind_runtime(nullptr);
|
||||
bind_wacom_tablet(nullptr);
|
||||
return 0;
|
||||
case const_hash("-vrmode"):
|
||||
start_in_vr = true;
|
||||
@@ -205,6 +223,7 @@ int run_main_application(int argc, char** argv)
|
||||
}
|
||||
|
||||
pp::platform::windows::run_main_window_runtime(startup, start_in_vr, splash);
|
||||
bind_wacom_tablet(nullptr);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user