Revert "wgi: refcount the delegate objects"

This reverts commit ff233fe306.

This doesn't compile cleanly with Visual Studio and I don't want to introduce any subtle issues because we're passing the wrong types of pointers to WGI functions.
This commit is contained in:
Sam Lantinga 2022-08-30 12:09:07 -07:00
parent 3fe6768caf
commit 675d90c708

View file

@ -22,8 +22,6 @@
#ifdef SDL_JOYSTICK_WGI #ifdef SDL_JOYSTICK_WGI
#include "SDL_assert.h"
#include "SDL_atomic.h"
#include "SDL_endian.h" #include "SDL_endian.h"
#include "SDL_events.h" #include "SDL_events.h"
#include "../SDL_sysjoystick.h" #include "../SDL_sysjoystick.h"
@ -209,11 +207,6 @@ SDL_IsXInputDevice(Uint16 vendor, Uint16 product)
return SDL_FALSE; return SDL_FALSE;
} }
typedef struct RawGameControllerDelegate {
__FIEventHandler_1_Windows__CGaming__CInput__CRawGameController *vtbl;
SDL_atomic_t refcount;
} RawGameControllerDelegate;
static HRESULT STDMETHODCALLTYPE IEventHandler_CRawGameControllerVtbl_QueryInterface(__FIEventHandler_1_Windows__CGaming__CInput__CRawGameController * This, REFIID riid, void **ppvObject) static HRESULT STDMETHODCALLTYPE IEventHandler_CRawGameControllerVtbl_QueryInterface(__FIEventHandler_1_Windows__CGaming__CInput__CRawGameController * This, REFIID riid, void **ppvObject)
{ {
if (!ppvObject) { if (!ppvObject) {
@ -223,10 +216,9 @@ static HRESULT STDMETHODCALLTYPE IEventHandler_CRawGameControllerVtbl_QueryInter
*ppvObject = NULL; *ppvObject = NULL;
if (WIN_IsEqualIID(riid, &IID_IUnknown) || WIN_IsEqualIID(riid, &IID_IAgileObject) || WIN_IsEqualIID(riid, &IID_IEventHandler_RawGameController)) { if (WIN_IsEqualIID(riid, &IID_IUnknown) || WIN_IsEqualIID(riid, &IID_IAgileObject) || WIN_IsEqualIID(riid, &IID_IEventHandler_RawGameController)) {
*ppvObject = This; *ppvObject = This;
__x_ABI_CWindows_CGaming_CInput_CIRawGameControllerStatics_AddRef(This);
return S_OK; return S_OK;
} else if (WIN_IsEqualIID(riid, &IID_IMarshal)) { } else if (WIN_IsEqualIID(riid, &IID_IMarshal)) {
/* This seems complicated. Let's hope it doesn't happen. */ // This seems complicated. Let's hope it doesn't happen.
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
} else { } else {
return E_NOINTERFACE; return E_NOINTERFACE;
@ -235,17 +227,12 @@ static HRESULT STDMETHODCALLTYPE IEventHandler_CRawGameControllerVtbl_QueryInter
static ULONG STDMETHODCALLTYPE IEventHandler_CRawGameControllerVtbl_AddRef(__FIEventHandler_1_Windows__CGaming__CInput__CRawGameController * This) static ULONG STDMETHODCALLTYPE IEventHandler_CRawGameControllerVtbl_AddRef(__FIEventHandler_1_Windows__CGaming__CInput__CRawGameController * This)
{ {
RawGameControllerDelegate *self = (RawGameControllerDelegate *)This; return 1;
return SDL_AtomicAdd(&self->refcount, 1) + 1;
} }
static ULONG STDMETHODCALLTYPE IEventHandler_CRawGameControllerVtbl_Release(__FIEventHandler_1_Windows__CGaming__CInput__CRawGameController * This) static ULONG STDMETHODCALLTYPE IEventHandler_CRawGameControllerVtbl_Release(__FIEventHandler_1_Windows__CGaming__CInput__CRawGameController * This)
{ {
RawGameControllerDelegate *self = (RawGameControllerDelegate *)This; return 1;
int rc = SDL_AtomicAdd(&self->refcount, -1) - 1;
/* Should never free the static delegate objects */
SDL_assert(rc > 0);
return rc;
} }
static HRESULT STDMETHODCALLTYPE IEventHandler_CRawGameControllerVtbl_InvokeAdded(__FIEventHandler_1_Windows__CGaming__CInput__CRawGameController * This, IInspectable *sender, __x_ABI_CWindows_CGaming_CInput_CIRawGameController *e) static HRESULT STDMETHODCALLTYPE IEventHandler_CRawGameControllerVtbl_InvokeAdded(__FIEventHandler_1_Windows__CGaming__CInput__CRawGameController * This, IInspectable *sender, __x_ABI_CWindows_CGaming_CInput_CIRawGameController *e)
@ -435,9 +422,8 @@ static __FIEventHandler_1_Windows__CGaming__CInput__CRawGameControllerVtbl contr
IEventHandler_CRawGameControllerVtbl_Release, IEventHandler_CRawGameControllerVtbl_Release,
IEventHandler_CRawGameControllerVtbl_InvokeAdded IEventHandler_CRawGameControllerVtbl_InvokeAdded
}; };
static RawGameControllerDelegate controller_added = { static __FIEventHandler_1_Windows__CGaming__CInput__CRawGameController controller_added = {
{ &controller_added_vtbl }, &controller_added_vtbl
{ 1 }
}; };
static __FIEventHandler_1_Windows__CGaming__CInput__CRawGameControllerVtbl controller_removed_vtbl = { static __FIEventHandler_1_Windows__CGaming__CInput__CRawGameControllerVtbl controller_removed_vtbl = {
@ -446,9 +432,8 @@ static __FIEventHandler_1_Windows__CGaming__CInput__CRawGameControllerVtbl contr
IEventHandler_CRawGameControllerVtbl_Release, IEventHandler_CRawGameControllerVtbl_Release,
IEventHandler_CRawGameControllerVtbl_InvokeRemoved IEventHandler_CRawGameControllerVtbl_InvokeRemoved
}; };
static RawGameControllerDelegate controller_removed = { static __FIEventHandler_1_Windows__CGaming__CInput__CRawGameController controller_removed = {
{ &controller_removed_vtbl }, &controller_removed_vtbl
{ 1 }
}; };
static int static int