mirror of
https://github.com/cemu-project/Cemu.git
synced 2025-07-16 11:48:28 +12:00
Add all the files
This commit is contained in:
parent
e3db07a16a
commit
d60742f52b
1445 changed files with 430238 additions and 0 deletions
74
src/util/libusbWrapper/libusbWrapper.cpp
Normal file
74
src/util/libusbWrapper/libusbWrapper.cpp
Normal file
|
@ -0,0 +1,74 @@
|
|||
#include "libusbWrapper.h"
|
||||
|
||||
/*
|
||||
|
||||
#include "config/ActiveSettings.h"
|
||||
|
||||
libusbWrapper::libusbWrapper()
|
||||
{
|
||||
}
|
||||
|
||||
void libusbWrapper::init()
|
||||
{
|
||||
#if BOOST_OS_WINDOWS
|
||||
if (m_isInitialized)
|
||||
return;
|
||||
m_isInitialized = true;
|
||||
// load module
|
||||
m_module = LoadLibraryW(L"libusb-1.0.dll");
|
||||
if (!m_module)
|
||||
{
|
||||
const auto path = ActiveSettings::GetPath("resources/libusb-1.0.dll");
|
||||
m_module = LoadLibraryW(path.generic_wstring().c_str());
|
||||
if (!m_module)
|
||||
{
|
||||
cemuLog_log(LogType::Force, "libusbWrapper: can't load libusb-1.0.dll");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// grab imports
|
||||
#define FETCH_IMPORT(__NAME__) p_##__NAME__ = (decltype(&__NAME__))GetProcAddress(m_module, #__NAME__)
|
||||
FETCH_IMPORT(libusb_init);
|
||||
FETCH_IMPORT(libusb_exit);
|
||||
FETCH_IMPORT(libusb_interrupt_transfer);
|
||||
FETCH_IMPORT(libusb_get_device_list);
|
||||
FETCH_IMPORT(libusb_get_device_descriptor);
|
||||
FETCH_IMPORT(libusb_open);
|
||||
FETCH_IMPORT(libusb_close);
|
||||
FETCH_IMPORT(libusb_kernel_driver_active);
|
||||
FETCH_IMPORT(libusb_detach_kernel_driver);
|
||||
FETCH_IMPORT(libusb_claim_interface);
|
||||
FETCH_IMPORT(libusb_free_device_list);
|
||||
FETCH_IMPORT(libusb_get_config_descriptor);
|
||||
FETCH_IMPORT(libusb_hotplug_register_callback);
|
||||
FETCH_IMPORT(libusb_hotplug_deregister_callback);
|
||||
FETCH_IMPORT(libusb_has_capability);
|
||||
FETCH_IMPORT(libusb_error_name);
|
||||
FETCH_IMPORT(libusb_get_string_descriptor);
|
||||
FETCH_IMPORT(libusb_get_string_descriptor_ascii);
|
||||
FETCH_IMPORT(libusb_free_config_descriptor);
|
||||
#undef FETCH_IMPORT
|
||||
|
||||
// create default context
|
||||
if (p_libusb_init)
|
||||
p_libusb_init(nullptr);
|
||||
#else
|
||||
cemuLog_log(LogType::Force, "libusbWrapper: Not supported on this OS");
|
||||
#endif
|
||||
}
|
||||
|
||||
libusbWrapper::~libusbWrapper()
|
||||
{
|
||||
#if BOOST_OS_WINDOWS > 0
|
||||
// destroy default context
|
||||
if(p_libusb_exit)
|
||||
p_libusb_exit(nullptr);
|
||||
|
||||
// unload module
|
||||
if(m_module)
|
||||
FreeLibrary(m_module);
|
||||
#endif
|
||||
}
|
||||
|
||||
*/
|
50
src/util/libusbWrapper/libusbWrapper.h
Normal file
50
src/util/libusbWrapper/libusbWrapper.h
Normal file
|
@ -0,0 +1,50 @@
|
|||
#pragma once
|
||||
|
||||
// todo - port to cmake build
|
||||
|
||||
/*
|
||||
|
||||
#include "util/helpers/ClassWrapper.h"
|
||||
|
||||
#pragma warning(disable:4200)
|
||||
#include "libusb-1.0/libusb.h"
|
||||
#pragma warning(default:4200)
|
||||
|
||||
class libusbWrapper : public SingletonRef<libusbWrapper>
|
||||
{
|
||||
public:
|
||||
libusbWrapper();
|
||||
~libusbWrapper();
|
||||
|
||||
void init();
|
||||
bool isAvailable() const { return p_libusb_init != nullptr; };
|
||||
|
||||
decltype(&libusb_init) p_libusb_init = nullptr;
|
||||
decltype(&libusb_exit) p_libusb_exit = nullptr;
|
||||
decltype(&libusb_interrupt_transfer) p_libusb_interrupt_transfer;
|
||||
decltype(&libusb_get_device_list) p_libusb_get_device_list;
|
||||
decltype(&libusb_get_device_descriptor) p_libusb_get_device_descriptor;
|
||||
decltype(&libusb_open) p_libusb_open;
|
||||
decltype(&libusb_kernel_driver_active) p_libusb_kernel_driver_active;
|
||||
decltype(&libusb_detach_kernel_driver) p_libusb_detach_kernel_driver;
|
||||
decltype(&libusb_claim_interface) p_libusb_claim_interface;
|
||||
decltype(&libusb_free_device_list) p_libusb_free_device_list;
|
||||
decltype(&libusb_get_config_descriptor) p_libusb_get_config_descriptor;
|
||||
decltype(&libusb_free_config_descriptor) p_libusb_free_config_descriptor;
|
||||
decltype(&libusb_close) p_libusb_close;
|
||||
decltype(&libusb_hotplug_register_callback) p_libusb_hotplug_register_callback;
|
||||
decltype(&libusb_hotplug_deregister_callback) p_libusb_hotplug_deregister_callback;
|
||||
decltype(&libusb_has_capability) p_libusb_has_capability;
|
||||
decltype(&libusb_error_name) p_libusb_error_name;
|
||||
decltype(&libusb_get_string_descriptor) p_libusb_get_string_descriptor;
|
||||
decltype(&libusb_get_string_descriptor_ascii) p_libusb_get_string_descriptor_ascii;
|
||||
|
||||
|
||||
private:
|
||||
#if BOOST_OS_WINDOWS > 0
|
||||
HMODULE m_module = nullptr;
|
||||
bool m_isInitialized = false;
|
||||
#endif
|
||||
};
|
||||
|
||||
*/
|
Loading…
Add table
Add a link
Reference in a new issue