mirror of https://github.com/encounter/SDL.git
windows: Try to unify all the GUID comparison code into a core helper function.
There are likely several more I missed.
This commit is contained in:
parent
e5fc93baca
commit
70c0400b12
|
@ -158,7 +158,7 @@ WIN_LookupAudioDeviceName(const WCHAR *name, const GUID *guid)
|
|||
DWORD len = 0;
|
||||
char *retval = NULL;
|
||||
|
||||
if (SDL_memcmp(guid, &nullguid, sizeof (*guid)) == 0) {
|
||||
if (WIN_IsEqualGUID(guid, &nullguid)) {
|
||||
return WIN_StringToUTF8(name); /* No GUID, go with what we've got. */
|
||||
}
|
||||
|
||||
|
@ -202,6 +202,18 @@ WIN_LookupAudioDeviceName(const WCHAR *name, const GUID *guid)
|
|||
#endif /* if __WINRT__ / else */
|
||||
}
|
||||
|
||||
BOOL
|
||||
WIN_IsEqualGUID(const GUID * a, const GUID * b)
|
||||
{
|
||||
return (SDL_memcmp(a, b, sizeof (*a)) == 0);
|
||||
}
|
||||
|
||||
BOOL
|
||||
WIN_IsEqualIID(REFIID a, REFIID b)
|
||||
{
|
||||
return (SDL_memcmp(a, b, sizeof (*a)) == 0);
|
||||
}
|
||||
|
||||
#endif /* __WIN32__ || __WINRT__ */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
|
|
|
@ -62,6 +62,10 @@ extern BOOL WIN_IsWindowsVistaOrGreater(void);
|
|||
/* You need to SDL_free() the result of this call. */
|
||||
extern char *WIN_LookupAudioDeviceName(const WCHAR *name, const GUID *guid);
|
||||
|
||||
/* Checks to see if two GUID are the same. */
|
||||
extern BOOL WIN_IsEqualGUID(const GUID * a, const GUID * b);
|
||||
extern BOOL WIN_IsEqualIID(REFIID a, REFIID b);
|
||||
|
||||
#endif /* _INCLUDED_WINDOWS_H */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
|
|
|
@ -58,15 +58,6 @@ DI_SetError(const char *str, HRESULT err)
|
|||
return SDL_SetError("Haptic error %s", str);
|
||||
}
|
||||
|
||||
/*
|
||||
* Checks to see if two GUID are the same.
|
||||
*/
|
||||
static int
|
||||
DI_GUIDIsSame(const GUID * a, const GUID * b)
|
||||
{
|
||||
return (SDL_memcmp(a, b, sizeof (GUID)) == 0);
|
||||
}
|
||||
|
||||
/*
|
||||
* Callback to find the haptic devices.
|
||||
*/
|
||||
|
@ -219,17 +210,17 @@ DI_DeviceObjectCallback(LPCDIDEVICEOBJECTINSTANCE dev, LPVOID pvRef)
|
|||
if ((dev->dwType & DIDFT_AXIS) && (dev->dwFlags & DIDOI_FFACTUATOR)) {
|
||||
const GUID *guid = &dev->guidType;
|
||||
DWORD offset = 0;
|
||||
if (DI_GUIDIsSame(guid, &GUID_XAxis)) {
|
||||
if (WIN_IsEqualGUID(guid, &GUID_XAxis)) {
|
||||
offset = DIJOFS_X;
|
||||
} else if (DI_GUIDIsSame(guid, &GUID_YAxis)) {
|
||||
} else if (WIN_IsEqualGUID(guid, &GUID_YAxis)) {
|
||||
offset = DIJOFS_Y;
|
||||
} else if (DI_GUIDIsSame(guid, &GUID_ZAxis)) {
|
||||
} else if (WIN_IsEqualGUID(guid, &GUID_ZAxis)) {
|
||||
offset = DIJOFS_Z;
|
||||
} else if (DI_GUIDIsSame(guid, &GUID_RxAxis)) {
|
||||
} else if (WIN_IsEqualGUID(guid, &GUID_RxAxis)) {
|
||||
offset = DIJOFS_RX;
|
||||
} else if (DI_GUIDIsSame(guid, &GUID_RyAxis)) {
|
||||
} else if (WIN_IsEqualGUID(guid, &GUID_RyAxis)) {
|
||||
offset = DIJOFS_RY;
|
||||
} else if (DI_GUIDIsSame(guid, &GUID_RzAxis)) {
|
||||
} else if (WIN_IsEqualGUID(guid, &GUID_RzAxis)) {
|
||||
offset = DIJOFS_RZ;
|
||||
} else {
|
||||
return DIENUM_CONTINUE; /* can't use this, go on. */
|
||||
|
@ -251,7 +242,7 @@ DI_DeviceObjectCallback(LPCDIDEVICEOBJECTINSTANCE dev, LPVOID pvRef)
|
|||
* Callback to get all supported effects.
|
||||
*/
|
||||
#define EFFECT_TEST(e,s) \
|
||||
if (DI_GUIDIsSame(&pei->guid, &(e))) \
|
||||
if (WIN_IsEqualGUID(&pei->guid, &(e))) \
|
||||
haptic->supported |= (s)
|
||||
static BOOL CALLBACK
|
||||
DI_EffectCallback(LPCDIEFFECTINFO pei, LPVOID pv)
|
||||
|
@ -481,7 +472,7 @@ SDL_DINPUT_JoystickSameHaptic(SDL_Haptic * haptic, SDL_Joystick * joystick)
|
|||
return 0;
|
||||
}
|
||||
|
||||
return DI_GUIDIsSame(&hap_instance.guidInstance, &joy_instance.guidInstance);
|
||||
return WIN_IsEqualGUID(&hap_instance.guidInstance, &joy_instance.guidInstance);
|
||||
}
|
||||
|
||||
int
|
||||
|
@ -500,7 +491,7 @@ SDL_DINPUT_HapticOpenFromJoystick(SDL_Haptic * haptic, SDL_Joystick * joystick)
|
|||
|
||||
/* Since it comes from a joystick we have to try to match it with a haptic device on our haptic list. */
|
||||
for (item = SDL_hapticlist; item != NULL; item = item->next) {
|
||||
if (!item->bXInputHaptic && DI_GUIDIsSame(&item->instance.guidInstance, &joy_instance.guidInstance)) {
|
||||
if (!item->bXInputHaptic && WIN_IsEqualGUID(&item->instance.guidInstance, &joy_instance.guidInstance)) {
|
||||
haptic->index = index;
|
||||
return SDL_DINPUT_HapticOpenFromDevice(haptic, joystick->hwdata->InputDevice, SDL_TRUE);
|
||||
}
|
||||
|
|
|
@ -331,9 +331,6 @@ static DWORD IME_GetId(SDL_VideoData *videodata, UINT uIndex);
|
|||
static void IME_SendEditingEvent(SDL_VideoData *videodata);
|
||||
static void IME_DestroyTextures(SDL_VideoData *videodata);
|
||||
|
||||
#define SDL_IsEqualIID(riid1, riid2) SDL_IsEqualGUID(riid1, riid2)
|
||||
#define SDL_IsEqualGUID(rguid1, rguid2) (!SDL_memcmp(rguid1, rguid2, sizeof(GUID)))
|
||||
|
||||
static SDL_bool UILess_SetupSinks(SDL_VideoData *videodata);
|
||||
static void UILess_ReleaseSinks(SDL_VideoData *videodata);
|
||||
static void UILess_EnableUIUpdates(SDL_VideoData *videodata);
|
||||
|
@ -1052,9 +1049,9 @@ STDMETHODIMP UIElementSink_QueryInterface(TSFSink *sink, REFIID riid, PVOID *ppv
|
|||
return E_INVALIDARG;
|
||||
|
||||
*ppv = 0;
|
||||
if (SDL_IsEqualIID(riid, &IID_IUnknown))
|
||||
if (WIN_IsEqualIID(riid, &IID_IUnknown))
|
||||
*ppv = (IUnknown *)sink;
|
||||
else if (SDL_IsEqualIID(riid, &IID_ITfUIElementSink))
|
||||
else if (WIN_IsEqualIID(riid, &IID_ITfUIElementSink))
|
||||
*ppv = (ITfUIElementSink *)sink;
|
||||
|
||||
if (*ppv) {
|
||||
|
@ -1158,9 +1155,9 @@ STDMETHODIMP IPPASink_QueryInterface(TSFSink *sink, REFIID riid, PVOID *ppv)
|
|||
return E_INVALIDARG;
|
||||
|
||||
*ppv = 0;
|
||||
if (SDL_IsEqualIID(riid, &IID_IUnknown))
|
||||
if (WIN_IsEqualIID(riid, &IID_IUnknown))
|
||||
*ppv = (IUnknown *)sink;
|
||||
else if (SDL_IsEqualIID(riid, &IID_ITfInputProcessorProfileActivationSink))
|
||||
else if (WIN_IsEqualIID(riid, &IID_ITfInputProcessorProfileActivationSink))
|
||||
*ppv = (ITfInputProcessorProfileActivationSink *)sink;
|
||||
|
||||
if (*ppv) {
|
||||
|
@ -1174,8 +1171,8 @@ STDMETHODIMP IPPASink_OnActivated(TSFSink *sink, DWORD dwProfileType, LANGID lan
|
|||
{
|
||||
static const GUID TF_PROFILE_DAYI = { 0x037B2C25, 0x480C, 0x4D7F, { 0xB0, 0x27, 0xD6, 0xCA, 0x6B, 0x69, 0x78, 0x8A } };
|
||||
SDL_VideoData *videodata = (SDL_VideoData *)sink->data;
|
||||
videodata->ime_candlistindexbase = SDL_IsEqualGUID(&TF_PROFILE_DAYI, guidProfile) ? 0 : 1;
|
||||
if (SDL_IsEqualIID(catid, &GUID_TFCAT_TIP_KEYBOARD) && (dwFlags & TF_IPSINK_FLAG_ACTIVE))
|
||||
videodata->ime_candlistindexbase = WIN_IsEqualGUID(&TF_PROFILE_DAYI, guidProfile) ? 0 : 1;
|
||||
if (WIN_IsEqualIID(catid, &GUID_TFCAT_TIP_KEYBOARD) && (dwFlags & TF_IPSINK_FLAG_ACTIVE))
|
||||
IME_InputLangChanged((SDL_VideoData *)sink->data);
|
||||
|
||||
IME_HideCandidateList(videodata);
|
||||
|
|
Loading…
Reference in New Issue