From: <ba...@us...> - 2006-06-11 23:35:18
|
Revision: 343 Author: bardtx Date: 2006-06-11 16:35:13 -0700 (Sun, 11 Jun 2006) ViewCVS: http://svn.sourceforge.net/cadcdev/?rev=343&view=rev Log Message: ----------- tiki: process genmenu input events in main thread, to make standard Tsunami-style input/drawable interactions simpler Modified Paths: -------------- tiki/include/Tiki/genmenu.h tiki/src/gl/genmenu.cpp Modified: tiki/include/Tiki/genmenu.h =================================================================== --- tiki/include/Tiki/genmenu.h 2006-06-11 23:33:14 UTC (rev 342) +++ tiki/include/Tiki/genmenu.h 2006-06-11 23:35:13 UTC (rev 343) @@ -13,6 +13,7 @@ #include "Tiki/refcnt.h" #include "Tiki/drawables/layer.h" #include "Tiki/hid.h" +#include "Tiki/eventCollector.h" #include "Tiki/oggvorbis.h" /* @@ -64,7 +65,6 @@ protected: // HID input callback. - static void hidCallback(const Hid::Event & evt, void * data); virtual void processHidEvent(const Hid::Event & evt); // Called once per frame to update the screen. Generally no need @@ -136,6 +136,10 @@ // The time of the last frame rendered uint64 m_lastTime; + + // Event collector object, so we can process incoming events + // in the drawing thread. + RefPtr<Hid::EventCollector> m_ec; }; } Modified: tiki/src/gl/genmenu.cpp =================================================================== --- tiki/src/gl/genmenu.cpp 2006-06-11 23:33:14 UTC (rev 342) +++ tiki/src/gl/genmenu.cpp 2006-06-11 23:35:13 UTC (rev 343) @@ -56,17 +56,15 @@ m_postDelay = 0; - m_startTime=m_lastTime=Time::gettime(); + m_startTime = m_lastTime = Time::gettime(); + + m_ec = new Hid::EventCollector(false); } GenericMenu::~GenericMenu() { } void GenericMenu::doMenu() { - // Register us for HID input callbacks. - int hidCookie = Hid::callbackReg(hidCallback, this); - assert( hidCookie >= 0 ); - // Start background music if necessary if (m_usebgm) { m_bgm = new VorbisStream(); @@ -77,6 +75,9 @@ // Reset our timeout resetTimeout(); + // And start collecting events. + m_ec->start(); + // Enter the main loop m_exiting = false; while (!m_exiting) { @@ -84,6 +85,9 @@ visualPerFrame(); } + // Stop collecting events now. + m_ec->stop(); + // Ok, we're exiting -- do the same as before, but we'll exit out // entirely when the scene is finished (and music faded). while (!m_scene->isFinished() && m_exitCount > 0.0f) { @@ -116,8 +120,6 @@ // Stop any sound effects Sound::stopAll(); } - - Hid::callbackUnreg(hidCookie); } void GenericMenu::setPostDelay(int d) { @@ -167,6 +169,12 @@ resetTimeout(); inputEvent(Event(Event::EvtTimeout)); } + + // Check for regular HID events. + Hid::Event evt; + while (m_ec->getEvent(evt)) { + processHidEvent(evt); + } } // The default inputEvent just gives you simple debugging output so @@ -211,11 +219,6 @@ m_bg[2] = b; } -void GenericMenu::hidCallback(const Hid::Event & evt, void * data) { - assert( data ); - ((GenericMenu *)data)->processHidEvent(evt); -} - void GenericMenu::processHidEvent(const Hid::Event & evt) { // Just pass the event down as-is first. // And why exactly C++ can't deal with making a default copy constructor This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |