25 _last_poll_time = 0.0f;
30 _client_thread =
nullptr;
43 Devices devices_copy = _devices;
44 for (di = devices_copy.begin(); di != devices_copy.end(); ++di) {
45 DevicesByName &dbn = (*di).second;
46 DevicesByName::iterator dbni;
47 for (dbni = dbn.begin(); dbni != dbn.end(); ++dbni) {
60 _client_thread->join(&ret);
76 <<
"Attempt to fork client thread twice.\n";
80 if (asynchronous_clients) {
81 _sleep_time = (int)(1000000 * poll_time);
83 _client_thread = thread::create(&st_callback,
this);
85 if (device_cat.is_debug()) {
87 <<
"fork_asynchronous_thread() - forking client thread" 116 get_device(
TypeHandle device_type,
const std::string &device_name) {
117 DevicesByName &dbn = _devices[device_type];
119 DevicesByName::iterator dbni;
120 dbni = dbn.find(device_name);
121 if (dbni != dbn.end()) {
123 return (*dbni).second;
127 PT(
ClientDevice) device = make_device(device_type, device_name);
129 if (device !=
nullptr) {
130 dbn.insert(DevicesByName::value_type(device_name, device));
145 disconnect_device(
TypeHandle device_type,
const std::string &device_name,
147 DevicesByName &dbn = _devices[device_type];
149 DevicesByName::iterator dbni;
150 dbni = dbn.find(device_name);
151 if (dbni != dbn.end()) {
152 if ((*dbni).second == device) {
186 st_callback(
void *arg) {
187 nassertr(arg !=
nullptr,
nullptr);
203 ipc_traits::sleep(0, _sleep_time);
206 #endif // OLD_HAVE_IPC static ClockObject * get_global_clock()
Returns a pointer to the global ClockObject.
PT(ClientDevice) ClientBase
Returns a ClientDevice pointer that corresponds to the named device of the indicated device type...
void disconnect()
Disconnects the ClientDevice from its ClientBase object.
get_frame_time
Returns the time in seconds as of the last time tick() was called (typically, this will be as of the ...
get_frame_count
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.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
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...