Files
spice2x-r3d/src/spice2x/overlay/windows/iidx_sub.cpp
T
bicarusandGitHub a8cc85531c overlay: disable subscreen overlay if "native touch" option is on (#811)
## Link to GitHub Issue or related Pull Request, if one exists
#345 

## Description of change
If IIDX/SDVX/POPN "native touch" option is enabled, show an error
message if user toggles subscreen window.

Those options are meant for users with touch screens, and disables mouse
interactions. Users who like to randomly turn on options often latch on
to this option and get confused when clicks don't register.

## Testing
2026-07-18 21:49:50 -07:00

75 lines
3.0 KiB
C++

#undef CINTERFACE
#include "iidx_sub.h"
#include "cfg/screen_resize.h"
#include "games/iidx/iidx.h"
#include "hooks/graphics/graphics.h"
#include "touch/touch.h"
namespace overlay::windows {
IIDXSubScreen::IIDXSubScreen(SpiceOverlay *overlay) : GenericSubScreen(overlay) {
this->title = "IIDX TDJ Subscreen";
if (GRAPHICS_IIDX_WSUB) {
this->disabled_message = "Close this overlay and use the second window. (try ALT+TAB)";
} else if (games::iidx::IIDX_TDJ_MONITOR_WARNING) {
this->disabled_message = "TDJ mode subscreen overlay is not compatible with -dxmainadapter option; use -mainmonitor instead";
} else if (games::iidx::NATIVE_TOUCH) {
this->disabled_message = "Overlay disabled by user (-iidxnativetouch option is on, used for real touch screens)";
}
float size = 0.5f;
if (games::iidx::SUBSCREEN_OVERLAY_SIZE.has_value()) {
if (games::iidx::SUBSCREEN_OVERLAY_SIZE.value() == "large") {
size = 0.8f;
} else if (games::iidx::SUBSCREEN_OVERLAY_SIZE.value() == "small") {
size = 0.3f;
} else if (games::iidx::SUBSCREEN_OVERLAY_SIZE.value() == "fullscreen") {
GENERIC_SUB_WINDOW_FULLSIZE = true;
this->draws_window = false;
}
}
this->init_size = ImVec2(
ImGui::GetIO().DisplaySize.x * size,
(ImGui::GetIO().DisplaySize.x * size * 9 / 16) + ImGui::GetFrameHeight());
this->size_max = ImVec2(
ImGui::GetIO().DisplaySize.x - ImGui::GetFrameHeight() * 2,
ImGui::GetIO().DisplaySize.y - ImGui::GetFrameHeight() * 2);
// middle / bottom
this->init_pos = ImVec2(
ImGui::GetIO().DisplaySize.x / 2 - this->init_size.x / 2,
ImGui::GetIO().DisplaySize.y - this->init_size.y - (ImGui::GetFrameHeight() / 2));
}
void IIDXSubScreen::check_for_errors() {
if (games::iidx::CURRENT_IO_EMULATION_STATE ==
games::iidx::iidx_aio_emulation_state::bi2a_com2) {
// explicitly check if LDJ I/O is enabled (as opposed to checking if NOT TDJ I/O)
// to account for the fact that I/O emulation may be disabled
this->disabled_message =
"LDJ I/O detected; TDJ mode subscreen overlay requires TDJ I/O.\n"
"Ensure you apply applicable TDJ I/O patches, or run with TDJ DLL.";
}
}
void IIDXSubScreen::touch_transform(const ImVec2 xy_in, LONG *x_out, LONG *y_out) {
if (!this->get_active()) {
return;
}
if (GRAPHICS_WINDOWED) {
// Touch needs to be registered on global coords
*x_out = SPICETOUCH_TOUCH_X + xy_in.x * SPICETOUCH_TOUCH_WIDTH;
*y_out = SPICETOUCH_TOUCH_Y + xy_in.y * SPICETOUCH_TOUCH_HEIGHT;
} else {
// Fullscreen mode, scale to game coords
*x_out = xy_in.x * ImGui::GetIO().DisplaySize.x;
*y_out = xy_in.y * ImGui::GetIO().DisplaySize.y;
}
}
}