GCAdapter: protect some more functions

Reset() and Setup() are not used outside of this namespace
This commit is contained in:
mathieui 2016-05-19 21:52:44 +02:00
parent 54b4efff6b
commit 1bbbe92cd2
4 changed files with 9 additions and 8 deletions

View File

@ -23,6 +23,8 @@ namespace GCAdapter
static bool CheckDeviceAccess(libusb_device* device); static bool CheckDeviceAccess(libusb_device* device);
static void AddGCAdapter(libusb_device* device); static void AddGCAdapter(libusb_device* device);
static void ResetRumbleLockNeeded(); static void ResetRumbleLockNeeded();
static void Reset();
static void Setup();
static bool s_detected = false; static bool s_detected = false;
static libusb_device_handle* s_handle = nullptr; static libusb_device_handle* s_handle = nullptr;
@ -183,7 +185,7 @@ void StopScanThread()
} }
} }
void Setup() static void Setup()
{ {
libusb_device** list; libusb_device** list;
ssize_t cnt = libusb_get_device_list(s_libusb_context, &list); ssize_t cnt = libusb_get_device_list(s_libusb_context, &list);
@ -333,7 +335,7 @@ void Shutdown()
s_libusb_driver_not_supported = false; s_libusb_driver_not_supported = false;
} }
void Reset() static void Reset()
{ {
std::unique_lock<std::mutex> lock(s_init_mutex, std::defer_lock); std::unique_lock<std::mutex> lock(s_init_mutex, std::defer_lock);
if (!lock.try_lock()) if (!lock.try_lock())

View File

@ -19,9 +19,7 @@ enum ControllerTypes
CONTROLLER_WIRELESS = 2 CONTROLLER_WIRELESS = 2
}; };
void Init(); void Init();
void Reset();
void ResetRumble(); void ResetRumble();
void Setup();
void Shutdown(); void Shutdown();
void SetAdapterCallback(std::function<void(void)> func); void SetAdapterCallback(std::function<void(void)> func);
void StartScanThread(); void StartScanThread();

View File

@ -24,6 +24,9 @@ extern JavaVM* g_java_vm;
namespace GCAdapter namespace GCAdapter
{ {
static void Setup();
static void Reset();
// Java classes // Java classes
static jclass s_adapter_class; static jclass s_adapter_class;
@ -207,7 +210,7 @@ void Init()
StartScanThread(); StartScanThread();
} }
void Setup() static void Setup()
{ {
s_fd = 0; s_fd = 0;
s_detected = true; s_detected = true;
@ -220,7 +223,7 @@ void Setup()
s_read_adapter_thread = std::thread(Read); s_read_adapter_thread = std::thread(Read);
} }
void Reset() static void Reset()
{ {
if (!s_detected) if (!s_detected)
return; return;

View File

@ -9,9 +9,7 @@ namespace GCAdapter
{ {
void Init() {} void Init() {}
void Reset() {}
void ResetRumble() {} void ResetRumble() {}
void Setup() {}
void Shutdown() {} void Shutdown() {}
void SetAdapterCallback(std::function<void(void)> func) {} void SetAdapterCallback(std::function<void(void)> func) {}
void StartScanThread() {} void StartScanThread() {}