More work on Gamepad support
This commit is contained in:
@@ -9,6 +9,7 @@ namespace lime {
|
||||
|
||||
public:
|
||||
|
||||
static const char* GetDeviceGUID (int id);
|
||||
static const char* GetDeviceName (int id);
|
||||
|
||||
};
|
||||
|
||||
@@ -353,6 +353,13 @@ namespace lime {
|
||||
}
|
||||
|
||||
|
||||
value lime_gamepad_get_device_guid (value id) {
|
||||
|
||||
return alloc_string (Gamepad::GetDeviceGUID (val_int (id)));
|
||||
|
||||
}
|
||||
|
||||
|
||||
value lime_gamepad_get_device_name (value id) {
|
||||
|
||||
return alloc_string (Gamepad::GetDeviceName (val_int (id)));
|
||||
@@ -734,6 +741,7 @@ namespace lime {
|
||||
DEFINE_PRIM (lime_font_render_glyphs, 3);
|
||||
DEFINE_PRIM (lime_font_set_size, 2);
|
||||
DEFINE_PRIM (lime_gamepad_event_manager_register, 2);
|
||||
DEFINE_PRIM (lime_gamepad_get_device_guid, 1);
|
||||
DEFINE_PRIM (lime_gamepad_get_device_name, 1);
|
||||
DEFINE_PRIM (lime_image_encode, 3);
|
||||
DEFINE_PRIM (lime_image_load, 1);
|
||||
|
||||
@@ -251,15 +251,11 @@ namespace lime {
|
||||
|
||||
case SDL_CONTROLLERDEVICEREMOVED: {
|
||||
|
||||
if (SDLGamepad::Disconnect (event->cdevice.which)) {
|
||||
|
||||
gamepadEvent.type = DISCONNECT;
|
||||
gamepadEvent.id = event->cdevice.which;
|
||||
|
||||
GamepadEvent::Dispatch (&gamepadEvent);
|
||||
|
||||
}
|
||||
gamepadEvent.type = DISCONNECT;
|
||||
gamepadEvent.id = event->cdevice.which;
|
||||
|
||||
GamepadEvent::Dispatch (&gamepadEvent);
|
||||
SDLGamepad::Disconnect (event->cdevice.which);
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
@@ -50,13 +50,6 @@ namespace lime {
|
||||
}
|
||||
|
||||
|
||||
const char* Gamepad::GetDeviceName (int id) {
|
||||
|
||||
return SDL_GameControllerName (gameControllers[id]);
|
||||
|
||||
}
|
||||
|
||||
|
||||
int SDLGamepad::GetInstanceID (int deviceID) {
|
||||
|
||||
return gameControllerIDs[deviceID];
|
||||
@@ -64,4 +57,20 @@ namespace lime {
|
||||
}
|
||||
|
||||
|
||||
const char* Gamepad::GetDeviceGUID (int id) {
|
||||
|
||||
char* guid = new char[64];
|
||||
SDL_JoystickGetGUIDString (SDL_JoystickGetDeviceGUID (id), guid, 64);
|
||||
return guid;
|
||||
|
||||
}
|
||||
|
||||
|
||||
const char* Gamepad::GetDeviceName (int id) {
|
||||
|
||||
return SDL_GameControllerName (gameControllers[id]);
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user