
Untitled
By: a guest on
May 4th, 2012 | syntax:
None | size: 2.37 KB | hits: 17 | expires: Never
Index: Source/Plugins/Plugin_WiimoteNew/Src/WiimoteReal/WiimoteReal.cpp
===================================================================
--- Source/Plugins/Plugin_WiimoteNew/Src/WiimoteReal/WiimoteReal.cpp (revision 5827)
+++ Source/Plugins/Plugin_WiimoteNew/Src/WiimoteReal/WiimoteReal.cpp (working copy)
@@ -79,6 +79,8 @@
u8 m_last_data_report[MAX_PAYLOAD];
bool m_last_data_report_valid;
+ bool m_is_connected;
+
std::queue<u8*> m_reports;
};
@@ -87,6 +89,7 @@
, m_index(index)
, m_channel(0)
, m_last_data_report_valid(false)
+ , m_is_connected(false)
{
{
// disable reporting
@@ -98,12 +101,6 @@
// clear all msgs, silly maybe
while (wiiuse_io_read(m_wiimote));
- {
- // request status, will be sent to game on start
- wm_request_status rpt = wm_request_status();
- SendPacket(m_wiimote, WM_REQUEST_STATUS, &rpt, sizeof(rpt));
- }
-
//{
// LEDs test
//wm_leds rpt = wm_leds();
@@ -113,6 +110,8 @@
// set LEDs
wiiuse_set_leds(m_wiimote, WIIMOTE_LED_1 << m_index);
+
+ // TODO: make Dolphin connect wiimote, maybe
}
Wiimote::~Wiimote()
@@ -134,6 +133,7 @@
void Wiimote::ClearReports()
{
+ m_last_data_report_valid = false;
while (m_reports.size())
{
delete[] m_reports.front();
@@ -158,10 +158,9 @@
void Wiimote::Read()
{
- if (!m_channel)
- return;
-
if (wiiuse_io_read(m_wiimote))
+ // if not connected to Dolphin just drop all the packets
+ if (m_is_connected)
{
// a data report, save it
if (m_wiimote->event_buf[1] >= 0x30)
@@ -181,6 +180,15 @@
void Wiimote::Update()
{
+ if (false == m_is_connected)
+ {
+ // request status
+ wm_request_status rpt = wm_request_status();
+ SendPacket(m_wiimote, WM_REQUEST_STATUS, &rpt, sizeof(rpt));
+
+ m_is_connected = true;
+ }
+
// do we have some queued reports
if (m_reports.size())
{
@@ -198,6 +206,8 @@
void Wiimote::Disconnect()
{
+ m_is_connected = false;
+
{
// disable reporting
wm_report_mode rpt = wm_report_mode();
@@ -206,7 +216,6 @@
}
// clear queue
- m_last_data_report_valid = false;
ClearReports();
// clear out wiiuse queue, or maybe not, silly? idk
@@ -378,6 +387,8 @@
THREAD_RETURN WiimoteThreadFunc(void* arg)
{
+ Common::SetCurrentThreadName("Wiimote Read");
+
while (g_run_wiimote_thread)
{
g_wiimote_critsec.Enter(); // enter