mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-04 10:54:24 -04:00
add inactivity_timeout_event
This commit is contained in:
parent
989af98143
commit
56f63aaff6
@ -55,6 +55,9 @@ ConfigVariableDouble drive_horizontal_ramp_up_time
|
||||
ConfigVariableDouble drive_horizontal_ramp_down_time
|
||||
("drive-horizontal-ramp-down-time", 0.0);
|
||||
|
||||
ConfigVariableDouble inactivity_timeout
|
||||
("inactivity-timeout", 0.0);
|
||||
|
||||
ConfigureFn(config_tform) {
|
||||
DriveInterface::init_type();
|
||||
ButtonThrower::init_type();
|
||||
|
@ -38,4 +38,6 @@ extern EXPCL_PANDA ConfigVariableDouble drive_vertical_ramp_down_time;
|
||||
extern EXPCL_PANDA ConfigVariableDouble drive_horizontal_ramp_up_time;
|
||||
extern EXPCL_PANDA ConfigVariableDouble drive_horizontal_ramp_down_time;
|
||||
|
||||
extern EXPCL_PANDA ConfigVariableDouble inactivity_timeout;
|
||||
|
||||
#endif
|
||||
|
@ -511,12 +511,15 @@ has_display_region() const {
|
||||
// Function: MouseWatcher::set_inactivity_timeout
|
||||
// Access: Published
|
||||
// Description: Sets an inactivity timeout on the mouse activity.
|
||||
// When this timeout (in seconds) is exceed with no
|
||||
// When this timeout (in seconds) is exceeded with no
|
||||
// keyboard or mouse activity, all currently-held
|
||||
// buttons are automatically released. This is intended
|
||||
// to help protect against people who inadvertently (or
|
||||
// intentionally) leave a keyboard key stuck down and
|
||||
// then wander away from the keyboard.
|
||||
//
|
||||
// Also, when this timeout expires, the event specified
|
||||
// by set_inactivity_timeout() will be generated.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE void MouseWatcher::
|
||||
set_inactivity_timeout(double timeout) {
|
||||
@ -563,6 +566,30 @@ clear_inactivity_timeout() {
|
||||
note_activity();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: MouseWatcher::set_inactivity_timeout_event
|
||||
// Access: Published
|
||||
// Description: Specifies the event string that will be generated
|
||||
// when the inactivity timeout counter expires. See
|
||||
// set_inactivity_timeout().
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE void MouseWatcher::
|
||||
set_inactivity_timeout_event(const string &event) {
|
||||
_inactivity_timeout_event = event;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: MouseWatcher::get_inactivity_timeout_event
|
||||
// Access: Published
|
||||
// Description: Returns the event string that will be generated
|
||||
// when the inactivity timeout counter expires. See
|
||||
// set_inactivity_timeout().
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE const string &MouseWatcher::
|
||||
get_inactivity_timeout_event() const {
|
||||
return _inactivity_timeout_event;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: MouseWatcher::within_region
|
||||
// Access: Protected
|
||||
|
@ -32,6 +32,7 @@
|
||||
#include "dcast.h"
|
||||
#include "indent.h"
|
||||
#include "mutexHolder.h"
|
||||
#include "nearly_zero.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
@ -67,8 +68,11 @@ MouseWatcher(const string &name) :
|
||||
_button_down = false;
|
||||
_eh = (EventHandler *)NULL;
|
||||
_display_region = (DisplayRegion *)NULL;
|
||||
_has_inactivity_timeout = false;
|
||||
_inactivity_timeout = 0.0;
|
||||
|
||||
_inactivity_timeout = inactivity_timeout;
|
||||
_has_inactivity_timeout = !IS_NEARLY_ZERO(_inactivity_timeout);
|
||||
|
||||
_inactivity_timeout_event = "inactivity_timeout";
|
||||
_last_activity = 0.0;
|
||||
_inactivity_state = IS_active;
|
||||
|
||||
@ -1425,6 +1429,7 @@ do_transmit_data(DataGraphTraverser *trav, const DataNodeTransmit &input,
|
||||
}
|
||||
}
|
||||
_inactivity_state = IS_inactive;
|
||||
throw_event(_inactivity_timeout_event);
|
||||
break;
|
||||
|
||||
case IS_inactive_to_active:
|
||||
|
@ -126,6 +126,10 @@ PUBLISHED:
|
||||
INLINE bool has_inactivity_timeout() const;
|
||||
INLINE double get_inactivity_timeout() const;
|
||||
INLINE void clear_inactivity_timeout();
|
||||
|
||||
INLINE void set_inactivity_timeout_event(const string &event);
|
||||
INLINE const string &get_inactivity_timeout_event() const;
|
||||
|
||||
void note_activity();
|
||||
|
||||
public:
|
||||
@ -217,6 +221,7 @@ private:
|
||||
|
||||
bool _has_inactivity_timeout;
|
||||
double _inactivity_timeout;
|
||||
string _inactivity_timeout_event;
|
||||
double _last_activity;
|
||||
|
||||
enum InactivityState {
|
||||
|
Loading…
x
Reference in New Issue
Block a user