From 9156ce62f34de5c80d5103d874e20f231f22a054 Mon Sep 17 00:00:00 2001 From: k-m_schindler Date: Fri, 1 Jan 2016 23:13:16 +0000 Subject: add checkmousebutton git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@3163 b956fd51-792f-4845-bead-9b4dfca2ff2c --- src/base/UMain.pas | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/src/base/UMain.pas b/src/base/UMain.pas index f0dc3d4e..416e0a50 100644 --- a/src/base/UMain.pas +++ b/src/base/UMain.pas @@ -37,6 +37,11 @@ uses SysUtils, SDL; +var + CheckMouseButton: boolean; // for checking mouse motion + MAX_FPS: byte; // 0 to 255 is enough + + procedure Main; procedure MainLoop; procedure CheckEvents; @@ -106,6 +111,14 @@ begin WindowTitle := USDXVersionStr; Platform.Init; + + // Commandline Parameter Parser + Params := TCMDParams.Create; + + // Log + Benchmark + Log := TLog.Create; + Log.Title := WindowTitle; + //Log.FileOutputEnabled := not Params.NoLog; if Platform.TerminateIfAlreadyRunning(WindowTitle) then Exit; @@ -136,14 +149,6 @@ begin USTime := TTime.Create; VideoBGTimer := TRelativeTimer.Create; - // Commandline Parameter Parser - Params := TCMDParams.Create; - - // Log + Benchmark - Log := TLog.Create; - Log.Title := WindowTitle; - Log.FileOutputEnabled := not Params.NoLog; - // Language Log.LogStatus('Initialize Paths', 'Initialization'); InitializePaths; @@ -301,7 +306,7 @@ begin CountSkipTime(); // JB - for some reason this seems to be needed when we use the SDL Timer functions. repeat TicksBeforeFrame := SDL_GetTicks; - + // joypad if (Ini.Joypad = 1) or (Params.Joypad) then Joy.Update; @@ -365,14 +370,17 @@ begin case Event.type_ of SDL_MOUSEMOTION: begin - mouseDown := false; + if (CheckMouseButton) then + mouseDown := true + else + mouseDown := false; mouseBtn := 0; end; SDL_MOUSEBUTTONDOWN: begin mouseDown := true; mouseBtn := Event.button.button; - + CheckMouseButton := true; if (mouseBtn = SDL_BUTTON_LEFT) or (mouseBtn = SDL_BUTTON_RIGHT) then Display.OnMouseButton(true); end; @@ -380,7 +388,7 @@ begin begin mouseDown := false; mouseBtn := Event.button.button; - + CheckMouseButton := false; if (mouseBtn = SDL_BUTTON_LEFT) or (mouseBtn = SDL_BUTTON_RIGHT) then Display.OnMouseButton(false); end; -- cgit v1.2.3