Created
April 21, 2020 17:20
-
-
Save Plecra/b3a2b52bdb877e9ff63bd633df724a1c to your computer and use it in GitHub Desktop.
Adventures into the cursed land of c++ #NaN.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <Windows.h> | |
#include <Xinput.h> | |
#pragma comment (lib, "xinput.lib") | |
int main() | |
{ | |
std::cout << "Hello World!\n"; | |
DWORD id = 0; | |
XINPUT_STATE state; | |
// First, a little sanity check: Gotta make sure we can see the controller | |
if (XInputGetState(id, &state) != ERROR_SUCCESS) | |
{ | |
printf("Controller %d doesn't exist\n", id); | |
return 1; | |
} | |
// Now I just want to play around with the audio functionality. This is the only | |
// example available that hasn't been plastered with deprecation warnings. | |
// https://docs.microsoft.com/en-us/windows/win32/xinput/getting-started-with-xinput#getting-audio-device-identifiers | |
WCHAR renderId[256] = { 0 }; | |
WCHAR captureId[256] = { 0 }; | |
UINT rcount = 256; | |
UINT ccount = 256; | |
// Annoyingly, it doesn't seem like anything is ending up in those buffers, so | |
// let's check out the return value. | |
DWORD result = XInputGetAudioDeviceIds(id, renderId, &rcount, captureId, &ccount); | |
printf("%d", result); // => 1167 (ERROR_DEVICE_NOT_CONNECTED) | |
// - https://docs.microsoft.com/en-us/windows/win32/api/xinput/nf-xinput-xinputgetaudiodeviceids#return-value | |
// So if the documentation is to be trusted, this explicitly means the controller isn't | |
// physically connected. After we *just* polled it. Right. | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment