00001 #include "input.hpp"
00002 #include "gui_event.hpp"
00003 #include "gui_eventreceiver.hpp"
00004 #include "gui_eventmanager.hpp"
00005 #include "gui_out.hpp"
00006 #include <utils_exception.hpp>
00007 #include <utils_string.hpp>
00008 #include <iostream>
00009 
00010 namespace input
00011 {
00012 handler::handler() : bManuallyUpdated_(false)
00013 {
00014 }
00015 
00016 void handler::update()
00017 {
00018     if (!pImpl_)
00019         throw utils::exception("input::manager::handler", "No input source defined !");
00020 
00021     pImpl_->update();
00022     pImpl_->lChars.clear();
00023     std::swap(pImpl_->lChars, pImpl_->lCharsCache_);
00024 }
00025 
00026 bool handler::is_manually_updated() const
00027 {
00028     return bManuallyUpdated_;
00029 }
00030 
00031 void handler::set_manually_updated(bool bManuallyUpdated)
00032 {
00033     bManuallyUpdated_ = bManuallyUpdated;
00034 }
00035 
00036 const handler_impl::key_state& handler::get_key_state() const
00037 {
00038     return pImpl_->mKeyboard;
00039 }
00040 
00041 std::vector<char32_t> handler::get_chars() const
00042 {
00043     return pImpl_->lChars;
00044 }
00045 
00046 std::string handler::get_key_name(key::code mKey) const
00047 {
00048     return pImpl_->get_key_name(mKey);
00049 }
00050 
00051 const handler_impl::mouse_state& handler::get_mouse_state() const
00052 {
00053     return pImpl_->mMouse;
00054 }
00055 
00056 utils::wptr<handler_impl> handler::get_impl()
00057 {
00058     return pImpl_;
00059 }
00060 
00061 handler_impl::handler_impl()
00062 {
00063     mKeyboard.lKeyState.fill(false);
00064 
00065     mMouse.bHasDelta = false;
00066     mMouse.fAbsX = mMouse.fAbsY = 0.0f;
00067     mMouse.fRelX = mMouse.fRelY = 0.0f;
00068     mMouse.fDX = mMouse.fDY = 0.0f;
00069     mMouse.fRelDX = mMouse.fRelDY = 0.0f;
00070     mMouse.fRelWheel = 0.0f;
00071     mMouse.lButtonState.fill(false);
00072 }
00073 
00074 manager::manager(const handler& mHandler) :
00075     bRemoveFocus_(false), bFocus_(false), pFocusReceiver_(nullptr), bCtrlPressed_(false),
00076     bShiftPressed_(false), bAltPressed_ (false), bKey_(false),
00077     dDoubleClickTime_(0.25), fMX_(0.0f), fMY_(0.0f), fRelMX_(0.0f), fRelMY_(0.0f),
00078     fDMX_(0.0f), fDMY_(0.0f), fRelDMX_(0.0f), fRelDMY_(0.0f), fRawDMX_(0.0f), fRawDMY_(0.0f),
00079     fMouseSensibility_(1.0f), dMouseHistoryMaxLength_(0.1), dLongPressDelay_(0.7),
00080     fSmoothDMX_(0.0f), fSmoothDMY_(0.0f), fSmoothMWheel_(0.0f), fMWheel_(0.0f),
00081     bWheelRolled_(false), bLastDragged_(false), dTime_(0.0), mHandler_(mHandler)
00082 {
00083     lKeyDelay_.fill(false);
00084     lKeyLong_.fill(false);
00085     lKeyBuf_.fill(false);
00086     lKeyBufOld_.fill(false);
00087 
00088     lDoubleClickDelay_.fill(0.0);
00089     lMouseDelay_.fill(0.0);
00090     lMouseLong_.fill(false);
00091     lMouseBuf_.fill(false);
00092     lMouseBufOld_.fill(false);
00093     lMouseState_.fill(mouse::UP);
00094 }
00095 
00096 void manager::allow_input(const std::string& sGroupName)
00097 {
00098     lClickGroupList_[sGroupName] = true;
00099 }
00100 
00101 void manager::block_input(const std::string& sGroupName)
00102 {
00103     lClickGroupList_[sGroupName] = false;
00104 }
00105 
00106 bool manager::can_receive_input(const std::string& sGroupName) const
00107 {
00108     std::map<std::string, bool>::const_iterator iter = lClickGroupList_.find(sGroupName);
00109     if (iter != lClickGroupList_.end() && !iter->second)
00110     {
00111         iter = lForcedClickGroupList_.find(sGroupName);
00112         if (iter == lForcedClickGroupList_.end() || !iter->second)
00113             return false;
00114     }
00115 
00116     return true;
00117 }
00118 
00119 void manager::force_input_allowed(const std::string& sGroupName, bool bForce)
00120 {
00121     lForcedClickGroupList_[sGroupName] = bForce;
00122 }
00123 
00124 bool manager::get_key(bool bForce) const
00125 {
00126     if (!bForce && bFocus_)
00127         return false;
00128     else
00129         return bKey_;
00130 }
00131 
00132 std::string manager::get_key_name(key::code mKey) const
00133 {
00134     return mHandler_.get_key_name(mKey);
00135 }
00136 
00137 std::string manager::get_key_name(key::code mKey, key::code mModifier) const
00138 {
00139     std::string sString;
00140     switch (mModifier)
00141     {
00142         case (key::K_LSHIFT) :
00143         case (key::K_RSHIFT) :
00144             sString = "Shift + ";
00145             break;
00146 
00147         case (key::K_LCONTROL) :
00148         case (key::K_RCONTROL) :
00149             sString = "Ctrl + ";
00150             break;
00151 
00152         case (key::K_LMENU) :
00153         case (key::K_RMENU) :
00154             sString = "Alt + ";
00155             break;
00156 
00157         default :
00158             sString = get_key_name(mModifier) + " + ";
00159             break;
00160     }
00161 
00162     return sString + get_key_name(mKey);
00163 }
00164 
00165 std::string manager::get_key_name(key::code mKey, key::code mModifier1, key::code mModifier2) const
00166 {
00167     std::string sString;
00168     switch (mModifier1)
00169     {
00170         case (key::K_LSHIFT) :
00171         case (key::K_RSHIFT) :
00172             sString = "Shift + ";
00173             break;
00174 
00175         case (key::K_LCONTROL) :
00176         case (key::K_RCONTROL) :
00177             sString = "Ctrl + ";
00178             break;
00179 
00180         case (key::K_LMENU) :
00181         case (key::K_RMENU) :
00182             sString = "Alt + ";
00183             break;
00184 
00185         default :
00186             sString = get_key_name(mModifier1) + " + ";
00187             break;
00188     }
00189 
00190     switch (mModifier2)
00191     {
00192         case (key::K_LSHIFT) :
00193         case (key::K_RSHIFT) :
00194             sString += "Shift + ";
00195             break;
00196 
00197         case (key::K_LCONTROL) :
00198         case (key::K_RCONTROL) :
00199             sString += "Ctrl + ";
00200             break;
00201 
00202         case (key::K_LMENU) :
00203         case (key::K_RMENU) :
00204             sString += "Alt + ";
00205             break;
00206 
00207         default :
00208             sString += get_key_name(mModifier2) + " + ";
00209             break;
00210     }
00211 
00212     return sString + get_key_name(mKey);
00213 }
00214 
00215 const std::deque<key::code>& manager::get_key_press_stack() const
00216 {
00217     return lDownStack_;
00218 }
00219 
00220 const std::deque<key::code>& manager::get_key_release_stack() const
00221 {
00222     return lUpStack_;
00223 }
00224 
00225 bool manager::key_is_down(key::code mKey, bool bForce) const
00226 {
00227     if (!bForce && bFocus_)
00228         return false;
00229     else
00230         return lKeyBuf_[mKey];
00231 }
00232 
00233 bool manager::key_is_down_long(key::code mKey, bool bForce) const
00234 {
00235     if (!bForce && bFocus_)
00236         return false;
00237     else
00238         return (lKeyBuf_[mKey] && lKeyLong_[mKey]);
00239 }
00240 
00241 double manager::get_key_press_duration(key::code mKey) const
00242 {
00243     return lKeyDelay_[mKey];
00244 }
00245 
00246 bool manager::key_is_pressed(key::code mKey, bool bForce) const
00247 {
00248     if (!bForce && bFocus_)
00249         return false;
00250     else
00251         return (lKeyBuf_[mKey] && !lKeyBufOld_[mKey]);
00252 }
00253 
00254 bool manager::key_is_released(key::code mKey, bool bForce) const
00255 {
00256     if (!bForce && bFocus_)
00257         return false;
00258     else
00259         return (!lKeyBuf_[mKey] && lKeyBufOld_[mKey]);
00260 }
00261 
00262 std::vector<char32_t> manager::get_chars() const
00263 {
00264     return lChars_;
00265 }
00266 
00267 bool manager::mouse_is_down(mouse::button mID) const
00268 {
00269     return lMouseBuf_[mID];
00270 }
00271 
00272 bool manager::mouse_is_down_long(mouse::button mID) const
00273 {
00274     return (lMouseBuf_[mID] && lMouseLong_[mID]);
00275 }
00276 
00277 double manager::get_mouse_press_duration(mouse::button mID) const
00278 {
00279     return lMouseDelay_[mID];
00280 }
00281 
00282 bool manager::mouse_is_pressed(mouse::button mID) const
00283 {
00284     return (lMouseBuf_[mID] && !lMouseBufOld_[mID]);
00285 }
00286 
00287 bool manager::mouse_is_released(mouse::button mID) const
00288 {
00289     return (!lMouseBuf_[mID] && lMouseBufOld_[mID]);
00290 }
00291 
00292 bool manager::mouse_is_doubleclicked(mouse::button mID) const
00293 {
00294     return (mouse_is_pressed(mID) && lDoubleClickDelay_[mID] > 0.0);
00295 }
00296 
00297 bool manager::wheel_is_rolled() const
00298 {
00299     return bWheelRolled_;
00300 }
00301 
00302 void manager::update(float fTempDelta)
00303 {
00304     if (bRemoveFocus_)
00305     {
00306         bFocus_ = false;
00307         pFocusReceiver_ = nullptr;
00308         bRemoveFocus_ = false;
00309     }
00310 
00311     if (!mHandler_.is_manually_updated())
00312         mHandler_.update();
00313 
00314     lChars_ = mHandler_.get_chars();
00315 
00316     lDownStack_.clear();
00317     lUpStack_.clear();
00318 
00319     
00320     double dDelta = fTempDelta;
00321     if ((dDelta < 0.0) || (dDelta > 1.0))
00322         dDelta = 0.05;
00323 
00324     gui::event mKeyboardEvent;
00325     mKeyboardEvent.add(uint(0));
00326     mKeyboardEvent.add(std::string());
00327 
00328     
00329     bKey_ = false;
00330     for (uint i = 0; i < 256; ++i)
00331     {
00332         lKeyBufOld_[i] = lKeyBuf_[i];
00333 
00334         
00335         if (lKeyBufOld_[i])
00336         {
00337             lKeyDelay_[i] += dDelta;
00338             if (lKeyDelay_[i] >= dLongPressDelay_)
00339                 lKeyLong_[i] = true;
00340         }
00341         else
00342         {
00343             lKeyDelay_[i] = 0.0;
00344             lKeyLong_[i] = false;
00345         }
00346 
00347         
00348         lKeyBuf_[i] = mHandler_.get_key_state().lKeyState[i];
00349 
00350         if (lKeyBuf_[i])
00351         {
00352             bKey_ = true;
00353             if (!lKeyBufOld_[i])
00354             {
00355                 
00356                 lDownStack_.push_back((key::code)i);
00357             }
00358         }
00359         else if (lKeyBufOld_[i])
00360         {
00361             
00362             lUpStack_.push_back((key::code)i);
00363         }
00364 
00365         
00366         if (lKeyBuf_[i])
00367         {
00368             if (!lKeyBufOld_[i])
00369             {
00370                 mKeyboardEvent.set_name("KEY_PRESSED");
00371                 mKeyboardEvent[0] = i;
00372                 mKeyboardEvent[1] = get_key_name((key::code)i);
00373                 fire_event_(mKeyboardEvent);
00374             }
00375         }
00376         else if (lKeyBufOld_[i])
00377         {
00378             mKeyboardEvent.set_name("KEY_RELEASED");
00379             mKeyboardEvent[0] = i;
00380             mKeyboardEvent[1] = get_key_name((key::code)i);
00381             fire_event_(mKeyboardEvent);
00382         }
00383     }
00384 
00385     if (!lChars_.empty())
00386     {
00387         gui::event mCharEvent("TEXT_ENTERED");
00388         mCharEvent.add(char32_t(0));
00389         for (char32_t c : lChars_)
00390         {
00391             mCharEvent[0] = c;
00392             fire_event_(mCharEvent);
00393         }
00394     }
00395 
00396     
00397     bCtrlPressed_  = key_is_down(key::K_LCONTROL, true) || key_is_down(key::K_RCONTROL, true);
00398     bShiftPressed_ = key_is_down(key::K_LSHIFT, true) || key_is_down(key::K_RSHIFT, true);
00399     bAltPressed_   = key_is_down(key::K_LMENU, true) || key_is_down(key::K_RMENU, true);
00400 
00401     const handler_impl::mouse_state& mMouseState = mHandler_.get_mouse_state();
00402     gui::event mMouseEvent;
00403     mMouseEvent.add(uint(0));
00404     mMouseEvent.add(mMouseState.fAbsX);
00405     mMouseEvent.add(mMouseState.fAbsY);
00406     mMouseEvent.add(std::string());
00407 
00408     
00409     bLastDragged_ = false;
00410     for (uint i = 0; i < INPUT_MOUSE_BUTTON_NUMBER; ++i)
00411     {
00412         bool bOldMouseState = lMouseBufOld_[i] = lMouseBuf_[i];
00413 
00414         
00415         lDoubleClickDelay_[i] -= dDelta;
00416 
00417         if (bOldMouseState)
00418             lDoubleClickDelay_[i] = dDoubleClickTime_;
00419 
00420         
00421         if (bOldMouseState)
00422         {
00423             lMouseDelay_[i] += dDelta;
00424             if (lMouseDelay_[i] >= dLongPressDelay_)
00425                 lMouseLong_[i] = true;
00426         }
00427         else
00428         {
00429             lMouseDelay_[i] = 0.0;
00430             lMouseLong_[i] = false;
00431         }
00432 
00433         
00434         bool bMouseState = lMouseBuf_[i] = mMouseState.lButtonState[i];
00435 
00436         
00437         if (bMouseState)
00438         {
00439             if (!bOldMouseState)
00440             {
00441                 lMouseState_[i] = mouse::CLICKED; 
00442 
00443                 if (lDoubleClickDelay_[i] > 0.0)
00444                     lMouseState_[i] = mouse::DOUBLE; 
00445             }
00446             else
00447             {
00448                 bLastDragged_ = true;
00449                 lMouseState_[i] = mouse::DRAGGED; 
00450             }
00451         }
00452         else if (bOldMouseState)
00453             lMouseState_[i] = mouse::RELEASED; 
00454         else
00455             lMouseState_[i] = mouse::UP; 
00456 
00457         
00458         mMouseEvent[0] = i;
00459         mMouseEvent[3] = get_mouse_button_string((mouse::button)i);
00460         if (bMouseState)
00461         {
00462             if (!bOldMouseState)
00463             {
00464                 mMouseEvent.set_name("MOUSE_PRESSED");
00465                 fire_event_(mMouseEvent, true);
00466 
00467                 if (lDoubleClickDelay_[i] > 0.0)
00468                 {
00469                     mMouseEvent.set_name("MOUSE_DOUBLE_CLICKED");
00470                     fire_event_(mMouseEvent, true);
00471                 }
00472             }
00473         }
00474         else if (bOldMouseState)
00475         {
00476             mMouseEvent.set_name("MOUSE_RELEASED");
00477             fire_event_(mMouseEvent, true);
00478         }
00479     }
00480 
00481     
00482     if (mMouseState.bHasDelta)
00483     {
00484         fRawDMX_ = fDMX_ = mMouseState.fDX;
00485         fRawDMY_ = fDMY_ = mMouseState.fDY;
00486         fRelDMX_ = mMouseState.fRelDX;
00487         fRelDMY_ = mMouseState.fRelDY;
00488     }
00489     else
00490     {
00491         fRawDMX_ = fDMX_ = mMouseState.fAbsX - fMX_;
00492         fRawDMY_ = fDMY_ = mMouseState.fAbsY - fMY_;
00493         fRelDMX_ = mMouseState.fRelX - fRelMX_;
00494         fRelDMY_ = mMouseState.fRelY - fRelMY_;
00495     }
00496 
00497     fMX_    = mMouseState.fAbsX;
00498     fMY_    = mMouseState.fAbsY;
00499     fRelMX_ = mMouseState.fRelX;
00500     fRelMY_ = mMouseState.fRelY;
00501 
00502     fDMX_ *= fMouseSensibility_;
00503     fDMY_ *= fMouseSensibility_;
00504     fRelDMX_ *= fMouseSensibility_;
00505     fRelDMY_ *= fMouseSensibility_;
00506 
00507     fMWheel_ = mMouseState.fRelWheel;
00508     if (fMWheel_ == 0.0f)
00509         bWheelRolled_ = false;
00510     else
00511         bWheelRolled_ = true;
00512 
00513     if (dMouseHistoryMaxLength_ == 0.0)
00514     {
00515         fSmoothDMX_    = fDMX_;
00516         fSmoothDMY_    = fDMY_;
00517         fSmoothMWheel_ = fMWheel_;
00518     }
00519     else
00520     {
00521         std::array<float,3> data;
00522         data[0] = fDMX_; data[1] = fDMY_; data[2] = fMWheel_;
00523         lMouseHistory_.push_front(std::make_pair(dTime_, data));
00524 
00525         double dHistoryLength = lMouseHistory_.front().first - lMouseHistory_.back().first;
00526         while (dHistoryLength > dMouseHistoryMaxLength_ && (lMouseHistory_.size() > 1))
00527         {
00528             lMouseHistory_.pop_back();
00529             dHistoryLength = lMouseHistory_.front().first - lMouseHistory_.back().first;
00530         }
00531 
00532         fSmoothDMX_ = fSmoothDMY_ = fSmoothMWheel_ = 0.0f;
00533         float fHistoryWeight = 0.0f;
00534         float fWeight = 1.0f/lMouseHistory_.size();
00535         std::deque<std::pair<double, std::array<float,3>>>::iterator iterHistory;
00536         foreach (iterHistory, lMouseHistory_)
00537         {
00538             fSmoothDMX_    += iterHistory->second[0]*fWeight;
00539             fSmoothDMY_    += iterHistory->second[1]*fWeight;
00540             fSmoothMWheel_ += iterHistory->second[2]*fWeight;
00541 
00542             fHistoryWeight += fWeight;
00543         }
00544 
00545         fSmoothDMX_    /= fHistoryWeight;
00546         fSmoothDMY_    /= fHistoryWeight;
00547         fSmoothMWheel_ /= fHistoryWeight;
00548     }
00549 
00550     
00551     if (fDMX_ != 0.0 || fDMY_ != 0.0)
00552     {
00553         gui::event mMouseMovedEvent("MOUSE_MOVED", true);
00554         mMouseMovedEvent.add(fDMX_);
00555         mMouseMovedEvent.add(fDMY_);
00556         mMouseMovedEvent.add(fDMX_*mMouseState.fRelX/mMouseState.fAbsX);
00557         mMouseMovedEvent.add(fDMY_*mMouseState.fRelY/mMouseState.fAbsY);
00558         fire_event_(mMouseMovedEvent, true);
00559     }
00560 
00561     if (fDMX_ != 0.0 || fDMY_ != 0.0)
00562     {
00563         gui::event mMouseMovedEvent("MOUSE_MOVED_RAW", true);
00564         mMouseMovedEvent.add(fRawDMX_);
00565         mMouseMovedEvent.add(fRawDMY_);
00566         mMouseMovedEvent.add(fRawDMX_*mMouseState.fRelX/mMouseState.fAbsX);
00567         mMouseMovedEvent.add(fRawDMY_*mMouseState.fRelY/mMouseState.fAbsY);
00568         fire_event_(mMouseMovedEvent, true);
00569     }
00570 
00571     if (fSmoothDMX_ != 0.0 || fSmoothDMY_ != 0.0)
00572     {
00573         gui::event mMouseMovedEvent("MOUSE_MOVED_SMOOTH", true);
00574         mMouseMovedEvent.add(fSmoothDMX_);
00575         mMouseMovedEvent.add(fSmoothDMY_);
00576         mMouseMovedEvent.add(fSmoothDMX_*mMouseState.fRelX/mMouseState.fAbsX);
00577         mMouseMovedEvent.add(fSmoothDMY_*mMouseState.fRelY/mMouseState.fAbsY);
00578         fire_event_(mMouseMovedEvent, true);
00579     }
00580 
00581     if (bWheelRolled_)
00582     {
00583         gui::event mMouseWheelEvent("MOUSE_WHEEL", true);
00584         mMouseWheelEvent.add(fMWheel_);
00585         fire_event_(mMouseWheelEvent, true);
00586     }
00587 
00588     if (fSmoothMWheel_ != 0.0)
00589     {
00590         gui::event mMouseWheelEvent("MOUSE_WHEEL_SMOOTH", true);
00591         mMouseWheelEvent.add(fSmoothMWheel_);
00592         fire_event_(mMouseWheelEvent, true);
00593     }
00594 
00595     dTime_ += dDelta;
00596 }
00597 
00598 void manager::set_doubleclick_time(double dDoubleClickTime)
00599 {
00600     dDoubleClickTime_ = dDoubleClickTime;
00601 }
00602 
00603 double manager::get_doubleclick_time() const
00604 {
00605     return dDoubleClickTime_;
00606 }
00607 
00608 void manager::set_mouse_buffer_duration(double dMouseHistoryMaxLength)
00609 {
00610     dMouseHistoryMaxLength_ = dMouseHistoryMaxLength;
00611 }
00612 
00613 double manager::get_mouse_buffer_duration() const
00614 {
00615     return dMouseHistoryMaxLength_;
00616 }
00617 
00618 void manager::set_focus(bool bFocus, gui::event_receiver* pReceiver)
00619 {
00620     if (bFocus_ && !bFocus)
00621         bRemoveFocus_ = true;
00622     else
00623     {
00624         bRemoveFocus_ = false;
00625         bFocus_ = bFocus;
00626         pFocusReceiver_ = pReceiver;
00627     }
00628 }
00629 
00630 bool manager::is_focused() const
00631 {
00632     return bFocus_;
00633 }
00634 
00635 bool manager::alt_is_pressed() const
00636 {
00637     return bAltPressed_;
00638 }
00639 
00640 bool manager::shift_is_pressed() const
00641 {
00642     return bShiftPressed_;
00643 }
00644 
00645 bool manager::ctrl_is_pressed() const
00646 {
00647     return bCtrlPressed_;
00648 }
00649 
00650 bool manager::mouse_last_dragged() const
00651 {
00652     return bLastDragged_;
00653 }
00654 
00655 mouse::state manager::get_mouse_state(mouse::button mID) const
00656 {
00657     return lMouseState_[mID];
00658 }
00659 
00660 float manager::get_mouse_x() const
00661 {
00662     return fMX_;
00663 }
00664 
00665 float manager::get_mouse_y() const
00666 {
00667     return fMY_;
00668 }
00669 
00670 float manager::get_mouse_rel_x() const
00671 {
00672     return fRelMX_;
00673 }
00674 
00675 float manager::get_mouse_rel_y() const
00676 {
00677     return fRelMY_;
00678 }
00679 
00680 float manager::get_mouse_raw_dx() const
00681 {
00682     return fRawDMX_;
00683 }
00684 
00685 float manager::get_mouse_raw_dy() const
00686 {
00687     return fRawDMY_;
00688 }
00689 
00690 float manager::get_mouse_dx() const
00691 {
00692     return fDMX_;
00693 }
00694 
00695 float manager::get_mouse_dy() const
00696 {
00697     return fDMY_;
00698 }
00699 
00700 float manager::get_mouse_rel_dx() const
00701 {
00702     return fRelDMX_;
00703 }
00704 
00705 float manager::get_mouse_rel_dy() const
00706 {
00707     return fRelDMY_;
00708 }
00709 
00710 float manager::get_mouse_smooth_dx() const
00711 {
00712     return fSmoothDMX_;
00713 }
00714 
00715 float manager::get_mouse_smooth_dy() const
00716 {
00717     return fSmoothDMY_;
00718 }
00719 
00720 float manager::get_mouse_wheel() const
00721 {
00722     return fMWheel_;
00723 }
00724 
00725 void manager::set_mouse_sensibility(float fMouseSensibility)
00726 {
00727     fMouseSensibility_ = fMouseSensibility;
00728 }
00729 
00730 float manager::get_mouse_sensibility() const
00731 {
00732     return fMouseSensibility_;
00733 }
00734 
00735 void manager::set_long_press_delay(double dLongPressDelay)
00736 {
00737     dLongPressDelay_ = dLongPressDelay;
00738 }
00739 
00740 double manager::get_long_press_delay() const
00741 {
00742     return dLongPressDelay_;
00743 }
00744 
00745 std::string manager::get_mouse_button_string(mouse::button mID) const
00746 {
00747     switch (mID)
00748     {
00749         case mouse::LEFT :   return "LeftButton";
00750         case mouse::RIGHT :  return "RightButton";
00751         case mouse::MIDDLE : return "MiddleButton";
00752         default :            return "";
00753     }
00754 }
00755 
00756 const handler& manager::get_handler() const
00757 {
00758     return mHandler_;
00759 }
00760 
00761 handler& manager::get_handler()
00762 {
00763     return mHandler_;
00764 }
00765 
00766 void manager::register_event_manager(utils::wptr<gui::event_manager> pManager)
00767 {
00768     if (utils::find(lEventManagerList_, pManager) == lEventManagerList_.end())
00769         lEventManagerList_.push_back(pManager);
00770 }
00771 
00772 void manager::unregister_event_manager(utils::wptr<gui::event_manager> pManager)
00773 {
00774     auto iter = utils::find(lEventManagerList_, pManager);
00775     if (iter != lEventManagerList_.end())
00776         lEventManagerList_.erase(iter);
00777 }
00778 
00779 void manager::fire_event_(const gui::event& mEvent, bool bForce)
00780 {
00781     if (pFocusReceiver_ && !bForce)
00782         pFocusReceiver_->on_event(mEvent);
00783     else
00784     {
00785         for (auto iter : lEventManagerList_)
00786             iter->fire_event(mEvent);
00787     }
00788 }
00789 }