mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-23 14:19:46 -06:00
Merge remote-tracking branch 'adlr/macwiimote'
This commit is contained in:
@ -127,11 +127,6 @@ int FindWiimotes(Wiimote **wm, int max_wiimotes)
|
|||||||
bti = [[IOBluetoothDeviceInquiry alloc] init];
|
bti = [[IOBluetoothDeviceInquiry alloc] init];
|
||||||
[bti setDelegate: sbt];
|
[bti setDelegate: sbt];
|
||||||
[bti setInquiryLength: 5];
|
[bti setInquiryLength: 5];
|
||||||
[bti setSearchCriteria: kBluetoothServiceClassMajorAny
|
|
||||||
majorDeviceClass: kBluetoothDeviceClassMajorPeripheral
|
|
||||||
minorDeviceClass: kBluetoothDeviceClassMinorAny
|
|
||||||
];
|
|
||||||
[bti setUpdateNewDeviceNames: NO];
|
|
||||||
|
|
||||||
if ([bti start] == kIOReturnSuccess)
|
if ([bti start] == kIOReturnSuccess)
|
||||||
[bti retain];
|
[bti retain];
|
||||||
@ -149,6 +144,9 @@ int FindWiimotes(Wiimote **wm, int max_wiimotes)
|
|||||||
en = [[bti foundDevices] objectEnumerator];
|
en = [[bti foundDevices] objectEnumerator];
|
||||||
for (int i = 0; i < found_devices; i++)
|
for (int i = 0; i < found_devices; i++)
|
||||||
{
|
{
|
||||||
|
IOBluetoothDevice *dev = [en nextObject];
|
||||||
|
if (!IsValidBluetoothName([[dev name] UTF8String]))
|
||||||
|
continue;
|
||||||
// Find an unused slot
|
// Find an unused slot
|
||||||
for (int k = 0; k < MAX_WIIMOTES; k++) {
|
for (int k = 0; k < MAX_WIIMOTES; k++) {
|
||||||
if (wm[k] != NULL ||
|
if (wm[k] != NULL ||
|
||||||
@ -156,7 +154,7 @@ int FindWiimotes(Wiimote **wm, int max_wiimotes)
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
wm[k] = new Wiimote(k);
|
wm[k] = new Wiimote(k);
|
||||||
wm[k]->btd = [en nextObject];
|
wm[k]->btd = dev;
|
||||||
found_wiimotes++;
|
found_wiimotes++;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -177,10 +175,6 @@ bool Wiimote::Connect()
|
|||||||
if (IsConnected())
|
if (IsConnected())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if ([btd remoteNameRequest:nil] == kIOReturnSuccess)
|
|
||||||
m_motion_plus_inside =
|
|
||||||
static_cast<bool>([[btd getName] hasSuffix:@"-TR"]);
|
|
||||||
|
|
||||||
[btd openL2CAPChannelSync: &cchan
|
[btd openL2CAPChannelSync: &cchan
|
||||||
withPSM: kBluetoothL2CAPPSMHIDControl delegate: cbt];
|
withPSM: kBluetoothL2CAPPSMHIDControl delegate: cbt];
|
||||||
[btd openL2CAPChannelSync: &ichan
|
[btd openL2CAPChannelSync: &ichan
|
||||||
|
@ -50,7 +50,6 @@ Wiimote::Wiimote(const unsigned int _index)
|
|||||||
#endif
|
#endif
|
||||||
, leds(0), m_last_data_report(Report((u8 *)NULL, 0))
|
, leds(0), m_last_data_report(Report((u8 *)NULL, 0))
|
||||||
, m_channel(0), m_connected(false)
|
, m_channel(0), m_connected(false)
|
||||||
, m_motion_plus_inside(false)
|
|
||||||
{
|
{
|
||||||
#if defined(__linux__) && HAVE_BLUEZ
|
#if defined(__linux__) && HAVE_BLUEZ
|
||||||
bdaddr = (bdaddr_t){{0, 0, 0, 0, 0, 0}};
|
bdaddr = (bdaddr_t){{0, 0, 0, 0, 0, 0}};
|
||||||
@ -143,16 +142,16 @@ void Wiimote::InterruptChannel(const u16 channel, const void* const data, const
|
|||||||
rpt.second = (u8)size;
|
rpt.second = (u8)size;
|
||||||
memcpy(rpt.first, (u8*)data, size);
|
memcpy(rpt.first, (u8*)data, size);
|
||||||
|
|
||||||
// Convert output DATA packets to SET_REPORT packets for non-TR
|
// Convert output DATA packets to SET_REPORT packets.
|
||||||
// Wiimotes. Nintendo Wiimotes work without this translation, but 3rd
|
// Nintendo Wiimotes work without this translation, but 3rd
|
||||||
// party ones don't.
|
// party ones don't.
|
||||||
u8 head = m_motion_plus_inside ? 0xa2 : 0x52;
|
|
||||||
if (rpt.first[0] == 0xa2)
|
if (rpt.first[0] == 0xa2)
|
||||||
{
|
{
|
||||||
rpt.first[0] = head;
|
rpt.first[0] = WM_SET_REPORT | WM_BT_OUTPUT;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rpt.first[0] == head && rpt.first[1] == 0x18 && rpt.second == 23)
|
if (rpt.first[0] == (WM_SET_REPORT | WM_BT_OUTPUT) &&
|
||||||
|
rpt.first[1] == 0x18 && rpt.second == 23)
|
||||||
{
|
{
|
||||||
m_audio_reports.Push(rpt);
|
m_audio_reports.Push(rpt);
|
||||||
return;
|
return;
|
||||||
@ -513,4 +512,19 @@ void StateChange(EMUSTATE_CHANGE newState)
|
|||||||
// TODO: disable/enable auto reporting, maybe
|
// TODO: disable/enable auto reporting, maybe
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define ARRAYSIZE(_arr) (sizeof(_arr)/(sizeof(_arr[0])))
|
||||||
|
|
||||||
|
bool IsValidBluetoothName(const char* name) {
|
||||||
|
static const char* kValidWiiRemoteBluetoothNames[] = {
|
||||||
|
"Nintendo RVL-CNT-01",
|
||||||
|
"Nintendo RVL-CNT-01-TR",
|
||||||
|
"Nintendo RVL-WBC-01",
|
||||||
|
};
|
||||||
|
for (size_t i = 0; i < ARRAYSIZE(kValidWiiRemoteBluetoothNames); i++)
|
||||||
|
if (strcmp(name, kValidWiiRemoteBluetoothNames[i]) == 0)
|
||||||
|
return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}; // end of namespace
|
}; // end of namespace
|
||||||
|
@ -95,7 +95,6 @@ private:
|
|||||||
void ThreadFunc();
|
void ThreadFunc();
|
||||||
|
|
||||||
bool m_connected;
|
bool m_connected;
|
||||||
bool m_motion_plus_inside;
|
|
||||||
std::thread m_wiimote_thread;
|
std::thread m_wiimote_thread;
|
||||||
Common::FifoQueue<Report> m_read_reports;
|
Common::FifoQueue<Report> m_read_reports;
|
||||||
Common::FifoQueue<Report> m_write_reports;
|
Common::FifoQueue<Report> m_write_reports;
|
||||||
@ -114,6 +113,8 @@ void StateChange(EMUSTATE_CHANGE newState);
|
|||||||
|
|
||||||
int FindWiimotes(Wiimote** wm, int max_wiimotes);
|
int FindWiimotes(Wiimote** wm, int max_wiimotes);
|
||||||
|
|
||||||
|
bool IsValidBluetoothName(const char* name);
|
||||||
|
|
||||||
}; // WiimoteReal
|
}; // WiimoteReal
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -32,7 +32,14 @@
|
|||||||
#define WM_OUTPUT_CHANNEL 0x11
|
#define WM_OUTPUT_CHANNEL 0x11
|
||||||
#define WM_INPUT_CHANNEL 0x13
|
#define WM_INPUT_CHANNEL 0x13
|
||||||
|
|
||||||
|
// The 4 most significant bits of the first byte of an outgoing command must be
|
||||||
|
// 0x50 if sending on the command channel and 0xA0 if sending on the interrupt
|
||||||
|
// channel. On Mac we use interrupt channel; on Windows/Linux, command.
|
||||||
|
#ifndef __APPLE__
|
||||||
#define WM_SET_REPORT 0x50
|
#define WM_SET_REPORT 0x50
|
||||||
|
#else
|
||||||
|
#define WM_SET_REPORT 0xA0
|
||||||
|
#endif
|
||||||
|
|
||||||
// Commands
|
// Commands
|
||||||
#define WM_CMD_RUMBLE 0x10
|
#define WM_CMD_RUMBLE 0x10
|
||||||
|
Reference in New Issue
Block a user