Any of a number of different devices that might be attached to a ClientBase, including trackers, etc. More...
#include "clientDevice.h"
Public Member Functions | |
virtual | ~ClientDevice () |
We don't actually call disconnect() at the ClientDevice level destructor, because by the time we get here we're already partly destructed. More... | |
void | disconnect () |
Disconnects the ClientDevice from its ClientBase object. More... | |
virtual void | do_poll () final |
Causes the connected ClientBase to poll all of its clients, if necessary. More... | |
virtual TypeHandle | force_init_type () |
ClientBase * | get_client () const |
Returns the ClientBase this device is associated with. More... | |
TypeHandle | get_device_type () const |
Returns the type of device this is considered to be to the ClientBase: a ClientTrackerDevice, ClientAnalogDevice, or what have you. More... | |
virtual TypeHandle | get_type () const |
virtual void | output (std::ostream &out) const |
Writes a one-line string describing the device. More... | |
virtual void | write (std::ostream &out, int indent_level=0) const |
Public Member Functions inherited from InputDevice | |
InputDevice (const InputDevice ©)=delete | |
void | disable_pointer_events () |
Disables the generation of mouse-movement events. More... | |
void | enable_pointer_events () |
Enables the generation of mouse-movement events. More... | |
AxisState | find_axis (Axis axis) const |
Returns the first AnalogAxis found with the given axis, or throw an assert if the axis was not found in the list. More... | |
ButtonState | find_button (ButtonHandle handle) const |
Returns the first ButtonState found with the given axis, or throw an assert if the button handle was not found in the list. More... | |
AxisState | get_axis (size_t index) const |
double | get_axis_value (size_t index) const |
Returns the current position of indicated analog axis (identified by its index number), or 0.0 if the axis is unknown. More... | |
BatteryData | get_battery () const |
ButtonState | get_button (size_t index) const |
ButtonHandle | get_button_map (size_t index) const |
Returns the ButtonHandle that was previously associated with the given index number by a call to map_button(), or ButtonHandle::none() if no button was associated. More... | |
DeviceClass | get_device_class () const |
std::string | get_manufacturer () const |
std::string | get_name () const |
size_t | get_num_axes () const |
size_t | get_num_buttons () const |
unsigned short | get_product_id () const |
std::string | get_serial_number () const |
TrackerData | get_tracker () const |
unsigned short | get_vendor_id () const |
bool | has_battery () const |
bool | has_button_event () const |
Returns true if this device has a pending button event (a mouse button or keyboard button down/up), false otherwise. More... | |
bool | has_feature (Feature feature) const |
Returns true if the device supports the indicated feature. More... | |
bool | has_keyboard () const |
Returns true if the device has a physical keyboard designed for text entry. More... | |
bool | has_pointer () const |
Returns true if this is a pointing device. More... | |
bool | has_pointer_event () const |
Returns true if this device has a pending pointer event (a mouse movement), or false otherwise. More... | |
bool | has_tracker () const |
bool | has_vibration () const |
Returns true if the device has vibration motors that can be controlled by calling set_vibration(). More... | |
bool | is_axis_known (size_t index) const |
Returns true if the state of the indicated analog axis is known, or false if we have never heard anything about this particular axis. More... | |
bool | is_button_known (size_t index) const |
Returns true if the state of the indicated button is known, or false if we have never heard anything about this particular button. More... | |
bool | is_button_pressed (size_t index) const |
Returns true if the indicated button (identified by its index number) is currently known to be down, or false if it is up or unknown. More... | |
bool | is_connected () const |
void | map_axis (size_t index, Axis axis) |
Associates the indicated Axis with the axis of the indicated index number. More... | |
void | map_button (size_t index, ButtonHandle handle) |
Associates the indicated ButtonHandle with the button of the indicated index number. More... | |
InputDevice & | operator= (const InputDevice ©)=delete |
void | output_buttons (std::ostream &out) const |
Writes a one-line string of all of the current button states. More... | |
void | poll () |
Polls the input device for new activity, to ensure it contains the latest events. More... | |
PT (ButtonEventList) get_button_events() | |
PT (PointerEventList) get_pointer_events() | |
void | set_connected (bool connected) |
Called to indicate that the device has been disconnected or connected from its host. More... | |
void | set_vibration (double strong, double weak) |
Sets the strength of the vibration effect, if supported. More... | |
void | write_axes (std::ostream &out, int indent_level) const |
Writes a multi-line description of the current analog axis states. More... | |
void | write_buttons (std::ostream &out, int indent_level) const |
Writes a multi-line description of the current button states. More... | |
Public Member Functions inherited from TypedReferenceCount | |
TypedReferenceCount (const TypedReferenceCount ©) | |
void | operator= (const TypedReferenceCount ©) |
Public Member Functions inherited from TypedObject | |
TypedObject (const TypedObject ©)=default | |
TypedObject * | as_typed_object () |
Returns the object, upcast (if necessary) to a TypedObject pointer. More... | |
const TypedObject * | as_typed_object () const |
Returns the object, upcast (if necessary) to a TypedObject pointer. More... | |
int | get_best_parent_from_Set (const std::set< int > &) const |
int | get_type_index () const |
Returns the internal index number associated with this object's TypeHandle, a unique number for each different type. More... | |
bool | is_exact_type (TypeHandle handle) const |
Returns true if the current object is the indicated type exactly. More... | |
bool | is_of_type (TypeHandle handle) const |
Returns true if the current object is or derives from the indicated type. More... | |
TypedObject & | operator= (const TypedObject ©)=default |
Public Member Functions inherited from ReferenceCount | |
int | get_ref_count () const |
WeakReferenceList * | get_weak_list () const |
Returns the WeakReferenceList associated with this ReferenceCount object. More... | |
bool | has_weak_list () const |
Returns true if this particular ReferenceCount object has a WeakReferenceList created, false otherwise. More... | |
void | local_object () |
This function should be called, once, immediately after creating a new instance of some ReferenceCount-derived object on the stack. More... | |
void | ref () const |
Explicitly increments the reference count. More... | |
bool | ref_if_nonzero () const |
Atomically increases the reference count of this object if it is not zero. More... | |
bool | test_ref_count_integrity () const |
Does some easy checks to make sure that the reference count isn't completely bogus. More... | |
bool | test_ref_count_nonzero () const |
Does some easy checks to make sure that the reference count isn't zero, or completely bogus. More... | |
virtual bool | unref () const |
Explicitly decrements the reference count. More... | |
WeakReferenceList * | weak_ref () |
Adds the indicated PointerToVoid as a weak reference to this object. More... | |
void | weak_unref () |
Removes the indicated PointerToVoid as a weak reference to this object. More... | |
Static Public Member Functions | |
static TypeHandle | get_class_type () |
static void | init_type () |
Static Public Member Functions inherited from InputDevice | |
static std::string | format_axis (Axis axis) |
Returns a string describing the given axis enumerant. More... | |
static std::string | format_device_class (DeviceClass dc) |
Returns a string describing the given device class enumerant. More... | |
static TypeHandle | get_class_type () |
static void | init_type () |
Static Public Member Functions inherited from TypedReferenceCount | |
static TypeHandle | get_class_type () |
static void | init_type () |
Static Public Member Functions inherited from TypedObject | |
static TypeHandle | get_class_type () |
static void | init_type () |
This function is declared non-inline to work around a compiler bug in g++ 2.96. More... | |
Static Public Member Functions inherited from ReferenceCount | |
static TypeHandle | get_class_type () |
static void | init_type () |
Friends | |
class | ClientBase |
Additional Inherited Members | |
Public Types inherited from InputDevice | |
typedef pvector< AxisState > | Axes |
enum | Axis { none, x, y, z, yaw, pitch, roll, left_x, left_y, left_trigger, right_x, right_y, right_trigger, throttle, rudder, wheel, accelerator, brake } |
typedef pvector< ButtonState > | Buttons |
enum | DeviceClass { unknown, virtual_device, keyboard, mouse, touch, gamepad, flight_stick, steering_wheel, dance_pad, hmd, spatial_mouse } |
enum | Feature { pointer, keyboard, tracker, vibration, battery } |
enum | State { S_unknown, S_up, S_down } |
Public Attributes inherited from InputDevice | |
Axes | _axes |
BatteryData | _battery_data |
Buttons | _buttons |
PointerData | _pointer_data |
TrackerData | _tracker_data |
get_axis | |
Returns the axis state that is set at the given index, or throw an assert if the index was not found in the list. More... | |
get_battery | |
Returns a rough indication of the battery level, ranging from 0 (completely empty battery) to the indicated max_level value. More... | |
get_button | |
Returns the ButtonState that is set at the given index, or throw an assert if the index was not found in the list. More... | |
get_device_class | |
Returns an identification of the general type of device. More... | |
get_manufacturer | |
Returns a string containing the manufacturer of the device, if this information is known. More... | |
get_name | |
Returns a human-readable name for the device. More... | |
get_num_axes | |
Returns the number of analog axes known to the InputDevice. More... | |
get_num_buttons | |
Returns the number of buttons known to the device. More... | |
get_product_id | |
Returns a string containing the USB product ID of the device, if this information is known. More... | |
get_serial_number | |
Returns a string containing the serial number of the device, if this information is known. More... | |
get_tracker | |
Returns the TrackerData associated with the input device's tracker. More... | |
get_vendor_id | |
Returns a string containing the USB vendor ID of the device, if this information is known. More... | |
has_battery | |
Returns true if the device may be able to provide information about its battery life. More... | |
has_tracker | |
Returns true if the device features a tracker that can track position and/or orientation in 3D space. More... | |
is_connected | |
Returns true if the device is still connected and able to receive data, false otherwise. More... | |
Public Attributes inherited from TypedObject | |
get_type | |
Public Attributes inherited from ReferenceCount | |
get_ref_count | |
Returns the current reference count. More... | |
Any of a number of different devices that might be attached to a ClientBase, including trackers, etc.
This is an abstract interface; the actual implementations are in ClientTrackerDevice, etc.
Definition at line 27 of file clientDevice.h.
|
virtual |
We don't actually call disconnect() at the ClientDevice level destructor, because by the time we get here we're already partly destructed.
Instead, we should call disconnect() from each specific kind of derived class.
Definition at line 42 of file clientDevice.cxx.
void ClientDevice::disconnect | ( | ) |
Disconnects the ClientDevice from its ClientBase object.
The device will stop receiving updates.
Normally, you should not need to call this explicitly (and it is probably a mistake to do so); it will automatically be called when the ClientDevice object destructs.
The lock should *not* be held while this call is made; it will explicitly grab the lock itself.
Definition at line 61 of file clientDevice.cxx.
References InputDevice::get_name, InputDevice::is_connected, and InputDevice::set_connected().
|
finalvirtual |
Causes the connected ClientBase to poll all of its clients, if necessary.
This will be a no-op if the client is running in forked mode, or if it has already polled everything this frame.
This should generally be called before accessing the data in this ClientDevice to ensure that it is fresh.
Reimplemented from InputDevice.
Definition at line 79 of file clientDevice.cxx.
References ClientBase::poll().
Referenced by ClientBase::poll().
|
inline |
Returns the ClientBase this device is associated with.
Definition at line 18 of file clientDevice.I.
|
inline |
Returns the type of device this is considered to be to the ClientBase: a ClientTrackerDevice, ClientAnalogDevice, or what have you.
This is not exactly the same thing as get_type(), because it does not return the exact type of the ClientDevice (e.g. it reports ClientTrackerDevice, not VrpnTrackerDevice).
Definition at line 30 of file clientDevice.I.
|
virtual |
Writes a one-line string describing the device.
Reimplemented from InputDevice.
Reimplemented in ClientButtonDevice.
Definition at line 87 of file clientDevice.cxx.
References InputDevice::get_name.