aorecomp

Anarchy Online classic in the browser

git clone https://aorecomp.ubeagle.com/code/aorecomp.git


commit 5148a03731db014bb9598d4f2da01b8b954225c9
parent 2e20e2860492e817907f4b41a84b9e0657d73a42
Author: anon <anon@example.com>
Date:   Fri, 23 Oct 2026 14:50:48 +0000

Route browser wheel input without synthetic item clicks

Diffstat:
MTODO.md | 11++++++++++-
Mclient/browser/index.html | 22+++++++++++++++++++++-
Mclient/runtime/browser_resolution.c | 19++++++++++++++++---
Mclient/runtime/linux_window.c | 54+++++++++++++++++-------------------------------------
Mclient/tests/browser_camera.c | 85++++++++++++++++++++++++++++++++++++++++++++++++++-----------------------------
Mclient/tests/browser_controls.mjs | 77+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--
Mclient/tests/browser_resolution.c | 50+++++++++++++++++++++++++++++++++++++++++++++++++-
7 files changed, 242 insertions(+), 76 deletions(-)

diff --git a/TODO.md b/TODO.md @@ -648,12 +648,21 @@ and server restarts. Turn every reproduced bug into a focused regression test. Cover leaving/returning to the tab, opening/closing options or chat, held keys/modifiers, repeats, reconnect and slow frames. Compare the first input after each transition and the final selected target in the UI and server. -- [ ] Prevent browser wheel camera gestures from activating native GUI items. +- [x] Prevent browser wheel camera gestures from activating native GUI items. Check: wheel/trackpad input over inventory cannot equip or use the hovered item; world-camera gestures still work. A WASM armor test reproduced a wheel gesture equipping hovered gloves through the synthetic right-button action. Verify inventory, containers, toolbar and other native windows, including focus loss during a gesture, and add a focused regression for the fix. + World wheels now use native camera orbit; UI wheels use native scrolling, + without synthetic clicks. All 73 browser-control tests, WASM input/camera + fixtures, native window tests and focused Go HTTP/HTTPS checks pass. The + published WASM client passed inventory, filled-backpack, toolbar, equipment, + rapid world/UI transition and focus-cancellation checks in CSS and Retina + modes. All 28 fixture items retained their records and locations, all 16 + native inventory entries matched SQLite, and ordinary equip/remove still + worked. Evidence: `local/wheel-input-smoke/verification.json` and + browser input details. ## Checks that apply to each milestone diff --git a/client/browser/index.html b/client/browser/index.html @@ -414,6 +414,26 @@ show(); return touchRegions.regions.find(region => x >= region.left && x < region.right && y >= region.top && y < region.bottom); } + // Route camera motion separately from native UI scrolling; neither needs a click. + canvas.addEventListener('wheel', event => { + if (!gameReady) return; + event.preventDefault(); + event.stopImmediatePropagation(); + const bounds = canvas.getBoundingClientRect(); + const [width, height] = renderSize(); + let scale; + if (event.deltaMode === 0) scale = 0.01; + else if (event.deltaMode === 1) scale = 1 / 3; + else scale = 80; + if (touchRegion(event.clientX, event.clientY)?.world === true) { + Module._browser_camera_wheel(Math.round(event.deltaX * scale * 100 / bounds.width * 65536), + Math.round(event.deltaY * scale * 100 / bounds.height * 65536)); + } else { + Module._browser_input_wheel(Math.round((event.clientX - bounds.left) * width / bounds.width), + Math.round((event.clientY - bounds.top) * height / bounds.height), + -event.deltaY * scale); + } + }, {capture: true, passive: false}); function finishCanvasTouch() { if (!canvasTouch) return; clearTimeout(canvasTouch.timer); @@ -433,7 +453,7 @@ show(); } function releaseControls() { finishCanvasTouch(); - finishOrbit(); + if (gameReady) Module._browser_orbit(0, 0, 0); orbitTouch = null; moveForward = false; for (const key of heldKeys) setKey(key, false); diff --git a/client/runtime/browser_resolution.c b/client/runtime/browser_resolution.c @@ -12,6 +12,7 @@ static _Atomic uint32_t requested_size; static _Atomic unsigned chat_viewport_bottom; static _Atomic int orbit_x, orbit_y, orbit_active; +static _Atomic int wheel_x, wheel_y; static _Atomic int orbit_zoom; static _Atomic int cursor_hidden; static _Atomic uint32_t hud_insets; @@ -125,10 +126,18 @@ EMSCRIPTEN_KEEPALIVE void browser_orbit(int x, int y, int active) atomic_store(&orbit_x, 0); atomic_store(&orbit_y, 0); atomic_store(&orbit_zoom, 0); + atomic_store(&wheel_x, 0); + atomic_store(&wheel_y, 0); } atomic_store(&orbit_active, active); } +EMSCRIPTEN_KEEPALIVE void browser_camera_wheel(int x, int y) +{ + atomic_fetch_add(&wheel_x, x); + atomic_fetch_add(&wheel_y, y); +} + EMSCRIPTEN_KEEPALIVE void browser_zoom(int amount) { atomic_fetch_add(&orbit_zoom, amount); @@ -147,9 +156,12 @@ static void call_method(uint32_t address, uint32_t object, unsigned count, static void orbit_frame(void) { - int active = atomic_load(&orbit_active); + /* Consume each wheel once, even when several events arrive between frames. */ + int x = atomic_exchange(&wheel_x, 0), y = atomic_exchange(&wheel_y, 0); + int active = atomic_load(&orbit_active) || x || y; if (!active && !orbit_running) return; - int x = atomic_exchange(&orbit_x, 0), y = atomic_exchange(&orbit_y, 0); + x += atomic_exchange(&orbit_x, 0); + y += atomic_exchange(&orbit_y, 0); int zoom = atomic_exchange(&orbit_zoom, 0); uint32_t engine = MEM32(0x2d01752c); if (!engine) { orbit_running = 0; return; } @@ -622,7 +634,8 @@ static void resize_frame(void) void browser_resize_frame(void) { if (!atomic_load(&requested_size) && !atomic_load(&chat_viewport_bottom) && !mobile_chat.chat && - !atomic_load(&orbit_active) && !orbit_running && !atomic_load(&hud_insets) && !hud_adjusted) { + !atomic_load(&orbit_active) && !orbit_running && !atomic_load(&wheel_x) && + !atomic_load(&wheel_y) && !atomic_load(&hud_insets) && !hud_adjusted) { publish_chat_bounds(); publish_touch_regions(); return; diff --git a/client/runtime/linux_window.c b/client/runtime/linux_window.c @@ -46,9 +46,6 @@ static uint32_t queued_mouse_buttons; /* Browsers cannot warp the physical pointer; camera recentering is virtual. */ static int cursor_x, cursor_y, cursor_warped; static int browser_mouse, browser_mouse_x, browser_mouse_y; -static int wheel_drag; -static uint32_t wheel_deadline; -static float wheel_x, wheel_y; #endif /* The SDL default cursor has a guest handle; native pointers never enter guest state. */ static uint32_t current_cursor = 0xf4500000u; @@ -771,11 +768,6 @@ static void cursor_position(void) int x, y; #ifdef __EMSCRIPTEN__ if (!cursor_warped && !browser_mouse) SDL_GetMouseState(&cursor_x, &cursor_y); - if (cursor_warped) { - int dx = (int)wheel_x, dy = (int)wheel_y; - wheel_x -= dx; wheel_y -= dy; - cursor_x += dx; cursor_y += dy; - } x = cursor_x; y = cursor_y; #else SDL_GetGlobalMouseState(&x, &y); @@ -1003,15 +995,14 @@ EMSCRIPTEN_KEEPALIVE void browser_input_button(unsigned button, int down, int x, if (SDL_PushEvent(&event) != 1) abort(); } -static void end_wheel_drag(void) +EMSCRIPTEN_KEEPALIVE void browser_input_wheel(int x, int y, float vertical) { - if (!wheel_drag) return; - wheel_drag = 0; - wheel_x = wheel_y = 0; - queued_mouse_buttons &= ~2u; - queue_message(client.handle, 0x205, queued_mouse_buttons, - (cursor_x & 0xffffu) | ((uint32_t)cursor_y << 16), 2, 0); + SDL_Event event = {.type = SDL_MOUSEWHEEL}; + event.wheel.mouseX = x; event.wheel.mouseY = y; + event.wheel.preciseY = vertical; + if (SDL_PushEvent(&event) != 1) abort(); } + #endif static void process_event(const SDL_Event *event) @@ -1041,7 +1032,6 @@ static void process_event(const SDL_Event *event) break; case SDL_WINDOWEVENT_FOCUS_LOST: #ifdef __EMSCRIPTEN__ - end_wheel_drag(); static const uint32_t releases[][2] = {{1, 0x202}, {2, 0x205}, {16, 0x208}}; for (unsigned i = 0; i < 3; ++i) { if (!(queued_mouse_buttons & releases[i][0])) continue; @@ -1083,7 +1073,7 @@ static void process_event(const SDL_Event *event) #ifdef __EMSCRIPTEN__ /* Include virtual gestures and keep lost-focus buttons released. */ state = queued_mouse_buttons; - if (!wheel_drag && event->motion.which != SDL_TOUCH_MOUSEID) { + if (event->motion.which != SDL_TOUCH_MOUSEID) { if (cursor_warped && (state & 2)) { cursor_x += event->motion.xrel; cursor_y += event->motion.yrel; @@ -1102,9 +1092,6 @@ static void process_event(const SDL_Event *event) (event->motion.x & 0xffffu) | ((uint32_t)event->motion.y << 16), input, 0); } else if (event->type == SDL_MOUSEBUTTONDOWN || event->type == SDL_MOUSEBUTTONUP) { uint32_t button = event->button.button, message, mask; -#ifdef __EMSCRIPTEN__ - end_wheel_drag(); -#endif if (button == SDL_BUTTON_LEFT) { message = 0x201; mask = 1; } else if (button == SDL_BUTTON_RIGHT) { message = 0x204; mask = 2; } else if (button == SDL_BUTTON_MIDDLE) { message = 0x207; mask = 16; } @@ -1123,19 +1110,15 @@ static void process_event(const SDL_Event *event) (event->button.x & 0xffffu) | ((uint32_t)event->button.y << 16), input, 0); } else if (event->type == SDL_MOUSEWHEEL) { #ifdef __EMSCRIPTEN__ - /* SDL converts pixel wheel deltas to steps; restore pixels for the camera. */ - if (!wheel_drag && !(queued_mouse_buttons & 2)) { - wheel_drag = 1; - cursor_warped = 0; - queued_mouse_buttons |= 2; - SDL_GetMouseState(&cursor_x, &cursor_y); - queue_message(client.handle, 0x204, queued_mouse_buttons, - (cursor_x & 0xffffu) | ((uint32_t)cursor_y << 16), 2, 0); - } - float direction = event->wheel.direction == SDL_MOUSEWHEEL_FLIPPED ? -100 : 100; - wheel_x += event->wheel.preciseX * direction; - wheel_y -= event->wheel.preciseY * direction; - wheel_deadline = SDL_GetTicks() + 200; + static float remainder; + float movement = event->wheel.preciseY * 120 + remainder; + int delta = (int)movement; + remainder = movement - delta; + if (!delta) return; + uint32_t state = queued_mouse_buttons | (SDL_GetModState() & KMOD_SHIFT ? 4 : 0) | + (SDL_GetModState() & KMOD_CTRL ? 8 : 0); + queue_message(client.handle, 0x20a, ((uint32_t)delta << 16) | state, + (event->wheel.mouseX & 0xffffu) | ((uint32_t)event->wheel.mouseY << 16), 3, 0); #else int x, y; SDL_GetGlobalMouseState(&x, &y); @@ -1168,7 +1151,7 @@ static int read_message(uint32_t output, uint32_t window, uint32_t first, uint32 keyboard_state[2] = entry->words[2] & 2 ? 0x80 : 0; keyboard_state[4] = entry->words[2] & 16 ? 0x80 : 0; #ifdef __EMSCRIPTEN__ - /* Touch presses must see their own point, before later drag motion. */ + /* Browser input must see its captured point before later pointer motion. */ browser_mouse = entry->keyboard == 3; if (browser_mouse) { int x = (int16_t)entry->words[3], y = (int16_t)(entry->words[3] >> 16); @@ -1226,9 +1209,6 @@ static void retrieve_message(int wait) for (;;) { SDL_Event event; while (SDL_PollEvent(&event)) process_event(&event); -#ifdef __EMSCRIPTEN__ - if (wheel_drag && SDL_TICKS_PASSED(SDL_GetTicks(), wheel_deadline)) end_wheel_drag(); -#endif if (read_message(output, window, first, last, flags & 1)) { g_eax = !wait || MEM32(output + 4) != 0x12; return; diff --git a/client/tests/browser_camera.c b/client/tests/browser_camera.c @@ -4,7 +4,6 @@ #include <SDL2/SDL.h> #include <assert.h> #include <stdio.h> -#include <unistd.h> static SDL_Window *native_window; static uint32_t window; @@ -12,6 +11,7 @@ void browser_input_key(int key, int down, int repeat, int modifiers); void browser_input_character(unsigned character); void browser_input_motion(int x, int y); void browser_input_button(unsigned button, int down, int x, int y); +void browser_input_wheel(int x, int y, float vertical); struct SDL_Window *linux_graphics_window(void) { return native_window; } int linux_graphics_display_mode(SDL_DisplayMode *mode) { return SDL_GetCurrentDisplayMode(0, mode); } recomp_func_t recomp_lookup(uint32_t address) @@ -86,36 +86,10 @@ static void control_left_click_keeps_its_native_button(void) assert(!mouse_message()); } -static void wheel_rotation_keeps_fractional_motion_and_ends(void) -{ - SDL_Event event = {.type = SDL_MOUSEWHEEL}; - event.wheel.preciseX = 0.125f; - event.wheel.preciseY = -0.0625f; - assert(SDL_PushEvent(&event) == 1); - assert(mouse_message() == 0x204); - /* The game saves the physical position before its first camera recenter. */ - uint32_t output = 0x50003100; - assert(call("GetCursorPos", 1, &output)); - assert(call("SetCursorPos", 2, (uint32_t[]){320, 240})); - - assert(call("GetCursorPos", 1, &output)); - - assert(MEM32(output) == 332 && MEM32(output + 4) == 246); - assert(call("SetCursorPos", 2, (uint32_t[]){320, 240})); - assert(SDL_PushEvent(&event) == 1); - assert(!mouse_message()); - assert(call("GetCursorPos", 1, &output)); - assert(MEM32(output) == 333 && MEM32(output + 4) == 246); - usleep(250000); - assert(mouse_message() == 0x205); - assert(!MEM32(0x50003008)); - assert(!mouse_message()); -} - static void focus_loss_releases_camera_button(void) { - SDL_Event event = {.type = SDL_MOUSEWHEEL}; - event.wheel.preciseX = 0.5f; + SDL_Event event = {.type = SDL_MOUSEBUTTONDOWN}; + event.button.button = SDL_BUTTON_RIGHT; assert(SDL_PushEvent(&event) == 1); assert(mouse_message() == 0x204); @@ -134,6 +108,53 @@ static void focus_loss_releases_camera_button(void) assert(!MEM32(0x50003008)); } +static void native_ui_wheel_preserves_position_and_modifiers(void) +{ + SDL_SetModState(KMOD_CTRL); + uint32_t output = 0x50003100; + + browser_input_wheel(600, 100, -1.25f); + assert(mouse_message() == 0x20a); + assert(call("GetCursorPos", 1, &output)); + + assert((int16_t)(MEM32(0x50003008) >> 16) == -150); + assert((MEM32(0x50003008) & 0xffff) == 8); + assert(MEM32(0x5000300c) == (600 | (100 << 16))); + assert(MEM32(output) == 600 && MEM32(output + 4) == 100); + assert(!mouse_message()); + SDL_SetModState(KMOD_NONE); +} + +static void queued_wheels_keep_their_captured_points(void) +{ + uint32_t output = 0x50003100; + + browser_input_wheel(450, 80, 1); + browser_input_motion(600, 100); + browser_input_wheel(600, 100, -1); + + assert(mouse_message() == 0x20a); + assert(call("GetCursorPos", 1, &output)); + assert(MEM32(output) == 450 && MEM32(output + 4) == 80); + assert(mouse_message() == 0x200); + assert(mouse_message() == 0x20a); + assert(call("GetCursorPos", 1, &output)); + assert(MEM32(output) == 600 && MEM32(output + 4) == 100); + assert(!mouse_message()); +} + +static void native_ui_wheel_accumulates_fractional_motion(void) +{ + browser_input_wheel(600, 100, -0.005f); + + assert(!mouse_message()); + browser_input_wheel(600, 100, -0.005f); + + assert(mouse_message() == 0x20a); + assert((int16_t)(MEM32(0x50003008) >> 16) == -1); + assert(!mouse_message()); +} + static void browser_controls_preserve_key_and_text_order(void) { uint32_t output = 0x50003000, keys = 0x50003100; @@ -305,14 +326,16 @@ int main(void) SDL_FlushEvents(SDL_FIRSTEVENT, SDL_LASTEVENT); recentering_preserves_relative_motion(); control_left_click_keeps_its_native_button(); - wheel_rotation_keeps_fractional_motion_and_ends(); focus_loss_releases_camera_button(); + native_ui_wheel_preserves_position_and_modifiers(); + queued_wheels_keep_their_captured_points(); + native_ui_wheel_accumulates_fractional_motion(); browser_controls_preserve_key_and_text_order(); keypad_keys_preserve_physical_scans_and_releases(); keypad_input_preserves_modifiers_in_queue_order(); touch_drag_preserves_the_press_position(); touch_camera_accumulates_motion_after_recentering(); touch_camera_release_preserves_recentered_position(); - puts("camera: recentering, Ctrl-left-click, wheel motion, focus loss and browser key/text/touch input passed"); + puts("camera: recentering, Ctrl-left-click, native UI wheel routing, focus loss and browser key/text/touch input passed"); return 0; } diff --git a/client/tests/browser_controls.mjs b/client/tests/browser_controls.mjs @@ -6,7 +6,7 @@ import test from 'node:test'; function page({navigator = {userAgent: 'Mozilla/5.0 (Android) Gecko Firefox/149.0'}, saved = null, ready = true} = {}) { const elements = new Map(); const keys = [], characters = [], mouse = [], orbits = [], sizes = [], chatViewports = [], cursorHidden = [], hudInsets = []; - const scrolls = [], zooms = []; + const scrolls = [], zooms = [], wheels = [], cameraWheels = []; const repeats = []; const modifiers = []; const timers = new Map(); @@ -80,6 +80,8 @@ function page({navigator = {userAgent: 'Mozilla/5.0 (Android) Gecko Firefox/149. context.Module._browser_input_character = character => characters.push(character); context.Module._browser_input_motion = (x, y) => mouse.push(['mousemove', x, y, 0]); context.Module._browser_input_button = (button, down, x, y) => mouse.push([down ? 'mousedown' : 'mouseup', x, y, button === 3 ? 2 : 0]); + context.Module._browser_input_wheel = (x, y, vertical) => wheels.push([x, y, vertical]); + context.Module._browser_camera_wheel = (x, y) => cameraWheels.push([x, y]); context.Module._browser_orbit = (x, y, active) => orbits.push([x, y, active]); context.Module._browser_zoom = amount => zooms.push(amount); context.Module._browser_hide_cursor = hidden => cursorHidden.push(hidden); @@ -105,7 +107,7 @@ function page({navigator = {userAgent: 'Mozilla/5.0 (Android) Gecko Firefox/149. document.querySelector(selector).dispatchEvent(event); return event; } - return {document, window, navigator, canvas, audio, keys, repeats, modifiers, characters, mouse, orbits, sizes, chatViewports, cursorHidden, hudInsets, scrolls, zooms, storage, actions, fire, reloads, + return {document, window, navigator, canvas, audio, keys, repeats, modifiers, characters, mouse, wheels, cameraWheels, orbits, sizes, chatViewports, cursorHidden, hudInsets, scrolls, zooms, storage, actions, fire, reloads, firstFrame: () => context.Module.onFirstFrame(), closed: replaced => context.Module.onGameClosed(replaced), graphics: lost => context.Module.onGraphicsStatus(lost), @@ -115,6 +117,77 @@ function page({navigator = {userAgent: 'Mozilla/5.0 (Android) Gecko Firefox/149. hold: () => { for (const callback of timers.values()) callback(); timers.clear(); }}; } +test('wheel over native UI bypasses the camera gesture and preserves wheel units', () => { + const game = page({navigator: {userAgent: 'Mozilla/5.0 (X11; Linux x86_64) Chrome/156.0.0.0'}}); + game.touchRegions({screenWidth: 844, screenHeight: 390, regions: [ + {left: 50, top: 100, right: 200, bottom: 180, world: false}, + {left: 0, top: 0, right: 844, bottom: 390, world: true} + ]}); + const cameraEvents = []; + game.canvas.addEventListener('wheel', event => cameraEvents.push(event)); + + const pixel = game.fire('#canvas', 'wheel', {deltaX: 0, deltaY: 100, deltaMode: 0}); + const line = game.fire('#canvas', 'wheel', {deltaX: 0, deltaY: -3, deltaMode: 1}); + const pageEvent = game.fire('#canvas', 'wheel', {deltaX: 0, deltaY: 1, deltaMode: 2}); + const fractional = game.fire('#canvas', 'wheel', {deltaX: 0, deltaY: 0.5, deltaMode: 0}); + + assert.deepEqual(game.wheels, [[100, 120, -1], [100, 120, 1], + [100, 120, -80], [100, 120, -0.005]]); + assert.equal(cameraEvents.length, 0); + assert([pixel, line, pageEvent, fractional].every(event => event.defaultPrevented)); + assert.deepEqual(game.mouse, []); +}); + +test('world wheel captures its camera target and UI hit testing follows Retina coordinates', () => { + const game = page(); + game.element('#pixel-mode').value = 'retina'; + game.fire('#pixel-mode', 'change'); + game.touchRegions({screenWidth: 1688, screenHeight: 780, regions: [ + {left: 180, top: 220, right: 240, bottom: 280, world: false}, + {left: 0, top: 0, right: 1688, bottom: 780, world: true} + ]}); + const cameraEvents = []; + game.canvas.addEventListener('wheel', event => cameraEvents.push(event)); + + game.fire('#canvas', 'wheel', {deltaX: 0, deltaY: 100, deltaMode: 0}); + const world = game.fire('#canvas', 'wheel', {clientX: 300, deltaX: 12, deltaY: -50, deltaMode: 0}); + + assert.deepEqual(game.wheels, [[200, 240, -1]]); + assert.deepEqual(game.cameraWheels, [[932, -8402]]); + assert.deepEqual(game.mouse, []); + assert.deepEqual(cameraEvents, []); + assert.equal(world.defaultPrevented, true); +}); + +test('wheel cannot start a camera gesture before native world bounds are available', () => { + const game = page(); + game.touchRegions({screenWidth: 844, screenHeight: 390, regions: []}); + const cameraEvents = []; + game.canvas.addEventListener('wheel', event => cameraEvents.push(event)); + + game.fire('#canvas', 'wheel', {deltaX: 0, deltaY: 100, deltaMode: 0}); + + assert.deepEqual(game.wheels, [[100, 120, -1]]); + assert.deepEqual(cameraEvents, []); +}); + +test('world to UI wheels never synthesize buttons and focus loss stops pending camera input', () => { + const game = page(); + game.touchRegions({screenWidth: 844, screenHeight: 390, regions: [ + {left: 50, top: 100, right: 200, bottom: 180, world: false}, + {left: 0, top: 0, right: 844, bottom: 390, world: true} + ]}); + + game.fire('#canvas', 'wheel', {clientX: 300, deltaX: 0.5, deltaY: -0.25, deltaMode: 0}); + game.fire('#canvas', 'wheel', {deltaX: 0, deltaY: 100, deltaMode: 0}); + game.window.dispatchEvent(new Event('blur')); + + assert.deepEqual(game.cameraWheels, [[39, -42]]); + assert.deepEqual(game.wheels, [[100, 120, -1]]); + assert.deepEqual(game.mouse, []); + assert.deepEqual(game.orbits, [[0, 0, 0]]); +}); + test('Tab stays in the focused game and still reaches native key handlers', () => { const game = page(); const delivered = []; diff --git a/client/tests/browser_resolution.c b/client/tests/browser_resolution.c @@ -4,6 +4,7 @@ void browser_request_resize(unsigned width, unsigned height); void browser_chat_viewport(unsigned bottom); void browser_orbit(int x, int y, int active); +void browser_camera_wheel(int x, int y); void browser_zoom(int amount); void browser_hud_insets(unsigned right, unsigned top); void browser_chat_scroll(int pixels); @@ -343,6 +344,50 @@ recomp_func_t recomp_lookup(uint32_t address) } } +static void wheel_camera_consumes_a_burst_once(void) +{ + orbit_updates = orbit_stops = 0; + + browser_camera_wheel(64, -32); + browser_camera_wheel(64, -32); + browser_resize_frame(); + + assert(orbit_updates == 1 && orbit_stops == 0); + assert(orbit_x == 0.0009765625f && orbit_y == -0.00048828125f); + browser_resize_frame(); + browser_resize_frame(); + assert(orbit_updates == 1 && orbit_stops == 1); +} + +static void stopping_camera_cancels_pending_wheels(void) +{ + orbit_updates = orbit_stops = 0; + browser_camera_wheel(128, -64); + + browser_orbit(0, 0, 0); + browser_resize_frame(); + + assert(orbit_updates == 0 && orbit_stops == 0); +} + +static void wheel_camera_preserves_an_active_touch_orbit(void) +{ + orbit_updates = orbit_stops = 0; + browser_orbit(64, -32, 1); + + browser_camera_wheel(64, -32); + browser_resize_frame(); + + assert(orbit_updates == 1 && orbit_stops == 0); + assert(orbit_x == 0.0009765625f && orbit_y == -0.00048828125f); + browser_resize_frame(); + assert(orbit_updates == 2 && orbit_stops == 0); + assert(orbit_x == 0 && orbit_y == 0); + browser_orbit(0, 0, 0); + browser_resize_frame(); + assert(orbit_stops == 1); +} + int main(void) { assert(guest_map("display globals", 0x25230000, 0x10000)); @@ -860,6 +905,9 @@ int main(void) assert(fabsf(*(float *)ADDR(0x50005374) - 0.7f) < 0.00001f); assert(*(float *)ADDR(0x5000525c) == 30); - puts("Browser resize, guest state, mobile chat, camera orbit and pinch zoom checks passed"); + wheel_camera_consumes_a_burst_once(); + stopping_camera_cancels_pending_wheels(); + wheel_camera_preserves_an_active_touch_orbit(); + puts("Browser resize, guest state, mobile chat, camera orbit, wheel and pinch zoom checks passed"); return 0; }