예제 #1
0
Wiimote::~Wiimote()
{
	StopThread();
	ClearReadQueue();
	m_write_reports.Clear();
	TeardownInternal();
}
예제 #2
0
Wiimote::~Wiimote()
{
	RealDisconnect();

	ClearReadQueue();

	// clear write queue
	Report rpt;
	while (m_write_reports.Pop(rpt))
		delete[] rpt.first;
}
예제 #3
0
void Wiimote::InterruptChannel(const u16 channel, const void* const _data, const u32 size)
{
	// first interrupt/control channel sent
	if (channel != m_channel)
	{
		m_channel = channel;

		ClearReadQueue();

		EmuStart();
	}

	auto const data = static_cast<const u8*>(_data);
	Report rpt(data, data + size);
	WiimoteEmu::Wiimote *const wm = (WiimoteEmu::Wiimote*)::Wiimote::GetConfig()->controllers[m_index];

	// Convert output DATA packets to SET_REPORT packets.
	// Nintendo Wiimotes work without this translation, but 3rd
	// party ones don't.
	if (rpt[0] == 0xa2)
	{
		rpt[0] = WM_SET_REPORT | WM_BT_OUTPUT;
	}

	// Disallow games from turning off all of the LEDs.
	// It makes Wiimote connection status confusing.
	if (rpt[1] == WM_LEDS)
	{
		auto& leds_rpt = *reinterpret_cast<wm_leds*>(&rpt[2]);
		if (0 == leds_rpt.leds)
		{
			// Turn on ALL of the LEDs.
			leds_rpt.leds = 0xf;
		}
	}
	else if (rpt[1] == WM_WRITE_SPEAKER_DATA &&
	         (!SConfig::GetInstance().m_WiimoteEnableSpeaker ||
	         (!wm->m_status.speaker || wm->m_speaker_mute)))
	{
		// Translate speaker data reports into rumble reports.
		rpt[1] = WM_RUMBLE;
		// Keep only the rumble bit.
		rpt[2] &= 0x1;
		rpt.resize(3);
	}

	WriteReport(std::move(rpt));
}
예제 #4
0
void Wiimote::InterruptChannel(const u16 channel, const void* const data, const u32 size)
{
	if (0 == m_channel)	// first interrupt/control channel sent
	{
		ClearReadQueue();

		// request status
		wm_request_status rpt;
		rpt.rumble = 0;
		SendPacket(WM_REQUEST_STATUS, &rpt, sizeof(rpt));
	}

	m_channel = channel;	// this right?

	Report rpt;
	rpt.first = new u8[size];
	rpt.second = (u8)size;
	memcpy(rpt.first, (u8*)data, size);

	// some hax, since we just send the last data report to Dolphin on each Update() call
	// , make the wiimote only send updated data reports when data changes
	// == less bt traffic, eliminates some unneeded packets
	//if (WM_REPORT_MODE == ((u8*)data)[1])
	//{
	//	// also delete the last data report
	//	if (m_last_data_report.first)
	//	{
	//		delete[] m_last_data_report.first;
	//		m_last_data_report.first = NULL;
	//	}

	//	// nice var names :p, this seems to be this one
	//	((wm_report_mode*)(rpt.first + 2))->all_the_time = false;
	//	//((wm_report_mode*)(data + 2))->continuous = false;
	//}

 	if (rpt.first[0] == 0xa2 && rpt.first[1] == 0x18 && rpt.second == 23)
	{
		m_audio_reports.Push(rpt);
 		return;
 	}

	m_write_reports.Push(rpt);
}
예제 #5
0
void Wiimote::Shutdown()
{
	StopThread();
	ClearReadQueue();
	m_write_reports.Clear();
}