diff --git a/control.cpp b/control.cpp index 6de66fc7..82c01d84 100644 --- a/control.cpp +++ b/control.cpp @@ -200,7 +200,9 @@ enum class tmode { move, info, drag, fire, ranged }; #endif EX bool touch_interface; -EX ld drag_sensitivity, drag_distance; +EX ld drag_sensitivity; +EX shiftpoint drag_start; +EX bool not_started_dragging; EX tmode touchmode; EX vector touch_description = { "touch to move", "touch for info", "touch to drag", "touch to aim", "touch for ranged" }; @@ -823,11 +825,22 @@ EX void handleKeyNormal(int sym, int uni) { multi::cpid = 0; bool adr = drag_sensitivity && !vid.quickmouse && mouse_state != 2; - if(touchmode == tmode::drag || adr) { + if(adr) { + if(holdmouse && not_started_dragging) { + ld d = hdist(drag_start, mouseh); + if(d < 1/drag_sensitivity) actonrelease = true; + else panning(drag_start, mouseh), not_started_dragging = false; + } + else if(holdmouse) { + panning(mouseoh, mouseh); + } + else if(!holdmouse) + drag_start = mouseh, not_started_dragging = true, actonrelease = true; + holdmouse = true; + } + else if(touchmode == tmode::drag) { if(holdmouse) panning(mouseoh, mouseh); - if(!holdmouse) drag_distance = 0; holdmouse = true; - if(adr && drag_distance < 1/drag_sensitivity) actonrelease = true; } else if(touchmode == tmode::info) gotoHelp(help); diff --git a/hypgraph.cpp b/hypgraph.cpp index a2bf8f0a..0ca70037 100644 --- a/hypgraph.cpp +++ b/hypgraph.cpp @@ -2501,16 +2501,12 @@ EX void resetview() { // SDL_UnlockSurface(s); } - EX void panning(shiftpoint hf0, shiftpoint ht0) { hyperpoint hf = hf0.h; hyperpoint ht = unshift(ht0, hf0.shift); - ld d = hdist(hf, ht); - if(drag_sensitivity && d < 1/drag_sensitivity && drag_distance == 0) return; View = rgpushxto0(hf) * rgpushxto0(gpushxto0(hf) * ht) * gpushxto0(hf) * View; playermoved = false; currently_scrolling = true; - drag_distance += d; } EX int cells_drawn, cells_generated;