diff options
Diffstat (limited to '')
-rw-r--r-- | platform/win32.c | 19 |
1 files changed, 14 insertions, 5 deletions
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; |