Reference Manual

Main Page | Namespace List | Class Hierarchy | Alphabetical List | Compound List | File List | Namespace Members | Compound Members | File Members

# Inti::Gdk::Device Class Reference

A GdkDevice C++ wrapper class. More...

`#include <inti/gdk/input.h>`

Inheritance diagram for Inti::Gdk::Device:

List of all members.

## Public Member Functions

Constructors

- virtual ~Device ()
    Destructor.

Accessors

- GdkDevice * gdk_device () const
    Get a pointer to the GdkDevice structure.
- GdkDeviceClass * gdk_device_class () const
    Get a pointer to the GdkDeviceClass structure.
- operator GdkDevice * () const
    Conversion operator; safely converts a Device to a GdkDevice pointer.
- String name () const
    Returns the name of the device.
- InputSource source () const
    Returns the type of the device.
- InputMode mode () const
    Returns the mode of the device.
- bool has_cursor () const
    Returns true if the X pointer follows device motion.
- void get_state (Window &window, double *axes, ModifierTypeField *mask) const
    Gets the current state of the device.
- bool get_history (Window &window, unsigned long start, unsigned long stop, GdkTimeCoord ***events, int *n_events) const
    Obtains the motion history for a device, given a starting and ending timestamp, and returns all events in the motion history for the given time range.
- bool get_axis (double *axes, AxisUse use, double *value) const
    Interprets an array of double as axis values for a given device, and locates the value in the array for a given axis use.

Methods

- void set_source (InputSource source)
    Sets the source type for the input device.
- bool set_mode (InputMode mode)
    Sets the mode of an input device.
- void set_key (unsigned int index, unsigned int keyval, ModifierTypeField modifiers)
    Specifies the X key event to generate when a macro button of a device is pressed.
- void set_axis_use (unsigned int index, AxisUse use)
    Specifies how an axis of a device is used.

## Static Public Member Functions

- void free_history (GdkTimeCoord **events, int n_events)
    Frees the array of GdkTimeCoord that was returned by get_history().
- Device * get_core_pointer (const Display *display=0)
    Returns the core pointer device for display.

## Protected Member Functions

Constructors

- Device (GdkDevice *device, bool reference=true)
    Construct a new Device from an existing GdkDevice.

## Detailed Description

A GdkDevice C++ wrapper class.

In addition to the normal keyboard and mouse input devices, GTK+ also contains support for extended input devices. In particular, this support is targeted at graphics tablets. Graphics tablets typically return sub-pixel positioning information and possibly information about the pressure and tilt of the stylus. Under X, the support for extended devices is done through the XInput extension.

Because handling extended input devices may involve considerable overhead, they need to be turned on for each Gdk::Window individually using set_extension_events(). (Or, more typically, for Gtk::Widgets, using Gtk::Widget::set_extension_events()). As an additional complication, depending on the support from the windowing system, its possible that a normal mouse cursor will not be displayed for a particular extension device. If an application does not want to deal with displaying a cursor itself, it can ask only to get extension events from devices that will display a cursor, by passing the EXTENSION_EVENTS_CURSOR value to set_extension_events(). Otherwise, the application must retrieve the device information using list_devices(), check the has_cursor() accessor, and, if it returns false, draw a cursor itself when it receives motion events.

Each pointing device is assigned a unique integer ID; events from a particular device can be identified by the deviceid field in the event structure. The events generated by pointer devices have also been extended to contain pressure, xtilt and ytilt fields which contain the extended information reported as additional valuators from the device. The pressure field is a double value ranging from 0.0 to 1.0, while the tilt fields are double values ranging from -1.0 to 1.0. (With -1.0 representing the maximum tilt to the left or up, and 1.0 representing the maximum tilt to the right or down.)

One additional field in each event is the source field, which contains an enumeration value describing the type of device; this currently can be one of SOURCE_MOUSE, SOURCE_PEN, SOURCE_ERASER, or SOURCE_CURSOR. This field is present to allow simple applications to (for instance) delete when they detect eraser devices without having to keep track of complicated per-device settings.

Various aspects of each device may be configured. The easiest way of creating a GUI to allow the user to configure such a device is to use the GtkInputDialog widget in GTK+. Inti doesn't wrap GtkInputDialog because it is considered too specialized and will eventually be moved out of GTK+. If you use this widget, application writers will need to directly query and set the configuration parameters in order to save the state between invocations of the application. The configuration of devices is queried using list_devices(). Each device must be activated using set_mode(), which also controls whether the device's range is mapped to the entire screen or to a single window. The mapping of the valuators of the device onto the predefined valuator types is set using set_axis_use(). And the source type for each device can be set with set_source().

Devices may also have associated keys or macro buttons. Such keys can be globally set to map into normal X keyboard events. The mapping is set using set_key(). The interfaces in this section will most likely be considerably modified in the future to accomodate devices that may have different sets of additional valuators than the pressure xtilt and ytilt.

## Constructor & Destructor Documentation

Inti::Gdk::Device::Device | ( | GdkDevice * | device,
|  | bool | reference = true
| ) | `[explicit, protected]`

  | Construct a new Device from an existing GdkDevice. Parameters:
  device | A pointer to a GdkDevice.
  reference | Set false if the initial reference count is floating, set true if it's not.
The device can be a newly created GdkDevice or an existing GdkDevice. (see G::Object::Object).

## Member Function Documentation

void Inti::Gdk::Device::free_history | ( | GdkTimeCoord ** | events,
|  | int | n_events
| ) | `[static]`

  | Frees the array of GdkTimeCoord that was returned by get_history(). Parameters:
  events | An array of GdkTimeCoord.
  n_events | The length of the array.

bool Inti::Gdk::Device::get_axis | ( | double * | axes,
|  | AxisUse | use,
|  | double * | value
| ) | const

  | Interprets an array of double as axis values for a given device, and locates the value in the array for a given axis use. Parameters:
  axes | The pointer to an array of axes.
  use | The use to look for.
  value | The location to store the found value.
Returns: true if the given axis use was found, otherwise false.

Device* Inti::Gdk::Device::get_core_pointer | ( | const Display * | display = 0 | ) | `[static]`

  | Returns the core pointer device for display. Parameters:
  display | The Display, or null for the default display.
This device is owned by the display and should not be unreferenced.

bool Inti::Gdk::Device::get_history | ( | Window & | window,
|  | unsigned long | start,
|  | unsigned long | stop,
|  | GdkTimeCoord *** | events,
|  | int * | n_events
| ) | const

  | Obtains the motion history for a device, given a starting and ending timestamp, and returns all events in the motion history for the given time range. Parameters:
  window | The window with respect to which which the event coordinates will be reported.
  start | The starting timestamp for range of events to return.
  stop | The ending timestamp for the range of events to return.
  events | The location to store a newly-allocated array of GdkTimeCoord, or null.
  n_events | The location to store the length of events, or null.
Returns: true if the windowing system supports motion history and at least one event was found. Some windowing systems do not support motion history, in which case, false will be returned. This is not distinguishable from the case where motion history is supported and no events were found. If successful, the vector contents must be freed by calling free_history();

void Inti::Gdk::Device::get_state | ( | Window & | window,
|  | double * | axes,
|  | ModifierTypeField * | mask
| ) | const

  | Gets the current state of the device. Parameters:
  window | A Gdk::Window.
  axes | An array of doubles to store the values of the axes of device in, or null.
  mask | The location to store the modifiers, or null.

void Inti::Gdk::Device::set_axis_use | ( | unsigned int | index,
|  | AxisUse | use
| ) |

  | Specifies how an axis of a device is used. Parameters:
  index | The index of the axis.
  use | Specifies how the axis is used.

void Inti::Gdk::Device::set_key | ( | unsigned int | index,
|  | unsigned int | keyval,
|  | ModifierTypeField | modifiers
| ) |

  | Specifies the X key event to generate when a macro button of a device is pressed. Parameters:
  index | The index of the macro button to set.
  keyval | The keyval to generate.
  modifiers | The modifiers to set.

bool Inti::Gdk::Device::set_mode | ( | InputMode | mode | ) |

  | Sets the mode of an input device. Parameters:
  mode | The input mode.
Returns: true if the mode was successfully changed. The mode controls if the device is active and whether the device's range is mapped to the entire screen or to a single window.

void Inti::Gdk::Device::set_source | ( | InputSource | source | ) |

  | Sets the source type for the input device. Parameters:
  source | The source type.

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

- input.h

Main Page - Footer