mirror of
https://github.com/spice2x/spice2x.github.io.git
synced 2026-08-01 22:30:42 -07:00
touch: rawinput touch to compensate for letterboxing (#790)
## Link to GitHub Issue or related Pull Request, if one exists Fixes #697 ## Description of change Adds aspect-ratio compensation for raw input touch handler. This addresses the problem with playing rawinput touch games - namely jubeat and reflec beat - on a display that is not 16:9, and user chose to preserve the aspect ratio. This happens a lot on: * 16:10 touch screens * touch screen laptops (which range from 3:2, 16:10, and so on). Root cause is a **Windows Raw Input limitation**. Unlike `WM_POINTER`/`WM_TOUCH`, where the OS already maps digitizer coordinates to screen space (applying the display's calibration/scaling), Raw Input delivers the HID digitizer's *raw* logical coordinates, spanning the whole physical panel, with **no calibration or display-mapping data attached**. We have to reconstruct that mapping ourselves. When a game runs at a display mode whose aspect ratio differs from the panel's native resolution, Windows scales the image with letterboxing/pillarboxing (black bars). That is standard OS/GPU behavior. Because Raw Input gives us no mapping to account for those bars, touches land off-target. This change detects the mismatch and remaps each touch from panel-space into the displayed image region; touches inside the black bars are treated as released. Adds new launcher option **`-rawtouchaspect`**. Notes: - Native resolution is the largest-area mode from `EnumDisplaySettings` on the **primary** display, consistent with the existing primary-only touch pipeline. - Math assumes centered, aspect-preserving scaling; only one axis is ever inset. - A small epsilon (0.01) makes near-matched panels (e.g. 1366×768 vs true 16:9) a no-op. - If the user forces a stretched image, then the touches will be off again. In this case, the user needs to use the `force off` setting. ## Testing On my tiny Surface Go tablet, * checked that jubeat squares align correctly * good enough to full combo level 11 for reflec beat
This commit is contained in:
@@ -1064,6 +1064,15 @@ int main_implementation(int argc, char *argv[]) {
|
||||
if (options[launcher::Options::InvertTouchCoordinates].value_bool()) {
|
||||
rawinput::touch::INVERTED = true;
|
||||
}
|
||||
if (options[launcher::Options::RawInputTouchAspectRatio].is_active()) {
|
||||
auto mode = options[launcher::Options::RawInputTouchAspectRatio].value_text();
|
||||
if (mode == "on") {
|
||||
rawinput::touch::ASPECT_COMPENSATION_MODE = rawinput::touch::AspectMode::On;
|
||||
} else if (mode == "off") {
|
||||
rawinput::touch::ASPECT_COMPENSATION_MODE = rawinput::touch::AspectMode::Off;
|
||||
}
|
||||
// "auto" leaves the default (per-game)
|
||||
}
|
||||
// DisableTouchCardInsert is no longer honored in spice2x
|
||||
// if (options[launcher::Options::DisableTouchCardInsert].value_bool()) {
|
||||
// SPICETOUCH_CARD_DISABLE = true;
|
||||
|
||||
Reference in New Issue
Block a user