16 #include "clientBase.h" 17 #include "config_device.h" 29 _last_poll_time = 0.0f;
34 _client_thread = (thread *)NULL;
49 Devices devices_copy = _devices;
50 for (di = devices_copy.begin(); di != devices_copy.end(); ++di) {
51 DevicesByName &dbn = (*di).second;
52 DevicesByName::iterator dbni;
53 for (dbni = dbn.begin(); dbni != dbn.end(); ++dbni) {
66 _client_thread->join(&ret);
86 <<
"Attempt to fork client thread twice.\n";
90 if (asynchronous_clients) {
91 _sleep_time = (int)(1000000 * poll_time);
93 _client_thread = thread::create(&st_callback,
this);
95 if (device_cat.is_debug()) {
97 <<
"fork_asynchronous_thread() - forking client thread" 132 get_device(
TypeHandle device_type,
const string &device_name) {
135 DevicesByName::iterator dbni;
136 dbni = dbn.find(device_name);
137 if (dbni != dbn.end()) {
139 return (*dbni).second;
143 PT(
ClientDevice) device = make_device(device_type, device_name);
146 dbn.insert(DevicesByName::value_type(device_name, device));
147 device->_is_connected =
true;
167 disconnect_device(
TypeHandle device_type,
const string &device_name,
171 DevicesByName::iterator dbni;
172 dbni = dbn.find(device_name);
173 if (dbni != dbn.end()) {
174 if ((*dbni).second == device) {
215 st_callback(
void *arg) {
216 nassertr(arg != NULL, NULL);
235 ipc_traits::sleep(0, _sleep_time);
238 #endif // OLD_HAVE_IPC static ClockObject * get_global_clock()
Returns a pointer to the global ClockObject.
This is our own Panda specialization on the default STL map.
double get_frame_time(Thread *current_thread=Thread::get_current_thread()) const
Returns the time in seconds as of the last time tick() was called (typically, this will be as of the ...
void disconnect()
Disconnects the ClientDevice from its ClientBase object.
int get_frame_count(Thread *current_thread=Thread::get_current_thread()) const
Returns the number of times tick() has been called since the ClockObject was created, or since it was last reset.
A ClockObject keeps track of elapsed real time and discrete time.
An abstract base class for a family of client device interfaces–including trackers, buttons, dials, and other analog inputs.
TypeHandle is the identifier used to differentiate C++ class types.
bool fork_asynchronous_thread(double poll_time)
Forks a separate thread to do all the polling of connected devices.
Any of a number of different devices that might be attached to a ClientBase, including trackers...