1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | static bool playing = false; ... case WM_SYSKEYDOWN: case WM_SYSKEYUP: case WM_KEYDOWN: { uint64 vk_code = wParam; if ( !playing && vk_code == 'F') { playing = true; GlobalSecondaryBuffer->SetCurrentPosition(0); if ( GlobalSecondaryBuffer->Play(0, 0, DSBPLAY_LOOPING) == DS_OK) { OutputDebugStringA( "play\n" ); } } if (vk_code == 'G') { GlobalSecondaryBuffer->Stop(); playing = false; } } break; case WM_KEYUP: { uint64 vk_code = wParam; if (vk_code == 'F') { GlobalSecondaryBuffer->Stop(); playing = false; } } break; |
1 2 3 4 5 6 7 8 9 | case WM_SYSKEYDOWN: case WM_SYSKEYUP: case WM_KEYDOWN: { uint64 vk_code = wParam; bool was_down = ((lparam >> 30) & 1) != 0; if ( !was_down && vk_code == 'F') { ... |
You're more likely to get an answer on the discord server.
Also if you're OK with the code not being the same as Casey, I'd suggest trying using WASAPI (thread linked above) as it's better to spend time on a current good way of doing sound than on DSound.
Be aware that DirectSounds code in HH changed multiple times. If you get some issue, check episodes for few next days - maybe the issue is addressed there. But as Simon already said, consider switching to WASAPI. There's no reason anymore to use DirectSound on Windows nowadays.