From c45058d3ae235e4a69c84394633f85cfe312ae64 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Andr=C3=A9=20Santoni?= Date: Wed, 21 Sep 2016 16:06:14 +0200 Subject: [PATCH] Start adding a WiFi driver --- Makefile.common | 6 ++ config.def.h | 9 ++ configuration.h | 6 ++ driver.c | 14 +++ driver.h | 6 +- griffin/griffin.c | 6 ++ intl/msg_hash_us.c | 4 + list_special.c | 15 +++ list_special.h | 1 + menu/menu_displaylist.c | 3 + menu/menu_setting.c | 19 ++++ msg_hash.h | 2 + wifi/drivers/connmanctl.c | 47 +++++++++ wifi/drivers/nullwifi.c | 47 +++++++++ wifi/wifi_driver.c | 213 ++++++++++++++++++++++++++++++++++++++ wifi/wifi_driver.h | 98 ++++++++++++++++++ 16 files changed, 494 insertions(+), 2 deletions(-) create mode 100644 wifi/drivers/connmanctl.c create mode 100644 wifi/drivers/nullwifi.c create mode 100644 wifi/wifi_driver.c create mode 100644 wifi/wifi_driver.h diff --git a/Makefile.common b/Makefile.common index 120d6a7700..369ee893da 100644 --- a/Makefile.common +++ b/Makefile.common @@ -173,6 +173,7 @@ OBJ += frontend/frontend.o \ gfx/video_coord_array.o \ gfx/video_driver.o \ camera/camera_driver.o \ + wifi/wifi_driver.o \ location/location_driver.o \ driver.o \ configuration.o \ @@ -217,6 +218,7 @@ OBJ += frontend/frontend.o \ audio/drivers_resampler/cc_resampler.o \ location/drivers/nulllocation.o \ camera/drivers/nullcamera.o \ + wifi/drivers/nullwifi.o \ gfx/drivers/nullgfx.o \ audio/drivers/nullaudio.o \ input/drivers/nullinput.o \ @@ -324,6 +326,10 @@ OBJ += frontend/drivers/platform_emscripten.o \ camera/drivers/rwebcam.o endif +ifeq ($(HAVE_LAKKA), 1) +OBJ += wifi/drivers/connmanctl.o +endif + # Audio # ifeq ($(HAVE_COREAUDIO), 1) diff --git a/config.def.h b/config.def.h index 9ba8bc1195..ad5e9e8cc2 100644 --- a/config.def.h +++ b/config.def.h @@ -114,6 +114,9 @@ enum CAMERA_AVFOUNDATION, CAMERA_NULL, + WIFI_CONNMANCTL, + WIFI_NULL, + LOCATION_ANDROID, LOCATION_CORELOCATION, LOCATION_NULL, @@ -309,6 +312,12 @@ enum #define CAMERA_DEFAULT_DRIVER CAMERA_NULL #endif +#if defined(HAVE_LAKKA) +#define WIFI_DEFAULT_DRIVER WIFI_CONNMANCTL +#else +#define WIFI_DEFAULT_DRIVER WIFI_NULL +#endif + #if defined(ANDROID) #define LOCATION_DEFAULT_DRIVER LOCATION_ANDROID #elif defined(HAVE_CORELOCATION) && (defined(HAVE_COCOA) || defined(HAVE_COCOATOUCH)) diff --git a/configuration.h b/configuration.h index a2f38187ae..8fa9185c13 100644 --- a/configuration.h +++ b/configuration.h @@ -216,6 +216,12 @@ typedef struct settings unsigned height; } camera; + struct + { + char driver[32]; + bool allow; + } wifi; + struct { char driver[32]; diff --git a/driver.c b/driver.c index 7bf7f0e094..6f969fb4f2 100644 --- a/driver.c +++ b/driver.c @@ -34,6 +34,7 @@ #include "camera/camera_driver.h" #include "record/record_driver.h" #include "location/location_driver.h" +#include "wifi/wifi_driver.h" #include "configuration.h" #include "core.h" #include "driver.h" @@ -49,6 +50,7 @@ #define HASH_AUDIO_DRIVER 0x26594002U #define HASH_AUDIO_RESAMPLER_DRIVER 0xedcba9ecU #define HASH_RECORD_DRIVER 0x144cd2cfU +#define HASH_WIFI_DRIVER 0x64d7d17fU /** * find_driver_nonempty: @@ -118,6 +120,11 @@ static const void *find_driver_nonempty(const char *label, int i, if (drv) strlcpy(s, audio_resampler_driver_find_ident(i), len); break; + case HASH_WIFI_DRIVER: + drv = wifi_driver_find_handle(i); + if (drv) + strlcpy(s, wifi_driver_find_ident(i), len); + break; } return drv; @@ -294,6 +301,8 @@ static void init_drivers(int flags) camera_driver_ctl(RARCH_CAMERA_CTL_UNSET_OWN_DRIVER, NULL); if (flags & DRIVER_LOCATION) location_driver_ctl(RARCH_LOCATION_CTL_UNSET_OWN_DRIVER, NULL); + if (flags & DRIVER_WIFI) + wifi_driver_ctl(RARCH_WIFI_CTL_UNSET_OWN_DRIVER, NULL); #ifdef HAVE_MENU /* By default, we want the menu to persist through driver reinits. */ @@ -390,6 +399,9 @@ static void uninit_drivers(int flags) if (flags & DRIVER_AUDIO) audio_driver_deinit(); + if ((flags & DRIVER_WIFI) && !wifi_driver_ctl(RARCH_WIFI_CTL_OWNS_DRIVER, NULL)) + wifi_driver_ctl(RARCH_WIFI_CTL_DEINIT, NULL); + if (flags & DRIVERS_VIDEO_INPUT) video_driver_deinit(); @@ -416,6 +428,7 @@ bool driver_ctl(enum driver_ctl_state state, void *data) #endif location_driver_ctl(RARCH_LOCATION_CTL_DESTROY, NULL); camera_driver_ctl(RARCH_CAMERA_CTL_DESTROY, NULL); + wifi_driver_ctl(RARCH_WIFI_CTL_DESTROY, NULL); core_uninit_libretro_callbacks(); break; case RARCH_DRIVER_CTL_UNINIT: @@ -449,6 +462,7 @@ bool driver_ctl(enum driver_ctl_state state, void *data) video_driver_find_driver(); input_driver_find_driver(); camera_driver_ctl(RARCH_CAMERA_CTL_FIND_DRIVER, NULL); + wifi_driver_ctl(RARCH_WIFI_CTL_FIND_DRIVER, NULL); find_location_driver(); #ifdef HAVE_MENU menu_driver_ctl(RARCH_MENU_CTL_FIND_DRIVER, NULL); diff --git a/driver.h b/driver.h index 9a260e9825..1451df9cc5 100644 --- a/driver.h +++ b/driver.h @@ -33,7 +33,8 @@ RETRO_BEGIN_DECLS | DRIVER_CAMERA \ | DRIVER_LOCATION \ | DRIVER_MENU \ - | DRIVERS_VIDEO_INPUT ) + | DRIVERS_VIDEO_INPUT \ + | DRIVER_WIFI ) enum { @@ -43,7 +44,8 @@ enum DRIVER_CAMERA = 1 << 3, DRIVER_LOCATION = 1 << 4, DRIVER_MENU = 1 << 5, - DRIVERS_VIDEO_INPUT = 1 << 6 + DRIVERS_VIDEO_INPUT = 1 << 6, + DRIVER_WIFI = 1 << 7 }; enum driver_ctl_state diff --git a/griffin/griffin.c b/griffin/griffin.c index f5aac1e1a8..de048d8198 100644 --- a/griffin/griffin.c +++ b/griffin/griffin.c @@ -560,6 +560,12 @@ CAMERA #include "../camera/drivers/nullcamera.c" +/*============================================================ +WIFI +============================================================ */ + +#include "../wifi/drivers/nullwifi.c" + /*============================================================ LOCATION ============================================================ */ diff --git a/intl/msg_hash_us.c b/intl/msg_hash_us.c index dfefcb4f0b..c442a4b856 100644 --- a/intl/msg_hash_us.c +++ b/intl/msg_hash_us.c @@ -2886,6 +2886,8 @@ static const char *menu_hash_to_str_us_label_enum(enum msg_hash_enums msg) return "menu_driver"; case MENU_ENUM_LABEL_CAMERA_DRIVER: return "camera_driver"; + case MENU_ENUM_LABEL_WIFI_DRIVER: + return "wifi_driver"; case MENU_ENUM_LABEL_LOCATION_DRIVER: return "location_driver"; case MENU_ENUM_LABEL_OVERLAY_SCALE: @@ -4163,6 +4165,8 @@ const char *msg_hash_to_str_us(enum msg_hash_enums msg) return "Menu Driver"; case MENU_ENUM_LABEL_VALUE_CAMERA_DRIVER: return "Camera Driver"; + case MENU_ENUM_LABEL_VALUE_WIFI_DRIVER: + return "WiFi Driver"; case MENU_ENUM_LABEL_VALUE_LOCATION_DRIVER: return "Location Driver"; case MENU_ENUM_LABEL_VALUE_UNABLE_TO_READ_COMPRESSED_FILE: diff --git a/list_special.c b/list_special.c index 29d308754a..e1f80777cf 100644 --- a/list_special.c +++ b/list_special.c @@ -32,6 +32,10 @@ #include "camera/camera_driver.h" #endif +#ifdef HAVE_WIFI +#include "wifi/wifi_driver.h" +#endif + #ifdef HAVE_LOCATION #include "location/location_driver.h" #endif @@ -180,6 +184,17 @@ struct string_list *string_list_new_special(enum string_list_type type, string_list_append(s, opt, attr); } break; +#endif + case STRING_LIST_WIFI_DRIVERS: +#ifdef HAVE_WIFI + for (i = 0; wifi_driver_find_handle(i); i++) + { + const char *opt = wifi_driver_find_ident(i); + *len += strlen(opt) + 1; + + string_list_append(s, opt, attr); + } + break; #endif case STRING_LIST_LOCATION_DRIVERS: #ifdef HAVE_LOCATION diff --git a/list_special.h b/list_special.h index 4af32c996d..709b4cb90a 100644 --- a/list_special.h +++ b/list_special.h @@ -40,6 +40,7 @@ enum string_list_type STRING_LIST_NONE = 0, STRING_LIST_MENU_DRIVERS, STRING_LIST_CAMERA_DRIVERS, + STRING_LIST_WIFI_DRIVERS, STRING_LIST_LOCATION_DRIVERS, STRING_LIST_AUDIO_DRIVERS, STRING_LIST_AUDIO_RESAMPLER_DRIVERS, diff --git a/menu/menu_displaylist.c b/menu/menu_displaylist.c index 7f452b4d22..8388310200 100644 --- a/menu/menu_displaylist.c +++ b/menu/menu_displaylist.c @@ -4342,6 +4342,9 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type, void *data) ret = menu_displaylist_parse_settings_enum(menu, info, MENU_ENUM_LABEL_RECORD_DRIVER, PARSE_ONLY_STRING_OPTIONS, false); + ret = menu_displaylist_parse_settings_enum(menu, info, + MENU_ENUM_LABEL_WIFI_DRIVER, + PARSE_ONLY_STRING_OPTIONS, false); info->need_refresh = true; info->need_push = true; diff --git a/menu/menu_setting.c b/menu/menu_setting.c index 080ec912ee..8d47f840b5 100644 --- a/menu/menu_setting.c +++ b/menu/menu_setting.c @@ -62,6 +62,7 @@ #include "../runloop.h" #include "../verbosity.h" #include "../camera/camera_driver.h" +#include "../wifi/wifi_driver.h" #include "../location/location_driver.h" #include "../record/record_driver.h" #include "../audio/audio_driver.h" @@ -2658,6 +2659,24 @@ static bool setting_append_list( (*list)[list_info->index - 1].action_right = setting_string_action_right_driver; menu_settings_list_current_add_enum_idx(list, list_info, MENU_ENUM_LABEL_CAMERA_DRIVER); + CONFIG_STRING_OPTIONS( + list, list_info, + settings->wifi.driver, + sizeof(settings->wifi.driver), + msg_hash_to_str(MENU_ENUM_LABEL_WIFI_DRIVER), + msg_hash_to_str(MENU_ENUM_LABEL_VALUE_WIFI_DRIVER), + config_get_default_camera(), + config_get_camera_driver_options(), + &group_info, + &subgroup_info, + parent_group, + general_read_handler, + general_write_handler); + settings_data_list_current_add_flags(list, list_info, SD_FLAG_IS_DRIVER); + (*list)[list_info->index - 1].action_left = setting_string_action_left_driver; + (*list)[list_info->index - 1].action_right = setting_string_action_right_driver; + menu_settings_list_current_add_enum_idx(list, list_info, MENU_ENUM_LABEL_WIFI_DRIVER); + CONFIG_STRING_OPTIONS( list, list_info, settings->location.driver, diff --git a/msg_hash.h b/msg_hash.h index 83b8eea021..fa490ff835 100644 --- a/msg_hash.h +++ b/msg_hash.h @@ -1175,6 +1175,7 @@ enum msg_hash_enums MENU_ENUM_LABEL_MENU_DRIVER, MENU_ENUM_LABEL_LOCATION_DRIVER, MENU_ENUM_LABEL_CAMERA_DRIVER, + MENU_ENUM_LABEL_WIFI_DRIVER, MENU_ENUM_LABEL_AUDIO_RESAMPLER_DRIVER, MENU_ENUM_LABEL_RECORD_DRIVER, MENU_ENUM_LABEL_VIDEO_DRIVER, @@ -1187,6 +1188,7 @@ enum msg_hash_enums MENU_ENUM_LABEL_VALUE_VIDEO_DRIVER, MENU_ENUM_LABEL_VALUE_LOCATION_DRIVER, MENU_ENUM_LABEL_VALUE_CAMERA_DRIVER, + MENU_ENUM_LABEL_VALUE_WIFI_DRIVER, MENU_ENUM_LABEL_VALUE_RECORD_DRIVER, MENU_ENUM_LABEL_VALUE_MENU_DRIVER, diff --git a/wifi/drivers/connmanctl.c b/wifi/drivers/connmanctl.c new file mode 100644 index 0000000000..d36e1717f8 --- /dev/null +++ b/wifi/drivers/connmanctl.c @@ -0,0 +1,47 @@ +/* RetroArch - A frontend for libretro. + * Copyright (C) 2010-2015 - Michael Lelli + * + * 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 . + */ + +#include "../wifi_driver.h" + +static void *connmanctl_init(const char *device, uint64_t caps, + unsigned width, unsigned height) +{ + (void)device; + return (void*)-1; +} + +static void connmanctl_free(void *data) +{ + (void)data; +} + +static bool connmanctl_start(void *data) +{ + (void)data; + return true; +} + +static void connmanctl_stop(void *data) +{ + (void)data; +} + +wifi_driver_t wifi_connmanctl = { + connmanctl_init, + connmanctl_free, + connmanctl_start, + connmanctl_stop, + "connmanctl", +}; diff --git a/wifi/drivers/nullwifi.c b/wifi/drivers/nullwifi.c new file mode 100644 index 0000000000..2dedbf8303 --- /dev/null +++ b/wifi/drivers/nullwifi.c @@ -0,0 +1,47 @@ +/* RetroArch - A frontend for libretro. + * Copyright (C) 2010-2015 - Michael Lelli + * + * 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 . + */ + +#include "../wifi_driver.h" + +static void *nullwifi_init(const char *device, uint64_t caps, + unsigned width, unsigned height) +{ + (void)device; + return (void*)-1; +} + +static void nullwifi_free(void *data) +{ + (void)data; +} + +static bool nullwifi_start(void *data) +{ + (void)data; + return true; +} + +static void nullwifi_stop(void *data) +{ + (void)data; +} + +wifi_driver_t wifi_null = { + nullwifi_init, + nullwifi_free, + nullwifi_start, + nullwifi_stop, + "null", +}; diff --git a/wifi/wifi_driver.c b/wifi/wifi_driver.c new file mode 100644 index 0000000000..fa4945973f --- /dev/null +++ b/wifi/wifi_driver.c @@ -0,0 +1,213 @@ +/* RetroArch - A frontend for libretro. + * Copyright (C) 2010-2014 - Hans-Kristian Arntzen + * Copyright (C) 2011-2016 - Daniel De Matteis + * + * 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 . + */ + +#include + +#ifdef HAVE_CONFIG_H +#include "../config.h" +#endif + +#include "wifi_driver.h" + +#include "../configuration.h" +#include "../driver.h" +#include "../retroarch.h" +#include "../runloop.h" +#include "../list_special.h" +#include "../verbosity.h" + +static const wifi_driver_t *wifi_drivers[] = { +#ifdef HAVE_LAKKA + &wifi_connmanctl, +#endif + &wifi_null, + NULL, +}; + +/** + * wifi_driver_find_handle: + * @idx : index of driver to get handle to. + * + * Returns: handle to wifi driver at index. Can be NULL + * if nothing found. + **/ +const void *wifi_driver_find_handle(int idx) +{ + const void *drv = wifi_drivers[idx]; + if (!drv) + return NULL; + return drv; +} + +/** + * wifi_driver_find_ident: + * @idx : index of driver to get handle to. + * + * Returns: Human-readable identifier of wifi driver at index. Can be NULL + * if nothing found. + **/ +const char *wifi_driver_find_ident(int idx) +{ + const wifi_driver_t *drv = wifi_drivers[idx]; + if (!drv) + return NULL; + return drv->ident; +} + +/** + * config_get_wifi_driver_options: + * + * Get an enumerated list of all wifi driver names, + * separated by '|'. + * + * Returns: string listing of all wifi driver names, + * separated by '|'. + **/ +const char* config_get_wifi_driver_options(void) +{ + return char_list_new_special(STRING_LIST_WIFI_DRIVERS, NULL); +} + +void driver_wifi_stop(void) +{ + wifi_driver_ctl(RARCH_WIFI_CTL_START, NULL); +} + +bool driver_wifi_start(void) +{ + return wifi_driver_ctl(RARCH_WIFI_CTL_START, NULL); +} + +bool wifi_driver_ctl(enum rarch_wifi_ctl_state state, void *data) +{ + settings_t *settings = config_get_ptr(); + static const wifi_driver_t *wifi_driver = NULL; + static void *wifi_data = NULL; + static bool wifi_driver_active = false; + static bool wifi_driver_data_own = false; + + switch (state) + { + case RARCH_WIFI_CTL_DESTROY: + wifi_driver_active = false; + wifi_driver_data_own = false; + wifi_driver = NULL; + wifi_data = NULL; + break; + case RARCH_WIFI_CTL_SET_OWN_DRIVER: + wifi_driver_data_own = true; + break; + case RARCH_WIFI_CTL_UNSET_OWN_DRIVER: + wifi_driver_data_own = false; + break; + case RARCH_WIFI_CTL_OWNS_DRIVER: + return wifi_driver_data_own; + case RARCH_WIFI_CTL_SET_ACTIVE: + wifi_driver_active = true; + break; + case RARCH_WIFI_CTL_FIND_DRIVER: + { + int i; + driver_ctx_info_t drv; + + drv.label = "wifi_driver"; + drv.s = settings->wifi.driver; + + driver_ctl(RARCH_DRIVER_CTL_FIND_INDEX, &drv); + + i = drv.len; + + if (i >= 0) + wifi_driver = (const wifi_driver_t*)wifi_driver_find_handle(i); + else + { + unsigned d; + RARCH_ERR("Couldn't find any wifi driver named \"%s\"\n", + settings->wifi.driver); + RARCH_LOG_OUTPUT("Available wifi drivers are:\n"); + for (d = 0; wifi_driver_find_handle(d); d++) + RARCH_LOG_OUTPUT("\t%s\n", wifi_driver_find_ident(d)); + + RARCH_WARN("Going to default to first wifi driver...\n"); + + wifi_driver = (const wifi_driver_t*)wifi_driver_find_handle(0); + + if (!wifi_driver) + retroarch_fail(1, "find_wifi_driver()"); + } + } + break; + case RARCH_WIFI_CTL_UNSET_ACTIVE: + wifi_driver_active = false; + break; + case RARCH_WIFI_CTL_IS_ACTIVE: + return wifi_driver_active; + case RARCH_WIFI_CTL_DEINIT: + if (wifi_data && wifi_driver) + { + if (wifi_driver->free) + wifi_driver->free(wifi_data); + } + + wifi_data = NULL; + break; + case RARCH_WIFI_CTL_STOP: + if ( wifi_driver + && wifi_driver->stop + && wifi_data) + wifi_driver->stop(wifi_data); + break; + case RARCH_WIFI_CTL_START: + if (wifi_driver && wifi_data && wifi_driver->start) + { + if (settings->wifi.allow) + return wifi_driver->start(wifi_data); + + runloop_msg_queue_push( + "Camera is explicitly disabled.\n", 1, 180, false); + } + return false; + case RARCH_WIFI_CTL_SET_CB: + { + /*struct retro_wifi_callback *cb = + (struct retro_wifi_callback*)data; + wifi_cb = *cb;*/ + } + break; + case RARCH_WIFI_CTL_INIT: + /* Resource leaks will follow if wifi is initialized twice. */ + if (wifi_data) + return false; + + wifi_driver_ctl(RARCH_WIFI_CTL_FIND_DRIVER, NULL); + + wifi_data = wifi_driver->init(); + + if (!wifi_data) + { + RARCH_ERR("Failed to initialize wifi driver. Will continue without wifi.\n"); + wifi_driver_ctl(RARCH_WIFI_CTL_UNSET_ACTIVE, NULL); + } + + /*if (wifi_cb.initialized) + wifi_cb.initialized();*/ + break; + default: + break; + } + + return false; +} diff --git a/wifi/wifi_driver.h b/wifi/wifi_driver.h new file mode 100644 index 0000000000..d075c9c590 --- /dev/null +++ b/wifi/wifi_driver.h @@ -0,0 +1,98 @@ +/* RetroArch - A frontend for libretro. + * Copyright (C) 2010-2014 - Hans-Kristian Arntzen + * Copyright (C) 2011-2016 - Daniel De Matteis + * + * 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 . + */ + +#ifndef __WIFI_DRIVER__H +#define __WIFI_DRIVER__H + +#include + +#include +#include +#include + +RETRO_BEGIN_DECLS + +enum rarch_wifi_ctl_state +{ + RARCH_WIFI_CTL_NONE = 0, + RARCH_WIFI_CTL_DESTROY, + RARCH_WIFI_CTL_DEINIT, + RARCH_WIFI_CTL_SET_OWN_DRIVER, + RARCH_WIFI_CTL_UNSET_OWN_DRIVER, + RARCH_WIFI_CTL_OWNS_DRIVER, + RARCH_WIFI_CTL_SET_ACTIVE, + RARCH_WIFI_CTL_UNSET_ACTIVE, + RARCH_WIFI_CTL_IS_ACTIVE, + RARCH_WIFI_CTL_FIND_DRIVER, + RARCH_WIFI_CTL_SET_CB, + RARCH_WIFI_CTL_STOP, + RARCH_WIFI_CTL_START, + RARCH_WIFI_CTL_INIT +}; + +typedef struct wifi_driver +{ + void *(*init)(); + + void (*free)(void *data); + + bool (*start)(void *data); + void (*stop)(void *data); + + const char *ident; +} wifi_driver_t; + +extern wifi_driver_t wifi_connmanctl; +extern wifi_driver_t wifi_null; + +/** + * config_get_wifi_driver_options: + * + * Get an enumerated list of all wifi driver names, + * separated by '|'. + * + * Returns: string listing of all wifi driver names, + * separated by '|'. + **/ +const char* config_get_wifi_driver_options(void); + +/** + * wifi_driver_find_handle: + * @index : index of driver to get handle to. + * + * Returns: handle to wifi driver at index. Can be NULL + * if nothing found. + **/ +const void *wifi_driver_find_handle(int index); + +/** + * wifi_driver_find_ident: + * @index : index of driver to get handle to. + * + * Returns: Human-readable identifier of wifi driver at index. Can be NULL + * if nothing found. + **/ +const char *wifi_driver_find_ident(int index); + +void driver_wifi_stop(void); + +bool driver_wifi_start(void); + +bool wifi_driver_ctl(enum rarch_wifi_ctl_state state, void *data); + +RETRO_END_DECLS + +#endif