Skip to content

Commit a864082

Browse files
MarkOatesSiegeLord
authored andcommitted
Extract function "add_joystick_device"
1 parent 9e32448 commit a864082

File tree

1 file changed

+16
-12
lines changed

1 file changed

+16
-12
lines changed

src/macosx/hidjoy.m

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -298,16 +298,8 @@ static void osx_joy_generate_configure_event(void)
298298
_al_generate_joystick_event(&event);
299299
}
300300

301-
static void device_add_callback(
302-
void *context,
303-
IOReturn result,
304-
void *sender,
305-
IOHIDDeviceRef ref
306-
) {
307-
(void)context;
308-
(void)result;
309-
(void)sender;
310-
301+
static void add_joystick_device(IOHIDDeviceRef ref, bool emit_reconfigure_event)
302+
{
311303
al_lock_mutex(add_mutex);
312304

313305
ALLEGRO_JOYSTICK_OSX *joy = find_joystick(ref);
@@ -329,15 +321,27 @@ static void device_add_callback(
329321

330322
CFRelease(elements);
331323

332-
333324
al_unlock_mutex(add_mutex);
334325

335-
osx_joy_generate_configure_event();
326+
if (emit_reconfigure_event) osx_joy_generate_configure_event();
336327

337328
ALLEGRO_INFO("Found joystick (%d buttons, %d sticks)\n",
338329
joy->parent.info.num_buttons, joy->parent.info.num_sticks);
339330
}
340331

332+
static void device_add_callback(
333+
void *context,
334+
IOReturn result,
335+
void *sender,
336+
IOHIDDeviceRef ref
337+
) {
338+
(void)context;
339+
(void)result;
340+
(void)sender;
341+
342+
add_joystick_device(ref, true);
343+
}
344+
341345
static void device_remove_callback(
342346
void *context,
343347
IOReturn result,

0 commit comments

Comments
 (0)