Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 4th, 2012  |  syntax: None  |  size: 2.37 KB  |  hits: 17  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Index: Source/Plugins/Plugin_WiimoteNew/Src/WiimoteReal/WiimoteReal.cpp
  2. ===================================================================
  3. --- Source/Plugins/Plugin_WiimoteNew/Src/WiimoteReal/WiimoteReal.cpp    (revision 5827)
  4. +++ Source/Plugins/Plugin_WiimoteNew/Src/WiimoteReal/WiimoteReal.cpp    (working copy)
  5. @@ -79,6 +79,8 @@
  6.         u8              m_last_data_report[MAX_PAYLOAD];
  7.         bool    m_last_data_report_valid;
  8.  
  9. +       bool    m_is_connected;
  10. +
  11.         std::queue<u8*>         m_reports;
  12.  };
  13.  
  14. @@ -87,6 +89,7 @@
  15.         , m_index(index)
  16.         , m_channel(0)
  17.         , m_last_data_report_valid(false)
  18. +       , m_is_connected(false)
  19.  {
  20.         {
  21.         // disable reporting
  22. @@ -98,12 +101,6 @@
  23.         // clear all msgs, silly maybe
  24.         while (wiiuse_io_read(m_wiimote));
  25.  
  26. -       {
  27. -       // request status, will be sent to game on start
  28. -       wm_request_status rpt = wm_request_status();
  29. -       SendPacket(m_wiimote, WM_REQUEST_STATUS, &rpt, sizeof(rpt));
  30. -       }
  31. -
  32.         //{
  33.         // LEDs test
  34.         //wm_leds       rpt = wm_leds();
  35. @@ -113,6 +110,8 @@
  36.  
  37.         // set LEDs
  38.         wiiuse_set_leds(m_wiimote, WIIMOTE_LED_1 << m_index);
  39. +
  40. +       // TODO: make Dolphin connect wiimote, maybe
  41.  }
  42.  
  43.  Wiimote::~Wiimote()
  44. @@ -134,6 +133,7 @@
  45.  
  46.  void Wiimote::ClearReports()
  47.  {
  48. +       m_last_data_report_valid = false;
  49.         while (m_reports.size())
  50.         {
  51.                 delete[] m_reports.front();
  52. @@ -158,10 +158,9 @@
  53.  
  54.  void Wiimote::Read()
  55.  {
  56. -       if (!m_channel)
  57. -               return;
  58. -
  59.         if (wiiuse_io_read(m_wiimote))
  60. +       // if not connected to Dolphin just drop all the packets
  61. +       if (m_is_connected)
  62.         {
  63.                 // a data report, save it
  64.                 if (m_wiimote->event_buf[1] >= 0x30)
  65. @@ -181,6 +180,15 @@
  66.  
  67.  void Wiimote::Update()
  68.  {
  69. +       if (false == m_is_connected)
  70. +       {
  71. +               // request status
  72. +               wm_request_status rpt = wm_request_status();
  73. +               SendPacket(m_wiimote, WM_REQUEST_STATUS, &rpt, sizeof(rpt));
  74. +
  75. +               m_is_connected = true;
  76. +       }
  77. +
  78.         // do we have some queued reports
  79.         if (m_reports.size())
  80.         {
  81. @@ -198,6 +206,8 @@
  82.  
  83.  void Wiimote::Disconnect()
  84.  {
  85. +       m_is_connected = false;
  86. +
  87.         {
  88.         // disable reporting
  89.         wm_report_mode rpt = wm_report_mode();
  90. @@ -206,7 +216,6 @@
  91.         }      
  92.  
  93.         // clear queue
  94. -       m_last_data_report_valid = false;
  95.         ClearReports();
  96.  
  97.         // clear out wiiuse queue, or maybe not, silly? idk
  98. @@ -378,6 +387,8 @@
  99.  
  100.  THREAD_RETURN WiimoteThreadFunc(void* arg)
  101.  {
  102. +       Common::SetCurrentThreadName("Wiimote Read");
  103. +
  104.         while (g_run_wiimote_thread)
  105.         {
  106.                 g_wiimote_critsec.Enter();      // enter