[supertuxkart] Adding a Wiimote with other one alredy placed (asked Richard Shaw)

Igor Gnatenko ignatenkobrain at fedoraproject.org
Sun May 25 13:00:37 UTC 2014


commit bd15c663ec86b5ebcbd20bacff81f4627d15501e
Author: Igor Gnatenko <i.gnatenko.brain at gmail.com>
Date:   Sun May 25 17:00:27 2014 +0400

    Adding a Wiimote with other one alredy placed (asked Richard Shaw)
    
    Signed-off-by: Igor Gnatenko <i.gnatenko.brain at gmail.com>

 ...ix-.desktop-file-and-install-destinations.patch |    4 +-
 0002-unbundle-bullet.patch                         |    4 +-
 0003-unbundle-enet.patch                           |    4 +-
 0004-unbundle-irrlicht.patch                       |    4 +-
 0005-unbundle-wiiuse.patch                         |    4 +-
 ...imote-with-other-one-alredy-placed-Bug-12.patch |  127 ++++++++++++++++++++
 supertuxkart.spec                                  |   13 ++-
 7 files changed, 147 insertions(+), 13 deletions(-)
---
diff --git a/0001-fix-.desktop-file-and-install-destinations.patch b/0001-fix-.desktop-file-and-install-destinations.patch
index 1404ae4..9cfb6c7 100644
--- a/0001-fix-.desktop-file-and-install-destinations.patch
+++ b/0001-fix-.desktop-file-and-install-destinations.patch
@@ -1,7 +1,7 @@
 From 434083d5647ae052693eff559acbd08de09cbc37 Mon Sep 17 00:00:00 2001
 From: Igor Gnatenko <i.gnatenko.brain at gmail.com>
 Date: Sun, 11 May 2014 22:58:04 +0400
-Subject: [PATCH 1/5] fix .desktop file and install destinations
+Subject: [PATCH 1/6] fix .desktop file and install destinations
 
 Signed-off-by: Igor Gnatenko <i.gnatenko.brain at gmail.com>
 ---
@@ -69,5 +69,5 @@ index aeb48ab..0000000
 -TryExec=@PREFIX@/@STK_INSTALL_BINARY_DIR@/supertuxkart
 -Categories=Game;ArcadeGame;
 -- 
-1.9.0
+1.9.3
 
diff --git a/0002-unbundle-bullet.patch b/0002-unbundle-bullet.patch
index 75fd37f..47fe557 100644
--- a/0002-unbundle-bullet.patch
+++ b/0002-unbundle-bullet.patch
@@ -1,7 +1,7 @@
 From 01468f607b03ba612aa9fb401641e611092915cd Mon Sep 17 00:00:00 2001
 From: Igor Gnatenko <i.gnatenko.brain at gmail.com>
 Date: Sun, 11 May 2014 22:59:28 +0400
-Subject: [PATCH 2/5] unbundle bullet
+Subject: [PATCH 2/6] unbundle bullet
 
 Signed-off-by: Igor Gnatenko <i.gnatenko.brain at gmail.com>
 ---
@@ -114,5 +114,5 @@ index fcff1f0..b49446a 100644
          unsigned int num_contacts = contact_manifold->getNumContacts();
          if(!num_contacts) continue;   // no real collision
 -- 
-1.9.0
+1.9.3
 
diff --git a/0003-unbundle-enet.patch b/0003-unbundle-enet.patch
index ed4906a..6ec84ad 100644
--- a/0003-unbundle-enet.patch
+++ b/0003-unbundle-enet.patch
@@ -1,7 +1,7 @@
 From f71003a718a75843a4936702ec3c2bd90e804e3f Mon Sep 17 00:00:00 2001
 From: Igor Gnatenko <i.gnatenko.brain at gmail.com>
 Date: Wed, 14 May 2014 16:28:29 +0400
-Subject: [PATCH 3/5] unbundle enet
+Subject: [PATCH 3/6] unbundle enet
 
 Signed-off-by: Igor Gnatenko <i.gnatenko.brain at gmail.com>
 ---
@@ -90,5 +90,5 @@ index 0000000..b6c146c
 +MARK_AS_ADVANCED(ENet_LIBRARY ENet_LIBRARIES ENet_INCLUDE_DIRS)
 +
 -- 
-1.9.0
+1.9.3
 
diff --git a/0004-unbundle-irrlicht.patch b/0004-unbundle-irrlicht.patch
index c2ca27b..afa30a7 100644
--- a/0004-unbundle-irrlicht.patch
+++ b/0004-unbundle-irrlicht.patch
@@ -1,7 +1,7 @@
 From d86ff9a4e8ee4d7df53f26a686a0e4defcd749be Mon Sep 17 00:00:00 2001
 From: Igor Gnatenko <i.gnatenko.brain at gmail.com>
 Date: Wed, 14 May 2014 16:39:13 +0400
-Subject: [PATCH 4/5] unbundle irrlicht
+Subject: [PATCH 4/6] unbundle irrlicht
 
 Signed-off-by: Igor Gnatenko <i.gnatenko.brain at gmail.com>
 ---
@@ -139,5 +139,5 @@ index 0000000..8c94ec2
 +
 +MARK_AS_ADVANCED(IRRLICHT_LIBRARY IRRLICHT_INCLUDE_DIR IRRLICHT_DLL)
 -- 
-1.9.0
+1.9.3
 
diff --git a/0005-unbundle-wiiuse.patch b/0005-unbundle-wiiuse.patch
index 414145a..67eae80 100644
--- a/0005-unbundle-wiiuse.patch
+++ b/0005-unbundle-wiiuse.patch
@@ -1,7 +1,7 @@
 From f67c7bee8b308c2e8427154cee2ab9290befca7d Mon Sep 17 00:00:00 2001
 From: Igor Gnatenko <i.gnatenko.brain at gmail.com>
 Date: Wed, 14 May 2014 16:44:37 +0400
-Subject: [PATCH 5/5] unbundle wiiuse
+Subject: [PATCH 5/6] unbundle wiiuse
 
 Signed-off-by: Igor Gnatenko <i.gnatenko.brain at gmail.com>
 ---
@@ -142,5 +142,5 @@ index 0000000..2657cbb
 +	WIIUSE_LIBRARY
 +	WIIUSE_RUNTIME_LIBRARY)
 -- 
-1.9.0
+1.9.3
 
diff --git a/0006-Adding-a-Wiimote-with-other-one-alredy-placed-Bug-12.patch b/0006-Adding-a-Wiimote-with-other-one-alredy-placed-Bug-12.patch
new file mode 100644
index 0000000..38a3226
--- /dev/null
+++ b/0006-Adding-a-Wiimote-with-other-one-alredy-placed-Bug-12.patch
@@ -0,0 +1,127 @@
+From 1eb131f4d3b7f9cb160c2c525208e75780c439ac Mon Sep 17 00:00:00 2001
+From: pgabor <peterffy95 at gmail.com>
+Date: Sat, 15 Mar 2014 21:15:04 +0100
+Subject: [PATCH 6/6] Adding a Wiimote with other one alredy placed - Bug:
+ #1209 fixed
+
+(cherry picked from commit f84f49dfc8ae9b407ecb2794aef0cef26de531b7)
+---
+ src/input/wiimote_manager.cpp | 78 ++++++++++++++++++++++++++++++++++++++++++-
+ 1 file changed, 77 insertions(+), 1 deletion(-)
+
+diff --git a/src/input/wiimote_manager.cpp b/src/input/wiimote_manager.cpp
+index 61be4e0..0203c74 100644
+--- a/src/input/wiimote_manager.cpp
++++ b/src/input/wiimote_manager.cpp
+@@ -17,6 +17,7 @@
+ //  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ 
+ #ifdef ENABLE_WIIUSE
++#define WCONST
+ 
+ #include "input/wiimote_manager.hpp"
+ 
+@@ -60,24 +61,99 @@ WiimoteManager::~WiimoteManager()
+  */
+ void WiimoteManager::launchDetection(int timeout)
+ {
++  // It's only needed on systems with bluez, because wiiuse_find does not find alredy connected wiimotes
++#ifdef WIIUSE_BLUEZ
++    //Cleans up the config and the disconnected wiimotes
++    int number_previous_wiimotes = 0;
++    wiimote_t** previous_wiimotes = (wiimote_t**) malloc(sizeof(struct wiimote_t*) * MAX_WIIMOTES);
++    memset(previous_wiimotes,0,sizeof(struct wiimote_t*) * MAX_WIIMOTES);
++    for (unsigned int i = 0; i < m_wiimotes.size(); i++)
++    {
++      if (WIIMOTE_IS_CONNECTED(m_all_wiimote_handles[i]))
++      {
++        previous_wiimotes[i]=m_all_wiimote_handles[i];
++        m_all_wiimote_handles[i] = NULL;
++        number_previous_wiimotes++;
++      }
++    }
++
++    //To prevent segmentation fault, have to delete NULLs
++    wiimote_t** deletable_wiimotes = (wiimote_t**) malloc(sizeof(struct wiimote_t*) * (m_wiimotes.size()-number_previous_wiimotes));
++    memset(deletable_wiimotes,0,sizeof(struct wiimote_t*) * (m_wiimotes.size()-number_previous_wiimotes));
++    int number_deletables = 0;
++    for (unsigned int i = 0; i < m_wiimotes.size(); i++)
++    {
++      if (m_all_wiimote_handles[i] != NULL)
++      {
++        deletable_wiimotes[number_deletables++] = m_all_wiimote_handles[i];
++      }
++    }
++    m_all_wiimote_handles = wiiuse_init(MAX_WIIMOTES);
++    wiiuse_cleanup(deletable_wiimotes, number_deletables);
++
++#endif
++
+     // Stop WiiUse, remove wiimotes, gamepads, gamepad configs.
+     cleanup();
+ 
+-    m_all_wiimote_handles =  wiiuse_init(MAX_WIIMOTES);
++    m_all_wiimote_handles = wiiuse_init(MAX_WIIMOTES);
+ 
+     // Detect wiimotes
+     int nb_found_wiimotes = wiiuse_find(m_all_wiimote_handles, MAX_WIIMOTES, timeout);
+ 
++#ifndef WIIUSE_BLUEZ
+     // Couldn't find any wiimote?
+     if(nb_found_wiimotes == 0)
+         return;
++#endif
++
++#ifdef WIIUSE_BLUEZ
++    // Couldn't find any wiimote?
++    if(nb_found_wiimotes + number_previous_wiimotes == 0)
++        return;
++#endif
+ 
+     // Try to connect to all found wiimotes
+     int nb_wiimotes = wiiuse_connect(m_all_wiimote_handles, nb_found_wiimotes);
+ 
++#ifndef WIIUSE_BLUEZ
+     // Couldn't connect to any wiimote?
+     if(nb_wiimotes == 0)
+         return;
++#endif
++
++#ifdef WIIUSE_BLUEZ
++    // Couldn't connect to any wiimote?
++    if(nb_wiimotes + number_previous_wiimotes == 0)
++        return;
++
++    //Merges previous and new wiimote's list
++    int number_merged_wiimotes = 0;
++    for (int i = 0; i < number_previous_wiimotes && i + nb_wiimotes < MAX_WIIMOTES; i++)
++    {
++      m_all_wiimote_handles[i+nb_wiimotes] = previous_wiimotes[i];
++      previous_wiimotes[i] = NULL;
++      m_all_wiimote_handles[i]->unid = nb_wiimotes+i+1;
++      number_merged_wiimotes++;
++    }
++    nb_wiimotes += number_merged_wiimotes;
++
++    //To prevent segmentation fault, have to delete NULLs
++    number_deletables = 0;
++    number_deletables = 0;
++    deletable_wiimotes = (wiimote_t**) malloc(sizeof(struct wiimote_t*) * (number_previous_wiimotes-number_merged_wiimotes));
++    memset(deletable_wiimotes,0,sizeof(struct wiimote_t*) * (number_previous_wiimotes-number_merged_wiimotes));
++    for (int i = 0; i < number_previous_wiimotes; i++)
++    {
++      if (previous_wiimotes[i] != NULL)
++      {
++        deletable_wiimotes[number_deletables++] = previous_wiimotes[i];
++      }
++    }
++    // Cleans up wiimotes which ones didn't fit in limit
++    wiiuse_cleanup(deletable_wiimotes, number_deletables);
++
++#endif
+ 
+     // ---------------------------------------------------
+     // Create or find a GamepadConfig for all wiimotes
+-- 
+1.9.3
+
diff --git a/supertuxkart.spec b/supertuxkart.spec
index bb3e5dc..ddd4c74 100644
--- a/supertuxkart.spec
+++ b/supertuxkart.spec
@@ -1,6 +1,6 @@
 Name:           supertuxkart
 Version:        0.8.1
-Release:        5%{?dist}
+Release:        6%{?dist}
 Summary:        Kids 3D go-kart racing game featuring Tux
 Group:          Amusements/Games
 License:        GPLv2+ and GPLv3 and CC-BY-SA
@@ -15,6 +15,7 @@ Patch2:         0002-unbundle-bullet.patch
 Patch3:         0003-unbundle-enet.patch
 Patch4:         0004-unbundle-irrlicht.patch
 Patch5:         0005-unbundle-wiiuse.patch
+Patch6:         0006-Adding-a-Wiimote-with-other-one-alredy-placed-Bug-12.patch
 BuildRequires:  cmake
 BuildRequires:  libvorbis-devel freeglut-devel desktop-file-utils
 BuildRequires:  openal-soft-devel freealut-devel >= 1.1.0-10 libtool
@@ -67,8 +68,8 @@ cd build
 ln -s opengl-game-wrapper.sh %{buildroot}%{_bindir}/%{name}-wrapper
 
 # add the manpage (courtesy of Debian)
-mkdir -p $RPM_BUILD_ROOT%{_mandir}/man6
-install -p -m 644 %{SOURCE1} $RPM_BUILD_ROOT%{_mandir}/man6
+mkdir -p %{buildroot}%{_mandir}/man6
+install -p -m 644 %{SOURCE1} %{buildroot}%{_mandir}/man6
 
 %post
 touch --no-create %{_datadir}/icons/hicolor &>/dev/null || :
@@ -82,6 +83,9 @@ fi
 %posttrans
 gtk-update-icon-cache %{_datadir}/icons/hicolor &>/dev/null || :
 
+%check
+desktop-file-validate %{buildroot}%{_datadir}/applications/*%{name}.desktop
+
 %files
 %doc AUTHORS COPYING ChangeLog README TODO supertuxkart-0.7.3-license-clarification.txt
 %{_bindir}/%{name}*
@@ -93,6 +97,9 @@ gtk-update-icon-cache %{_datadir}/icons/hicolor &>/dev/null || :
 %{_datadir}/%{name}
 
 %changelog
+* Sun May 25 2014 Igor Gnatenko <i.gnatenko.brain at gmail.com> - 0.8.1-6
+- Adding a Wiimote with other one alredy placed (asked Richard Shaw)
+
 * Wed May 14 2014 Igor Gnatenko <i.gnatenko.brain at gmail.com> - 0.8.1-5
 - fix building with old bullet
 


More information about the scm-commits mailing list