Handmade Hero»Forums»Code
Brian Smith
2 posts
xinput lambda stubs
Just thought I'd share a C++11 thing you can do for the XInput stubs.

1
2
3
4
5
typedef DWORD WINAPI xinput_fn_get_state(DWORD, XINPUT_STATE*);
typedef DWORD WINAPI xinput_fn_set_state(DWORD, XINPUT_VIBRATION*);

xinput_fn_get_state* xinput_get_state = [](DWORD, XINPUT_STATE*)->DWORD{return 0;};
xinput_fn_set_state* xinput_set_state = [](DWORD, XINPUT_VIBRATION*)->DWORD{return 0;};


Then later, the fn pointers get replaced by GetProcAddress() calls, as before.

Coming from languages that support lambdas, taking advantage of this new feature in C++ is appealing to me.

(I'm using GCC 4.9 under MinGW64; I assume this will work in the latest MSVC.)
Benjamin Kloster
48 posts
xinput lambda stubs
With decltype, you can even save the typedef.
Brian Smith
2 posts
xinput lambda stubs
Even better! I'm really enjoying these new features.