summaryrefslogtreecommitdiff
path: root/Source
diff options
context:
space:
mode:
authorGlenn Rice <glennricster@gmail.com>2010-07-07 02:19:16 +0000
committerGlenn Rice <glennricster@gmail.com>2010-07-07 02:19:16 +0000
commitc37bca75b656a6ecded15f7a6ab55856ff4f382a (patch)
tree6c1e1286ea6514a403dad822e947cff291ce1dd2 /Source
parent539f63b58b2be74d5d50323d3acc1a62f4cdd11e (diff)
Make the refresh button on the Wiimote New plugin add new wiimotes in linux, instead of disconnecting and reconnecting those that were already connected. This makes it possible to connect new wiimotes during a game by openning the wiimote configuration dialog and refreshing. You still need to tell dolphin that a new wiimote is connected using Ctrl+F5-F8 or the corresponding menu entries.
Also fixed a segmentation fault caused by the UDP Wiimote stuff when a thread was not properly ended. git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@5847 8ced0084-cf51-0410-be5f-012b33b47a6e
Diffstat (limited to 'Source')
-rw-r--r--Source/Core/InputCommon/Src/UDPWiimote.cpp1
-rw-r--r--Source/Plugins/Plugin_WiimoteNew/Src/WiimoteReal/WiimoteReal.cpp47
2 files changed, 48 insertions, 0 deletions
diff --git a/Source/Core/InputCommon/Src/UDPWiimote.cpp b/Source/Core/InputCommon/Src/UDPWiimote.cpp
index d48a58fdcb..7a5f586cfa 100644
--- a/Source/Core/InputCommon/Src/UDPWiimote.cpp
+++ b/Source/Core/InputCommon/Src/UDPWiimote.cpp
@@ -198,6 +198,7 @@ void UDPWiimote::mainThread()
UDPWiimote::~UDPWiimote()
{
d->exit=true;
+ d->thread->WaitForDeath();
d->termLock.Enter();
d->termLock.Leave();
for (std::list<sock_t>::iterator i=d->sockfds.begin(); i!=d->sockfds.end(); i++)
diff --git a/Source/Plugins/Plugin_WiimoteNew/Src/WiimoteReal/WiimoteReal.cpp b/Source/Plugins/Plugin_WiimoteNew/Src/WiimoteReal/WiimoteReal.cpp
index a352699812..0c88f4b4f4 100644
--- a/Source/Plugins/Plugin_WiimoteNew/Src/WiimoteReal/WiimoteReal.cpp
+++ b/Source/Plugins/Plugin_WiimoteNew/Src/WiimoteReal/WiimoteReal.cpp
@@ -102,6 +102,11 @@ Wiimote::Wiimote(wiimote_t* const wm, const unsigned int index)
//SendPacket(g_wiimotes_from_wiiuse[i], WM_LEDS, &rpt, sizeof(rpt));
//}
+ // Rumble briefly
+ wiiuse_rumble(m_wiimote, 1);
+ SLEEP(200);
+ wiiuse_rumble(m_wiimote, 0);
+
// set LEDs
wiiuse_set_leds(m_wiimote, WIIMOTE_LED_1 << m_index);
@@ -340,12 +345,54 @@ void Shutdown(void)
wiiuse_cleanup(g_wiimotes_from_wiiuse, MAX_WIIMOTES);
}
+#ifdef __linux__
+void Refresh()
+{
+ // find the number of slots configured for real wiimotes
+ unsigned int wanted_wiimotes = 0;
+ for (unsigned int i = 0; i < MAX_WIIMOTES; ++i)
+ if (g_wiimote_sources[i] == WIIMOTE_SRC_REAL)
+ ++wanted_wiimotes;
+
+ // don't scan for wiimotes if we don't want any more
+ if (wanted_wiimotes <= g_wiimotes_found)
+ return;
+
+ // scan for wiimotes
+ unsigned int num_wiimotes = wiiuse_find_more(g_wiimotes_from_wiiuse, wanted_wiimotes, 5);
+
+ DEBUG_LOG(WIIMOTE, "Found %i Real Wiimotes, %i wanted", num_wiimotes, wanted_wiimotes);
+
+ int num_new_wiimotes = wiiuse_connect(g_wiimotes_from_wiiuse, num_wiimotes);
+
+ DEBUG_LOG(WIIMOTE, "Connected to %i additional Real Wiimotes", num_new_wiimotes);
+
+ g_wiimote_critsec.Enter(); // enter
+
+ // create real wiimote class instances, and assign wiimotes for the new wiimotes
+ for (unsigned int i = g_wiimotes_found, w = g_wiimotes_found;
+ i < MAX_WIIMOTES && w < num_wiimotes; ++i)
+ {
+ if (g_wiimote_sources[i] != WIIMOTE_SRC_REAL || g_wiimotes[i] != NULL)
+ continue;
+
+ // create/assign wiimote
+ g_wiimotes[i] = new Wiimote(g_wiimotes_from_wiiuse[w++], i);
+ }
+ g_wiimotes_found = num_wiimotes;
+
+ g_wiimote_critsec.Leave(); // leave
+
+ return;
+}
+#else
void Refresh()
{
// should be fine i think
Shutdown();
Initialize();
}
+#endif
void InterruptChannel(int _WiimoteNumber, u16 _channelID, const void* _pData, u32 _Size)
{