comparison src/main.c @ 10:42ac054c0231

*: huge refactoring dirtools now uses wchar (wayyy overdue) the timer doesn't have a stupid design anymore we don't use windows.h at all now ...
author Paper <paper@paper.us.eu.org>
date Sun, 11 Feb 2024 19:43:31 -0500
parents be4835547dd0
children
comparison
equal deleted inserted replaced
9:07f0e2f43204 10:42ac054c0231
1 /** 1 /**
2 * wgsdk - Winamp plugin for Discord's GameSDK 2 * wgsdk - Winamp plugin for Discord's GameSDK
3 **/ 3 **/
4 #include <assert.h>
5 #include <stdio.h>
6 #include <stdlib.h>
7 #include <Winamp/wa_ipc.h>
8 #include "discord_game_sdk.h"
9 #include "timer.h" 4 #include "timer.h"
10 #include "config.h" 5 #include "config.h"
11 #include "resource.h" 6 #include "resource.h"
12 #include "utils.h" 7 #include "utils.h"
13 #ifndef WIN32_LEAN_AND_MEAN 8
14 # define WIN32_LEAN_AND_MEAN 9 #include <Winamp/wa_ipc.h>
15 #endif 10 #include "discord_game_sdk.h"
16 #include <windows.h> 11
17 #include <windowsx.h> 12 #include <assert.h>
13 #include <stdio.h>
14 #include <stdlib.h>
18 15
19 #define CLIENT_ID 969367220599803955 16 #define CLIENT_ID 969367220599803955
20 #define DISCORD_REQUIRE(x) \ 17 #define DISCORD_REQUIRE(x) \
21 assert(x == DiscordResult_Ok) 18 assert((x) == DiscordResult_Ok)
22 19
23 #define GPPHDR_VER 0x10 20 #define GPPHDR_VER 0x10
24 21
25 int init(); 22 int init();
26 void conf(); 23 void conf();
55 .instance = 0 52 .instance = 0
56 }; 53 };
57 54
58 struct IDiscordActivityEvents activities_events; 55 struct IDiscordActivityEvents activities_events;
59 56
60 struct application { 57 struct {
61 struct IDiscordCore* core; 58 struct IDiscordCore* core;
62 struct IDiscordUsers* users; 59 struct IDiscordUsers* users;
63 struct IDiscordActivityManager* activities; 60 struct IDiscordActivityManager* activities;
64 } app; 61 } app;
65 62
66 /* Now we get to our built-in stuff */ 63 /* Now we get to our built-in stuff */
67 64
68 struct timer timer_callbacks = { .interval = 16 }; 65 struct timer timer_callbacks = {0};
69 66
70 struct config config = { 67 struct config config = {
71 .display_title = 1, 68 .display_title = 1,
72 .show_elapsed_time = 1 69 .show_elapsed_time = 1
73 }; 70 };
114 report_idle_status(); 111 report_idle_status();
115 break; 112 break;
116 case 1: 113 case 1:
117 case 3: 114 case 3:
118 report_current_song_status(is_playing); 115 report_current_song_status(is_playing);
116 break;
119 default: 117 default:
120 break; 118 break;
121 } 119 }
122 } 120 }
123 121
153 151
154 DISCORD_REQUIRE(DiscordCreate(DISCORD_VERSION, &params, &app.core)); 152 DISCORD_REQUIRE(DiscordCreate(DISCORD_VERSION, &params, &app.core));
155 153
156 app.activities = app.core->get_activity_manager(app.core); 154 app.activities = app.core->get_activity_manager(app.core);
157 155
158 timer_init(&timer_callbacks, g_plugin.hwndParent, TimerProc); 156 timer_init(&timer_callbacks, 16, TimerProc);
159 timer_set(&timer_callbacks, g_plugin.hwndParent); 157 timer_set(&timer_callbacks);
160 158
161 cfg_load(&config); 159 cfg_load(&config);
162 160
163 strcpy(activity.assets.large_image, "winamp-logo"); 161 strcpy(activity.assets.large_image, "winamp-logo");
164 162