DXGL r817 - Code Review

Jump to navigation Jump to search
Repository:DXGL
Revision:r816‎ | r817 | r818 >
Date:19:34, 28 May 2018
Author:admin
Status:new
Tags:
Comment:
Rewrite the SetCursorPos hook.
Modified paths:
  • /ddraw/hooks.c (modified) (history)

Diff [purge]

Index: ddraw/hooks.c
@@ -746,7 +746,10 @@
747747 HWND_HOOK *wndhook;
748748 LONG sizes[6];
749749 POINT pt;
750 - int winWidth, winHeight;
 750+ BOOL error;
 751+ int oldx, oldy;
 752+ float mulx, muly;
 753+ int translatex, translatey;
751754
752755 if (dxglcfg.DebugNoMouseHooks) {
753756 return _SetCursorPos(x, y);
@@ -756,13 +759,31 @@
757760 if (!wndhook) {
758761 return _SetCursorPos(x, y);
759762 }
760 -
761 - pt.x = 0;
762 - pt.y = 0;
763 - glDirectDraw7_GetSizes(wndhook->lpDD7, sizes);
764 - ClientToScreen(wndhook->hwnd, &pt);
765 -
766 - return _SetCursorPos(x * sizes[4] / sizes[2] + pt.x, y * sizes[5] / sizes[3] + pt.y);
 763+ if (((dxglcfg.scaler != 0) || ((dxglcfg.fullmode >= 2) && (dxglcfg.fullmode <= 4)))
 764+ && glDirectDraw7_GetFullscreen(wndhook->lpDD7))
 765+ {
 766+ oldx = x;
 767+ oldy = y;
 768+ glDirectDraw7_GetSizes(wndhook->lpDD7, sizes);
 769+ mulx = (float)sizes[0] / (float)sizes[2];
 770+ muly = (float)sizes[1] / (float)sizes[3];
 771+ oldx = (int)((float)oldx * mulx);
 772+ oldy = (int)((float)oldy * muly);
 773+ translatex = (sizes[4] - sizes[0]) / 2;
 774+ translatey = (sizes[5] - sizes[1]) / 2;
 775+ oldx += translatex;
 776+ oldy += translatey;
 777+ if ((dxglcfg.fullmode >= 2) && (dxglcfg.fullmode <= 4))
 778+ {
 779+ pt.x = 0;
 780+ pt.y = 0;
 781+ ClientToScreen(wndhook->hwnd, &pt);
 782+ oldx += pt.x;
 783+ oldy += pt.y;
 784+ }
 785+ return _SetCursorPos(oldx, oldy);
 786+ }
 787+ else return _SetCursorPos(x, y);
767788 }
768789 HCURSOR WINAPI HookSetCursor(HCURSOR hCursor)
769790 {