mirror of
https://github.com/kichikuou/xsystem35-sdl2.git
synced 2026-10-12 00:58:27 +03:00
Handle SDL_JOYDEVICEADDED event
This commit is contained in:
@@ -204,6 +204,9 @@ static void sdl_getEvent(void) {
|
||||
mousey = e.tfinger.y * view_h;
|
||||
break;
|
||||
|
||||
case SDL_JOYDEVICEADDED:
|
||||
sdl_joy_open(e.jdevice.which);
|
||||
break;
|
||||
|
||||
case SDL_JOYAXISMOTION:
|
||||
if (abs(e.jaxis.value) < 0x4000) {
|
||||
|
||||
+4
-3
@@ -55,9 +55,10 @@ struct sdl_private_data {
|
||||
boolean (*custom_event_handler)(const SDL_Event *);
|
||||
};
|
||||
|
||||
extern void sdl_cursor_init(void);
|
||||
extern void sdl_shadow_init(void);
|
||||
extern int sdl_nearest_color(int r, int g, int b);
|
||||
void sdl_cursor_init(void);
|
||||
void sdl_shadow_init(void);
|
||||
int sdl_nearest_color(int r, int g, int b);
|
||||
boolean sdl_joy_open(int index);
|
||||
|
||||
extern struct sdl_private_data *sdl_videodev;
|
||||
|
||||
|
||||
+12
-10
@@ -45,7 +45,10 @@ static boolean integer_scaling = FALSE;
|
||||
|
||||
static SDL_Joystick *js;
|
||||
|
||||
static boolean joy_open_index(int index) {
|
||||
boolean sdl_joy_open(int index) {
|
||||
if (js)
|
||||
return FALSE;
|
||||
|
||||
js = SDL_JoystickOpen(index);
|
||||
if (!js)
|
||||
return FALSE;
|
||||
@@ -58,16 +61,15 @@ static boolean joy_open_index(int index) {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static int joy_open(void) {
|
||||
if (joy_device_index >= 0) {
|
||||
return joy_open_index(joy_device_index) ? 1 : -1;
|
||||
} else {
|
||||
for (int i = 0; i < SDL_NumJoysticks(); i++) {
|
||||
if (joy_open_index(i))
|
||||
return 1;
|
||||
}
|
||||
static boolean joy_open(void) {
|
||||
if (joy_device_index >= 0)
|
||||
return sdl_joy_open(joy_device_index);
|
||||
|
||||
for (int i = 0; i < SDL_NumJoysticks(); i++) {
|
||||
if (sdl_joy_open(i))
|
||||
return TRUE;
|
||||
}
|
||||
return -1;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* SDL の初期化 */
|
||||
|
||||
Reference in New Issue
Block a user