dinput: Move internal function calculate_ids to where it's really used.
This commit is contained in:
parent
c17e06d5c0
commit
267cbf8289
|
@ -287,7 +287,50 @@ void release_DataFormat(DataFormat * format)
|
||||||
HeapFree(GetProcessHeap(), 0, format->dt);
|
HeapFree(GetProcessHeap(), 0, format->dt);
|
||||||
}
|
}
|
||||||
|
|
||||||
DataFormat *create_DataFormat(const DIDATAFORMAT *wine_format, LPCDIDATAFORMAT asked_format, int *offset) {
|
/* Make all instances sequential */
|
||||||
|
static void calculate_ids(LPDIDATAFORMAT df)
|
||||||
|
{
|
||||||
|
int i, axis = 0, pov = 0, button = 0;
|
||||||
|
int axis_base, pov_base, button_base;
|
||||||
|
DWORD type;
|
||||||
|
|
||||||
|
/* Make two passes over the format. The first counts the number
|
||||||
|
* for each type and the second sets the id */
|
||||||
|
for (i = 0; i < df->dwNumObjs; i++)
|
||||||
|
{
|
||||||
|
type = DIDFT_GETTYPE(df->rgodf[i].dwType);
|
||||||
|
if (type & DIDFT_AXIS) axis++;
|
||||||
|
else if (type & DIDFT_POV) pov++;
|
||||||
|
else if (type & DIDFT_BUTTON) button++;
|
||||||
|
}
|
||||||
|
|
||||||
|
axis_base = 0;
|
||||||
|
pov_base = axis_base + axis;
|
||||||
|
button_base = pov_base + pov;
|
||||||
|
axis = pov = button = 0;
|
||||||
|
|
||||||
|
for (i = 0; i < df->dwNumObjs; i++)
|
||||||
|
{
|
||||||
|
type = DIDFT_GETTYPE(df->rgodf[i].dwType);
|
||||||
|
if (type & DIDFT_AXIS)
|
||||||
|
{
|
||||||
|
type |= DIDFT_MAKEINSTANCE(axis_base + axis++);
|
||||||
|
TRACE("axis type = 0x%08x\n", type);
|
||||||
|
} else if (type & DIDFT_POV)
|
||||||
|
{
|
||||||
|
type |= DIDFT_MAKEINSTANCE(pov_base + pov++);
|
||||||
|
TRACE("POV type = 0x%08x\n", type);
|
||||||
|
} else if (type & DIDFT_BUTTON)
|
||||||
|
{
|
||||||
|
type |= DIDFT_MAKEINSTANCE(button_base + button++);
|
||||||
|
TRACE("button type = 0x%08x\n", type);
|
||||||
|
}
|
||||||
|
df->rgodf[i].dwType = type;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
DataFormat *create_DataFormat(LPCDIDATAFORMAT wine_format, LPDIDATAFORMAT asked_format, int *offset)
|
||||||
|
{
|
||||||
DataFormat *ret;
|
DataFormat *ret;
|
||||||
DataTransform *dt;
|
DataTransform *dt;
|
||||||
unsigned int i, j;
|
unsigned int i, j;
|
||||||
|
@ -405,6 +448,8 @@ DataFormat *create_DataFormat(const DIDATAFORMAT *wine_format, LPCDIDATAFORMAT a
|
||||||
|
|
||||||
HeapFree(GetProcessHeap(), 0, done);
|
HeapFree(GetProcessHeap(), 0, done);
|
||||||
|
|
||||||
|
/* Last step - reset all instances of the new format */
|
||||||
|
calculate_ids(asked_format);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -60,7 +60,7 @@ typedef struct {
|
||||||
DataTransform *dt;
|
DataTransform *dt;
|
||||||
} DataFormat;
|
} DataFormat;
|
||||||
extern void fill_DataFormat(void *out, const void *in, DataFormat *df) ;
|
extern void fill_DataFormat(void *out, const void *in, DataFormat *df) ;
|
||||||
extern DataFormat *create_DataFormat(const DIDATAFORMAT *wine_format, LPCDIDATAFORMAT asked_format, int *offset) ;
|
extern DataFormat *create_DataFormat(LPCDIDATAFORMAT wine_format, LPDIDATAFORMAT asked_format, int *offset);
|
||||||
extern void release_DataFormat(DataFormat *df) ;
|
extern void release_DataFormat(DataFormat *df) ;
|
||||||
extern void queue_event(LPDIRECTINPUTDEVICE8A iface, int ofs, DWORD data, DWORD time, DWORD seq);
|
extern void queue_event(LPDIRECTINPUTDEVICE8A iface, int ofs, DWORD data, DWORD time, DWORD seq);
|
||||||
|
|
||||||
|
|
|
@ -393,57 +393,6 @@ static HRESULT setup_dinput_options(JoystickImpl * device)
|
||||||
return DI_OK;
|
return DI_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void calculate_ids(JoystickImpl* device)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
int axis = 0;
|
|
||||||
int button = 0;
|
|
||||||
int pov = 0;
|
|
||||||
int axis_base;
|
|
||||||
int pov_base;
|
|
||||||
int button_base;
|
|
||||||
|
|
||||||
/* Make two passes over the format. The first counts the number
|
|
||||||
* for each type and the second sets the id */
|
|
||||||
for (i = 0; i < device->user_df->dwNumObjs; i++) {
|
|
||||||
if (DIDFT_GETTYPE(device->user_df->rgodf[i].dwType) & DIDFT_AXIS)
|
|
||||||
axis++;
|
|
||||||
else if (DIDFT_GETTYPE(device->user_df->rgodf[i].dwType) & DIDFT_POV)
|
|
||||||
pov++;
|
|
||||||
else if (DIDFT_GETTYPE(device->user_df->rgodf[i].dwType) & DIDFT_BUTTON)
|
|
||||||
button++;
|
|
||||||
}
|
|
||||||
|
|
||||||
axis_base = 0;
|
|
||||||
pov_base = axis;
|
|
||||||
button_base = axis + pov;
|
|
||||||
|
|
||||||
axis = 0;
|
|
||||||
button = 0;
|
|
||||||
pov = 0;
|
|
||||||
|
|
||||||
for (i = 0; i < device->user_df->dwNumObjs; i++) {
|
|
||||||
DWORD type = 0;
|
|
||||||
if (DIDFT_GETTYPE(device->user_df->rgodf[i].dwType) & DIDFT_AXIS) {
|
|
||||||
axis++;
|
|
||||||
type = DIDFT_GETTYPE(device->user_df->rgodf[i].dwType) |
|
|
||||||
DIDFT_MAKEINSTANCE(axis + axis_base);
|
|
||||||
TRACE("axis type = 0x%08x\n", type);
|
|
||||||
} else if (DIDFT_GETTYPE(device->user_df->rgodf[i].dwType) & DIDFT_POV) {
|
|
||||||
pov++;
|
|
||||||
type = DIDFT_GETTYPE(device->user_df->rgodf[i].dwType) |
|
|
||||||
DIDFT_MAKEINSTANCE(pov + pov_base);
|
|
||||||
TRACE("POV type = 0x%08x\n", type);
|
|
||||||
} else if (DIDFT_GETTYPE(device->user_df->rgodf[i].dwType) & DIDFT_BUTTON) {
|
|
||||||
button++;
|
|
||||||
type = DIDFT_GETTYPE(device->user_df->rgodf[i].dwType) |
|
|
||||||
DIDFT_MAKEINSTANCE(button + button_base);
|
|
||||||
TRACE("button type = 0x%08x\n", type);
|
|
||||||
}
|
|
||||||
device->user_df->rgodf[i].dwType = type;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static HRESULT alloc_device(REFGUID rguid, const void *jvt, IDirectInputImpl *dinput, LPDIRECTINPUTDEVICEA* pdev)
|
static HRESULT alloc_device(REFGUID rguid, const void *jvt, IDirectInputImpl *dinput, LPDIRECTINPUTDEVICEA* pdev)
|
||||||
{
|
{
|
||||||
DWORD i;
|
DWORD i;
|
||||||
|
@ -554,8 +503,6 @@ static HRESULT alloc_device(REFGUID rguid, const void *jvt, IDirectInputImpl *di
|
||||||
/* create the default transform filter */
|
/* create the default transform filter */
|
||||||
newDevice->transform = create_DataFormat(&c_dfDIJoystick2, newDevice->user_df, newDevice->offsets);
|
newDevice->transform = create_DataFormat(&c_dfDIJoystick2, newDevice->user_df, newDevice->offsets);
|
||||||
|
|
||||||
calculate_ids(newDevice);
|
|
||||||
|
|
||||||
IDirectInputDevice_AddRef((LPDIRECTINPUTDEVICE8A)newDevice->dinput);
|
IDirectInputDevice_AddRef((LPDIRECTINPUTDEVICE8A)newDevice->dinput);
|
||||||
|
|
||||||
newDevice->devcaps.dwSize = sizeof(newDevice->devcaps);
|
newDevice->devcaps.dwSize = sizeof(newDevice->devcaps);
|
||||||
|
@ -765,8 +712,6 @@ static HRESULT WINAPI JoystickAImpl_SetDataFormat(
|
||||||
}
|
}
|
||||||
This->transform = create_DataFormat(&c_dfDIJoystick2, This->user_df, This->offsets);
|
This->transform = create_DataFormat(&c_dfDIJoystick2, This->user_df, This->offsets);
|
||||||
|
|
||||||
calculate_ids(This);
|
|
||||||
|
|
||||||
return DI_OK;
|
return DI_OK;
|
||||||
|
|
||||||
FAILED:
|
FAILED:
|
||||||
|
|
|
@ -152,7 +152,6 @@ static DWORD map_pov(int event_value, int is_x);
|
||||||
static void find_joydevs(void);
|
static void find_joydevs(void);
|
||||||
static int lxinput_to_user_offset(JoystickImpl *This, int ie_type, int ie_code);
|
static int lxinput_to_user_offset(JoystickImpl *This, int ie_type, int ie_code);
|
||||||
static int offset_to_object(JoystickImpl *This, int offset);
|
static int offset_to_object(JoystickImpl *This, int offset);
|
||||||
static void calculate_ids(LPDIDATAFORMAT df);
|
|
||||||
|
|
||||||
/* This GUID is slightly different from the linux joystick one. Take note. */
|
/* This GUID is slightly different from the linux joystick one. Take note. */
|
||||||
static const GUID DInput_Wine_Joystick_Base_GUID = { /* 9e573eda-7734-11d2-8d4a-23903fb6bdf7 */
|
static const GUID DInput_Wine_Joystick_Base_GUID = { /* 9e573eda-7734-11d2-8d4a-23903fb6bdf7 */
|
||||||
|
@ -414,7 +413,6 @@ static JoystickImpl *alloc_device(REFGUID rguid, const void *jvt, IDirectInputIm
|
||||||
|
|
||||||
/* create the default transform filter */
|
/* create the default transform filter */
|
||||||
newDevice->transform = create_DataFormat(&c_dfDIJoystick2, newDevice->df, newDevice->offsets);
|
newDevice->transform = create_DataFormat(&c_dfDIJoystick2, newDevice->df, newDevice->offsets);
|
||||||
calculate_ids(newDevice->df);
|
|
||||||
|
|
||||||
return newDevice;
|
return newDevice;
|
||||||
|
|
||||||
|
@ -577,7 +575,6 @@ static HRESULT WINAPI JoystickAImpl_SetDataFormat(
|
||||||
memcpy(This->df->rgodf,df->rgodf,df->dwNumObjs*df->dwObjSize);
|
memcpy(This->df->rgodf,df->rgodf,df->dwNumObjs*df->dwObjSize);
|
||||||
|
|
||||||
This->transform = create_DataFormat(&c_dfDIJoystick2, This->df, This->offsets);
|
This->transform = create_DataFormat(&c_dfDIJoystick2, This->df, This->offsets);
|
||||||
calculate_ids(This->df);
|
|
||||||
|
|
||||||
return DI_OK;
|
return DI_OK;
|
||||||
}
|
}
|
||||||
|
@ -798,57 +795,6 @@ static int offset_to_object(JoystickImpl *This, int offset)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void calculate_ids(LPDIDATAFORMAT df)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
int axis = 0;
|
|
||||||
int button = 0;
|
|
||||||
int pov = 0;
|
|
||||||
int axis_base;
|
|
||||||
int pov_base;
|
|
||||||
int button_base;
|
|
||||||
|
|
||||||
/* Make two passes over the format. The first counts the number
|
|
||||||
* for each type and the second sets the id */
|
|
||||||
for (i = 0; i < df->dwNumObjs; i++) {
|
|
||||||
if (DIDFT_GETTYPE(df->rgodf[i].dwType) & DIDFT_AXIS)
|
|
||||||
axis++;
|
|
||||||
else if (DIDFT_GETTYPE(df->rgodf[i].dwType) & DIDFT_POV)
|
|
||||||
pov++;
|
|
||||||
else if (DIDFT_GETTYPE(df->rgodf[i].dwType) & DIDFT_BUTTON)
|
|
||||||
button++;
|
|
||||||
}
|
|
||||||
|
|
||||||
axis_base = 0;
|
|
||||||
pov_base = axis;
|
|
||||||
button_base = axis + pov;
|
|
||||||
|
|
||||||
axis = 0;
|
|
||||||
button = 0;
|
|
||||||
pov = 0;
|
|
||||||
|
|
||||||
for (i = 0; i < df->dwNumObjs; i++) {
|
|
||||||
DWORD type = 0;
|
|
||||||
if (DIDFT_GETTYPE(df->rgodf[i].dwType) & DIDFT_AXIS) {
|
|
||||||
axis++;
|
|
||||||
type = DIDFT_GETTYPE(df->rgodf[i].dwType) |
|
|
||||||
DIDFT_MAKEINSTANCE(axis + axis_base);
|
|
||||||
TRACE("axis type = 0x%08x\n", type);
|
|
||||||
} else if (DIDFT_GETTYPE(df->rgodf[i].dwType) & DIDFT_POV) {
|
|
||||||
pov++;
|
|
||||||
type = DIDFT_GETTYPE(df->rgodf[i].dwType) |
|
|
||||||
DIDFT_MAKEINSTANCE(pov + pov_base);
|
|
||||||
TRACE("POV type = 0x%08x\n", type);
|
|
||||||
} else if (DIDFT_GETTYPE(df->rgodf[i].dwType) & DIDFT_BUTTON) {
|
|
||||||
button++;
|
|
||||||
type = DIDFT_GETTYPE(df->rgodf[i].dwType) |
|
|
||||||
DIDFT_MAKEINSTANCE(button + button_base);
|
|
||||||
TRACE("button type = 0x%08x\n", type);
|
|
||||||
}
|
|
||||||
df->rgodf[i].dwType = type;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void joy_polldev(JoystickImpl *This) {
|
static void joy_polldev(JoystickImpl *This) {
|
||||||
struct pollfd plfd;
|
struct pollfd plfd;
|
||||||
struct input_event ie;
|
struct input_event ie;
|
||||||
|
|
|
@ -366,7 +366,7 @@ static HRESULT WINAPI SysMouseAImpl_SetDataFormat(
|
||||||
memcpy(This->df->rgodf,df->rgodf,df->dwNumObjs*df->dwObjSize);
|
memcpy(This->df->rgodf,df->rgodf,df->dwNumObjs*df->dwObjSize);
|
||||||
|
|
||||||
/* Prepare all the data-conversion filters */
|
/* Prepare all the data-conversion filters */
|
||||||
This->wine_df = create_DataFormat(&(Wine_InternalMouseFormat), df, This->offset_array);
|
This->wine_df = create_DataFormat(&Wine_InternalMouseFormat, This->df, This->offset_array);
|
||||||
|
|
||||||
return DI_OK;
|
return DI_OK;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue