Panda3D

Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
GraphicsWindowInputDevice Class Reference

This is a virtual input device that represents the keyboard and mouse pair that is associated with a particular window. More...

`#include "graphicsWindowInputDevice.h"`

Inheritance diagram for GraphicsWindowInputDevice:

## Public Member Functions
void | button_down (ButtonHandle button, double time=ClockObject::get_global_clock() ->get_frame_time())
| Records that the indicated button has been depressed.
void | button_resume_down (ButtonHandle button, double time=ClockObject::get_global_clock() ->get_frame_time())
| Records that the indicated button was depressed earlier, and we only just detected the event after the fact.
void | button_up (ButtonHandle button, double time=ClockObject::get_global_clock() ->get_frame_time())
| Records that the indicated button has been released.
void | candidate (const std::wstring &candidate_string, size_t highlight_start, size_t highlight_end, size_t cursor_pos)
| Records that the indicated candidate string has been highlighted.
void | focus_lost (double time=ClockObject::get_global_clock() ->get_frame_time())
| This should be called when the window focus is lost, so that we may miss upcoming button events (especially "up" events) for the next period of time.
virtual TypeHandle | force_init_type ()
PointerData | get_pointer () const
| Returns the PointerData associated with the input device's pointer.
virtual TypeHandle | get_type () const
void | keystroke (int keycode, double time=ClockObject::get_global_clock() ->get_frame_time())
| Records that the indicated keystroke has been generated.
void | pointer_moved (double x, double y, double time=ClockObject::get_global_clock() ->get_frame_time())
| To be called by a particular kind of GraphicsWindow to indicate that the pointer has moved by the given relative amount.
void | raw_button_down (ButtonHandle button, double time=ClockObject::get_global_clock() ->get_frame_time())
| Records that the indicated button has been depressed.
void | raw_button_up (ButtonHandle button, double time=ClockObject::get_global_clock() ->get_frame_time())
| Records that the indicated button has been released.
void | remove_pointer (int id)
| To be called by a particular kind of GraphicsWindow to indicate that the pointer no longer exists.
void | set_pointer_in_window (double x, double y, double time=ClockObject::get_global_clock() ->get_frame_time())
| To be called by a particular kind of GraphicsWindow to indicate that the pointer is within the window, at the given pixel coordinates.
void | set_pointer_out_of_window (double time=ClockObject::get_global_clock() ->get_frame_time())
| To be called by a particular kind of GraphicsWindow to indicate that the pointer is no longer within the window.
void | update_pointer (PointerData data, double time=ClockObject::get_global_clock() ->get_frame_time())
| To be called by a particular kind of GraphicsWindow to indicate that the pointer data has changed.
Public Member Functions inherited from InputDevice
| InputDevice (const InputDevice &copy)=delete
void | disable_pointer_events ()
| Disables the generation of mouse-movement events.
void | enable_pointer_events ()
| Enables the generation of mouse-movement events.
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.
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.
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.
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.
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.
bool | has_feature (Feature feature) const
| Returns true if the device supports the indicated feature.
bool | has_keyboard () const
| Returns true if the device has a physical keyboard designed for text entry.
bool | has_pointer () const
| Returns true if this is a pointing device.
bool | has_pointer_event () const
| Returns true if this device has a pending pointer event (a mouse movement), or false otherwise.
bool | has_tracker () const
bool | has_vibration () const
| Returns true if the device has vibration motors that can be controlled by calling set_vibration().
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.
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.
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.
bool | is_connected () const
void | map_axis (size_t index, Axis axis)
| Associates the indicated Axis with the axis of the indicated index number.
void | map_button (size_t index, ButtonHandle handle)
| Associates the indicated ButtonHandle with the button of the indicated index number.
InputDevice & | operator= (const InputDevice &copy)=delete
virtual void | output (std::ostream &out) const
| Writes a one-line string describing the device.
void | output_buttons (std::ostream &out) const
| Writes a one-line string of all of the current button states.
void | poll ()
| Polls the input device for new activity, to ensure it contains the latest events.
| 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.
void | set_vibration (double strong, double weak)
| Sets the strength of the vibration effect, if supported.
void | write_axes (std::ostream &out, int indent_level) const
| Writes a multi-line description of the current analog axis states.
void | write_buttons (std::ostream &out, int indent_level) const
| Writes a multi-line description of the current button states.
Public Member Functions inherited from TypedReferenceCount
| TypedReferenceCount (const TypedReferenceCount &copy)
void | operator= (const TypedReferenceCount &copy)
Public Member Functions inherited from TypedObject
| TypedObject (const TypedObject &copy)=default
TypedObject * | as_typed_object ()
| Returns the object, upcast (if necessary) to a TypedObject pointer.
const TypedObject * | as_typed_object () const
| Returns the object, upcast (if necessary) to a TypedObject pointer.
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.
bool | is_exact_type (TypeHandle handle) const
| Returns true if the current object is the indicated type exactly.
bool | is_of_type (TypeHandle handle) const
| Returns true if the current object is or derives from the indicated type.
TypedObject & | operator= (const TypedObject &copy)=default
Public Member Functions inherited from MemoryBase
void | operator delete (void *, void *)
void | operator delete (void *ptr)
void | operator delete[] (void *, void *)
void | operator delete[] (void *ptr)
void * | operator new (size_t size)
void * | operator new (size_t size, void *ptr)
void * | operator new[] (size_t size)
void * | operator new[] (size_t size, void *ptr)
Public Member Functions inherited from ReferenceCount
int | get_ref_count () const
WeakReferenceList * | get_weak_list () const
| Returns the WeakReferenceList associated with this ReferenceCount object.
bool | has_weak_list () const
| Returns true if this particular ReferenceCount object has a WeakReferenceList created, false otherwise.
void | local_object ()
| This function should be called, once, immediately after creating a new instance of some ReferenceCount-derived object on the stack.
void | ref () const
| Explicitly increments the reference count.
bool | ref_if_nonzero () const
| Atomically increases the reference count of this object if it is not zero.
bool | test_ref_count_integrity () const
| Does some easy checks to make sure that the reference count isn't completely bogus.
bool | test_ref_count_nonzero () const
| Does some easy checks to make sure that the reference count isn't zero, or completely bogus.
virtual bool | unref () const
| Explicitly decrements the reference count.
bool | unref_if_one () const
| Atomically decreases the reference count of this object if it is one.
WeakReferenceList * | weak_ref ()
| Adds the indicated PointerToVoid as a weak reference to this object.
void | weak_unref ()
| Removes the indicated PointerToVoid as a weak reference to this object.

## Static Public Member Functions
static TypeHandle | get_class_type ()
static void | init_type ()
static | PT (GraphicsWindowInputDevice) keyboard_only(GraphicsWindow *host
static | PT (GraphicsWindowInputDevice) pointer_and_keyboard(GraphicsWindow *host
static | PT (GraphicsWindowInputDevice) pointer_only(GraphicsWindow *host
Static Public Member Functions inherited from InputDevice
static std::string | format_axis (Axis axis)
| Returns a string describing the given axis enumerant.
static std::string | format_device_class (DeviceClass dc)
| Returns a string describing the given device class enumerant.
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.
Static Public Member Functions inherited from ReferenceCount
static TypeHandle | get_class_type ()
static void | init_type ()

## Public Attributes
static const std::string & | name
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.
| get_battery
| Returns a rough indication of the battery level, ranging from 0 (completely empty battery) to the indicated max_level value.
| 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.
| get_device_class
| Returns an identification of the general type of device.
| get_manufacturer
| Returns a string containing the manufacturer of the device, if this information is known.
| get_name
| Returns a human-readable name for the device.
| get_num_axes
| Returns the number of analog axes known to the InputDevice.
| get_num_buttons
| Returns the number of buttons known to the device.
| get_product_id
| Returns a string containing the USB product ID of the device, if this information is known.
| get_serial_number
| Returns a string containing the serial number of the device, if this information is known.
| get_tracker
| Returns the TrackerData associated with the input device's tracker.
| get_vendor_id
| Returns a string containing the USB vendor ID of the device, if this information is known.
| has_battery
| Returns true if the device may be able to provide information about its battery life.
| has_tracker
| Returns true if the device features a tracker that can track position and/or orientation in 3D space.
| is_connected
| Returns true if the device is still connected and able to receive data, false otherwise.
Public Attributes inherited from TypedObject
| get_type
Public Attributes inherited from ReferenceCount
| get_ref_count
| Returns the current reference count.

## Additional Inherited Members
Public Types inherited from InputDevice
typedef pvector< AxisState > | Axes
enum class | 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 , pressure }
typedef pvector< ButtonState > | Buttons
enum class | DeviceClass { unknown , virtual_device , keyboard , mouse , touch , gamepad , flight_stick , steering_wheel , dance_pad , hmd , spatial_mouse , digitizer }
enum class | Feature { pointer , keyboard , tracker , vibration , battery }
enum | State { S_unknown , S_up , S_down }

## Detailed Description

This is a virtual input device that represents the keyboard and mouse pair that is associated with a particular window.

It collects mouse and keyboard events from the windowing system while the window is in focus.

Definition at line 28 of file graphicsWindowInputDevice.h.

## Member Function Documentation

## ◆ button_down()

void GraphicsWindowInputDevice::button_down | ( | ButtonHandle | button,
|  | double | time = ClockObject::get_global_clock()->get_frame_time() )

Records that the indicated button has been depressed.

Definition at line 74 of file graphicsWindowInputDevice.cxx.

## ◆ button_resume_down()

void GraphicsWindowInputDevice::button_resume_down | ( | ButtonHandle | button,
|  | double | time = ClockObject::get_global_clock()->get_frame_time() )

Records that the indicated button was depressed earlier, and we only just detected the event after the fact.

This is mainly useful for tracking the state of modifier keys.

Definition at line 86 of file graphicsWindowInputDevice.cxx.

## ◆ button_up()

void GraphicsWindowInputDevice::button_up | ( | ButtonHandle | button,
|  | double | time = ClockObject::get_global_clock()->get_frame_time() )

Records that the indicated button has been released.

Definition at line 96 of file graphicsWindowInputDevice.cxx.

## ◆ candidate()

void GraphicsWindowInputDevice::candidate | ( | const std::wstring & | candidate_string,
|  | size_t | highlight_start,
|  | size_t | highlight_end,
|  | size_t | cursor_pos )

Records that the indicated candidate string has been highlighted.

This is used to implement IME support for typing in international languages, especially Chinese/Japanese/Korean.

Definition at line 117 of file graphicsWindowInputDevice.cxx.

## ◆ focus_lost()

void GraphicsWindowInputDevice::focus_lost | ( | double | time = ClockObject::get_global_clock()->get_frame_time() | ) |

This should be called when the window focus is lost, so that we may miss upcoming button events (especially "up" events) for the next period of time.

It generates keyboard and mouse "up" events for those buttons that we previously sent unpaired "down" events, so that the Panda application will believe all buttons are now released.

Definition at line 133 of file graphicsWindowInputDevice.cxx.

## ◆ force_init_type()

virtual TypeHandle GraphicsWindowInputDevice::force_init_type | ( |  | ) |
| inline virtual

Reimplemented from InputDevice.

Definition at line 79 of file graphicsWindowInputDevice.h.

## ◆ get_class_type()

static TypeHandle GraphicsWindowInputDevice::get_class_type | ( |  | ) |
| inline static

Definition at line 68 of file graphicsWindowInputDevice.h.

## ◆ get_pointer()

PointerData GraphicsWindowInputDevice::get_pointer | ( |  | ) | const
| inline

Returns the PointerData associated with the input device's pointer.

This only makes sense if has_pointer() also returns true.

Definition at line 18 of file graphicsWindowInputDevice.I.

## ◆ get_type()

virtual TypeHandle GraphicsWindowInputDevice::get_type | ( |  | ) | const
| inline virtual

Reimplemented from InputDevice.

Definition at line 76 of file graphicsWindowInputDevice.h.

## ◆ init_type()

static void GraphicsWindowInputDevice::init_type | ( |  | ) |
| inline static

Definition at line 71 of file graphicsWindowInputDevice.h.

## ◆ keystroke()

void GraphicsWindowInputDevice::keystroke | ( | int | keycode,
|  | double | time = ClockObject::get_global_clock()->get_frame_time() )

Records that the indicated keystroke has been generated.

Definition at line 106 of file graphicsWindowInputDevice.cxx.

## ◆ pointer_moved()

void GraphicsWindowInputDevice::pointer_moved | ( | double | x,
|  | double | y,
|  | double | time = ClockObject::get_global_clock()->get_frame_time() )
| inline

To be called by a particular kind of GraphicsWindow to indicate that the pointer has moved by the given relative amount.

Definition at line 42 of file graphicsWindowInputDevice.I.

## ◆ raw_button_down()

void GraphicsWindowInputDevice::raw_button_down | ( | ButtonHandle | button,
|  | double | time = ClockObject::get_global_clock()->get_frame_time() )

Records that the indicated button has been depressed.

Definition at line 146 of file graphicsWindowInputDevice.cxx.

## ◆ raw_button_up()

void GraphicsWindowInputDevice::raw_button_up | ( | ButtonHandle | button,
|  | double | time = ClockObject::get_global_clock()->get_frame_time() )

Records that the indicated button has been released.

Definition at line 155 of file graphicsWindowInputDevice.cxx.

## ◆ remove_pointer()

void GraphicsWindowInputDevice::remove_pointer | ( | int | id | ) |
| inline

To be called by a particular kind of GraphicsWindow to indicate that the pointer no longer exists.

Definition at line 52 of file graphicsWindowInputDevice.I.

## ◆ set_pointer_in_window()

void GraphicsWindowInputDevice::set_pointer_in_window | ( | double | x,
|  | double | y,
|  | double | time = ClockObject::get_global_clock()->get_frame_time() )

To be called by a particular kind of GraphicsWindow to indicate that the pointer is within the window, at the given pixel coordinates.

Definition at line 165 of file graphicsWindowInputDevice.cxx.

## ◆ set_pointer_out_of_window()

void GraphicsWindowInputDevice::set_pointer_out_of_window | ( | double | time = ClockObject::get_global_clock()->get_frame_time() | ) |

To be called by a particular kind of GraphicsWindow to indicate that the pointer is no longer within the window.

Definition at line 181 of file graphicsWindowInputDevice.cxx.

## ◆ update_pointer()

void GraphicsWindowInputDevice::update_pointer | ( | PointerData | data,
|  | double | time = ClockObject::get_global_clock()->get_frame_time() )
| inline

To be called by a particular kind of GraphicsWindow to indicate that the pointer data has changed.

Definition at line 32 of file graphicsWindowInputDevice.I.

## Member Data Documentation

## ◆ name

static const std::string & GraphicsWindowInputDevice::name

Definition at line 34 of file graphicsWindowInputDevice.h.

The documentation for this class was generated from the following files:

- panda/src/display/graphicsWindowInputDevice.h
- panda/src/display/graphicsWindowInputDevice.cxx
- panda/src/display/graphicsWindowInputDevice.I