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 <victorseijih@gmail.com>
This commit is contained in:
Victor Seiji Hariki 2022-12-07 18:51:33 -03:00
parent 361efc76f2
commit aee812b70a
2 changed files with 16 additions and 18 deletions

View file

@ -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);
}

View file

@ -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,