mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-10-18 15:51:44 +00:00
Removed balls from the joystick API
They were only used by one joystick decades ago, so removing them for SDL3 Fixes https://github.com/libsdl-org/SDL/issues/6766
This commit is contained in:
@@ -861,23 +861,6 @@ static int allocate_hatdata(SDL_Joystick *joystick)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int allocate_balldata(SDL_Joystick *joystick)
|
||||
{
|
||||
int i;
|
||||
|
||||
joystick->hwdata->balls =
|
||||
(struct hwdata_ball *)SDL_malloc(joystick->nballs *
|
||||
sizeof(struct hwdata_ball));
|
||||
if (joystick->hwdata->balls == NULL) {
|
||||
return -1;
|
||||
}
|
||||
for (i = 0; i < joystick->nballs; ++i) {
|
||||
joystick->hwdata->balls[i].axis[0] = 0;
|
||||
joystick->hwdata->balls[i].axis[1] = 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static SDL_bool GuessIfAxesAreDigitalHat(struct input_absinfo *absinfo_x, struct input_absinfo *absinfo_y)
|
||||
{
|
||||
/* A "hat" is assumed to be a digital input with at most 9 possible states
|
||||
@@ -1029,9 +1012,6 @@ static void ConfigJoystick(SDL_Joystick *joystick, int fd)
|
||||
++joystick->naxes;
|
||||
}
|
||||
}
|
||||
if (test_bit(REL_X, relbit) || test_bit(REL_Y, relbit)) {
|
||||
++joystick->nballs;
|
||||
}
|
||||
|
||||
} else if ((ioctl(fd, JSIOCGBUTTONS, &key_pam_size, sizeof(key_pam_size)) >= 0) &&
|
||||
(ioctl(fd, JSIOCGAXES, &abs_pam_size, sizeof(abs_pam_size)) >= 0)) {
|
||||
@@ -1105,11 +1085,6 @@ static void ConfigJoystick(SDL_Joystick *joystick, int fd)
|
||||
joystick->nhats = 0;
|
||||
}
|
||||
}
|
||||
if (joystick->nballs > 0) {
|
||||
if (allocate_balldata(joystick) < 0) {
|
||||
joystick->nballs = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (ioctl(fd, EVIOCGBIT(EV_FF, sizeof(ffbit)), ffbit) >= 0) {
|
||||
if (test_bit(FF_RUMBLE, ffbit)) {
|
||||
@@ -1320,11 +1295,6 @@ static void HandleHat(Uint64 timestamp, SDL_Joystick *stick, int hatidx, int axi
|
||||
}
|
||||
}
|
||||
|
||||
static void HandleBall(SDL_Joystick *stick, Uint8 ball, int axis, int value)
|
||||
{
|
||||
stick->hwdata->balls[ball].axis[axis] += value;
|
||||
}
|
||||
|
||||
static int AxisCorrect(SDL_Joystick *joystick, int which, int value)
|
||||
{
|
||||
struct axis_correct *correct;
|
||||
@@ -1411,8 +1381,6 @@ static void PollAllValues(Uint64 timestamp, SDL_Joystick *joystick)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Joyballs are relative input, so there's no poll state. Events only! */
|
||||
}
|
||||
|
||||
static void HandleInputEvents(SDL_Joystick *joystick)
|
||||
@@ -1468,17 +1436,6 @@ static void HandleInputEvents(SDL_Joystick *joystick)
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case EV_REL:
|
||||
switch (code) {
|
||||
case REL_X:
|
||||
case REL_Y:
|
||||
code -= REL_X;
|
||||
HandleBall(joystick, code / 2, code % 2, event->value);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case EV_SYN:
|
||||
switch (code) {
|
||||
case SYN_DROPPED:
|
||||
@@ -1554,8 +1511,6 @@ static void HandleClassicEvents(SDL_Joystick *joystick)
|
||||
|
||||
static void LINUX_JoystickUpdate(SDL_Joystick *joystick)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (joystick->hwdata->m_bSteamController) {
|
||||
SDL_UpdateSteamController(joystick);
|
||||
return;
|
||||
@@ -1566,19 +1521,6 @@ static void LINUX_JoystickUpdate(SDL_Joystick *joystick)
|
||||
} else {
|
||||
HandleInputEvents(joystick);
|
||||
}
|
||||
|
||||
/* Deliver ball motion updates */
|
||||
for (i = 0; i < joystick->nballs; ++i) {
|
||||
int xrel, yrel;
|
||||
|
||||
xrel = joystick->hwdata->balls[i].axis[0];
|
||||
yrel = joystick->hwdata->balls[i].axis[1];
|
||||
if (xrel || yrel) {
|
||||
joystick->hwdata->balls[i].axis[0] = 0;
|
||||
joystick->hwdata->balls[i].axis[1] = 0;
|
||||
SDL_PrivateJoystickBall(0, joystick, (Uint8)i, xrel, yrel);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Function to close a joystick after use */
|
||||
@@ -1598,7 +1540,6 @@ static void LINUX_JoystickClose(SDL_Joystick *joystick)
|
||||
SDL_free(joystick->hwdata->key_pam);
|
||||
SDL_free(joystick->hwdata->abs_pam);
|
||||
SDL_free(joystick->hwdata->hats);
|
||||
SDL_free(joystick->hwdata->balls);
|
||||
SDL_free(joystick->hwdata->fname);
|
||||
SDL_free(joystick->hwdata);
|
||||
}
|
||||
|
Reference in New Issue
Block a user