Add bluetoothctl bluetooth driver

This commit is contained in:
parport0 2020-06-17 14:56:44 +03:00
parent 8486c8ebfb
commit 23c08ad9b0
29 changed files with 900 additions and 32 deletions

View file

@ -567,6 +567,10 @@ ifeq ($(HAVE_EMSCRIPTEN), 1)
camera/drivers/rwebcam.o
endif
ifeq ($(HAVE_BLUETOOTH), 1)
OBJ += bluetooth/drivers/bluetoothctl.o
endif
ifeq ($(HAVE_LAKKA), 1)
OBJ += wifi/drivers/connmanctl.o
endif
@ -809,6 +813,10 @@ ifeq ($(HAVE_MENU), 1)
endif
endif
ifeq ($(HAVE_BLUETOOTH), 1)
DEFINES += -DHAVE_BLUETOOTH
endif
ifeq ($(HAVE_LAKKA), 1)
DEFINES += -DHAVE_LAKKA
endif
@ -1793,6 +1801,7 @@ ifeq ($(HAVE_NETWORKING), 1)
tasks/task_http.o \
tasks/task_netplay_lan_scan.o \
tasks/task_netplay_nat_traversal.o \
tasks/task_bluetooth.o \
tasks/task_wifi.o \
tasks/task_pl_thumbnail_download.o \
tasks/task_netplay_find_content.o

View file

@ -0,0 +1,87 @@
/* RetroArch - A frontend for libretro.
*
* RetroArch is free software: you can redistribute it and/or modify it under the terms
* of the GNU General Public License as published by the Free Software Found-
* ation, either version 3 of the License, or (at your option) any later version.
*
* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with RetroArch.
* If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __BLUETOOTH_DRIVER__H
#define __BLUETOOTH_DRIVER__H
#include <stdint.h>
#include <boolean.h>
#include <retro_common_api.h>
#include <lists/string_list.h>
RETRO_BEGIN_DECLS
enum rarch_bluetooth_ctl_state
{
RARCH_BLUETOOTH_CTL_NONE = 0,
RARCH_BLUETOOTH_CTL_DESTROY,
RARCH_BLUETOOTH_CTL_DEINIT,
RARCH_BLUETOOTH_CTL_SET_ACTIVE,
RARCH_BLUETOOTH_CTL_UNSET_ACTIVE,
RARCH_BLUETOOTH_CTL_IS_ACTIVE,
RARCH_BLUETOOTH_CTL_FIND_DRIVER,
RARCH_BLUETOOTH_CTL_SET_CB,
RARCH_BLUETOOTH_CTL_STOP,
RARCH_BLUETOOTH_CTL_START,
RARCH_BLUETOOTH_CTL_INIT
};
typedef struct bluetooth_driver
{
void *(*init)(void);
void (*free)(void *data);
bool (*start)(void *data);
void (*stop)(void *data);
void (*scan)(void);
void (*get_devices)(struct string_list *list);
bool (*device_is_connected)(unsigned i);
bool (*connect_device)(unsigned i);
const char *ident;
} bluetooth_driver_t;
extern bluetooth_driver_t bluetooth_bluetoothctl;
/**
* config_get_bluetooth_driver_options:
*
* Get an enumerated list of all bluetooth driver names,
* separated by '|'.
*
* Returns: string listing of all bluetooth driver names,
* separated by '|'.
**/
const char* config_get_bluetooth_driver_options(void);
void driver_bluetooth_stop(void);
bool driver_bluetooth_start(void);
void driver_bluetooth_scan(void);
void driver_bluetooth_get_devices(struct string_list *list);
bool driver_bluetooth_device_is_connected(unsigned i);
bool driver_bluetooth_connect_device(unsigned i);
bool bluetooth_driver_ctl(enum rarch_bluetooth_ctl_state state, void *data);
RETRO_END_DECLS
#endif

View file

@ -0,0 +1,203 @@
/* RetroArch - A frontend for libretro.
*
* RetroArch is free software: you can redistribute it and/or modify it under the terms
* of the GNU General Public License as published by the Free Software Found-
* ation, either version 3 of the License, or (at your option) any later version.
*
* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with RetroArch.
* If not, see <http://www.gnu.org/licenses/>.
*/
#include <compat/strl.h>
#include <configuration.h>
#include "../bluetooth_driver.h"
#include "../../retroarch.h"
static bool bluetoothctl_cache[256] = {0};
static unsigned bluetoothctl_counter[256] = {0};
static struct string_list* lines = NULL;
static char command[256] = {0};
static void *bluetoothctl_init(void)
{
return (void*)-1;
}
static void bluetoothctl_free(void *data)
{
(void)data;
}
static bool bluetoothctl_start(void *data)
{
(void)data;
return true;
}
static void bluetoothctl_stop(void *data)
{
(void)data;
}
static void bluetoothctl_scan(void)
{
char line[512];
union string_list_elem_attr attr;
FILE *dev_file = NULL;
attr.i = 0;
if (lines)
free(lines);
lines = string_list_new();
pclose(popen("bluetoothctl -- power on", "r"));
pclose(popen("bluetoothctl --timeout 15 scan on", "r"));
runloop_msg_queue_push(msg_hash_to_str(MSG_BLUETOOTH_SCAN_COMPLETE),
1, 180, true, NULL, MESSAGE_QUEUE_ICON_DEFAULT,
MESSAGE_QUEUE_CATEGORY_INFO);
dev_file = popen("bluetoothctl -- devices", "r");
while (fgets(line, 512, dev_file))
{
size_t len = strlen(line);
if (len > 0 && line[len-1] == '\n')
line[--len] = '\0';
string_list_append(lines, line, attr);
}
pclose(dev_file);
}
static void bluetoothctl_get_devices(struct string_list* devices)
{
unsigned i;
union string_list_elem_attr attr;
attr.i = 0;
if (!lines)
return;
for (i = 0; i < lines->size; i++)
{
char device[64];
const char *line = lines->elems[i].data;
/* bluetoothctl devices outputs lines of the format:
* $ bluetoothctl devices
* 'Device (mac address) (device name)'
*/
strlcpy(device, line+7, sizeof(device));
string_list_append(devices, device, attr);
}
}
static bool bluetoothctl_device_is_connected(unsigned i)
{
char ln[512] = {0};
char device[18] = {0};
const char *line = lines->elems[i].data;
FILE *command_file = NULL;
if (bluetoothctl_counter[i] == 60)
{
static struct string_list* list = NULL;
bluetoothctl_counter[i] = 0;
list = string_split(line, " ");
if (!list)
return false;
if (list->size == 0)
{
string_list_free(list);
return false;
}
strlcpy(device, list->elems[1].data, sizeof(device));
string_list_free(list);
snprintf(command, sizeof(command), "\
bluetoothctl -- info %s | grep 'Connected: yes'",
device);
command_file = popen(command, "r");
while (fgets(ln, 512, command_file))
{
bluetoothctl_cache[i] = true;
return true;
}
pclose(command_file);
bluetoothctl_cache[i] = false;
}
else
{
bluetoothctl_counter[i]++;
return bluetoothctl_cache[i];
}
return false;
}
static bool bluetoothctl_connect_device(unsigned idx)
{
unsigned i;
char device[18] = {0};
const char *line = lines->elems[idx].data;
static struct string_list* list = NULL;
/* bluetoothctl devices outputs lines of the format:
* $ bluetoothctl devices
* 'Device (mac address) (device name)'
*/
list = string_split(line, " ");
if (!list)
return false;
if (list->size == 0)
{
string_list_free(list);
return false;
}
strlcpy(device, list->elems[1].data, sizeof(device));
string_list_free(list);
snprintf(command, sizeof(command), "\
bluetoothctl -- trust %s",
device);
pclose(popen(command, "r"));
snprintf(command, sizeof(command), "\
bluetoothctl -- pair %s",
device);
pclose(popen(command, "r"));
snprintf(command, sizeof(command), "\
bluetoothctl -- connect %s",
device);
pclose(popen(command, "r"));
bluetoothctl_counter[idx] = 0;
return true;
}
bluetooth_driver_t bluetooth_bluetoothctl = {
bluetoothctl_init,
bluetoothctl_free,
bluetoothctl_start,
bluetoothctl_stop,
bluetoothctl_scan,
bluetoothctl_get_devices,
bluetoothctl_device_is_connected,
bluetoothctl_connect_device,
"bluetoothctl",
};

View file

@ -271,9 +271,15 @@ enum camera_driver_enum
CAMERA_NULL
};
enum bluetooth_driver_enum
{
BLUETOOTH_BLUETOOTHCTL = CAMERA_NULL + 1,
BLUETOOTH_NULL
};
enum wifi_driver_enum
{
WIFI_CONNMANCTL = CAMERA_NULL + 1,
WIFI_CONNMANCTL = BLUETOOTH_NULL + 1,
WIFI_NULL
};
@ -559,6 +565,12 @@ static const enum camera_driver_enum CAMERA_DEFAULT_DRIVER = CAMERA_ANDROID;
static const enum camera_driver_enum CAMERA_DEFAULT_DRIVER = CAMERA_NULL;
#endif
#if defined(HAVE_BLUETOOTH)
static const enum bluetooth_driver_enum BLUETOOTH_DEFAULT_DRIVER = BLUETOOTH_BLUETOOTHCTL;
#else
static const enum bluetooth_driver_enum BLUETOOTH_DEFAULT_DRIVER = BLUETOOTH_NULL;
#endif
#if defined(HAVE_LAKKA)
static const enum wifi_driver_enum WIFI_DEFAULT_DRIVER = WIFI_CONNMANCTL;
#else
@ -1014,6 +1026,28 @@ const char *config_get_default_camera(void)
return "null";
}
/**
* config_get_default_bluetooth:
*
* Gets default bluetooth driver.
*
* Returns: Default bluetooth driver.
**/
const char *config_get_default_bluetooth(void)
{
enum bluetooth_driver_enum default_driver = BLUETOOTH_DEFAULT_DRIVER;
switch (default_driver)
{
case BLUETOOTH_BLUETOOTHCTL:
return "bluetoothctl";
case BLUETOOTH_NULL:
break;
}
return "null";
}
/**
* config_get_default_wifi:
*
@ -1148,6 +1182,7 @@ static struct config_array_setting *populate_settings_array(settings_t *settings
SETTING_ARRAY("video_driver", settings->arrays.video_driver, false, NULL, true);
SETTING_ARRAY("record_driver", settings->arrays.record_driver, false, NULL, true);
SETTING_ARRAY("camera_driver", settings->arrays.camera_driver, false, NULL, true);
SETTING_ARRAY("bluetooth_driver", settings->arrays.bluetooth_driver, false, NULL, true);
SETTING_ARRAY("wifi_driver", settings->arrays.wifi_driver, false, NULL, true);
SETTING_ARRAY("location_driver", settings->arrays.location_driver,false, NULL, true);
#ifdef HAVE_MENU
@ -2020,6 +2055,7 @@ void config_set_defaults(void *data)
const char *def_menu = config_get_default_menu();
#endif
const char *def_camera = config_get_default_camera();
const char *def_bluetooth = config_get_default_bluetooth();
const char *def_wifi = config_get_default_wifi();
const char *def_led = config_get_default_led();
const char *def_location = config_get_default_location();
@ -2091,6 +2127,10 @@ void config_set_defaults(void *data)
configuration_set_string(settings,
settings->arrays.camera_driver,
def_camera);
if (def_bluetooth)
configuration_set_string(settings,
settings->arrays.bluetooth_driver,
def_bluetooth);
if (def_wifi)
configuration_set_string(settings,
settings->arrays.wifi_driver,

View file

@ -310,6 +310,9 @@ typedef struct settings
/* Camera */
bool camera_allow;
/* Bluetooth */
bool bluetooth_allow;
/* WiFi */
bool wifi_allow;
@ -639,6 +642,7 @@ typedef struct settings
char video_driver[32];
char record_driver[32];
char camera_driver[32];
char bluetooth_driver[32];
char wifi_driver[32];
char led_driver[32];
char location_driver[32];
@ -759,6 +763,15 @@ typedef struct settings
**/
const char *config_get_default_camera(void);
/**
* config_get_default_bluetooth:
*
* Gets default bluetooth driver.
*
* Returns: Default bluetooth driver.
**/
const char *config_get_default_bluetooth(void);
/**
* config_get_default_wifi:
*

View file

@ -35,6 +35,7 @@ enum
DRIVER_LOCATION,
DRIVER_MENU,
DRIVERS_VIDEO_INPUT,
DRIVER_BLUETOOTH,
DRIVER_WIFI,
DRIVER_LED,
DRIVER_MIDI
@ -49,6 +50,7 @@ enum
DRIVER_LOCATION_MASK = 1 << DRIVER_LOCATION,
DRIVER_MENU_MASK = 1 << DRIVER_MENU,
DRIVERS_VIDEO_INPUT_MASK = 1 << DRIVERS_VIDEO_INPUT,
DRIVER_BLUETOOTH_MASK = 1 << DRIVER_BLUETOOTH,
DRIVER_WIFI_MASK = 1 << DRIVER_WIFI,
DRIVER_LED_MASK = 1 << DRIVER_LED,
DRIVER_MIDI_MASK = 1 << DRIVER_MIDI

View file

@ -1152,6 +1152,13 @@ RETROARCH
#include "../intl/msg_hash_us.c"
/*============================================================
BLUETOOTH
============================================================ */
#ifdef HAVE_BLUETOOTH
#include "../bluetooth/drivers/bluetoothctl.c"
#endif
/*============================================================
WIFI
============================================================ */
@ -1226,6 +1233,7 @@ NETPLAY
#include "../tasks/task_http.c"
#include "../tasks/task_netplay_lan_scan.c"
#include "../tasks/task_netplay_nat_traversal.c"
#include "../tasks/task_bluetooth.c"
#include "../tasks/task_wifi.c"
#include "../tasks/task_netplay_find_content.c"
#include "../tasks/task_pl_thumbnail_download.c"

View file

@ -204,6 +204,10 @@ MSG_HASH(
MENU_ENUM_LABEL_CAMERA_DRIVER,
"camera_driver"
)
MSG_HASH(
MENU_ENUM_LABEL_BLUETOOTH_DRIVER,
"bluetooth_driver"
)
MSG_HASH(
MENU_ENUM_LABEL_CB_CORE_CONTENT_DIRS_LIST,
"cb_core_content_dirs_list"
@ -988,6 +992,10 @@ MSG_HASH(
MENU_ENUM_LABEL_DEFERRED_CRT_SWITCHRES_SETTINGS_LIST,
"deferred_crt_switchres_settings_list"
)
MSG_HASH(
MENU_ENUM_LABEL_DEFERRED_BLUETOOTH_SETTINGS_LIST,
"deferred_bluetooth_settings_list"
)
MSG_HASH(
MENU_ENUM_LABEL_DEFERRED_WIFI_SETTINGS_LIST,
"deferred_wifi_settings_list"
@ -1854,6 +1862,10 @@ MSG_HASH(
MENU_ENUM_LABEL_NO_NETPLAY_HOSTS_FOUND,
"no_netplay_hosts_found"
)
MSG_HASH(
MENU_ENUM_LABEL_NO_BT_DEVICES_FOUND,
"no_bt_devices_found"
)
MSG_HASH(
MENU_ENUM_LABEL_NO_NETWORKS_FOUND,
"no_networks_found"
@ -3214,6 +3226,10 @@ MSG_HASH(
MENU_ENUM_LABEL_WIFI_SETTINGS,
"wifi_settings"
)
MSG_HASH(
MENU_ENUM_LABEL_BLUETOOTH_SETTINGS,
"bluetooth_settings"
)
MSG_HASH(
MENU_ENUM_LABEL_XMB_ALPHA_FACTOR,
"xmb_alpha_factor"

View file

@ -1193,6 +1193,14 @@ MSG_HASH(
MENU_ENUM_SUBLABEL_CAMERA_DRIVER,
"Camera driver to use."
)
MSG_HASH(
MENU_ENUM_LABEL_VALUE_BLUETOOTH_DRIVER,
"Bluetooth"
)
MSG_HASH(
MENU_ENUM_SUBLABEL_BLUETOOTH_DRIVER,
"Bluetooth driver to use."
)
MSG_HASH(
MENU_ENUM_LABEL_VALUE_WIFI_DRIVER,
"Wi-Fi"
@ -6372,6 +6380,10 @@ MSG_HASH(
MENU_ENUM_LABEL_VALUE_NO_SETTINGS_FOUND,
"No Settings Found"
)
MSG_HASH(
MENU_ENUM_LABEL_VALUE_NO_BT_DEVICES_FOUND,
"No Bluetooth Devices Found"
)
MSG_HASH(
MENU_ENUM_LABEL_VALUE_NO_NETWORKS_FOUND,
"No Networks Found"
@ -8962,6 +8974,10 @@ MSG_HASH(
MENU_ENUM_LABEL_VALUE_NO_PLAYLISTS,
"No playlists."
)
MSG_HASH(
MENU_ENUM_LABEL_VALUE_BT_CONNECTED,
"Connected"
)
MSG_HASH(
MENU_ENUM_LABEL_VALUE_ONLINE,
"Online"
@ -10630,10 +10646,18 @@ MSG_HASH(
MSG_DEVICE_NOT_CONFIGURED_FALLBACK,
"not configured, using fallback"
)
MSG_HASH(
MSG_BLUETOOTH_SCAN_COMPLETE,
"Bluetooth scan complete."
)
MSG_HASH(
MSG_WIFI_SCAN_COMPLETE,
"Wi-Fi scan complete."
)
MSG_HASH(
MSG_SCANNING_BLUETOOTH_DEVICES,
"Scanning bluetooth devices..."
)
MSG_HASH(
MSG_SCANNING_WIRELESS_NETWORKS,
"Scanning wireless networks..."
@ -11044,6 +11068,14 @@ MSG_HASH(
MENU_ENUM_LABEL_VALUE_VIDEO_SOFT_FILTER,
"Soft Filter"
)
MSG_HASH(
MENU_ENUM_LABEL_VALUE_BLUETOOTH_SETTINGS,
"Bluetooth"
)
MSG_HASH(
MENU_ENUM_SUBLABEL_BLUETOOTH_SETTINGS,
"Scans for bluetooth devices and connects them."
)
MSG_HASH(
MENU_ENUM_LABEL_VALUE_WIFI_SETTINGS,
"Wi-Fi"

View file

@ -44,6 +44,7 @@ enum string_list_type
STRING_LIST_NONE = 0,
STRING_LIST_MENU_DRIVERS,
STRING_LIST_CAMERA_DRIVERS,
STRING_LIST_BLUETOOTH_DRIVERS,
STRING_LIST_WIFI_DRIVERS,
STRING_LIST_LOCATION_DRIVERS,
STRING_LIST_AUDIO_DRIVERS,

View file

@ -198,6 +198,7 @@ GENERIC_DEFERRED_PUSH(deferred_push_user_interface_settings_list, DISPLAYLIST_
GENERIC_DEFERRED_PUSH(deferred_push_power_management_settings_list, DISPLAYLIST_POWER_MANAGEMENT_SETTINGS_LIST)
GENERIC_DEFERRED_PUSH(deferred_push_retro_achievements_settings_list,DISPLAYLIST_RETRO_ACHIEVEMENTS_SETTINGS_LIST)
GENERIC_DEFERRED_PUSH(deferred_push_updater_settings_list, DISPLAYLIST_UPDATER_SETTINGS_LIST)
GENERIC_DEFERRED_PUSH(deferred_push_bluetooth_settings_list, DISPLAYLIST_BLUETOOTH_SETTINGS_LIST)
GENERIC_DEFERRED_PUSH(deferred_push_wifi_settings_list, DISPLAYLIST_WIFI_SETTINGS_LIST)
GENERIC_DEFERRED_PUSH(deferred_push_network_settings_list, DISPLAYLIST_NETWORK_SETTINGS_LIST)
GENERIC_DEFERRED_PUSH(deferred_push_subsystem_settings_list, DISPLAYLIST_SUBSYSTEM_SETTINGS_LIST)
@ -741,6 +742,7 @@ static int menu_cbs_init_bind_deferred_push_compare_label(
{MENU_ENUM_LABEL_DEFERRED_NETWORK_SETTINGS_LIST, deferred_push_network_settings_list},
{MENU_ENUM_LABEL_DEFERRED_SUBSYSTEM_SETTINGS_LIST, deferred_push_subsystem_settings_list},
{MENU_ENUM_LABEL_DEFERRED_NETWORK_HOSTING_SETTINGS_LIST, deferred_push_network_hosting_settings_list},
{MENU_ENUM_LABEL_DEFERRED_BLUETOOTH_SETTINGS_LIST, deferred_push_bluetooth_settings_list},
{MENU_ENUM_LABEL_DEFERRED_WIFI_SETTINGS_LIST, deferred_push_wifi_settings_list},
{MENU_ENUM_LABEL_DEFERRED_LAKKA_SERVICES_LIST, deferred_push_lakka_services_list},
{MENU_ENUM_LABEL_DEFERRED_USER_SETTINGS_LIST, deferred_push_user_settings_list},

View file

@ -40,6 +40,7 @@
#include "../../performance_counters.h"
#include "../../paths.h"
#include "../../verbosity.h"
#include "../../bluetooth/bluetooth_driver.h"
#include "../../wifi/wifi_driver.h"
#include "../../playlist.h"
#include "../../manual_content_scan.h"
@ -815,6 +816,21 @@ static void menu_action_setting_disp_set_label_entry(
strlcpy(s2, path, len2);
}
static void menu_action_setting_disp_set_label_bluetooth_is_connected(
file_list_t* list,
unsigned *w, unsigned type, unsigned i,
const char *label,
char *s, size_t len,
const char *path,
char *s2, size_t len2)
{
strlcpy(s2, path, len2);
*w = 19;
if (driver_bluetooth_device_is_connected(i))
strlcpy(s, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_BT_CONNECTED), len);
}
static void menu_action_setting_disp_set_label_wifi_is_online(
file_list_t* list,
unsigned *w, unsigned type, unsigned i,
@ -1544,10 +1560,15 @@ static int menu_cbs_init_bind_get_string_representation_compare_label(
case MENU_ENUM_LABEL_MIDI_DRIVER:
case MENU_ENUM_LABEL_LOCATION_DRIVER:
case MENU_ENUM_LABEL_CAMERA_DRIVER:
case MENU_ENUM_LABEL_BLUETOOTH_DRIVER:
case MENU_ENUM_LABEL_WIFI_DRIVER:
case MENU_ENUM_LABEL_MENU_DRIVER:
BIND_ACTION_GET_VALUE(cbs, menu_action_setting_disp_set_label);
break;
case MENU_ENUM_LABEL_CONNECT_BLUETOOTH:
BIND_ACTION_GET_VALUE(cbs,
menu_action_setting_disp_set_label_bluetooth_is_connected);
break;
case MENU_ENUM_LABEL_CONNECT_WIFI:
BIND_ACTION_GET_VALUE(cbs,
menu_action_setting_disp_set_label_wifi_is_online);

View file

@ -72,6 +72,7 @@
#include "../../retroarch.h"
#include "../../verbosity.h"
#include "../../lakka.h"
#include "../../bluetooth/bluetooth_driver.h"
#include "../../wifi/wifi_driver.h"
#include "../../gfx/video_display_server.h"
#include "../../manual_content_scan.h"
@ -371,6 +372,8 @@ static enum msg_hash_enums action_ok_dl_to_enum(unsigned lbl)
return MENU_ENUM_LABEL_DEFERRED_SUBSYSTEM_SETTINGS_LIST;
case ACTION_OK_DL_NETWORK_SETTINGS_LIST:
return MENU_ENUM_LABEL_DEFERRED_NETWORK_SETTINGS_LIST;
case ACTION_OK_DL_BLUETOOTH_SETTINGS_LIST:
return MENU_ENUM_LABEL_DEFERRED_BLUETOOTH_SETTINGS_LIST;
case ACTION_OK_DL_WIFI_SETTINGS_LIST:
return MENU_ENUM_LABEL_DEFERRED_WIFI_SETTINGS_LIST;
case ACTION_OK_DL_NETPLAY:
@ -1233,6 +1236,7 @@ int generic_action_ok_displaylist_push(const char *path,
case ACTION_OK_DL_NETWORK_SETTINGS_LIST:
case ACTION_OK_DL_NETWORK_HOSTING_SETTINGS_LIST:
case ACTION_OK_DL_SUBSYSTEM_SETTINGS_LIST:
case ACTION_OK_DL_BLUETOOTH_SETTINGS_LIST:
case ACTION_OK_DL_WIFI_SETTINGS_LIST:
case ACTION_OK_DL_NETPLAY:
case ACTION_OK_DL_NETPLAY_LAN_SCAN_SETTINGS_LIST:
@ -2579,6 +2583,14 @@ int generic_action_ok_help(const char *path,
entry_idx, ACTION_OK_DL_HELP);
}
static int action_ok_bluetooth(const char *path, const char *label,
unsigned type, size_t idx, size_t entry_idx)
{
driver_bluetooth_connect_device(idx);
return 0;
}
static void menu_input_wifi_cb(void *userdata, const char *passphrase)
{
unsigned idx = menu_input_dialog_get_kb_idx();
@ -4876,6 +4888,7 @@ DEFAULT_ACTION_OK_FUNC(action_ok_network_list, ACTION_OK_DL_NETWORK_SETTINGS_LIS
DEFAULT_ACTION_OK_FUNC(action_ok_network_hosting_list, ACTION_OK_DL_NETWORK_HOSTING_SETTINGS_LIST)
DEFAULT_ACTION_OK_FUNC(action_ok_subsystem_list, ACTION_OK_DL_SUBSYSTEM_SETTINGS_LIST)
DEFAULT_ACTION_OK_FUNC(action_ok_database_manager_list, ACTION_OK_DL_DATABASE_MANAGER_LIST)
DEFAULT_ACTION_OK_FUNC(action_ok_bluetooth_list, ACTION_OK_DL_BLUETOOTH_SETTINGS_LIST)
DEFAULT_ACTION_OK_FUNC(action_ok_wifi_list, ACTION_OK_DL_WIFI_SETTINGS_LIST)
DEFAULT_ACTION_OK_FUNC(action_ok_cursor_manager_list, ACTION_OK_DL_CURSOR_MANAGER_LIST)
DEFAULT_ACTION_OK_FUNC(action_ok_compressed_archive_push, ACTION_OK_DL_COMPRESSED_ARCHIVE_PUSH)
@ -6952,6 +6965,7 @@ static int menu_cbs_init_bind_ok_compare_label(menu_file_list_cbs_t *cbs,
{MENU_ENUM_LABEL_FILE_BROWSER_OPEN_PICKER, action_ok_open_picker},
{MENU_ENUM_LABEL_RETRO_ACHIEVEMENTS_SETTINGS, action_ok_retro_achievements_list},
{MENU_ENUM_LABEL_UPDATER_SETTINGS, action_ok_updater_list},
{MENU_ENUM_LABEL_BLUETOOTH_SETTINGS, action_ok_bluetooth_list},
{MENU_ENUM_LABEL_WIFI_SETTINGS, action_ok_wifi_list},
{MENU_ENUM_LABEL_NETWORK_HOSTING_SETTINGS, action_ok_network_hosting_list},
{MENU_ENUM_LABEL_SUBSYSTEM_SETTINGS, action_ok_subsystem_list},
@ -7374,6 +7388,9 @@ static int menu_cbs_init_bind_ok_compare_type(menu_file_list_cbs_t *cbs,
case FILE_TYPE_RDB_ENTRY:
BIND_ACTION_OK(cbs, action_ok_rdb_entry);
break;
case MENU_BLUETOOTH:
BIND_ACTION_OK(cbs, action_ok_bluetooth);
break;
case MENU_WIFI:
BIND_ACTION_OK(cbs, action_ok_wifi);
break;

View file

@ -192,6 +192,7 @@ DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_input_settings_list, MENU_
DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_input_menu_settings_list, MENU_ENUM_SUBLABEL_INPUT_MENU_SETTINGS)
DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_input_haptic_feedback_settings_list, MENU_ENUM_SUBLABEL_INPUT_HAPTIC_FEEDBACK_SETTINGS)
DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_latency_settings_list, MENU_ENUM_SUBLABEL_LATENCY_SETTINGS)
DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_bluetooth_settings_list, MENU_ENUM_SUBLABEL_BLUETOOTH_SETTINGS)
DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_wifi_settings_list, MENU_ENUM_SUBLABEL_WIFI_SETTINGS)
DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_netplay_lan_scan_settings_list,MENU_ENUM_SUBLABEL_NETPLAY_LAN_SCAN_SETTINGS)
DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_help_list, MENU_ENUM_SUBLABEL_HELP_LIST)
@ -451,6 +452,7 @@ DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_location_driver, MENU_
DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_menu_driver, MENU_ENUM_SUBLABEL_MENU_DRIVER)
DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_record_driver, MENU_ENUM_SUBLABEL_RECORD_DRIVER)
DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_midi_driver, MENU_ENUM_SUBLABEL_MIDI_DRIVER)
DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_bluetooth_driver, MENU_ENUM_SUBLABEL_BLUETOOTH_DRIVER)
DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_wifi_driver, MENU_ENUM_SUBLABEL_WIFI_DRIVER)
DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_filter_supported_extensions, MENU_ENUM_SUBLABEL_NAVIGATION_BROWSER_FILTER_SUPPORTED_EXTENSIONS_ENABLE)
DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_wallpaper, MENU_ENUM_SUBLABEL_MENU_WALLPAPER)
@ -2599,6 +2601,9 @@ int menu_cbs_init_bind_sublabel(menu_file_list_cbs_t *cbs,
case MENU_ENUM_LABEL_NAVIGATION_BROWSER_FILTER_SUPPORTED_EXTENSIONS_ENABLE:
BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_filter_supported_extensions);
break;
case MENU_ENUM_LABEL_BLUETOOTH_DRIVER:
BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_bluetooth_driver);
break;
case MENU_ENUM_LABEL_WIFI_DRIVER:
BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_wifi_driver);
break;
@ -3413,6 +3418,9 @@ int menu_cbs_init_bind_sublabel(menu_file_list_cbs_t *cbs,
case MENU_ENUM_LABEL_INPUT_HAPTIC_FEEDBACK_SETTINGS:
BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_input_haptic_feedback_settings_list);
break;
case MENU_ENUM_LABEL_BLUETOOTH_SETTINGS:
BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_bluetooth_settings_list);
break;
case MENU_ENUM_LABEL_WIFI_SETTINGS:
BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_wifi_settings_list);
break;

View file

@ -485,6 +485,7 @@ DEFAULT_TITLE_MACRO(action_get_power_management_settings_list, MENU_ENUM_LABEL_
DEFAULT_TITLE_MACRO(action_get_menu_sounds_list, MENU_ENUM_LABEL_VALUE_MENU_SOUNDS)
DEFAULT_TITLE_MACRO(action_get_menu_file_browser_settings_list, MENU_ENUM_LABEL_VALUE_MENU_FILE_BROWSER_SETTINGS)
DEFAULT_TITLE_MACRO(action_get_retro_achievements_settings_list,MENU_ENUM_LABEL_VALUE_RETRO_ACHIEVEMENTS_SETTINGS)
DEFAULT_TITLE_MACRO(action_get_bluetooth_settings_list, MENU_ENUM_LABEL_VALUE_BLUETOOTH_SETTINGS)
DEFAULT_TITLE_MACRO(action_get_wifi_settings_list, MENU_ENUM_LABEL_VALUE_WIFI_SETTINGS)
DEFAULT_TITLE_MACRO(action_get_network_hosting_settings_list, MENU_ENUM_LABEL_VALUE_NETWORK_HOSTING_SETTINGS)
DEFAULT_TITLE_MACRO(action_get_subsystem_settings_list, MENU_ENUM_LABEL_VALUE_SUBSYSTEM_SETTINGS)
@ -783,6 +784,7 @@ static int menu_cbs_init_bind_title_compare_label(menu_file_list_cbs_t *cbs,
{MENU_ENUM_LABEL_DEFERRED_MENU_SOUNDS_LIST, action_get_menu_sounds_list},
{MENU_ENUM_LABEL_DEFERRED_MENU_FILE_BROWSER_SETTINGS_LIST, action_get_menu_file_browser_settings_list},
{MENU_ENUM_LABEL_DEFERRED_RETRO_ACHIEVEMENTS_SETTINGS_LIST, action_get_retro_achievements_settings_list},
{MENU_ENUM_LABEL_DEFERRED_BLUETOOTH_SETTINGS_LIST, action_get_bluetooth_settings_list},
{MENU_ENUM_LABEL_DEFERRED_WIFI_SETTINGS_LIST, action_get_wifi_settings_list},
{MENU_ENUM_LABEL_DEFERRED_UPDATER_SETTINGS_LIST, action_get_updater_settings_list},
{MENU_ENUM_LABEL_DEFERRED_NETWORK_HOSTING_SETTINGS_LIST, action_get_network_hosting_settings_list},

View file

@ -9522,6 +9522,7 @@ static void materialui_list_insert(
string_is_equal(label, msg_hash_to_str(MENU_ENUM_LABEL_RETRO_ACHIEVEMENTS_SETTINGS)) ||
string_is_equal(label, msg_hash_to_str(MENU_ENUM_LABEL_ACCOUNTS_YOUTUBE)) ||
string_is_equal(label, msg_hash_to_str(MENU_ENUM_LABEL_ACCOUNTS_TWITCH)) ||
string_is_equal(label, msg_hash_to_str(MENU_ENUM_LABEL_BLUETOOTH_SETTINGS)) ||
string_is_equal(label, msg_hash_to_str(MENU_ENUM_LABEL_WIFI_SETTINGS)) ||
string_is_equal(label, msg_hash_to_str(MENU_ENUM_LABEL_NETWORK_SETTINGS)) ||
string_is_equal(label, msg_hash_to_str(MENU_ENUM_LABEL_NETPLAY_LAN_SCAN_SETTINGS)) ||

View file

@ -263,6 +263,7 @@ uintptr_t ozone_entries_icon_get_texture(ozone_handle_t *ozone,
return ozone->icons_textures[OZONE_ENTRIES_ICONS_TEXTURE_ACHIEVEMENTS];
case MENU_ENUM_LABEL_NETWORK_INFORMATION:
case MENU_ENUM_LABEL_NETWORK_SETTINGS:
case MENU_ENUM_LABEL_BLUETOOTH_SETTINGS:
case MENU_ENUM_LABEL_WIFI_SETTINGS:
case MENU_ENUM_LABEL_NETWORK_INFO_ENTRY:
case MENU_ENUM_LABEL_NETWORK_HOSTING_SETTINGS:
@ -411,6 +412,8 @@ uintptr_t ozone_entries_icon_get_texture(ozone_handle_t *ozone,
#endif
case MENU_INFO_MESSAGE:
return ozone->icons_textures[OZONE_ENTRIES_ICONS_TEXTURE_CORE_INFO];
case MENU_BLUETOOTH:
return ozone->icons_textures[OZONE_ENTRIES_ICONS_TEXTURE_BLUETOOTH];
case MENU_WIFI:
return ozone->icons_textures[OZONE_ENTRIES_ICONS_TEXTURE_WIFI];
#ifdef HAVE_NETWORKING
@ -593,6 +596,8 @@ switch (id)
return "undo.png";
case OZONE_ENTRIES_ICONS_TEXTURE_CORE_INFO:
return "core-infos.png";
case OZONE_ENTRIES_ICONS_TEXTURE_BLUETOOTH:
return "bluetooth.png";
case OZONE_ENTRIES_ICONS_TEXTURE_WIFI:
return "wifi.png";
case OZONE_ENTRIES_ICONS_TEXTURE_CORE_OPTIONS:

View file

@ -90,6 +90,7 @@ enum
OZONE_ENTRIES_ICONS_TEXTURE_LOADSTATE,
OZONE_ENTRIES_ICONS_TEXTURE_UNDO,
OZONE_ENTRIES_ICONS_TEXTURE_CORE_INFO,
OZONE_ENTRIES_ICONS_TEXTURE_BLUETOOTH,
OZONE_ENTRIES_ICONS_TEXTURE_WIFI,
OZONE_ENTRIES_ICONS_TEXTURE_CORE_OPTIONS,
OZONE_ENTRIES_ICONS_TEXTURE_INPUT_REMAPPING_OPTIONS,

View file

@ -123,6 +123,7 @@ enum
STRIPES_TEXTURE_LOADSTATE,
STRIPES_TEXTURE_UNDO,
STRIPES_TEXTURE_CORE_INFO,
STRIPES_TEXTURE_BLUETOOTH,
STRIPES_TEXTURE_WIFI,
STRIPES_TEXTURE_CORE_OPTIONS,
STRIPES_TEXTURE_INPUT_REMAPPING_OPTIONS,
@ -2278,6 +2279,8 @@ static uintptr_t stripes_icon_get_id(stripes_handle_t *stripes,
return stripes->textures.list[STRIPES_TEXTURE_SETTING];
case MENU_INFO_MESSAGE:
return stripes->textures.list[STRIPES_TEXTURE_CORE_INFO];
case MENU_BLUETOOTH:
return stripes->textures.list[STRIPES_TEXTURE_BLUETOOTH];
case MENU_WIFI:
return stripes->textures.list[STRIPES_TEXTURE_WIFI];
#ifdef HAVE_NETWORKING
@ -3618,6 +3621,8 @@ static const char *stripes_texture_path(unsigned id)
return "undo.png";
case STRIPES_TEXTURE_CORE_INFO:
return "core-infos.png";
case STRIPES_TEXTURE_BLUETOOTH:
return "bluetooth.png";
case STRIPES_TEXTURE_WIFI:
return "wifi.png";
case STRIPES_TEXTURE_CORE_OPTIONS:

View file

@ -131,6 +131,7 @@ enum
XMB_TEXTURE_LOADSTATE,
XMB_TEXTURE_UNDO,
XMB_TEXTURE_CORE_INFO,
XMB_TEXTURE_BLUETOOTH,
XMB_TEXTURE_WIFI,
XMB_TEXTURE_CORE_OPTIONS,
XMB_TEXTURE_INPUT_REMAPPING_OPTIONS,
@ -2687,6 +2688,7 @@ static uintptr_t xmb_icon_get_id(xmb_handle_t *xmb,
return xmb->textures.list[XMB_TEXTURE_RELOAD];
case MENU_ENUM_LABEL_NETWORK_INFORMATION:
case MENU_ENUM_LABEL_NETWORK_SETTINGS:
case MENU_ENUM_LABEL_BLUETOOTH_SETTINGS:
case MENU_ENUM_LABEL_WIFI_SETTINGS:
case MENU_ENUM_LABEL_NETWORK_INFO_ENTRY:
case MENU_ENUM_LABEL_NETWORK_HOSTING_SETTINGS:
@ -2807,6 +2809,8 @@ static uintptr_t xmb_icon_get_id(xmb_handle_t *xmb,
return xmb->textures.list[XMB_TEXTURE_SETTING];
case MENU_INFO_MESSAGE:
return xmb->textures.list[XMB_TEXTURE_CORE_INFO];
case MENU_BLUETOOTH:
return xmb->textures.list[XMB_TEXTURE_BLUETOOTH];
case MENU_WIFI:
return xmb->textures.list[XMB_TEXTURE_WIFI];
#ifdef HAVE_NETWORKING
@ -5628,6 +5632,8 @@ static const char *xmb_texture_path(unsigned id)
return "undo.png";
case XMB_TEXTURE_CORE_INFO:
return "core-infos.png";
case XMB_TEXTURE_BLUETOOTH:
return "bluetooth.png";
case XMB_TEXTURE_WIFI:
return "wifi.png";
case XMB_TEXTURE_CORE_OPTIONS:

View file

@ -175,6 +175,7 @@ enum
ACTION_OK_DL_MENU_FILE_BROWSER_SETTINGS_LIST,
ACTION_OK_DL_RETRO_ACHIEVEMENTS_SETTINGS_LIST,
ACTION_OK_DL_UPDATER_SETTINGS_LIST,
ACTION_OK_DL_BLUETOOTH_SETTINGS_LIST,
ACTION_OK_DL_WIFI_SETTINGS_LIST,
ACTION_OK_DL_NETWORK_SETTINGS_LIST,
ACTION_OK_DL_SUBSYSTEM_SETTINGS_LIST,

View file

@ -94,6 +94,7 @@
#include "../list_special.h"
#include "../performance_counters.h"
#include "../core_info.h"
#include "../bluetooth/bluetooth_driver.h"
#include "../wifi/wifi_driver.h"
#include "../tasks/task_content.h"
#include "../tasks/tasks_internal.h"
@ -3884,6 +3885,47 @@ static void menu_displaylist_parse_playlist_generic(
playlist, playlist_name, is_collection);
}
#ifdef HAVE_BLUETOOTH
static void bluetooth_scan_callback(retro_task_t *task,
void *task_data,
void *user_data, const char *error)
{
unsigned i;
file_list_t *file_list = NULL;
struct string_list *device_list = NULL;
const char *path = NULL;
const char *label = NULL;
unsigned menu_type = 0;
menu_entries_get_last_stack(&path, &label, &menu_type, NULL, NULL);
/* Don't push the results if we left the bluetooth menu */
if (!string_is_equal(label,
msg_hash_to_str(MENU_ENUM_LABEL_DEFERRED_BLUETOOTH_SETTINGS_LIST)))
return;
file_list = menu_entries_get_selection_buf_ptr(0);
menu_entries_ctl(MENU_ENTRIES_CTL_CLEAR, file_list);
device_list = string_list_new();
driver_bluetooth_get_devices(device_list);
for (i = 0; i < device_list->size; i++)
{
const char *device = device_list->elems[i].data;
menu_entries_append_enum(file_list,
device,
msg_hash_to_str(MENU_ENUM_LABEL_CONNECT_BLUETOOTH),
MENU_ENUM_LABEL_CONNECT_BLUETOOTH,
MENU_BLUETOOTH, 0, 0);
}
string_list_free(device_list);
}
#endif
#ifdef HAVE_NETWORKING
static void wifi_scan_callback(retro_task_t *task,
void *task_data,
@ -4766,6 +4808,35 @@ unsigned menu_displaylist_build_list(
#endif
}
break;
case DISPLAYLIST_BLUETOOTH_SETTINGS_LIST:
#ifdef HAVE_BLUETOOTH
{
settings_t *settings = config_get_ptr();
if (!string_is_equal(settings->arrays.bluetooth_driver, "null"))
{
struct string_list *device_list = string_list_new();
driver_bluetooth_get_devices(device_list);
if (device_list->size == 0)
task_push_bluetooth_scan(bluetooth_scan_callback);
else
{
unsigned i;
for (i = 0; i < device_list->size; i++)
{
const char *device = device_list->elems[i].data;
if (menu_entries_append_enum(list,
device,
msg_hash_to_str(MENU_ENUM_LABEL_CONNECT_BLUETOOTH),
MENU_ENUM_LABEL_CONNECT_BLUETOOTH,
MENU_BLUETOOTH, 0, 0))
count++;
}
}
}
}
#endif
break;
case DISPLAYLIST_WIFI_SETTINGS_LIST:
#ifdef HAVE_NETWORKING
{
@ -7195,6 +7266,7 @@ unsigned menu_displaylist_build_list(
{MENU_ENUM_LABEL_ACCESSIBILITY_SETTINGS, PARSE_ACTION, true},
{MENU_ENUM_LABEL_POWER_MANAGEMENT_SETTINGS,PARSE_ACTION, true},
{MENU_ENUM_LABEL_RETRO_ACHIEVEMENTS_SETTINGS,PARSE_ACTION, true},
{MENU_ENUM_LABEL_BLUETOOTH_SETTINGS,PARSE_ACTION, true},
{MENU_ENUM_LABEL_WIFI_SETTINGS,PARSE_ACTION, true},
{MENU_ENUM_LABEL_NETWORK_SETTINGS,PARSE_ACTION, true},
{MENU_ENUM_LABEL_NETPLAY_LAN_SCAN_SETTINGS,PARSE_ACTION, true},
@ -7274,6 +7346,7 @@ unsigned menu_displaylist_build_list(
build_list[i].checked = settings->bools.settings_show_directory;
break;
/* MISSING:
* MENU_ENUM_LABEL_BLUETOOTH_SETTINGS
* MENU_ENUM_LABEL_WIFI_SETTINGS
* MENU_ENUM_LABEL_NETPLAY_LAN_SCAN_SETTINGS
* MENU_ENUM_LABEL_LAKKA_SERVICES
@ -7583,6 +7656,9 @@ unsigned menu_displaylist_build_list(
{MENU_ENUM_LABEL_MENU_DRIVER, PARSE_ONLY_STRING_OPTIONS},
{MENU_ENUM_LABEL_RECORD_DRIVER, PARSE_ONLY_STRING_OPTIONS},
{MENU_ENUM_LABEL_MIDI_DRIVER, PARSE_ONLY_STRING_OPTIONS},
#ifdef HAVE_BLUETOOTH
{MENU_ENUM_LABEL_BLUETOOTH_DRIVER, PARSE_ONLY_STRING_OPTIONS},
#endif
#ifdef HAVE_LAKKA
{MENU_ENUM_LABEL_WIFI_DRIVER, PARSE_ONLY_STRING_OPTIONS},
#endif
@ -9983,6 +10059,7 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type,
case DISPLAYLIST_INFORMATION_LIST:
case DISPLAYLIST_SCAN_DIRECTORY_LIST:
case DISPLAYLIST_SYSTEM_INFO:
case DISPLAYLIST_BLUETOOTH_SETTINGS_LIST:
case DISPLAYLIST_WIFI_SETTINGS_LIST:
case DISPLAYLIST_AUDIO_MIXER_SETTINGS_LIST:
case DISPLAYLIST_BROWSE_URL_START:
@ -10037,6 +10114,13 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type,
MENU_ENUM_LABEL_NO_PERFORMANCE_COUNTERS,
0, 0, 0);
break;
case DISPLAYLIST_BLUETOOTH_SETTINGS_LIST:
menu_entries_append_enum(info->list,
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NO_BT_DEVICES_FOUND),
msg_hash_to_str(MENU_ENUM_LABEL_NO_BT_DEVICES_FOUND),
MENU_ENUM_LABEL_NO_BT_DEVICES_FOUND,
0, 0, 0);
break;
case DISPLAYLIST_WIFI_SETTINGS_LIST:
menu_entries_append_enum(info->list,
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NO_NETWORKS_FOUND),

View file

@ -186,6 +186,7 @@ enum menu_displaylist_ctl_state
DISPLAYLIST_MENU_SOUNDS_LIST,
DISPLAYLIST_RETRO_ACHIEVEMENTS_SETTINGS_LIST,
DISPLAYLIST_UPDATER_SETTINGS_LIST,
DISPLAYLIST_BLUETOOTH_SETTINGS_LIST,
DISPLAYLIST_WIFI_SETTINGS_LIST,
DISPLAYLIST_NETWORK_SETTINGS_LIST,
DISPLAYLIST_NETWORK_HOSTING_SETTINGS_LIST,

View file

@ -121,6 +121,7 @@ enum menu_settings_type
MENU_SETTING_PLAYLIST_MANAGER_RIGHT_THUMBNAIL_MODE,
MENU_SETTING_PLAYLIST_MANAGER_LEFT_THUMBNAIL_MODE,
MENU_SETTING_PLAYLIST_MANAGER_SORT_MODE,
MENU_BLUETOOTH,
MENU_WIFI,
MENU_ROOM,
MENU_ROOM_LAN,

View file

@ -82,6 +82,7 @@
#include "../paths.h"
#include "../dynamic.h"
#include "../list_special.h"
#include "../bluetooth/bluetooth_driver.h"
#include "../wifi/wifi_driver.h"
#include "../midi/midi_driver.h"
#include "../tasks/tasks_internal.h"
@ -8372,6 +8373,19 @@ static bool setting_append_list(
SETTINGS_DATA_LIST_CURRENT_ADD_FLAGS(list, list_info, SD_FLAG_ADVANCED);
#endif
#ifdef HAVE_BLUETOOTH
if (string_is_not_equal(settings->arrays.bluetooth_driver, "null"))
{
CONFIG_ACTION(
list, list_info,
MENU_ENUM_LABEL_BLUETOOTH_SETTINGS,
MENU_ENUM_LABEL_VALUE_BLUETOOTH_SETTINGS,
&group_info,
&subgroup_info,
parent_group);
}
#endif
#ifdef HAVE_LAKKA
if (string_is_not_equal(settings->arrays.wifi_driver, "null"))
{
@ -8482,7 +8496,7 @@ static bool setting_append_list(
case SETTINGS_LIST_DRIVERS:
{
unsigned i;
struct string_options_entry string_options_entries[11];
struct string_options_entry string_options_entries[12];
START_GROUP(list, list_info, &group_info, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_DRIVER_SETTINGS), parent_group);
MENU_SETTINGS_LIST_CURRENT_ADD_ENUM_IDX_PTR(list, list_info, MENU_ENUM_LABEL_DRIVER_SETTINGS);
@ -8534,40 +8548,47 @@ static bool setting_append_list(
string_options_entries[5].default_value = config_get_default_camera();
string_options_entries[5].values = config_get_camera_driver_options();
string_options_entries[6].target = settings->arrays.wifi_driver;
string_options_entries[6].len = sizeof(settings->arrays.wifi_driver);
string_options_entries[6].name_enum_idx = MENU_ENUM_LABEL_WIFI_DRIVER;
string_options_entries[6].SHORT_enum_idx = MENU_ENUM_LABEL_VALUE_WIFI_DRIVER;
string_options_entries[6].default_value = config_get_default_wifi();
string_options_entries[6].values = config_get_wifi_driver_options();
string_options_entries[6].target = settings->arrays.bluetooth_driver;
string_options_entries[6].len = sizeof(settings->arrays.bluetooth_driver);
string_options_entries[6].name_enum_idx = MENU_ENUM_LABEL_BLUETOOTH_DRIVER;
string_options_entries[6].SHORT_enum_idx = MENU_ENUM_LABEL_VALUE_BLUETOOTH_DRIVER;
string_options_entries[6].default_value = config_get_default_bluetooth();
string_options_entries[6].values = config_get_bluetooth_driver_options();
string_options_entries[7].target = settings->arrays.location_driver;
string_options_entries[7].len = sizeof(settings->arrays.location_driver);
string_options_entries[7].name_enum_idx = MENU_ENUM_LABEL_LOCATION_DRIVER;
string_options_entries[7].SHORT_enum_idx = MENU_ENUM_LABEL_VALUE_LOCATION_DRIVER;
string_options_entries[7].default_value = config_get_default_location();
string_options_entries[7].values = config_get_location_driver_options();
string_options_entries[7].target = settings->arrays.wifi_driver;
string_options_entries[7].len = sizeof(settings->arrays.wifi_driver);
string_options_entries[7].name_enum_idx = MENU_ENUM_LABEL_WIFI_DRIVER;
string_options_entries[7].SHORT_enum_idx = MENU_ENUM_LABEL_VALUE_WIFI_DRIVER;
string_options_entries[7].default_value = config_get_default_wifi();
string_options_entries[7].values = config_get_wifi_driver_options();
string_options_entries[8].target = settings->arrays.menu_driver;
string_options_entries[8].len = sizeof(settings->arrays.menu_driver);
string_options_entries[8].name_enum_idx = MENU_ENUM_LABEL_MENU_DRIVER;
string_options_entries[8].SHORT_enum_idx = MENU_ENUM_LABEL_VALUE_MENU_DRIVER;
string_options_entries[8].default_value = config_get_default_menu();
string_options_entries[8].values = config_get_menu_driver_options();
string_options_entries[8].target = settings->arrays.location_driver;
string_options_entries[8].len = sizeof(settings->arrays.location_driver);
string_options_entries[8].name_enum_idx = MENU_ENUM_LABEL_LOCATION_DRIVER;
string_options_entries[8].SHORT_enum_idx = MENU_ENUM_LABEL_VALUE_LOCATION_DRIVER;
string_options_entries[8].default_value = config_get_default_location();
string_options_entries[8].values = config_get_location_driver_options();
string_options_entries[9].target = settings->arrays.record_driver;
string_options_entries[9].len = sizeof(settings->arrays.record_driver);
string_options_entries[9].name_enum_idx = MENU_ENUM_LABEL_RECORD_DRIVER;
string_options_entries[9].SHORT_enum_idx = MENU_ENUM_LABEL_VALUE_RECORD_DRIVER;
string_options_entries[9].default_value = config_get_default_record();
string_options_entries[9].values = config_get_record_driver_options();
string_options_entries[9].target = settings->arrays.menu_driver;
string_options_entries[9].len = sizeof(settings->arrays.menu_driver);
string_options_entries[9].name_enum_idx = MENU_ENUM_LABEL_MENU_DRIVER;
string_options_entries[9].SHORT_enum_idx = MENU_ENUM_LABEL_VALUE_MENU_DRIVER;
string_options_entries[9].default_value = config_get_default_menu();
string_options_entries[9].values = config_get_menu_driver_options();
string_options_entries[10].target = settings->arrays.midi_driver;
string_options_entries[10].len = sizeof(settings->arrays.midi_driver);
string_options_entries[10].name_enum_idx = MENU_ENUM_LABEL_MIDI_DRIVER;
string_options_entries[10].SHORT_enum_idx = MENU_ENUM_LABEL_VALUE_MIDI_DRIVER;
string_options_entries[10].default_value = config_get_default_midi();
string_options_entries[10].values = config_get_midi_driver_options();
string_options_entries[10].target = settings->arrays.record_driver;
string_options_entries[10].len = sizeof(settings->arrays.record_driver);
string_options_entries[10].name_enum_idx = MENU_ENUM_LABEL_RECORD_DRIVER;
string_options_entries[10].SHORT_enum_idx = MENU_ENUM_LABEL_VALUE_RECORD_DRIVER;
string_options_entries[10].default_value = config_get_default_record();
string_options_entries[10].values = config_get_record_driver_options();
string_options_entries[11].target = settings->arrays.midi_driver;
string_options_entries[11].len = sizeof(settings->arrays.midi_driver);
string_options_entries[11].name_enum_idx = MENU_ENUM_LABEL_MIDI_DRIVER;
string_options_entries[11].SHORT_enum_idx = MENU_ENUM_LABEL_VALUE_MIDI_DRIVER;
string_options_entries[11].default_value = config_get_default_midi();
string_options_entries[11].values = config_get_midi_driver_options();
for (i = 0; i < ARRAY_SIZE(string_options_entries); i++)
{

View file

@ -373,7 +373,9 @@ enum msg_hash_enums
MSG_TOGGLE_CONTENT_METADATA,
MSG_NO_THUMBNAIL_AVAILABLE,
MSG_PRESS_AGAIN_TO_QUIT,
MSG_BLUETOOTH_SCAN_COMPLETE,
MSG_WIFI_SCAN_COMPLETE,
MSG_SCANNING_BLUETOOTH_DEVICES,
MSG_SCANNING_WIRELESS_NETWORKS,
MSG_FAILED_TO_TAKE_SCREENSHOT,
MSG_CUSTOM_TIMING_GIVEN,
@ -1258,6 +1260,7 @@ enum msg_hash_enums
MENU_LABEL(RETRO_ACHIEVEMENTS_SETTINGS),
MENU_LABEL(MENU_FILE_BROWSER_SETTINGS),
MENU_LABEL(UPDATER_SETTINGS),
MENU_LABEL(BLUETOOTH_SETTINGS),
MENU_LABEL(WIFI_SETTINGS),
MENU_LABEL(USER_SETTINGS),
MENU_LABEL(DIRECTORY_SETTINGS),
@ -1268,6 +1271,7 @@ enum msg_hash_enums
MENU_LABEL(NETWORK_SETTINGS),
MENU_LABEL(NETPLAY_LAN_SCAN_SETTINGS),
MENU_ENUM_LABEL_CONNECT_BLUETOOTH,
MENU_ENUM_LABEL_CONNECT_WIFI,
MENU_ENUM_LABEL_CONNECT_NETPLAY_ROOM,
MENU_ENUM_LABEL_CONNECT_NETPLAY_LAN,
@ -1428,6 +1432,7 @@ enum msg_hash_enums
MENU_ENUM_LABEL_DEFERRED_MENU_FILE_BROWSER_SETTINGS_LIST,
MENU_ENUM_LABEL_DEFERRED_RETRO_ACHIEVEMENTS_SETTINGS_LIST,
MENU_ENUM_LABEL_DEFERRED_UPDATER_SETTINGS_LIST,
MENU_ENUM_LABEL_DEFERRED_BLUETOOTH_SETTINGS_LIST,
MENU_ENUM_LABEL_DEFERRED_WIFI_SETTINGS_LIST,
MENU_ENUM_LABEL_DEFERRED_SUBSYSTEM_SETTINGS_LIST,
MENU_ENUM_LABEL_DEFERRED_NETWORK_HOSTING_SETTINGS_LIST,
@ -1508,6 +1513,7 @@ enum msg_hash_enums
MENU_LABEL(LOAD_CONTENT_SPECIAL),
MENU_LABEL(NO_SETTINGS_FOUND),
MENU_LABEL(NO_PRESETS_FOUND),
MENU_LABEL(NO_BT_DEVICES_FOUND),
MENU_LABEL(NO_NETWORKS_FOUND),
MENU_LABEL(NO_PERFORMANCE_COUNTERS),
MENU_LABEL(FRAME_THROTTLE_SETTINGS),
@ -1775,6 +1781,7 @@ enum msg_hash_enums
MENU_LABEL(MENU_DRIVER),
MENU_LABEL(LOCATION_DRIVER),
MENU_LABEL(CAMERA_DRIVER),
MENU_LABEL(BLUETOOTH_DRIVER),
MENU_LABEL(WIFI_DRIVER),
MENU_LABEL(AUDIO_RESAMPLER_DRIVER),
MENU_LABEL(RECORD_DRIVER),
@ -1978,6 +1985,7 @@ enum msg_hash_enums
MENU_LABEL(SIDELOAD_CORE_ERROR),
MENU_LABEL(SIDELOAD_CORE_SUCCESS),
MENU_LABEL(MANAGEMENT),
MENU_LABEL(BT_CONNECTED),
MENU_LABEL(ONLINE),
MENU_LABEL(ONLINE_UPDATER),
MENU_LABEL(NETPLAY),

View file

@ -215,6 +215,7 @@
#endif
#include "gfx/video_display_server.h"
#include "gfx/video_crt_switch.h"
#include "bluetooth/bluetooth_driver.h"
#include "wifi/wifi_driver.h"
#include "led/led_driver.h"
#include "midi/midi_driver.h"
@ -857,6 +858,26 @@ static hid_driver_t *hid_drivers[] = {
};
#endif
static bluetooth_driver_t bluetooth_null = {
NULL, /* init */
NULL, /* free */
NULL, /* start */
NULL, /* stop */
NULL, /* scan */
NULL, /* get_devices */
NULL, /* device_is_connected */
NULL, /* connect_device */
"null",
};
static const bluetooth_driver_t *bluetooth_drivers[] = {
#ifdef HAVE_BLUETOOTH
&bluetooth_bluetoothctl,
#endif
&bluetooth_null,
NULL,
};
static wifi_driver_t wifi_null = {
NULL, /* init */
NULL, /* free */
@ -1025,6 +1046,7 @@ static const camera_driver_t *camera_drivers[] = {
| DRIVER_LOCATION_MASK \
| DRIVER_MENU_MASK \
| DRIVERS_VIDEO_INPUT_MASK \
| DRIVER_BLUETOOTH_MASK \
| DRIVER_WIFI_MASK \
| DRIVER_LED_MASK \
| DRIVER_MIDI_MASK )
@ -1036,6 +1058,7 @@ static const camera_driver_t *camera_drivers[] = {
| DRIVER_CAMERA_MASK \
| DRIVER_LOCATION_MASK \
| DRIVERS_VIDEO_INPUT_MASK \
| DRIVER_BLUETOOTH_MASK \
| DRIVER_WIFI_MASK \
| DRIVER_LED_MASK \
| DRIVER_MIDI_MASK )
@ -1949,6 +1972,7 @@ struct rarch_state
#endif
bool location_driver_active;
bool bluetooth_driver_active;
bool wifi_driver_active;
bool video_driver_active;
bool audio_driver_active;
@ -2355,6 +2379,9 @@ struct rarch_state
const location_driver_t *location_driver;
void *location_data;
const bluetooth_driver_t *bluetooth_driver;
void *bluetooth_data;
const wifi_driver_t *wifi_driver;
void *wifi_data;
@ -10136,6 +10163,21 @@ struct string_list *string_list_new_special(enum string_list_type type,
string_list_append(s, opt, attr);
}
break;
case STRING_LIST_BLUETOOTH_DRIVERS:
#ifdef HAVE_BLUETOOTH
for (i = 0; bluetooth_drivers[i]; i++)
{
const char *opt = bluetooth_drivers[i]->ident;
*len += strlen(opt) + 1;
if (!add_null_entries)
add_null_entries = (i == 0) || !string_is_equal(opt, "null");
if (add_null_entries)
string_list_append(s, opt, attr);
}
break;
#endif
case STRING_LIST_WIFI_DRIVERS:
#ifdef HAVE_WIFI
for (i = 0; wifi_drivers[i]; i++)
@ -20061,6 +20103,158 @@ static void clear_controller_port_map(struct rarch_state *p_rarch) { }
#endif
/* BLUETOOTH DRIVER */
/**
* config_get_bluetooth_driver_options:
*
* Get an enumerated list of all bluetooth driver names,
* separated by '|'.
*
* Returns: string listing of all bluetooth driver names,
* separated by '|'.
**/
const char* config_get_bluetooth_driver_options(void)
{
return char_list_new_special(STRING_LIST_BLUETOOTH_DRIVERS, NULL);
}
void driver_bluetooth_scan(void)
{
struct rarch_state *p_rarch = &rarch_st;
p_rarch->bluetooth_driver->scan();
}
void driver_bluetooth_get_devices(struct string_list* devices)
{
struct rarch_state *p_rarch = &rarch_st;
p_rarch->bluetooth_driver->get_devices(devices);
}
bool driver_bluetooth_device_is_connected(unsigned i)
{
struct rarch_state *p_rarch = &rarch_st;
return p_rarch->bluetooth_driver->device_is_connected(i);
}
bool driver_bluetooth_connect_device(unsigned i)
{
struct rarch_state *p_rarch = &rarch_st;
return p_rarch->bluetooth_driver->connect_device(i);
}
bool bluetooth_driver_ctl(enum rarch_bluetooth_ctl_state state, void *data)
{
struct rarch_state *p_rarch = &rarch_st;
settings_t *settings = p_rarch->configuration_settings;
switch (state)
{
case RARCH_BLUETOOTH_CTL_DESTROY:
p_rarch->bluetooth_driver_active = false;
p_rarch->bluetooth_driver = NULL;
p_rarch->bluetooth_data = NULL;
break;
case RARCH_BLUETOOTH_CTL_SET_ACTIVE:
p_rarch->bluetooth_driver_active = true;
break;
case RARCH_BLUETOOTH_CTL_FIND_DRIVER:
{
int i;
driver_ctx_info_t drv;
drv.label = "bluetooth_driver";
drv.s = settings->arrays.bluetooth_driver;
driver_ctl(RARCH_DRIVER_CTL_FIND_INDEX, &drv);
i = (int)drv.len;
if (i >= 0)
p_rarch->bluetooth_driver = (const bluetooth_driver_t*)bluetooth_drivers[i];
else
{
if (verbosity_is_enabled())
{
unsigned d;
RARCH_ERR("Couldn't find any bluetooth driver named \"%s\"\n",
settings->arrays.bluetooth_driver);
RARCH_LOG_OUTPUT("Available bluetooth drivers are:\n");
for (d = 0; bluetooth_drivers[d]; d++)
RARCH_LOG_OUTPUT("\t%s\n", bluetooth_drivers[d]->ident);
RARCH_WARN("Going to default to first bluetooth driver...\n");
}
p_rarch->bluetooth_driver = (const bluetooth_driver_t*)bluetooth_drivers[0];
if (!p_rarch->bluetooth_driver)
retroarch_fail(1, "find_bluetooth_driver()");
}
}
break;
case RARCH_BLUETOOTH_CTL_UNSET_ACTIVE:
p_rarch->bluetooth_driver_active = false;
break;
case RARCH_BLUETOOTH_CTL_IS_ACTIVE:
return p_rarch->bluetooth_driver_active;
case RARCH_BLUETOOTH_CTL_DEINIT:
if (p_rarch->bluetooth_data && p_rarch->bluetooth_driver)
{
if (p_rarch->bluetooth_driver->free)
p_rarch->bluetooth_driver->free(p_rarch->bluetooth_data);
}
p_rarch->bluetooth_data = NULL;
break;
case RARCH_BLUETOOTH_CTL_STOP:
if ( p_rarch->bluetooth_driver
&& p_rarch->bluetooth_driver->stop
&& p_rarch->bluetooth_data)
p_rarch->bluetooth_driver->stop(p_rarch->bluetooth_data);
break;
case RARCH_BLUETOOTH_CTL_START:
if ( p_rarch->bluetooth_driver
&& p_rarch->bluetooth_data
&& p_rarch->bluetooth_driver->start)
{
bool bluetooth_allow = settings->bools.bluetooth_allow;
if (bluetooth_allow)
return p_rarch->bluetooth_driver->start(p_rarch->bluetooth_data);
}
return false;
case RARCH_BLUETOOTH_CTL_SET_CB:
{
/*struct retro_bluetooth_callback *cb =
(struct retro_bluetooth_callback*)data;
bluetooth_cb = *cb;*/
}
break;
case RARCH_BLUETOOTH_CTL_INIT:
/* Resource leaks will follow if bluetooth is initialized twice. */
if (p_rarch->bluetooth_data)
return false;
bluetooth_driver_ctl(RARCH_BLUETOOTH_CTL_FIND_DRIVER, NULL);
p_rarch->bluetooth_data = p_rarch->bluetooth_driver->init();
if (!p_rarch->bluetooth_data)
{
RARCH_ERR("Failed to initialize bluetooth driver. Will continue without bluetooth.\n");
bluetooth_driver_ctl(RARCH_BLUETOOTH_CTL_UNSET_ACTIVE, NULL);
}
/*if (bluetooth_cb.initialized)
bluetooth_cb.initialized();*/
break;
default:
break;
}
return false;
}
/* WIFI DRIVER */
/**
@ -32936,6 +33130,21 @@ static const void *find_driver_nonempty(
}
}
}
else if (string_is_equal(label, "bluetooth_driver"))
{
if (bluetooth_drivers[i])
{
const char *ident = bluetooth_drivers[i]->ident;
if (!add_entry)
add_entry = i == 0 || !string_is_equal(ident, "null");
if (add_entry)
{
strlcpy(s, ident, len);
return bluetooth_drivers[i];
}
}
}
else if (string_is_equal(label, "wifi_driver"))
{
if (wifi_drivers[i])
@ -33365,6 +33574,9 @@ static void driver_uninit(struct rarch_state *p_rarch, int flags)
p_rarch->camera_data = NULL;
}
if ((flags & DRIVER_BLUETOOTH_MASK))
bluetooth_driver_ctl(RARCH_BLUETOOTH_CTL_DEINIT, NULL);
if ((flags & DRIVER_WIFI_MASK))
wifi_driver_ctl(RARCH_WIFI_CTL_DEINIT, NULL);
@ -33444,6 +33656,7 @@ static void retroarch_deinit_drivers(struct rarch_state *p_rarch)
p_rarch->camera_driver = NULL;
p_rarch->camera_data = NULL;
bluetooth_driver_ctl(RARCH_BLUETOOTH_CTL_DESTROY, NULL);
wifi_driver_ctl(RARCH_WIFI_CTL_DESTROY, NULL);
cbs->frame_cb = retro_frame_null;
@ -35409,6 +35622,7 @@ bool retroarch_main_init(int argc, char *argv[])
video_driver_find_driver(p_rarch);
input_driver_find_driver(p_rarch);
camera_driver_find_driver(p_rarch);
bluetooth_driver_ctl(RARCH_BLUETOOTH_CTL_FIND_DRIVER, NULL);
wifi_driver_ctl(RARCH_WIFI_CTL_FIND_DRIVER, NULL);
find_location_driver(p_rarch);
#ifdef HAVE_MENU

57
tasks/task_bluetooth.c Normal file
View file

@ -0,0 +1,57 @@
/* RetroArch - A frontend for libretro.
*
* RetroArch is free software: you can redistribute it and/or modify it under the terms
* of the GNU General Public License as published by the Free Software Found-
* ation, either version 3 of the License, or (at your option) any later version.
*
* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with RetroArch.
* If not, see <http://www.gnu.org/licenses/>.
*/
#include <string.h>
#include <errno.h>
#include <compat/strl.h>
#include <retro_assert.h>
#include <retro_miscellaneous.h>
#include <string/stdstring.h>
#include "tasks_internal.h"
#include "../msg_hash.h"
#include "../verbosity.h"
#include "../bluetooth/bluetooth_driver.h"
static void task_bluetooth_scan_handler(retro_task_t *task)
{
driver_bluetooth_scan();
task_set_progress(task, 100);
task_free_title(task);
task_set_title(task, strdup(msg_hash_to_str(MSG_BLUETOOTH_SCAN_COMPLETE)));
task_set_finished(task, true);
}
bool task_push_bluetooth_scan(retro_task_callback_t cb)
{
retro_task_t *task = task_init();
if (!task)
return false;
/* blocking means no other task can run while this one is running,
* which is the default */
task->type = TASK_TYPE_BLOCKING;
task->state = NULL;
task->handler = task_bluetooth_scan_handler;
task->callback = cb;
task->title = strdup(msg_hash_to_str(
MSG_SCANNING_BLUETOOTH_DEVICES));
task_queue_push(task);
return true;
}

View file

@ -84,6 +84,8 @@ void *task_push_http_post_transfer_with_user_agent(const char* url, const char*
task_retriever_info_t *http_task_get_transfer_list(void);
bool task_push_bluetooth_scan(retro_task_callback_t cb);
bool task_push_wifi_scan(retro_task_callback_t cb);
bool task_push_netplay_lan_scan(retro_task_callback_t cb);