|
@@ -60,10 +60,6 @@ VIRTUAL_FreeHWData(joystick_hwdata *hwdata)
|
|
SDL_free((void *)hwdata->axes);
|
|
SDL_free((void *)hwdata->axes);
|
|
hwdata->axes = NULL;
|
|
hwdata->axes = NULL;
|
|
}
|
|
}
|
|
- if (hwdata->balls) {
|
|
|
|
- SDL_free((void *)hwdata->balls);
|
|
|
|
- hwdata->balls = NULL;
|
|
|
|
- }
|
|
|
|
if (hwdata->buttons) {
|
|
if (hwdata->buttons) {
|
|
SDL_free((void *)hwdata->buttons);
|
|
SDL_free((void *)hwdata->buttons);
|
|
hwdata->buttons = NULL;
|
|
hwdata->buttons = NULL;
|
|
@@ -94,7 +90,6 @@ VIRTUAL_FreeHWData(joystick_hwdata *hwdata)
|
|
int
|
|
int
|
|
SDL_JoystickAttachVirtualInner(SDL_JoystickType type,
|
|
SDL_JoystickAttachVirtualInner(SDL_JoystickType type,
|
|
int naxes,
|
|
int naxes,
|
|
- int nballs,
|
|
|
|
int nbuttons,
|
|
int nbuttons,
|
|
int nhats)
|
|
int nhats)
|
|
{
|
|
{
|
|
@@ -108,7 +103,6 @@ SDL_JoystickAttachVirtualInner(SDL_JoystickType type,
|
|
}
|
|
}
|
|
|
|
|
|
hwdata->naxes = naxes;
|
|
hwdata->naxes = naxes;
|
|
- hwdata->nballs = nballs;
|
|
|
|
hwdata->nbuttons = nbuttons;
|
|
hwdata->nbuttons = nbuttons;
|
|
hwdata->nhats = nhats;
|
|
hwdata->nhats = nhats;
|
|
hwdata->name = "Virtual Joystick";
|
|
hwdata->name = "Virtual Joystick";
|
|
@@ -125,13 +119,6 @@ SDL_JoystickAttachVirtualInner(SDL_JoystickType type,
|
|
return SDL_OutOfMemory();
|
|
return SDL_OutOfMemory();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- if (nballs > 0) {
|
|
|
|
- hwdata->balls = SDL_calloc(nballs, sizeof(hwdata->balls[0]));
|
|
|
|
- if (!hwdata->balls) {
|
|
|
|
- VIRTUAL_FreeHWData(hwdata);
|
|
|
|
- return SDL_OutOfMemory();
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
if (nbuttons > 0) {
|
|
if (nbuttons > 0) {
|
|
hwdata->buttons = SDL_calloc(nbuttons, sizeof(Uint8));
|
|
hwdata->buttons = SDL_calloc(nbuttons, sizeof(Uint8));
|
|
if (!hwdata->buttons) {
|
|
if (!hwdata->buttons) {
|
|
@@ -201,32 +188,6 @@ SDL_JoystickSetVirtualAxisInner(SDL_Joystick * joystick, int axis, Sint16 value)
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
-int
|
|
|
|
-SDL_JoystickSetVirtualBallInner(SDL_Joystick * joystick, int ball, Sint16 xrel, Sint16 yrel)
|
|
|
|
-{
|
|
|
|
- joystick_hwdata *hwdata;
|
|
|
|
-
|
|
|
|
- SDL_LockJoysticks();
|
|
|
|
-
|
|
|
|
- if (!joystick || !joystick->hwdata) {
|
|
|
|
- SDL_UnlockJoysticks();
|
|
|
|
- return SDL_SetError("Invalid joystick");
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- hwdata = (joystick_hwdata *)joystick->hwdata;
|
|
|
|
- if (ball < 0 || ball >= hwdata->nbuttons) {
|
|
|
|
- SDL_UnlockJoysticks();
|
|
|
|
- return SDL_SetError("Invalid ball index");
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- hwdata->balls[ball].xrel = xrel;
|
|
|
|
- hwdata->balls[ball].yrel = yrel;
|
|
|
|
-
|
|
|
|
- SDL_UnlockJoysticks();
|
|
|
|
- return 0;
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-
|
|
|
|
int
|
|
int
|
|
SDL_JoystickSetVirtualButtonInner(SDL_Joystick * joystick, int button, Uint8 value)
|
|
SDL_JoystickSetVirtualButtonInner(SDL_Joystick * joystick, int button, Uint8 value)
|
|
{
|
|
{
|
|
@@ -364,7 +325,6 @@ VIRTUAL_JoystickOpen(SDL_Joystick * joystick, int device_index)
|
|
joystick->instance_id = hwdata->instance_id;
|
|
joystick->instance_id = hwdata->instance_id;
|
|
joystick->hwdata = hwdata;
|
|
joystick->hwdata = hwdata;
|
|
joystick->naxes = hwdata->naxes;
|
|
joystick->naxes = hwdata->naxes;
|
|
- joystick->nballs = hwdata->nballs;
|
|
|
|
joystick->nbuttons = hwdata->nbuttons;
|
|
joystick->nbuttons = hwdata->nbuttons;
|
|
joystick->nhats = hwdata->nhats;
|
|
joystick->nhats = hwdata->nhats;
|
|
hwdata->opened = SDL_TRUE;
|
|
hwdata->opened = SDL_TRUE;
|
|
@@ -396,9 +356,6 @@ VIRTUAL_JoystickUpdate(SDL_Joystick * joystick)
|
|
for (int i = 0; i < hwdata->naxes; ++i) {
|
|
for (int i = 0; i < hwdata->naxes; ++i) {
|
|
SDL_PrivateJoystickAxis(joystick, i, hwdata->axes[i]);
|
|
SDL_PrivateJoystickAxis(joystick, i, hwdata->axes[i]);
|
|
}
|
|
}
|
|
- for (int i = 0; i < hwdata->nballs; ++i) {
|
|
|
|
- SDL_PrivateJoystickBall(joystick, i, hwdata->balls[i].xrel, hwdata->balls[i].yrel);
|
|
|
|
- }
|
|
|
|
for (int i = 0; i < hwdata->nbuttons; ++i) {
|
|
for (int i = 0; i < hwdata->nbuttons; ++i) {
|
|
SDL_PrivateJoystickButton(joystick, i, hwdata->buttons[i]);
|
|
SDL_PrivateJoystickButton(joystick, i, hwdata->buttons[i]);
|
|
}
|
|
}
|