diff --git a/docs/src/refman/joystick.txt b/docs/src/refman/joystick.txt index 2a0398a456..a76f9585ab 100644 --- a/docs/src/refman/joystick.txt +++ b/docs/src/refman/joystick.txt @@ -131,6 +131,10 @@ handles may become inactive, and vice versa. See also: [al_reconfigure_joysticks] +## API: al_get_joystick_device_id + +Return the device id of the given joystick. + ## API: al_get_joystick_name Return the name of the given joystick. diff --git a/include/allegro5/internal/aintern_joystick.h b/include/allegro5/internal/aintern_joystick.h index ef313150ee..eca892261b 100644 --- a/include/allegro5/internal/aintern_joystick.h +++ b/include/allegro5/internal/aintern_joystick.h @@ -24,6 +24,7 @@ typedef struct ALLEGRO_JOYSTICK_DRIVER AL_METHOD(void, get_joystick_state, (ALLEGRO_JOYSTICK *joy, ALLEGRO_JOYSTICK_STATE *ret_state)); AL_METHOD(const char *, get_name, (ALLEGRO_JOYSTICK *joy)); AL_METHOD(bool, get_active, (ALLEGRO_JOYSTICK *joy)); + AL_METHOD(int, get_device_id, (ALLEGRO_JOYSTICK *joy)); } ALLEGRO_JOYSTICK_DRIVER; @@ -71,6 +72,7 @@ typedef struct _AL_JOYSTICK_INFO int num_buttons; _AL_JOYSTICK_STICK_INFO stick[_AL_MAX_JOYSTICK_STICKS]; _AL_JOYSTICK_BUTTON_INFO button[_AL_MAX_JOYSTICK_BUTTONS]; + int device_id; } _AL_JOYSTICK_INFO; diff --git a/include/allegro5/joystick.h b/include/allegro5/joystick.h index 4b3e648b98..a22ce83066 100644 --- a/include/allegro5/joystick.h +++ b/include/allegro5/joystick.h @@ -81,6 +81,7 @@ AL_FUNC(int, al_get_joystick_num_buttons, (ALLEGRO_JOYSTICK *)); AL_FUNC(const char*, al_get_joystick_button_name, (ALLEGRO_JOYSTICK *, int buttonn)); AL_FUNC(void, al_get_joystick_state, (ALLEGRO_JOYSTICK *, ALLEGRO_JOYSTICK_STATE *ret_state)); +AL_FUNC(int, al_get_joystick_device_id, (ALLEGRO_JOYSTICK *)); AL_FUNC(ALLEGRO_EVENT_SOURCE *, al_get_joystick_event_source, (void)); diff --git a/src/android/android_joystick.c b/src/android/android_joystick.c index 05c10b9a17..54a52781f0 100644 --- a/src/android/android_joystick.c +++ b/src/android/android_joystick.c @@ -326,5 +326,6 @@ ALLEGRO_JOYSTICK_DRIVER _al_android_joystick_driver = { andjoy_release_joystick, andjoy_get_joystick_state, andjoy_get_name, - andjoy_get_active + andjoy_get_active, + andjoy_get_device_id }; diff --git a/src/gp2xwiz/wiz_joystick.c b/src/gp2xwiz/wiz_joystick.c index 6688359d74..b510df801a 100644 --- a/src/gp2xwiz/wiz_joystick.c +++ b/src/gp2xwiz/wiz_joystick.c @@ -228,6 +228,16 @@ static void joywiz_get_joystick_state(ALLEGRO_JOYSTICK *joy, ALLEGRO_JOYSTICK_ST } +static int joywiz_get_joystick_device_id(ALLEGRO_JOYSTICK *joy) +{ + (void)joy; + // TODO: Add implementation here + ALLEGRO_INFO("joywiz_get_joystick_device_id: not implemented"); + return 0; +} + + + /* the driver vtable */ ALLEGRO_JOYSTICK_DRIVER _al_joydrv_gp2xwiz = @@ -241,7 +251,8 @@ ALLEGRO_JOYSTICK_DRIVER _al_joydrv_gp2xwiz = joywiz_get_num_joysticks, joywiz_get_joystick, joywiz_release_joystick, - joywiz_get_joystick_state + joywiz_get_joystick_state, + joywiz_get_joystick_device_id }; diff --git a/src/iphone/iphone_joystick.m b/src/iphone/iphone_joystick.m index 2f142849e6..bc9fae81c1 100644 --- a/src/iphone/iphone_joystick.m +++ b/src/iphone/iphone_joystick.m @@ -121,6 +121,14 @@ static bool ijoy_get_active(ALLEGRO_JOYSTICK *joy) return true; } +static int ijoy_get_device_id(ALLEGRO_JOYSTICK *joy) +{ + (void)joy; + // TODO: Add implementation here + ALLEGRO_INFO("ijoy_get_device_id: not implemented"); + return 0; +} + static ALLEGRO_JOYSTICK_DRIVER iphone_joystick_driver = { AL_ID('I', 'P', 'H', 'O'), "", @@ -134,7 +142,8 @@ static bool ijoy_get_active(ALLEGRO_JOYSTICK *joy) ijoy_release_joystick, ijoy_get_joystick_state, ijoy_get_name, - ijoy_get_active + ijoy_get_active, + ijoy_get_device_id }; ALLEGRO_JOYSTICK_DRIVER *_al_get_iphone_joystick_driver(void) diff --git a/src/joynu.c b/src/joynu.c index ef3ced8dbc..58625df4f3 100644 --- a/src/joynu.c +++ b/src/joynu.c @@ -300,6 +300,19 @@ void al_get_joystick_state(ALLEGRO_JOYSTICK *joy, ALLEGRO_JOYSTICK_STATE *ret_st new_joystick_driver->get_joystick_state(joy, ret_state); } + + +/* Function: al_get_joystick_device_id + */ +int al_get_joystick_device_id(ALLEGRO_JOYSTICK *joy) +{ + ASSERT(new_joystick_driver); + + return new_joystick_driver->get_device_id(joy); +} + + + /* * Local Variables: * c-basic-offset: 3 diff --git a/src/macosx/hidjoy-10.4.m b/src/macosx/hidjoy-10.4.m index 55a419ac9b..2067756929 100644 --- a/src/macosx/hidjoy-10.4.m +++ b/src/macosx/hidjoy-10.4.m @@ -297,6 +297,15 @@ static bool get_joystick_active(ALLEGRO_JOYSTICK *joy_) return true; } +static int get_joystick_device_id(ALLEGRO_JOYSTICK *joy_) +{ + (void)joy_; + // TODO: Add implementation here + ALLEGRO_INFO("get_joystick_device_id: not implemented"); + return 0; +} + + static bool reconfigure_joysticks(void) { return false; @@ -318,6 +327,7 @@ static bool reconfigure_joysticks(void) vt->reconfigure_joysticks = reconfigure_joysticks; vt->get_name = get_joystick_name; vt->get_active = get_joystick_active; + vt->get_device_id = get_joystick_device_id; } return vt; } diff --git a/src/macosx/hidjoy.m b/src/macosx/hidjoy.m index 5108b766a8..8aad2e6d5e 100644 --- a/src/macosx/hidjoy.m +++ b/src/macosx/hidjoy.m @@ -743,6 +743,15 @@ static bool get_joystick_active(ALLEGRO_JOYSTICK *joy_) return joy->cfg_state == JOY_STATE_ALIVE || joy->cfg_state == JOY_STATE_DYING; } +static int get_joystick_device_id(ALLEGRO_JOYSTICK *joy_) +{ + (void)joy_; + // TODO: Add implementation here + ALLEGRO_INFO("get_joystick_device_id: not implemented"); + return 0; +} + + ALLEGRO_JOYSTICK_DRIVER* _al_osx_get_joystick_driver_10_5(void) { static ALLEGRO_JOYSTICK_DRIVER* vt = NULL; @@ -759,6 +768,7 @@ static bool get_joystick_active(ALLEGRO_JOYSTICK *joy_) vt->get_joystick_state = get_joystick_state; vt->get_name = get_joystick_name; vt->get_active = get_joystick_active; + vt->get_device_id = get_joystick_device_id; } return vt; } diff --git a/src/sdl/sdl_joystick.c b/src/sdl/sdl_joystick.c index 492292d4c9..3a87c59fac 100644 --- a/src/sdl/sdl_joystick.c +++ b/src/sdl/sdl_joystick.c @@ -183,6 +183,14 @@ static bool sdl_get_active(ALLEGRO_JOYSTICK *joy) return SDL_JoystickGetAttached(sdl); } +static int sdl_get_device_id(ALLEGRO_JOYSTICK *joy) +{ + (void)joy; + // TODO: Add implementation here + ALLEGRO_INFO("sdl_get_device_id: not implemented"); + return 0; +} + ALLEGRO_JOYSTICK_DRIVER *_al_sdl_joystick_driver(void) { if (vt) @@ -202,6 +210,7 @@ ALLEGRO_JOYSTICK_DRIVER *_al_sdl_joystick_driver(void) vt->get_joystick_state = sdl_get_joystick_state;; vt->get_name = sdl_get_name; vt->get_active = sdl_get_active; + vt->get_device_id = sdl_get_device_id; return vt; } diff --git a/src/win/wjoyall.c b/src/win/wjoyall.c index 8475d99f0b..4b5297b8a5 100644 --- a/src/win/wjoyall.c +++ b/src/win/wjoyall.c @@ -83,6 +83,7 @@ static void joyall_release_joystick(ALLEGRO_JOYSTICK *joy); static void joyall_get_joystick_state(ALLEGRO_JOYSTICK *joy, ALLEGRO_JOYSTICK_STATE *ret_state); static const char *joyall_get_name(ALLEGRO_JOYSTICK *joy); static bool joyall_get_active(ALLEGRO_JOYSTICK *joy); +static int joyall_get_device_id(ALLEGRO_JOYSTICK *joy); /* the driver vtable */ @@ -100,7 +101,8 @@ ALLEGRO_JOYSTICK_DRIVER _al_joydrv_windows_all = joyall_release_joystick, joyall_get_joystick_state, joyall_get_name, - joyall_get_active + joyall_get_active, + joyall_get_device_id }; /* Mutex to protect state access. XXX is this needed? */ @@ -226,5 +228,12 @@ static bool joyall_get_active(ALLEGRO_JOYSTICK *joy) return joy->driver->get_active(joy); } +static int joyall_get_device_id(ALLEGRO_JOYSTICK *joy) +{ + (void)joy; + // TODO: Add implementation here + ALLEGRO_INFO("joyall_get_device_id: not implemented"); + return 0; +} #endif /* #ifdef ALLEGRO_CFG_XINPUT */ diff --git a/src/win/wjoydxnu.cpp b/src/win/wjoydxnu.cpp index c13c050a47..bcd17ead3a 100644 --- a/src/win/wjoydxnu.cpp +++ b/src/win/wjoydxnu.cpp @@ -110,6 +110,7 @@ static void joydx_release_joystick(ALLEGRO_JOYSTICK *joy); static void joydx_get_joystick_state(ALLEGRO_JOYSTICK *joy, ALLEGRO_JOYSTICK_STATE *ret_state); static const char *joydx_get_name(ALLEGRO_JOYSTICK *joy); static bool joydx_get_active(ALLEGRO_JOYSTICK *joy); +static int joydx_get_device_id(ALLEGRO_JOYSTICK *joy); static void joydx_inactivate_joy(ALLEGRO_JOYSTICK_DIRECTX *joy); @@ -138,7 +139,8 @@ ALLEGRO_JOYSTICK_DRIVER _al_joydrv_directx = joydx_release_joystick, joydx_get_joystick_state, joydx_get_name, - joydx_get_active + joydx_get_active, + joydx_get_device_id }; @@ -1390,6 +1392,16 @@ static bool joydx_get_active(ALLEGRO_JOYSTICK *joy) } +static int joydx_get_device_id(ALLEGRO_JOYSTICK *joy) +{ + (void)joy; + // TODO: Add implementation here + ALLEGRO_INFO("joydx_get_device_id: not implemented"); + return 0; +} + + + /* joydx_thread_proc: [joystick thread] * Thread loop function for the joystick thread. */ diff --git a/src/win/wjoyxi.c b/src/win/wjoyxi.c index 1dc49d1350..2ff9ca8160 100644 --- a/src/win/wjoyxi.c +++ b/src/win/wjoyxi.c @@ -86,6 +86,7 @@ static void joyxi_release_joystick(ALLEGRO_JOYSTICK *joy); static void joyxi_get_joystick_state(ALLEGRO_JOYSTICK *joy, ALLEGRO_JOYSTICK_STATE *ret_state); static const char *joyxi_get_name(ALLEGRO_JOYSTICK *joy); static bool joyxi_get_active(ALLEGRO_JOYSTICK *joy); +static int joyxi_get_device_id(ALLEGRO_JOYSTICK *joy); /* the driver vtable */ @@ -103,7 +104,8 @@ ALLEGRO_JOYSTICK_DRIVER _al_joydrv_xinput = joyxi_release_joystick, joyxi_get_joystick_state, joyxi_get_name, - joyxi_get_active + joyxi_get_active, + joyxi_get_device_id }; #define XINPUT_MIN_VERSION 3 @@ -718,4 +720,13 @@ static bool joyxi_get_active(ALLEGRO_JOYSTICK *joy) } +static int joyxi_get_device_id(ALLEGRO_JOYSTICK *joy) +{ + (void)joy; + // TODO: Add implementation here + ALLEGRO_INFO("joyxi_get_device_id: not implemented"); + return 0; +} + + #endif /* #ifdef ALLEGRO_CFG_XINPUT */