mirror of
https://github.com/valentderah/totk-pc-recomp.git
synced 2026-11-20 20:55:56 +00:00
Count mouse buttons only while the cursor is captured and ignore a button held when the capture began
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
dc80c88490
commit
f0b5c6e5ae
1 file changed
+10
@@ -370,10 +370,20 @@ static void poll_merged(uint64_t *buttons, int32_t *lx, int32_t *ly, int32_t *rx
|
||||
HWND w = gfx_window_handle();
|
||||
if (w && w == GetForegroundWindow()) {
|
||||
uint8_t down[KEY_COUNT] = {0};
|
||||
// Mouse buttons count only while the cursor is captured, and a button already held when the capture began
|
||||
// (the click that refocused the window) is ignored until it is released.
|
||||
static int was_captured;
|
||||
static uint8_t mouse_ignore[KEY_COUNT];
|
||||
int cap = cur_captured != 0;
|
||||
for (int k = 1; k < KEY_COUNT; k++) {
|
||||
int vk = key_vk(k);
|
||||
down[k] = vk && key_down(vk);
|
||||
if (k < KEY_MOUSE_L || k > KEY_MOUSE_M) continue;
|
||||
if (cap && !was_captured) mouse_ignore[k] = down[k];
|
||||
if (!down[k]) mouse_ignore[k] = 0;
|
||||
if (!cap || mouse_ignore[k]) down[k] = 0;
|
||||
}
|
||||
was_captured = cap;
|
||||
b |= input_map_buttons(down);
|
||||
int32_t k[2];
|
||||
input_map_stick(down, 0, k);
|
||||
|
||||
Reference in new issue
Block a user