From 6085d20c70af826f2a00d537c5616d799e647ce8 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Deuc=D0=B5?= <shurd@sasktel.net>
Date: Sat, 12 Feb 2022 02:20:50 -0500
Subject: [PATCH] Use xp_timer() instead of msclock()

I'm not really happy about rounding floats in time-critical bits,
but there you go.
---
 src/conio/mouse.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/src/conio/mouse.c b/src/conio/mouse.c
index 423016dff3..681ce726e3 100644
--- a/src/conio/mouse.c
+++ b/src/conio/mouse.c
@@ -31,6 +31,7 @@
  * Note: If this box doesn't appear square, then you need to fix your tabs.	*
  ****************************************************************************/
 
+#include <math.h>
 #include <stdlib.h>
 #include <string.h>
 
@@ -41,7 +42,7 @@
 
 #include "ciolib.h"
 
-#define MSEC_CLOCK()	(msclock()*MSCLOCKS_PER_SEC/1000)
+#define MSEC_CLOCK()	llroundl(xp_timer()*1000)
 
 enum {
 	 MOUSE_NOSTATE
@@ -62,7 +63,7 @@ struct in_mouse_event {
 	int	y;
 	int	x_res;
 	int	y_res;
-	clock_t	ts;
+	long long ts;
 	void	*nextevent;
 };
 
@@ -91,7 +92,7 @@ struct mouse_state {
 	int	button_y[5];
 	int	button_x_res[5];			/* Start X/Y position of the current state */
 	int	button_y_res[5];
-	clock_t	timeout[5];	/* Button event timeouts (timespecs ie: time of expiry) */
+	long long timeout[5];	/* Button event timeouts (timespecs ie: time of expiry) */
 	int	curx;					/* Current X position */
 	int	cury;					/* Current Y position */
 	int	curx_res;					/* Current X position */
@@ -265,7 +266,7 @@ void ciolib_mouse_thread(void *data)
 	int timeout_button=0;
 	int but;
 	int delay;
-	clock_t	ttime=0;
+	long long ttime=0;
 
 	SetThreadName("Mouse");
 	init_mouse();
-- 
GitLab