mirror of
https://github.com/libretro/RetroArch
synced 2025-03-30 16:20:27 +00:00
bluetooth: split into labels and sublabels
This commit is contained in:
parent
4f8ccb8642
commit
a24d2b50a5
@ -50,6 +50,7 @@ typedef struct bluetooth_driver
|
||||
void (*scan)(void);
|
||||
void (*get_devices)(struct string_list *list);
|
||||
bool (*device_is_connected)(unsigned i);
|
||||
void (*device_get_sublabel)(char *s, unsigned i, size_t len);
|
||||
bool (*connect_device)(unsigned i);
|
||||
|
||||
const char *ident;
|
||||
@ -79,6 +80,8 @@ void driver_bluetooth_get_devices(struct string_list *list);
|
||||
|
||||
bool driver_bluetooth_device_is_connected(unsigned i);
|
||||
|
||||
void driver_bluetooth_device_get_sublabel(char *s, unsigned i, size_t len);
|
||||
|
||||
bool driver_bluetooth_connect_device(unsigned i);
|
||||
|
||||
bool bluetooth_driver_ctl(enum rarch_bluetooth_ctl_state state, void *data);
|
||||
|
@ -93,7 +93,7 @@ static void bluetoothctl_get_devices(struct string_list* devices)
|
||||
* $ bluetoothctl devices
|
||||
* 'Device (mac address) (device name)'
|
||||
*/
|
||||
strlcpy(device, line+7, sizeof(device));
|
||||
strlcpy(device, line+24, sizeof(device));
|
||||
string_list_append(devices, device, attr);
|
||||
}
|
||||
}
|
||||
@ -190,6 +190,16 @@ static bool bluetoothctl_connect_device(unsigned idx)
|
||||
return true;
|
||||
}
|
||||
|
||||
void bluetoothctl_device_get_sublabel (char *s, unsigned i, size_t len)
|
||||
{
|
||||
/* bluetoothctl devices outputs lines of the format:
|
||||
* $ bluetoothctl devices
|
||||
* 'Device (mac address) (device name)'
|
||||
*/
|
||||
const char *line = lines->elems[i].data;
|
||||
strlcpy(s, line+7, 18);
|
||||
}
|
||||
|
||||
bluetooth_driver_t bluetooth_bluetoothctl = {
|
||||
bluetoothctl_init,
|
||||
bluetoothctl_free,
|
||||
@ -198,6 +208,7 @@ bluetooth_driver_t bluetooth_bluetoothctl = {
|
||||
bluetoothctl_scan,
|
||||
bluetoothctl_get_devices,
|
||||
bluetoothctl_device_is_connected,
|
||||
bluetoothctl_device_get_sublabel,
|
||||
bluetoothctl_connect_device,
|
||||
"bluetoothctl",
|
||||
};
|
||||
|
@ -529,7 +529,7 @@ static void bluez_get_devices (struct string_list* devices_string_list)
|
||||
for (i = 0; i < devices->count; i++)
|
||||
{
|
||||
char device[64];
|
||||
snprintf(device, 64, "%s %s", devices->data[i].address, devices->data[i].name);
|
||||
strlcpy(device, devices->data[i].name, 64);
|
||||
string_list_append(devices_string_list, device, attr);
|
||||
}
|
||||
}
|
||||
@ -553,6 +553,11 @@ static bool bluez_device_is_connected (unsigned i)
|
||||
}
|
||||
}
|
||||
|
||||
static void bluez_device_get_sublabel (char *s, unsigned i, size_t len)
|
||||
{
|
||||
strlcpy(s, devices->data[i].address, len);
|
||||
}
|
||||
|
||||
static bool bluez_connect_device (unsigned i)
|
||||
{
|
||||
bluez_dbus_connect();
|
||||
@ -582,6 +587,7 @@ bluetooth_driver_t bluetooth_bluez = {
|
||||
bluez_scan,
|
||||
bluez_get_devices,
|
||||
bluez_device_is_connected,
|
||||
bluez_device_get_sublabel,
|
||||
bluez_connect_device,
|
||||
"bluez",
|
||||
};
|
||||
|
@ -30,6 +30,7 @@
|
||||
#endif
|
||||
#include "../../core_info.h"
|
||||
#include "../../verbosity.h"
|
||||
#include "../../bluetooth/bluetooth_driver.h"
|
||||
|
||||
#ifdef HAVE_NETWORKING
|
||||
#include "../../network/netplay/netplay.h"
|
||||
@ -875,6 +876,16 @@ static int action_bind_sublabel_systeminfo_controller_entry(
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int action_bind_sublabel_bluetooth_list(
|
||||
file_list_t *list,
|
||||
unsigned type, unsigned i,
|
||||
const char *label, const char *path,
|
||||
char *s, size_t len)
|
||||
{
|
||||
driver_bluetooth_device_get_sublabel(s, i, len);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int action_bind_sublabel_cheevos_entry(
|
||||
file_list_t *list,
|
||||
unsigned type, unsigned i,
|
||||
@ -3042,6 +3053,9 @@ int menu_cbs_init_bind_sublabel(menu_file_list_cbs_t *cbs,
|
||||
case MENU_ENUM_LABEL_VIDEO_SHARED_CONTEXT:
|
||||
BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_video_shared_context);
|
||||
break;
|
||||
case MENU_ENUM_LABEL_CONNECT_BLUETOOTH:
|
||||
BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_bluetooth_list);
|
||||
break;
|
||||
case MENU_ENUM_LABEL_CHEEVOS_UNLOCKED_ENTRY:
|
||||
case MENU_ENUM_LABEL_CHEEVOS_UNLOCKED_ENTRY_HARDCORE:
|
||||
case MENU_ENUM_LABEL_CHEEVOS_LOCKED_ENTRY:
|
||||
|
@ -866,6 +866,7 @@ static bluetooth_driver_t bluetooth_null = {
|
||||
NULL, /* scan */
|
||||
NULL, /* get_devices */
|
||||
NULL, /* device_is_connected */
|
||||
NULL, /* device_get_sublabel */
|
||||
NULL, /* connect_device */
|
||||
"null",
|
||||
};
|
||||
@ -20140,6 +20141,12 @@ bool driver_bluetooth_device_is_connected(unsigned i)
|
||||
return p_rarch->bluetooth_driver->device_is_connected(i);
|
||||
}
|
||||
|
||||
void driver_bluetooth_device_get_sublabel(char *s, unsigned i, size_t len)
|
||||
{
|
||||
struct rarch_state *p_rarch = &rarch_st;
|
||||
p_rarch->bluetooth_driver->device_get_sublabel(s, i, len);
|
||||
}
|
||||
|
||||
bool driver_bluetooth_connect_device(unsigned i)
|
||||
{
|
||||
struct rarch_state *p_rarch = &rarch_st;
|
||||
|
Loading…
x
Reference in New Issue
Block a user