mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-01-26 07:45:33 +01:00
WiimoteReal: add m_ prefix to member variables
This commit is contained in:
parent
02dae1d1ba
commit
a1e974fedf
@ -122,8 +122,8 @@ void WiimoteScanner::FindWiimotes(std::vector<Wiimote*> & found_wiimotes, Wiimot
|
|||||||
|
|
||||||
void Wiimote::InitInternal()
|
void Wiimote::InitInternal()
|
||||||
{
|
{
|
||||||
cmd_sock = -1;
|
m_cmd_sock = -1;
|
||||||
int_sock = -1;
|
m_int_sock = -1;
|
||||||
|
|
||||||
int fds[2];
|
int fds[2];
|
||||||
if (pipe(fds))
|
if (pipe(fds))
|
||||||
@ -131,15 +131,15 @@ void Wiimote::InitInternal()
|
|||||||
ERROR_LOG(WIIMOTE, "pipe failed");
|
ERROR_LOG(WIIMOTE, "pipe failed");
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
wakeup_pipe_w = fds[1];
|
m_wakeup_pipe_w = fds[1];
|
||||||
wakeup_pipe_r = fds[0];
|
m_wakeup_pipe_r = fds[0];
|
||||||
bdaddr = (bdaddr_t){{0, 0, 0, 0, 0, 0}};
|
m_bdaddr = (bdaddr_t){{0, 0, 0, 0, 0, 0}};
|
||||||
}
|
}
|
||||||
|
|
||||||
void Wiimote::TeardownInternal()
|
void Wiimote::TeardownInternal()
|
||||||
{
|
{
|
||||||
close(wakeup_pipe_w);
|
close(m_wakeup_pipe_w);
|
||||||
close(wakeup_pipe_r);
|
close(m_wakeup_pipe_r);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Connect to a wiimote with a known address.
|
// Connect to a wiimote with a known address.
|
||||||
@ -147,29 +147,29 @@ bool Wiimote::ConnectInternal()
|
|||||||
{
|
{
|
||||||
sockaddr_l2 addr;
|
sockaddr_l2 addr;
|
||||||
addr.l2_family = AF_BLUETOOTH;
|
addr.l2_family = AF_BLUETOOTH;
|
||||||
addr.l2_bdaddr = bdaddr;
|
addr.l2_bdaddr = m_bdaddr;
|
||||||
addr.l2_cid = 0;
|
addr.l2_cid = 0;
|
||||||
|
|
||||||
// Output channel
|
// Output channel
|
||||||
addr.l2_psm = htobs(WM_OUTPUT_CHANNEL);
|
addr.l2_psm = htobs(WM_OUTPUT_CHANNEL);
|
||||||
if ((cmd_sock = socket(AF_BLUETOOTH, SOCK_SEQPACKET, BTPROTO_L2CAP)) == -1 ||
|
if ((m_cmd_sock = socket(AF_BLUETOOTH, SOCK_SEQPACKET, BTPROTO_L2CAP)) == -1 ||
|
||||||
connect(cmd_sock, (sockaddr*)&addr, sizeof(addr)) < 0)
|
connect(m_cmd_sock, (sockaddr*)&addr, sizeof(addr)) < 0)
|
||||||
{
|
{
|
||||||
DEBUG_LOG(WIIMOTE, "Unable to open output socket to wiimote.");
|
DEBUG_LOG(WIIMOTE, "Unable to open output socket to wiimote.");
|
||||||
close(cmd_sock);
|
close(m_cmd_sock);
|
||||||
cmd_sock = -1;
|
m_cmd_sock = -1;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Input channel
|
// Input channel
|
||||||
addr.l2_psm = htobs(WM_INPUT_CHANNEL);
|
addr.l2_psm = htobs(WM_INPUT_CHANNEL);
|
||||||
if ((int_sock = socket(AF_BLUETOOTH, SOCK_SEQPACKET, BTPROTO_L2CAP)) == -1 ||
|
if ((m_int_sock = socket(AF_BLUETOOTH, SOCK_SEQPACKET, BTPROTO_L2CAP)) == -1 ||
|
||||||
connect(int_sock, (sockaddr*)&addr, sizeof(addr)) < 0)
|
connect(m_int_sock, (sockaddr*)&addr, sizeof(addr)) < 0)
|
||||||
{
|
{
|
||||||
DEBUG_LOG(WIIMOTE, "Unable to open input socket from wiimote.");
|
DEBUG_LOG(WIIMOTE, "Unable to open input socket from wiimote.");
|
||||||
close(int_sock);
|
close(m_int_sock);
|
||||||
close(cmd_sock);
|
close(m_cmd_sock);
|
||||||
int_sock = cmd_sock = -1;
|
m_int_sock = m_cmd_sock = -1;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -178,22 +178,22 @@ bool Wiimote::ConnectInternal()
|
|||||||
|
|
||||||
void Wiimote::DisconnectInternal()
|
void Wiimote::DisconnectInternal()
|
||||||
{
|
{
|
||||||
close(cmd_sock);
|
close(m_cmd_sock);
|
||||||
close(int_sock);
|
close(m_int_sock);
|
||||||
|
|
||||||
cmd_sock = -1;
|
m_cmd_sock = -1;
|
||||||
int_sock = -1;
|
m_int_sock = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Wiimote::IsConnected() const
|
bool Wiimote::IsConnected() const
|
||||||
{
|
{
|
||||||
return cmd_sock != -1;// && int_sock != -1;
|
return m_cmd_sock != -1;// && int_sock != -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Wiimote::IOWakeup()
|
void Wiimote::IOWakeup()
|
||||||
{
|
{
|
||||||
char c = 0;
|
char c = 0;
|
||||||
if (write(wakeup_pipe_w, &c, 1) != 1)
|
if (write(m_wakeup_pipe_w, &c, 1) != 1)
|
||||||
{
|
{
|
||||||
ERROR_LOG(WIIMOTE, "Unable to write to wakeup pipe.");
|
ERROR_LOG(WIIMOTE, "Unable to write to wakeup pipe.");
|
||||||
}
|
}
|
||||||
@ -208,40 +208,40 @@ int Wiimote::IORead(u8* buf)
|
|||||||
|
|
||||||
fd_set fds;
|
fd_set fds;
|
||||||
FD_ZERO(&fds);
|
FD_ZERO(&fds);
|
||||||
FD_SET(int_sock, &fds);
|
FD_SET(m_int_sock, &fds);
|
||||||
FD_SET(wakeup_pipe_r, &fds);
|
FD_SET(m_wakeup_pipe_r, &fds);
|
||||||
|
|
||||||
if (select(int_sock + 1, &fds, nullptr, nullptr, nullptr) == -1)
|
if (select(m_int_sock + 1, &fds, nullptr, nullptr, nullptr) == -1)
|
||||||
{
|
{
|
||||||
ERROR_LOG(WIIMOTE, "Unable to select wiimote %i input socket.", index + 1);
|
ERROR_LOG(WIIMOTE, "Unable to select wiimote %i input socket.", m_index + 1);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (FD_ISSET(wakeup_pipe_r, &fds))
|
if (FD_ISSET(m_wakeup_pipe_r, &fds))
|
||||||
{
|
{
|
||||||
char c;
|
char c;
|
||||||
if (read(wakeup_pipe_r, &c, 1) != 1)
|
if (read(m_wakeup_pipe_r, &c, 1) != 1)
|
||||||
{
|
{
|
||||||
ERROR_LOG(WIIMOTE, "Unable to read from wakeup pipe.");
|
ERROR_LOG(WIIMOTE, "Unable to read from wakeup pipe.");
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!FD_ISSET(int_sock, &fds))
|
if (!FD_ISSET(m_int_sock, &fds))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
// Read the pending message into the buffer
|
// Read the pending message into the buffer
|
||||||
int r = read(int_sock, buf, MAX_PAYLOAD);
|
int r = read(m_int_sock, buf, MAX_PAYLOAD);
|
||||||
if (r == -1)
|
if (r == -1)
|
||||||
{
|
{
|
||||||
// Error reading data
|
// Error reading data
|
||||||
ERROR_LOG(WIIMOTE, "Receiving data from wiimote %i.", index + 1);
|
ERROR_LOG(WIIMOTE, "Receiving data from wiimote %i.", m_index + 1);
|
||||||
|
|
||||||
if (errno == ENOTCONN)
|
if (errno == ENOTCONN)
|
||||||
{
|
{
|
||||||
// This can happen if the bluetooth dongle is disconnected
|
// This can happen if the bluetooth dongle is disconnected
|
||||||
ERROR_LOG(WIIMOTE, "Bluetooth appears to be disconnected. "
|
ERROR_LOG(WIIMOTE, "Bluetooth appears to be disconnected. "
|
||||||
"Wiimote %i will be disconnected.", index + 1);
|
"Wiimote %i will be disconnected.", m_index + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
r = 0;
|
r = 0;
|
||||||
@ -252,7 +252,7 @@ int Wiimote::IORead(u8* buf)
|
|||||||
|
|
||||||
int Wiimote::IOWrite(u8 const* buf, size_t len)
|
int Wiimote::IOWrite(u8 const* buf, size_t len)
|
||||||
{
|
{
|
||||||
return write(int_sock, buf, (int)len);
|
return write(m_int_sock, buf, (int)len);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Wiimote::EnablePowerAssertionInternal()
|
void Wiimote::EnablePowerAssertionInternal()
|
||||||
|
@ -273,10 +273,10 @@ void WiimoteScanner::FindWiimotes(std::vector<Wiimote*> & found_wiimotes, Wiimot
|
|||||||
if (SetupDiGetDeviceInterfaceDetail(device_info, &device_data, detail_data, len, nullptr, nullptr))
|
if (SetupDiGetDeviceInterfaceDetail(device_info, &device_data, detail_data, len, nullptr, nullptr))
|
||||||
{
|
{
|
||||||
auto const wm = new Wiimote;
|
auto const wm = new Wiimote;
|
||||||
wm->devicepath = detail_data->DevicePath;
|
wm->m_devicepath = detail_data->DevicePath;
|
||||||
bool real_wiimote = false, is_bb = false;
|
bool real_wiimote = false, is_bb = false;
|
||||||
|
|
||||||
CheckDeviceType(wm->devicepath, real_wiimote, is_bb);
|
CheckDeviceType(wm->m_devicepath, real_wiimote, is_bb);
|
||||||
if (is_bb)
|
if (is_bb)
|
||||||
{
|
{
|
||||||
found_board = wm;
|
found_board = wm;
|
||||||
@ -507,7 +507,7 @@ bool Wiimote::ConnectInternal()
|
|||||||
|
|
||||||
#ifdef SHARE_WRITE_WIIMOTES
|
#ifdef SHARE_WRITE_WIIMOTES
|
||||||
std::lock_guard<std::mutex> lk(g_connected_wiimotes_lock);
|
std::lock_guard<std::mutex> lk(g_connected_wiimotes_lock);
|
||||||
if (g_connected_wiimotes.count(devicepath) != 0)
|
if (g_connected_wiimotes.count(m_devicepath) != 0)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
auto const open_flags = FILE_SHARE_READ | FILE_SHARE_WRITE;
|
auto const open_flags = FILE_SHARE_READ | FILE_SHARE_WRITE;
|
||||||
@ -519,13 +519,13 @@ bool Wiimote::ConnectInternal()
|
|||||||
auto const open_flags = FILE_SHARE_READ;
|
auto const open_flags = FILE_SHARE_READ;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
dev_handle = CreateFile(devicepath.c_str(),
|
m_dev_handle = CreateFile(m_devicepath.c_str(),
|
||||||
GENERIC_READ | GENERIC_WRITE, open_flags,
|
GENERIC_READ | GENERIC_WRITE, open_flags,
|
||||||
nullptr, OPEN_EXISTING, FILE_FLAG_OVERLAPPED, nullptr);
|
nullptr, OPEN_EXISTING, FILE_FLAG_OVERLAPPED, nullptr);
|
||||||
|
|
||||||
if (dev_handle == INVALID_HANDLE_VALUE)
|
if (m_dev_handle == INVALID_HANDLE_VALUE)
|
||||||
{
|
{
|
||||||
dev_handle = 0;
|
m_dev_handle = 0;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -564,7 +564,7 @@ bool Wiimote::ConnectInternal()
|
|||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
#ifdef SHARE_WRITE_WIIMOTES
|
#ifdef SHARE_WRITE_WIIMOTES
|
||||||
g_connected_wiimotes.insert(devicepath);
|
g_connected_wiimotes.insert(m_devicepath);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -575,36 +575,36 @@ void Wiimote::DisconnectInternal()
|
|||||||
if (!IsConnected())
|
if (!IsConnected())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
CloseHandle(dev_handle);
|
CloseHandle(m_dev_handle);
|
||||||
dev_handle = 0;
|
m_dev_handle = 0;
|
||||||
|
|
||||||
#ifdef SHARE_WRITE_WIIMOTES
|
#ifdef SHARE_WRITE_WIIMOTES
|
||||||
std::lock_guard<std::mutex> lk(g_connected_wiimotes_lock);
|
std::lock_guard<std::mutex> lk(g_connected_wiimotes_lock);
|
||||||
g_connected_wiimotes.erase(devicepath);
|
g_connected_wiimotes.erase(m_devicepath);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void Wiimote::InitInternal()
|
void Wiimote::InitInternal()
|
||||||
{
|
{
|
||||||
dev_handle = 0;
|
m_dev_handle = 0;
|
||||||
stack = MSBT_STACK_UNKNOWN;
|
m_stack = MSBT_STACK_UNKNOWN;
|
||||||
|
|
||||||
hid_overlap_read = OVERLAPPED();
|
m_hid_overlap_read = OVERLAPPED();
|
||||||
hid_overlap_read.hEvent = CreateEvent(nullptr, true, false, nullptr);
|
m_hid_overlap_read.hEvent = CreateEvent(nullptr, true, false, nullptr);
|
||||||
|
|
||||||
hid_overlap_write = OVERLAPPED();
|
m_hid_overlap_write = OVERLAPPED();
|
||||||
hid_overlap_write.hEvent = CreateEvent(nullptr, true, false, nullptr);
|
m_hid_overlap_write.hEvent = CreateEvent(nullptr, true, false, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Wiimote::TeardownInternal()
|
void Wiimote::TeardownInternal()
|
||||||
{
|
{
|
||||||
CloseHandle(hid_overlap_read.hEvent);
|
CloseHandle(m_hid_overlap_read.hEvent);
|
||||||
CloseHandle(hid_overlap_write.hEvent);
|
CloseHandle(m_hid_overlap_write.hEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Wiimote::IsConnected() const
|
bool Wiimote::IsConnected() const
|
||||||
{
|
{
|
||||||
return dev_handle != 0;
|
return m_dev_handle != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void _IOWakeup(HANDLE &dev_handle, OVERLAPPED &hid_overlap_read)
|
void _IOWakeup(HANDLE &dev_handle, OVERLAPPED &hid_overlap_read)
|
||||||
@ -668,7 +668,7 @@ int _IORead(HANDLE &dev_handle, OVERLAPPED &hid_overlap_read, u8* buf, int index
|
|||||||
|
|
||||||
void Wiimote::IOWakeup()
|
void Wiimote::IOWakeup()
|
||||||
{
|
{
|
||||||
_IOWakeup(dev_handle, hid_overlap_read);
|
_IOWakeup(m_dev_handle, m_hid_overlap_read);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -677,7 +677,7 @@ void Wiimote::IOWakeup()
|
|||||||
// zero = error
|
// zero = error
|
||||||
int Wiimote::IORead(u8* buf)
|
int Wiimote::IORead(u8* buf)
|
||||||
{
|
{
|
||||||
return _IORead(dev_handle, hid_overlap_read, buf, index);
|
return _IORead(m_dev_handle, m_hid_overlap_read, buf, m_index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -780,7 +780,7 @@ int _IOWrite(HANDLE &dev_handle, OVERLAPPED &hid_overlap_write, enum win_bt_stac
|
|||||||
|
|
||||||
int Wiimote::IOWrite(const u8* buf, size_t len)
|
int Wiimote::IOWrite(const u8* buf, size_t len)
|
||||||
{
|
{
|
||||||
return _IOWrite(dev_handle, hid_overlap_write, stack, buf, len, nullptr);
|
return _IOWrite(m_dev_handle, m_hid_overlap_write, m_stack, buf, len, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Wiimote::EnablePowerAssertionInternal()
|
void Wiimote::EnablePowerAssertionInternal()
|
||||||
|
@ -41,14 +41,14 @@
|
|||||||
{
|
{
|
||||||
IOBluetoothDevice *device = [l2capChannel device];
|
IOBluetoothDevice *device = [l2capChannel device];
|
||||||
WiimoteReal::Wiimote *wm = nullptr;
|
WiimoteReal::Wiimote *wm = nullptr;
|
||||||
|
|
||||||
std::lock_guard<std::recursive_mutex> lk(WiimoteReal::g_refresh_lock);
|
std::lock_guard<std::recursive_mutex> lk(WiimoteReal::g_refresh_lock);
|
||||||
|
|
||||||
for (int i = 0; i < MAX_WIIMOTES; i++)
|
for (int i = 0; i < MAX_WIIMOTES; i++)
|
||||||
{
|
{
|
||||||
if (WiimoteReal::g_wiimotes[i] == nullptr)
|
if (WiimoteReal::g_wiimotes[i] == nullptr)
|
||||||
continue;
|
continue;
|
||||||
if ([device isEqual: WiimoteReal::g_wiimotes[i]->btd] == TRUE)
|
if ([device isEqual: WiimoteReal::g_wiimotes[i]->m_btd] == TRUE)
|
||||||
wm = WiimoteReal::g_wiimotes[i];
|
wm = WiimoteReal::g_wiimotes[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -59,18 +59,18 @@
|
|||||||
|
|
||||||
if (length > MAX_PAYLOAD) {
|
if (length > MAX_PAYLOAD) {
|
||||||
WARN_LOG(WIIMOTE, "Dropping packet for wiimote %i, too large",
|
WARN_LOG(WIIMOTE, "Dropping packet for wiimote %i, too large",
|
||||||
wm->index + 1);
|
wm->m_index + 1);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (wm->inputlen != -1) {
|
if (wm->m_inputlen != -1) {
|
||||||
WARN_LOG(WIIMOTE, "Dropping packet for wiimote %i, queue full",
|
WARN_LOG(WIIMOTE, "Dropping packet for wiimote %i, queue full",
|
||||||
wm->index + 1);
|
wm->m_index + 1);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
memcpy(wm->input, data, length);
|
memcpy(wm->m_input, data, length);
|
||||||
wm->inputlen = length;
|
wm->m_inputlen = length;
|
||||||
|
|
||||||
CFRunLoopStop(CFRunLoopGetCurrent());
|
CFRunLoopStop(CFRunLoopGetCurrent());
|
||||||
}
|
}
|
||||||
@ -79,14 +79,14 @@
|
|||||||
{
|
{
|
||||||
IOBluetoothDevice *device = [l2capChannel device];
|
IOBluetoothDevice *device = [l2capChannel device];
|
||||||
WiimoteReal::Wiimote *wm = nullptr;
|
WiimoteReal::Wiimote *wm = nullptr;
|
||||||
|
|
||||||
std::lock_guard<std::recursive_mutex> lk(WiimoteReal::g_refresh_lock);
|
std::lock_guard<std::recursive_mutex> lk(WiimoteReal::g_refresh_lock);
|
||||||
|
|
||||||
for (int i = 0; i < MAX_WIIMOTES; i++)
|
for (int i = 0; i < MAX_WIIMOTES; i++)
|
||||||
{
|
{
|
||||||
if (WiimoteReal::g_wiimotes[i] == nullptr)
|
if (WiimoteReal::g_wiimotes[i] == nullptr)
|
||||||
continue;
|
continue;
|
||||||
if ([device isEqual: WiimoteReal::g_wiimotes[i]->btd] == TRUE)
|
if ([device isEqual: WiimoteReal::g_wiimotes[i]->m_btd] == TRUE)
|
||||||
wm = WiimoteReal::g_wiimotes[i];
|
wm = WiimoteReal::g_wiimotes[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -95,7 +95,7 @@
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
WARN_LOG(WIIMOTE, "Lost channel to wiimote %i", wm->index + 1);
|
WARN_LOG(WIIMOTE, "Lost channel to wiimote %i", wm->m_index + 1);
|
||||||
|
|
||||||
wm->DisconnectInternal();
|
wm->DisconnectInternal();
|
||||||
}
|
}
|
||||||
@ -165,7 +165,7 @@ void WiimoteScanner::FindWiimotes(std::vector<Wiimote*> & found_wiimotes, Wiimot
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
Wiimote *wm = new Wiimote();
|
Wiimote *wm = new Wiimote();
|
||||||
wm->btd = [dev retain];
|
wm->m_btd = [dev retain];
|
||||||
|
|
||||||
if (IsBalanceBoardName([[dev name] UTF8String]))
|
if (IsBalanceBoardName([[dev name] UTF8String]))
|
||||||
{
|
{
|
||||||
@ -190,10 +190,10 @@ bool WiimoteScanner::IsReady() const
|
|||||||
|
|
||||||
void Wiimote::InitInternal()
|
void Wiimote::InitInternal()
|
||||||
{
|
{
|
||||||
inputlen = 0;
|
m_inputlen = 0;
|
||||||
m_connected = false;
|
m_connected = false;
|
||||||
m_wiimote_thread_run_loop = nullptr;
|
m_wiimote_thread_run_loop = nullptr;
|
||||||
btd = nil;
|
m_btd = nil;
|
||||||
m_pm_assertion = kIOPMNullAssertionID;
|
m_pm_assertion = kIOPMNullAssertionID;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -204,8 +204,8 @@ void Wiimote::TeardownInternal()
|
|||||||
CFRelease(m_wiimote_thread_run_loop);
|
CFRelease(m_wiimote_thread_run_loop);
|
||||||
m_wiimote_thread_run_loop = nullptr;
|
m_wiimote_thread_run_loop = nullptr;
|
||||||
}
|
}
|
||||||
[btd release];
|
[m_btd release];
|
||||||
btd = nil;
|
m_btd = nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Connect to a wiimote with a known address.
|
// Connect to a wiimote with a known address.
|
||||||
@ -216,23 +216,23 @@ bool Wiimote::ConnectInternal()
|
|||||||
|
|
||||||
ConnectBT *cbt = [[ConnectBT alloc] init];
|
ConnectBT *cbt = [[ConnectBT alloc] init];
|
||||||
|
|
||||||
cchan = ichan = nil;
|
m_cchan = m_ichan = nil;
|
||||||
|
|
||||||
IOReturn ret = [btd openConnection];
|
IOReturn ret = [m_btd openConnection];
|
||||||
if (ret)
|
if (ret)
|
||||||
{
|
{
|
||||||
ERROR_LOG(WIIMOTE, "Unable to open Bluetooth connection to wiimote %i: %x",
|
ERROR_LOG(WIIMOTE, "Unable to open Bluetooth connection to wiimote %i: %x",
|
||||||
index + 1, ret);
|
m_index + 1, ret);
|
||||||
[cbt release];
|
[cbt release];
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = [btd openL2CAPChannelSync: &cchan
|
ret = [m_btd openL2CAPChannelSync: &m_cchan
|
||||||
withPSM: kBluetoothL2CAPPSMHIDControl delegate: cbt];
|
withPSM: kBluetoothL2CAPPSMHIDControl delegate: cbt];
|
||||||
if (ret)
|
if (ret)
|
||||||
{
|
{
|
||||||
ERROR_LOG(WIIMOTE, "Unable to open control channel for wiimote %i: %x",
|
ERROR_LOG(WIIMOTE, "Unable to open control channel for wiimote %i: %x",
|
||||||
index + 1, ret);
|
m_index + 1, ret);
|
||||||
goto bad;
|
goto bad;
|
||||||
}
|
}
|
||||||
// Apple docs claim:
|
// Apple docs claim:
|
||||||
@ -240,20 +240,20 @@ bool Wiimote::ConnectInternal()
|
|||||||
// success; the channel must be released when the caller is done with it."
|
// success; the channel must be released when the caller is done with it."
|
||||||
// But without this, the channels get over-autoreleased, even though the
|
// But without this, the channels get over-autoreleased, even though the
|
||||||
// refcounting behavior here is clearly correct.
|
// refcounting behavior here is clearly correct.
|
||||||
[cchan retain];
|
[m_cchan retain];
|
||||||
|
|
||||||
ret = [btd openL2CAPChannelSync: &ichan
|
ret = [m_btd openL2CAPChannelSync: &m_ichan
|
||||||
withPSM: kBluetoothL2CAPPSMHIDInterrupt delegate: cbt];
|
withPSM: kBluetoothL2CAPPSMHIDInterrupt delegate: cbt];
|
||||||
if (ret)
|
if (ret)
|
||||||
{
|
{
|
||||||
WARN_LOG(WIIMOTE, "Unable to open interrupt channel for wiimote %i: %x",
|
WARN_LOG(WIIMOTE, "Unable to open interrupt channel for wiimote %i: %x",
|
||||||
index + 1, ret);
|
m_index + 1, ret);
|
||||||
goto bad;
|
goto bad;
|
||||||
}
|
}
|
||||||
[ichan retain];
|
[m_ichan retain];
|
||||||
|
|
||||||
NOTICE_LOG(WIIMOTE, "Connected to wiimote %i at %s",
|
NOTICE_LOG(WIIMOTE, "Connected to wiimote %i at %s",
|
||||||
index + 1, [[btd addressString] UTF8String]);
|
m_index + 1, [[m_btd addressString] UTF8String]);
|
||||||
|
|
||||||
m_connected = true;
|
m_connected = true;
|
||||||
|
|
||||||
@ -272,20 +272,20 @@ bad:
|
|||||||
// Disconnect a wiimote.
|
// Disconnect a wiimote.
|
||||||
void Wiimote::DisconnectInternal()
|
void Wiimote::DisconnectInternal()
|
||||||
{
|
{
|
||||||
[ichan closeChannel];
|
[m_ichan closeChannel];
|
||||||
[ichan release];
|
[m_ichan release];
|
||||||
ichan = nil;
|
m_ichan = nil;
|
||||||
|
|
||||||
[cchan closeChannel];
|
[m_cchan closeChannel];
|
||||||
[cchan release];
|
[m_cchan release];
|
||||||
cchan = nil;
|
m_cchan = nil;
|
||||||
|
|
||||||
[btd closeConnection];
|
[m_btd closeConnection];
|
||||||
|
|
||||||
if (!IsConnected())
|
if (!IsConnected())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
NOTICE_LOG(WIIMOTE, "Disconnecting wiimote %i", index + 1);
|
NOTICE_LOG(WIIMOTE, "Disconnecting wiimote %i", m_index + 1);
|
||||||
|
|
||||||
m_connected = false;
|
m_connected = false;
|
||||||
}
|
}
|
||||||
@ -305,12 +305,12 @@ void Wiimote::IOWakeup()
|
|||||||
|
|
||||||
int Wiimote::IORead(unsigned char *buf)
|
int Wiimote::IORead(unsigned char *buf)
|
||||||
{
|
{
|
||||||
input = buf;
|
m_input = buf;
|
||||||
inputlen = -1;
|
m_inputlen = -1;
|
||||||
|
|
||||||
CFRunLoopRun();
|
CFRunLoopRun();
|
||||||
|
|
||||||
return inputlen;
|
return m_inputlen;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Wiimote::IOWrite(const unsigned char *buf, size_t len)
|
int Wiimote::IOWrite(const unsigned char *buf, size_t len)
|
||||||
@ -320,7 +320,7 @@ int Wiimote::IOWrite(const unsigned char *buf, size_t len)
|
|||||||
if (!IsConnected())
|
if (!IsConnected())
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
ret = [ichan writeAsync: const_cast<void*>((void *)buf) length: (int)len refcon: nil];
|
ret = [m_ichan writeAsync: const_cast<void*>((void *)buf) length: (int)len refcon: nil];
|
||||||
|
|
||||||
if (ret == kIOReturnSuccess)
|
if (ret == kIOReturnSuccess)
|
||||||
return len;
|
return len;
|
||||||
|
@ -37,7 +37,7 @@ Wiimote* g_wiimotes[MAX_BBMOTES];
|
|||||||
WiimoteScanner g_wiimote_scanner;
|
WiimoteScanner g_wiimote_scanner;
|
||||||
|
|
||||||
Wiimote::Wiimote()
|
Wiimote::Wiimote()
|
||||||
: index()
|
: m_index()
|
||||||
, m_last_input_report()
|
, m_last_input_report()
|
||||||
, m_channel(0)
|
, m_channel(0)
|
||||||
, m_rumble_state()
|
, m_rumble_state()
|
||||||
@ -140,7 +140,7 @@ void Wiimote::ControlChannel(const u16 channel, const void* const data, const u3
|
|||||||
if (hidp->type == HID_TYPE_SET_REPORT)
|
if (hidp->type == HID_TYPE_SET_REPORT)
|
||||||
{
|
{
|
||||||
u8 handshake_ok = HID_HANDSHAKE_SUCCESS;
|
u8 handshake_ok = HID_HANDSHAKE_SUCCESS;
|
||||||
Core::Callback_WiimoteInterruptChannel(index, channel, &handshake_ok, sizeof(handshake_ok));
|
Core::Callback_WiimoteInterruptChannel(m_index, channel, &handshake_ok, sizeof(handshake_ok));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -159,7 +159,7 @@ void Wiimote::InterruptChannel(const u16 channel, const void* const _data, const
|
|||||||
|
|
||||||
auto const data = static_cast<const u8*>(_data);
|
auto const data = static_cast<const u8*>(_data);
|
||||||
Report rpt(data, data + size);
|
Report rpt(data, data + size);
|
||||||
WiimoteEmu::Wiimote *const wm = (WiimoteEmu::Wiimote*)::Wiimote::GetConfig()->controllers[index];
|
WiimoteEmu::Wiimote *const wm = (WiimoteEmu::Wiimote*)::Wiimote::GetConfig()->controllers[m_index];
|
||||||
|
|
||||||
// Convert output DATA packets to SET_REPORT packets.
|
// Convert output DATA packets to SET_REPORT packets.
|
||||||
// Nintendo Wiimotes work without this translation, but 3rd
|
// Nintendo Wiimotes work without this translation, but 3rd
|
||||||
@ -202,7 +202,7 @@ bool Wiimote::Read()
|
|||||||
if (result > 0 && m_channel > 0)
|
if (result > 0 && m_channel > 0)
|
||||||
{
|
{
|
||||||
if (SConfig::GetInstance().m_LocalCoreStartupParameter.iBBDumpPort > 0 &&
|
if (SConfig::GetInstance().m_LocalCoreStartupParameter.iBBDumpPort > 0 &&
|
||||||
index == WIIMOTE_BALANCE_BOARD)
|
m_index == WIIMOTE_BALANCE_BOARD)
|
||||||
{
|
{
|
||||||
static sf::UdpSocket Socket;
|
static sf::UdpSocket Socket;
|
||||||
Socket.send((char*)rpt.data(),
|
Socket.send((char*)rpt.data(),
|
||||||
@ -218,7 +218,7 @@ bool Wiimote::Read()
|
|||||||
}
|
}
|
||||||
else if (0 == result)
|
else if (0 == result)
|
||||||
{
|
{
|
||||||
ERROR_LOG(WIIMOTE, "Wiimote::IORead failed. Disconnecting Wiimote %d.", index + 1);
|
ERROR_LOG(WIIMOTE, "Wiimote::IORead failed. Disconnecting Wiimote %d.", m_index + 1);
|
||||||
DisconnectInternal();
|
DisconnectInternal();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -235,7 +235,7 @@ bool Wiimote::Write()
|
|||||||
|
|
||||||
if (!is_speaker_data || m_last_audio_report.GetTimeDifference() > 5)
|
if (!is_speaker_data || m_last_audio_report.GetTimeDifference() > 5)
|
||||||
{
|
{
|
||||||
if (SConfig::GetInstance().m_LocalCoreStartupParameter.iBBDumpPort > 0 && index == WIIMOTE_BALANCE_BOARD)
|
if (SConfig::GetInstance().m_LocalCoreStartupParameter.iBBDumpPort > 0 && m_index == WIIMOTE_BALANCE_BOARD)
|
||||||
{
|
{
|
||||||
static sf::UdpSocket Socket;
|
static sf::UdpSocket Socket;
|
||||||
Socket.send((char*)rpt.data(), rpt.size(), sf::IpAddress::LocalHost, SConfig::GetInstance().m_LocalCoreStartupParameter.iBBDumpPort);
|
Socket.send((char*)rpt.data(), rpt.size(), sf::IpAddress::LocalHost, SConfig::GetInstance().m_LocalCoreStartupParameter.iBBDumpPort);
|
||||||
@ -290,7 +290,7 @@ void Wiimote::Update()
|
|||||||
{
|
{
|
||||||
if (!IsConnected())
|
if (!IsConnected())
|
||||||
{
|
{
|
||||||
HandleWiimoteDisconnect(index);
|
HandleWiimoteDisconnect(m_index);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -300,14 +300,14 @@ void Wiimote::Update()
|
|||||||
// Send the report
|
// Send the report
|
||||||
if (!rpt.empty() && m_channel > 0)
|
if (!rpt.empty() && m_channel > 0)
|
||||||
{
|
{
|
||||||
Core::Callback_WiimoteInterruptChannel(index, m_channel,
|
Core::Callback_WiimoteInterruptChannel(m_index, m_channel,
|
||||||
rpt.data(), (u32)rpt.size());
|
rpt.data(), (u32)rpt.size());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Wiimote::Prepare(int _index)
|
void Wiimote::Prepare(int _index)
|
||||||
{
|
{
|
||||||
index = _index;
|
m_index = _index;
|
||||||
m_need_prepare = true;
|
m_need_prepare = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -317,7 +317,7 @@ bool Wiimote::PrepareOnThread()
|
|||||||
u8 static const mode_report[] = {WM_SET_REPORT | WM_BT_OUTPUT, WM_REPORT_MODE, 0, WM_REPORT_CORE};
|
u8 static const mode_report[] = {WM_SET_REPORT | WM_BT_OUTPUT, WM_REPORT_MODE, 0, WM_REPORT_CORE};
|
||||||
|
|
||||||
// Set the active LEDs and turn on rumble.
|
// Set the active LEDs and turn on rumble.
|
||||||
u8 static const led_report[] = {WM_SET_REPORT | WM_BT_OUTPUT, WM_LEDS, u8(WIIMOTE_LED_1 << (index%WIIMOTE_BALANCE_BOARD) | 0x1)};
|
u8 static const led_report[] = {WM_SET_REPORT | WM_BT_OUTPUT, WM_LEDS, u8(WIIMOTE_LED_1 << (m_index%WIIMOTE_BALANCE_BOARD) | 0x1)};
|
||||||
|
|
||||||
// Turn off rumble
|
// Turn off rumble
|
||||||
u8 static const rumble_report[] = {WM_SET_REPORT | WM_BT_OUTPUT, WM_RUMBLE, 0};
|
u8 static const rumble_report[] = {WM_SET_REPORT | WM_BT_OUTPUT, WM_RUMBLE, 0};
|
||||||
@ -351,7 +351,7 @@ void Wiimote::EmuStop()
|
|||||||
|
|
||||||
void Wiimote::EmuResume()
|
void Wiimote::EmuResume()
|
||||||
{
|
{
|
||||||
WiimoteEmu::Wiimote *const wm = (WiimoteEmu::Wiimote*)::Wiimote::GetConfig()->controllers[index];
|
WiimoteEmu::Wiimote *const wm = (WiimoteEmu::Wiimote*)::Wiimote::GetConfig()->controllers[m_index];
|
||||||
|
|
||||||
m_last_input_report.clear();
|
m_last_input_report.clear();
|
||||||
|
|
||||||
@ -554,7 +554,7 @@ void Wiimote::ThreadFunc()
|
|||||||
m_need_prepare = false;
|
m_need_prepare = false;
|
||||||
if (!PrepareOnThread())
|
if (!PrepareOnThread())
|
||||||
{
|
{
|
||||||
ERROR_LOG(WIIMOTE, "Wiimote::PrepareOnThread failed. Disconnecting Wiimote %d.", index + 1);
|
ERROR_LOG(WIIMOTE, "Wiimote::PrepareOnThread failed. Disconnecting Wiimote %d.", m_index + 1);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -73,29 +73,29 @@ public:
|
|||||||
|
|
||||||
void QueueReport(u8 rpt_id, const void* data, unsigned int size);
|
void QueueReport(u8 rpt_id, const void* data, unsigned int size);
|
||||||
|
|
||||||
int index;
|
int m_index;
|
||||||
|
|
||||||
#if defined(__APPLE__)
|
#if defined(__APPLE__)
|
||||||
IOBluetoothDevice *btd;
|
IOBluetoothDevice *m_btd;
|
||||||
IOBluetoothL2CAPChannel *ichan;
|
IOBluetoothL2CAPChannel *m_ichan;
|
||||||
IOBluetoothL2CAPChannel *cchan;
|
IOBluetoothL2CAPChannel *m_cchan;
|
||||||
unsigned char* input;
|
unsigned char* m_input;
|
||||||
int inputlen;
|
int m_inputlen;
|
||||||
bool m_connected;
|
bool m_connected;
|
||||||
CFRunLoopRef m_wiimote_thread_run_loop;
|
CFRunLoopRef m_wiimote_thread_run_loop;
|
||||||
IOPMAssertionID m_pm_assertion;
|
IOPMAssertionID m_pm_assertion;
|
||||||
#elif defined(__linux__) && HAVE_BLUEZ
|
#elif defined(__linux__) && HAVE_BLUEZ
|
||||||
bdaddr_t bdaddr; // Bluetooth address
|
bdaddr_t m_bdaddr; // Bluetooth address
|
||||||
int cmd_sock; // Command socket
|
int m_cmd_sock; // Command socket
|
||||||
int int_sock; // Interrupt socket
|
int m_int_sock; // Interrupt socket
|
||||||
int wakeup_pipe_w, wakeup_pipe_r;
|
int m_wakeup_pipe_w, m_wakeup_pipe_r;
|
||||||
|
|
||||||
#elif defined(_WIN32)
|
#elif defined(_WIN32)
|
||||||
std::basic_string<TCHAR> devicepath; // Unique wiimote reference
|
std::basic_string<TCHAR> m_devicepath; // Unique wiimote reference
|
||||||
//ULONGLONG btaddr; // Bluetooth address
|
//ULONGLONG btaddr; // Bluetooth address
|
||||||
HANDLE dev_handle; // HID handle
|
HANDLE m_dev_handle; // HID handle
|
||||||
OVERLAPPED hid_overlap_read, hid_overlap_write; // Overlap handle
|
OVERLAPPED m_hid_overlap_read, m_hid_overlap_write; // Overlap handle
|
||||||
enum win_bt_stack_t stack; // Type of bluetooth stack to use
|
enum win_bt_stack_t m_stack; // Type of bluetooth stack to use
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user