diff src/timer.c @ 0:d91dfd53b8b4

Initial commit
author Paper <mrpapersonic@gmail.com>
date Sun, 07 Aug 2022 07:26:27 -0400
parents
children 7abb5d8b20ea
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/timer.c	Sun Aug 07 07:26:27 2022 -0400
@@ -0,0 +1,32 @@
+#include <assert.h>
+#ifndef WIN32_LEAN_AND_MEAN
+#  define WIN32_LEAN_AND_MEAN
+#endif
+#include <windows.h>
+#include "timer.h"
+void timer_init(struct timer_t* timer, HWND winampClientWindow, TIMERPROC timer_proc) {
+	timer->winampClientWindow = winampClientWindow;
+	timer->timer_proc = timer_proc;
+	timer->initialized = 1;
+}
+
+void timer_set(struct timer_t* timer, HWND winampClientWindow) {
+	assert(timer->initialized);
+	
+	if (timer->is_timer_alive)
+		return;
+	
+	timer->is_timer_alive = 1;
+	SetTimer(winampClientWindow, 1, timer->interval, timer->timer_proc);
+}
+
+void timer_stop(struct timer_t* timer, HWND winampClientWindow) {
+	assert(timer->initialized);
+	
+	if (!timer->is_timer_alive)
+		return;
+	
+	
+	timer->is_timer_alive = 0;
+	KillTimer(winampClientWindow, 1);
+}
\ No newline at end of file