From aee812b70a7cb51c3415147031eb64faab77bfc4 Mon Sep 17 00:00:00 2001 From: Victor Seiji Hariki Date: Wed, 7 Dec 2022 18:51:33 -0300 Subject: [PATCH] fix mouse for chrome (for now) Seems scroll delta is inconsistent between browsers, so for my chromium installation it was simply not working at all due to snapping. Made it so every event is a cursor size change for now. probably bad for smooth mouse wheels, but for a complete fix we would have to keep track of pixels scrolled and probably add a mouse wheel sensitivity setting somewhere. Signed-off-by: Victor Seiji Hariki --- js/ui/tool/dream.js | 10 +++++++--- js/ui/tool/interrogate.js | 24 +++++++++--------------- 2 files changed, 16 insertions(+), 18 deletions(-) diff --git a/js/ui/tool/dream.js b/js/ui/tool/dream.js index 5bdb277..b466e33 100644 --- a/js/ui/tool/dream.js +++ b/js/ui/tool/dream.js @@ -806,9 +806,13 @@ const _reticle_draw = (evn, state, tool, style = {}) => { const _dream_onwheel = (evn, state) => { if (!evn.evn.ctrlKey) { - const v = - state.cursorSize - - Math.floor(state.config.cursorSizeScrollSpeed * evn.delta); + // Seems mouse wheel scroll is very different between different browsers. + // Will use scroll as just an event to go to the next cursor snap position instead. + // + // TODO: Someone that has a smooth scrolling mouse should verify if this works with them. + + const v = state.cursorSize - 128 * (evn.delta / Math.abs(evn.delta)); + state.cursorSize = state.setCursorSize(v + snap(v, 0, 128)); state.mousemovecb(evn); } diff --git a/js/ui/tool/interrogate.js b/js/ui/tool/interrogate.js index 8425ac9..5e97375 100644 --- a/js/ui/tool/interrogate.js +++ b/js/ui/tool/interrogate.js @@ -48,8 +48,16 @@ const interrogateTool = () => reticleStyle: "#AFAF", }); }; + + state.redraw = () => { + state.mousemovecb({ + x: mouse.coords.world.pos.x, + y: mouse.coords.world.pos.y, + }); + }; + state.wheelcb = (evn) => { - _interrogate_onwheel(evn, state); + _dream_onwheel(evn, state); }; state.interrogatecb = (evn) => { @@ -91,20 +99,6 @@ const interrogateTool = () => } ); -/** - * Generic wheel handler - */ - -const _interrogate_onwheel = (evn, state) => { - if (!evn.evn.ctrlKey) { - const v = - state.cursorSize - - Math.floor(state.config.cursorSizeScrollSpeed * evn.delta); - state.cursorSize = state.setCursorSize(v + snap(v, 0, 128)); - state.mousemovecb(evn); - } -}; - const interrogate_callback = async (evn, state) => { const bb = getBoundingBox( evn.x,