From 28941f769345fc8f1c6466ca95eb01262106970b Mon Sep 17 00:00:00 2001 From: Nicholas Tay Date: Wed, 18 May 2022 00:49:24 +1000 Subject: Fix indent/styling --- platform/win32.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'platform/win32.c') diff --git a/platform/win32.c b/platform/win32.c index 0b1da80..b2ed264 100644 --- a/platform/win32.c +++ b/platform/win32.c @@ -13,8 +13,11 @@ static HHOOK keyboard_hook_windows; bool sound_init(float volume) { + /* Single channel volume (max = 0xFFFF) */ DWORD channel_volume = volume * 0xFFFF; - if (waveOutSetVolume(NULL, (channel_volume << 16) | channel_volume) != MMSYSERR_NOERROR) + /* Format is each channel is 16 bits */ + DWORD stereo_volume = (channel_volume << 16) | channel_volume; + if (waveOutSetVolume(NULL, stereo_volume) != MMSYSERR_NOERROR) return false; return true; } @@ -25,7 +28,10 @@ void sound_play(unsigned char *buffer, unsigned int) } /* https://docs.microsoft.com/en-us/previous-versions/windows/desktop/legacy/ms644985(v=vs.85) */ -static LRESULT CALLBACK keyboard_windows_callback(int nCode, WPARAM wParam, LPARAM lParam) +static LRESULT CALLBACK keyboard_windows_callback( + int nCode, + WPARAM wParam, + LPARAM lParam) { /* Needed to prevent repeat fires */ static DWORD prev_vk = 0; @@ -54,7 +60,8 @@ static LRESULT CALLBACK keyboard_windows_callback(int nCode, WPARAM wParam, LPAR bool keyboard_hook(void) { fprintf(stderr, "Setting up keyboard hook...\n"); - keyboard_hook_windows = SetWindowsHookEx(WH_KEYBOARD_LL, keyboard_windows_callback, NULL, 0); + keyboard_hook_windows = SetWindowsHookEx(WH_KEYBOARD_LL, + keyboard_windows_callback, NULL, 0); if (keyboard_hook_windows == NULL) { return false; } @@ -65,7 +72,8 @@ void keyboard_unhook(void) { fprintf(stderr, "Cleaning up keyboard hook...\n"); if (!UnhookWindowsHookEx(keyboard_hook_windows)) - printf("WARN: Windows keyboard hook could not be cleaned up! Error code: %lu\n", GetLastError()); + printf("WARN: Windows keyboard hook could not be cleaned up! Error code: %lu\n", + GetLastError()); } void enter_idle(void) @@ -97,7 +105,8 @@ struct board *load_board(char *board_name) return false; } // HACK: Cast to void function ptr then cast back, otherwise types are incompatible to the compiler. - fn_board_init board_init = (fn_board_init) (void (*)(void)) GetProcAddress(board_module, "board_init"); + fn_board_init board_init = (fn_board_init)(void (*)(void)) GetProcAddress( + board_module, "board_init"); if (board_init == NULL) { printf("ERROR: No board initialisation function could be loaded.\n"); return false; -- cgit