Skip to content

Commit

Permalink
ogc: gate on_hint_accel_as_joystick_cb behind __wii__
Browse files Browse the repository at this point in the history
  • Loading branch information
WinterMute committed Jan 21, 2024
1 parent 193bcb3 commit afe5bc3
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions src/joystick/ogc/SDL_sysjoystick.c
Original file line number Diff line number Diff line change
Expand Up @@ -298,13 +298,6 @@ static void update_rumble(SDL_Joystick *joystick)
enable_rumble(joystick->hwdata->index, rumble);
}

static void SDLCALL
on_hint_accel_as_joystick_cb(void *userdata, const char *name,
const char *oldValue, const char *hint)
{
s_accelerometers_as_axes = SDL_GetStringBoolean(hint, SDL_FALSE);
}

/* Function to scan the system for joysticks.
* This function should return the number of available
* joysticks. Joystick 0 should be the system default joystick.
Expand All @@ -319,8 +312,10 @@ static int OGC_JoystickInit(void)
/* We don't call WPAD_Init() here, since it's already been called by
* SDL_main for the Wii */

#ifdef __wii__
SDL_AddHintCallback(SDL_HINT_ACCELEROMETER_AS_JOYSTICK,
on_hint_accel_as_joystick_cb, NULL);
#endif

/* Initialize the needed variables */
for (int i = 0; i < MAX_JOYSTICKS; i++) {
Expand Down Expand Up @@ -648,6 +643,14 @@ static int OGC_JoystickSetSensorsEnabled(SDL_Joystick *joystick, SDL_bool enable
}

#ifdef __wii__

static void SDLCALL
on_hint_accel_as_joystick_cb(void *userdata, const char *name,
const char *oldValue, const char *hint)
{
s_accelerometers_as_axes = SDL_GetStringBoolean(hint, SDL_FALSE);
}

static s16 WPAD_Orient(WPADData *data, int motion)
{
float out;
Expand Down Expand Up @@ -1108,8 +1111,10 @@ static void OGC_JoystickClose(SDL_Joystick *joystick)

void OGC_JoystickQuit(void)
{
#ifdef __wii__
SDL_DelHintCallback(SDL_HINT_ACCELEROMETER_AS_JOYSTICK,
on_hint_accel_as_joystick_cb, NULL);
#endif
}

static SDL_bool OGC_JoystickGetGamepadMapping(int device_index,
Expand Down

0 comments on commit afe5bc3

Please sign in to comment.