Skip to content

Commit 9766ddb

Browse files
committed
Add internal scaffolding for ALLEGRO_JOYSTICK_DRIVER to get device id
1 parent 9e32448 commit 9766ddb

File tree

10 files changed

+90
-6
lines changed

10 files changed

+90
-6
lines changed

include/allegro5/internal/aintern_joystick.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ typedef struct ALLEGRO_JOYSTICK_DRIVER
2424
AL_METHOD(void, get_joystick_state, (ALLEGRO_JOYSTICK *joy, ALLEGRO_JOYSTICK_STATE *ret_state));
2525
AL_METHOD(const char *, get_name, (ALLEGRO_JOYSTICK *joy));
2626
AL_METHOD(bool, get_active, (ALLEGRO_JOYSTICK *joy));
27+
AL_METHOD(int, get_device_id, (ALLEGRO_JOYSTICK *joy));
2728
} ALLEGRO_JOYSTICK_DRIVER;
2829

2930

@@ -71,6 +72,7 @@ typedef struct _AL_JOYSTICK_INFO
7172
int num_buttons;
7273
_AL_JOYSTICK_STICK_INFO stick[_AL_MAX_JOYSTICK_STICKS];
7374
_AL_JOYSTICK_BUTTON_INFO button[_AL_MAX_JOYSTICK_BUTTONS];
75+
int device_id;
7476
} _AL_JOYSTICK_INFO;
7577

7678

src/android/android_joystick.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -326,5 +326,6 @@ ALLEGRO_JOYSTICK_DRIVER _al_android_joystick_driver = {
326326
andjoy_release_joystick,
327327
andjoy_get_joystick_state,
328328
andjoy_get_name,
329-
andjoy_get_active
329+
andjoy_get_active,
330+
andjoy_get_device_id
330331
};

src/gp2xwiz/wiz_joystick.c

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,16 @@ static void joywiz_get_joystick_state(ALLEGRO_JOYSTICK *joy, ALLEGRO_JOYSTICK_ST
228228
}
229229

230230

231+
static int joywiz_get_joystick_device_id(ALLEGRO_JOYSTICK *joy)
232+
{
233+
(void)joy;
234+
// TODO: Add implementation here
235+
ALLEGRO_INFO("joywiz_get_joystick_device_id: not implemented");
236+
return 0;
237+
}
238+
239+
240+
231241

232242
/* the driver vtable */
233243
ALLEGRO_JOYSTICK_DRIVER _al_joydrv_gp2xwiz =
@@ -241,7 +251,8 @@ ALLEGRO_JOYSTICK_DRIVER _al_joydrv_gp2xwiz =
241251
joywiz_get_num_joysticks,
242252
joywiz_get_joystick,
243253
joywiz_release_joystick,
244-
joywiz_get_joystick_state
254+
joywiz_get_joystick_state,
255+
joywiz_get_joystick_device_id
245256
};
246257

247258

src/iphone/iphone_joystick.m

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,14 @@ static bool ijoy_get_active(ALLEGRO_JOYSTICK *joy)
121121
return true;
122122
}
123123

124+
static int ijoy_get_device_id(ALLEGRO_JOYSTICK *joy)
125+
{
126+
(void)joy;
127+
// TODO: Add implementation here
128+
ALLEGRO_INFO("ijoy_get_device_id: not implemented");
129+
return 0;
130+
}
131+
124132
static ALLEGRO_JOYSTICK_DRIVER iphone_joystick_driver = {
125133
AL_ID('I', 'P', 'H', 'O'),
126134
"",
@@ -134,7 +142,8 @@ static bool ijoy_get_active(ALLEGRO_JOYSTICK *joy)
134142
ijoy_release_joystick,
135143
ijoy_get_joystick_state,
136144
ijoy_get_name,
137-
ijoy_get_active
145+
ijoy_get_active,
146+
ijoy_get_device_id
138147
};
139148

140149
ALLEGRO_JOYSTICK_DRIVER *_al_get_iphone_joystick_driver(void)

src/macosx/hidjoy-10.4.m

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,15 @@ static bool get_joystick_active(ALLEGRO_JOYSTICK *joy_)
297297
return true;
298298
}
299299

300+
static int get_joystick_device_id(ALLEGRO_JOYSTICK *joy_)
301+
{
302+
(void)joy_;
303+
// TODO: Add implementation here
304+
ALLEGRO_INFO("get_joystick_device_id: not implemented");
305+
return 0;
306+
}
307+
308+
300309
static bool reconfigure_joysticks(void)
301310
{
302311
return false;
@@ -318,6 +327,7 @@ static bool reconfigure_joysticks(void)
318327
vt->reconfigure_joysticks = reconfigure_joysticks;
319328
vt->get_name = get_joystick_name;
320329
vt->get_active = get_joystick_active;
330+
vt->get_device_id = get_joystick_device_id;
321331
}
322332
return vt;
323333
}

src/macosx/hidjoy.m

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -743,6 +743,15 @@ static bool get_joystick_active(ALLEGRO_JOYSTICK *joy_)
743743
return joy->cfg_state == JOY_STATE_ALIVE || joy->cfg_state == JOY_STATE_DYING;
744744
}
745745

746+
static int get_joystick_device_id(ALLEGRO_JOYSTICK *joy_)
747+
{
748+
(void)joy_;
749+
// TODO: Add implementation here
750+
ALLEGRO_INFO("get_joystick_device_id: not implemented");
751+
return 0;
752+
}
753+
754+
746755
ALLEGRO_JOYSTICK_DRIVER* _al_osx_get_joystick_driver_10_5(void)
747756
{
748757
static ALLEGRO_JOYSTICK_DRIVER* vt = NULL;
@@ -759,6 +768,7 @@ static bool get_joystick_active(ALLEGRO_JOYSTICK *joy_)
759768
vt->get_joystick_state = get_joystick_state;
760769
vt->get_name = get_joystick_name;
761770
vt->get_active = get_joystick_active;
771+
vt->get_device_id = get_joystick_device_id;
762772
}
763773
return vt;
764774
}

src/sdl/sdl_joystick.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,14 @@ static bool sdl_get_active(ALLEGRO_JOYSTICK *joy)
183183
return SDL_JoystickGetAttached(sdl);
184184
}
185185

186+
static int sdl_get_device_id(ALLEGRO_JOYSTICK *joy)
187+
{
188+
(void)joy;
189+
// TODO: Add implementation here
190+
ALLEGRO_INFO("sdl_get_device_id: not implemented");
191+
return 0;
192+
}
193+
186194
ALLEGRO_JOYSTICK_DRIVER *_al_sdl_joystick_driver(void)
187195
{
188196
if (vt)
@@ -202,6 +210,7 @@ ALLEGRO_JOYSTICK_DRIVER *_al_sdl_joystick_driver(void)
202210
vt->get_joystick_state = sdl_get_joystick_state;;
203211
vt->get_name = sdl_get_name;
204212
vt->get_active = sdl_get_active;
213+
vt->get_device_id = sdl_get_device_id;
205214

206215
return vt;
207216
}

src/win/wjoyall.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ static void joyall_release_joystick(ALLEGRO_JOYSTICK *joy);
8383
static void joyall_get_joystick_state(ALLEGRO_JOYSTICK *joy, ALLEGRO_JOYSTICK_STATE *ret_state);
8484
static const char *joyall_get_name(ALLEGRO_JOYSTICK *joy);
8585
static bool joyall_get_active(ALLEGRO_JOYSTICK *joy);
86+
static int joyall_get_device_id(ALLEGRO_JOYSTICK *joy);
8687

8788

8889
/* the driver vtable */
@@ -100,7 +101,8 @@ ALLEGRO_JOYSTICK_DRIVER _al_joydrv_windows_all =
100101
joyall_release_joystick,
101102
joyall_get_joystick_state,
102103
joyall_get_name,
103-
joyall_get_active
104+
joyall_get_active,
105+
joyall_get_device_id
104106
};
105107

106108
/* Mutex to protect state access. XXX is this needed? */
@@ -226,5 +228,12 @@ static bool joyall_get_active(ALLEGRO_JOYSTICK *joy)
226228
return joy->driver->get_active(joy);
227229
}
228230

231+
static int joyall_get_device_id(ALLEGRO_JOYSTICK *joy)
232+
{
233+
(void)joy;
234+
// TODO: Add implementation here
235+
ALLEGRO_INFO("joyall_get_device_id: not implemented");
236+
return 0;
237+
}
229238

230239
#endif /* #ifdef ALLEGRO_CFG_XINPUT */

src/win/wjoydxnu.cpp

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ static void joydx_release_joystick(ALLEGRO_JOYSTICK *joy);
110110
static void joydx_get_joystick_state(ALLEGRO_JOYSTICK *joy, ALLEGRO_JOYSTICK_STATE *ret_state);
111111
static const char *joydx_get_name(ALLEGRO_JOYSTICK *joy);
112112
static bool joydx_get_active(ALLEGRO_JOYSTICK *joy);
113+
static int joydx_get_device_id(ALLEGRO_JOYSTICK *joy);
113114

114115
static void joydx_inactivate_joy(ALLEGRO_JOYSTICK_DIRECTX *joy);
115116

@@ -138,7 +139,8 @@ ALLEGRO_JOYSTICK_DRIVER _al_joydrv_directx =
138139
joydx_release_joystick,
139140
joydx_get_joystick_state,
140141
joydx_get_name,
141-
joydx_get_active
142+
joydx_get_active,
143+
joydx_get_device_id
142144
};
143145

144146

@@ -1390,6 +1392,16 @@ static bool joydx_get_active(ALLEGRO_JOYSTICK *joy)
13901392
}
13911393

13921394

1395+
static int joydx_get_device_id(ALLEGRO_JOYSTICK *joy)
1396+
{
1397+
(void)joy;
1398+
// TODO: Add implementation here
1399+
ALLEGRO_INFO("joydx_get_device_id: not implemented");
1400+
return 0;
1401+
}
1402+
1403+
1404+
13931405
/* joydx_thread_proc: [joystick thread]
13941406
* Thread loop function for the joystick thread.
13951407
*/

src/win/wjoyxi.c

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ static void joyxi_release_joystick(ALLEGRO_JOYSTICK *joy);
8686
static void joyxi_get_joystick_state(ALLEGRO_JOYSTICK *joy, ALLEGRO_JOYSTICK_STATE *ret_state);
8787
static const char *joyxi_get_name(ALLEGRO_JOYSTICK *joy);
8888
static bool joyxi_get_active(ALLEGRO_JOYSTICK *joy);
89+
static int joyxi_get_device_id(ALLEGRO_JOYSTICK *joy);
8990

9091

9192
/* the driver vtable */
@@ -103,7 +104,8 @@ ALLEGRO_JOYSTICK_DRIVER _al_joydrv_xinput =
103104
joyxi_release_joystick,
104105
joyxi_get_joystick_state,
105106
joyxi_get_name,
106-
joyxi_get_active
107+
joyxi_get_active,
108+
joyxi_get_device_id
107109
};
108110

109111
#define XINPUT_MIN_VERSION 3
@@ -718,4 +720,13 @@ static bool joyxi_get_active(ALLEGRO_JOYSTICK *joy)
718720
}
719721

720722

723+
static int joyxi_get_device_id(ALLEGRO_JOYSTICK *joy)
724+
{
725+
(void)joy;
726+
// TODO: Add implementation here
727+
ALLEGRO_INFO("joyxi_get_device_id: not implemented");
728+
return 0;
729+
}
730+
731+
721732
#endif /* #ifdef ALLEGRO_CFG_XINPUT */

0 commit comments

Comments
 (0)