<?xml version="1.0" standalone="no"?>
<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN"
    "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd">

<refentry id="class-gdkdevice">
  <refnamediv>
    <refname>gtk.gdk.Device</refname>
    <refpurpose>an object for supporting input devices</refpurpose>
  </refnamediv>

  <refsect1>
    <title>Synopsis</title>

    <classsynopsis language="python">
      <ooclass><classname>gtk.gdk.Device</classname></ooclass>
      <ooclass><classname><link
linkend="class-gobject">gobject.GObject</link></classname></ooclass>
      <methodsynopsis language="python">
	<methodname><link
linkend="method-gdkdevice--set-source">set_source</link></methodname>
	<methodparam><parameter
		       role="keyword">source</parameter></methodparam>
      </methodsynopsis>
      <methodsynopsis language="python">
	<methodname><link
linkend="method-gdkdevice--set-mode">set_mode</link></methodname>
	<methodparam><parameter
		       role="keyword">mode</parameter></methodparam>
      </methodsynopsis>
      <methodsynopsis language="python">
	<methodname><link
linkend="method-gdkdevice--set-key">set_key</link></methodname>
	<methodparam><parameter
		       role="keyword">index</parameter></methodparam>
	<methodparam><parameter
		       role="keyword">keyval</parameter></methodparam>
	<methodparam><parameter
		       role="keyword">modifiers</parameter></methodparam>
      </methodsynopsis>
      <methodsynopsis language="python">
	<methodname><link
linkend="method-gdkdevice--set-axis-use">set_axis_use</link></methodname>
	<methodparam><parameter
		       role="keyword">index</parameter></methodparam>
	<methodparam><parameter role="keyword">use</parameter></methodparam>
      </methodsynopsis>
      <methodsynopsis language="python">
	<methodname><link
linkend="method-gdkdevice--get-state">get_state</link></methodname>
	<methodparam><parameter
		       role="keyword">window</parameter></methodparam>
      </methodsynopsis>
      <methodsynopsis language="python">
	<methodname><link
linkend="method-gdkdevice--get-history">get_history</link></methodname>
	<methodparam><parameter
		       role="keyword">window</parameter></methodparam>
	<methodparam><parameter
		       role="keyword">start</parameter></methodparam>
	<methodparam><parameter
		       role="keyword">stop</parameter></methodparam>
      </methodsynopsis>
      <methodsynopsis language="python">
	<methodname><link
linkend="method-gdkdevice--get-axis">get_axis</link></methodname>
	<methodparam><parameter
		       role="keyword">axes</parameter></methodparam>
	<methodparam><parameter role="keyword">use</parameter></methodparam>
      </methodsynopsis>
    </classsynopsis>

      <programlisting>
<emphasis role="bold">Functions</emphasis>

<methodsynopsis language="python">
	<methodname><link
linkend="function-gdk--devices-list">gtk.gdk.devices_list</link></methodname>
	<methodparam></methodparam>
      </methodsynopsis><methodsynopsis language="python">
	<methodname><link
linkend="function-gdk--device-get-core-pointer">gtk.gdk.device_get_core_pointer</link></methodname>
	<methodparam></methodparam>
      </methodsynopsis></programlisting>

  </refsect1>

  <refsect1>
    <title>Ancestry</title>

<synopsis>+-- <link linkend="class-gobject">gobject.GObject</link>
  +-- <link linkend="class-gdkdevice">gtk.gdk.Device</link>
</synopsis>

  </refsect1>

  <refsect1>
    <title>Attributes</title>

    <blockquote role="properties">
      <informaltable pgwide="1" frame="none">
	<tgroup cols="3">
	<?dbhtml cellpadding="5"?>
	  <colspec column="1" colwidth="1in"/>
	  <colspec column="2" colwidth="1in"/>
	  <colspec column="3" colwidth="4in"/>
	  <tbody>

	    <row valign="top">
	      <entry>"axes"</entry>
	      <entry>Read</entry>
	      <entry>a tuple containing axes information. Each axes is
described by a tuple containing: use information (one of:
<literal>gtk.gdk.AXIS_IGNORE</literal>, <literal>gtk.gdk.AXIS_X</literal>,
<literal>gtk.gdk.AXIS_Y</literal>, <literal>gtk.gdk.AXIS_PRESSURE</literal>,
<literal>gtk.gdk.AXIS_XTILT</literal>,
<literal>gtk.gdk.AXIS_YTILT</literal>,
<literal>gtk.gdk.AXIS_WHEEL</literal>,
<literal>gtk.gdk.AXIS_LAST</literal>), the minimum and maximum axes
values.</entry>
	    </row>

	    <row valign="top">
	      <entry>"has_cursor"</entry>
	      <entry>Read</entry>
	      <entry>if <literal>True</literal> the pointer follows device
motion.</entry>
	    </row>

	    <row valign="top">
	      <entry>"keys"</entry>
	      <entry>Read</entry>
	      <entry>a tuple describing the mapped macro buttons. Each macro
button is described by a tuple containing: a key value output when the macro
button is pressed and a set of modifiers output with the key value.</entry>
	    </row>

	    <row valign="top">
	      <entry>"mode"</entry>
	      <entry>Read</entry>
	      <entry>the mode of this device - one of:
<literal>gtk.gdk.MODE_DISABLED</literal>,
<literal>gtk.gdk.MODE_SCREEN</literal>,
<literal>gtk.gdk.MODE_WINDOW</literal></entry>
	    </row>

	    <row valign="top">
	      <entry>"name"</entry>
	      <entry>Read</entry>
	      <entry>the name of this device.</entry>
	    </row>

	    <row valign="top">
	      <entry>"num_axes"</entry>
	      <entry>Read</entry>
	      <entry>the length of the <literal>axes</literal>
tuple.</entry>
	    </row>

	    <row valign="top">
	      <entry>"num_keys"</entry>
	      <entry>Read</entry>
	      <entry>the length of the <literal>keys</literal> tuple</entry>
	    </row>

	    <row valign="top">
	      <entry>"source"</entry>
	      <entry>Read</entry>
	      <entry>the type of this device - one of:
<literal>gtk.gdk.SOURCE_MOUSE</literal>,
<literal>gtk.gdk.SOURCE_PEN</literal>,
<literal>gtk.gdk.SOURCE_ERASER</literal>,
<literal>gtk.gdk.SOURCE_CURSOR</literal></entry>
	    </row>

	</tbody>
      </tgroup>
      </informaltable>
    </blockquote>

  </refsect1>

  <refsect1>
    <title>Description</title>

    <para>In addition to the normal keyboard and mouse input devices,
<literal>PyGTK</literal> 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 <link
linkend="class-gdkwindow"><classname>gtk.gdk.Window</classname></link>
individually using <link
linkend="method-gdkwindow--input-set-extension-events"><methodname>gtk.gdk.Window.input_set_extension_events</methodname>()</link>. 
(Or, more typically, for <link
linkend="class-gtkwidget"><classname>gtk.Widget</classname></link> objects,
using the <link
linkend="method-gtkwidget--set-extension-events"><methodname>gtk.Widget.set_extension_events</methodname>()</link> 
method). 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
<literal>gtk.gdk.EXTENSION_EVENTS_CURSOR</literal> value to the <link
linkend="method-gdkwindow--input-set-extension-events"><methodname>gtk.gdk.Window.input_set_extension_events</methodname>()</link> 
method. Otherwise, the application must retrieve the device information
using the <link
linkend="function-gdk--devices-list"><methodname>gtk.gdk.devices_list</methodname>()</link> 
function, check the has_cursor field, and, if it is
<literal>False</literal>, draw a cursor itself when it receives motion
events. </para>

    <para>Each pointing device is assigned a unique integer ID; events from
a particular device can be identified by the <parameter>deviceid</parameter>
attribute in the event structure. The events generated by pointer devices
have also been extended to contain <parameter>pressure</parameter>,
<parameter>xtilt</parameter> and <parameter>ytilt</parameter> attributes
which contain the extended information reported as additional valuators from
the device. The <parameter>pressure</parameter> attribute ranges from 0.0 to
1.0, while the tilt attributes range 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 attribute in each event
is the <parameter>source</parameter> attribute, which contains an
enumeration value describing the type of device; this currently can be one
of <literal>gtk.gdk.SOURCE_MOUSE</literal>,
<literal>gtk.gdk.SOURCE_PEN</literal>,
<literal>gtk.gdk.SOURCE_ERASER</literal>, or
<literal>gtk.gdk.SOURCE_CURSOR</literal>. This attribute 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.</para>

    <para>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
<link
linkend="class-gtkinputdialog"><classname>gtk.InputDialog</classname></link>
widget in <literal>PyGTK</literal>. However, even when using 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 the <link
linkend="function-gdk--devices-list"><methodname>gtk.gdk.devices_list</methodname>()</link> 
function. Each device must be activated using the <link
linkend="method-gdkdevice--set-mode"><methodname>set_mode</methodname>()</link> 
method, 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 the <link
linkend="method-gdkdevice--set-axis-use"><methodname>set_axis_use</methodname>()</link> 
method. And the source type for each device can be set with the <link
linkend="method-gdkdevice--set-source"><methodname>set_source</methodname>()</link> 
method.</para>

    <para>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 the <link
linkend="method-gdkdevice--set-key"><methodname>set_key</methodname>()</link> 
method. The interfaces in this section will most likely be considerably
modified in the future to accommodate devices that may have different sets of
additional valuators than the pressure xtilt and ytilt.</para>

  </refsect1>

  <refsect1>
    <title>Methods</title>

    <refsect2 id="method-gdkdevice--set-source">
      <title>gtk.gdk.Device.set_source</title>

      <programlisting><methodsynopsis language="python">
	  <methodname>set_source</methodname>
	  <methodparam><parameter
			 role="keyword">source</parameter></methodparam>
	</methodsynopsis></programlisting>
      <variablelist>
	<varlistentry>
	  <term><parameter role="keyword">source</parameter>&nbsp;:</term>
	  <listitem><simpara>the source type of the
device</simpara></listitem>
	</varlistentry>
      </variablelist>

      <para>The <methodname>set_source</methodname>() method sets the source
type for the input device to the value specified by
<parameter>source</parameter>. The value of <parameter>source</parameter>
must be one of:</para>

      <variablelist>
	<varlistentry>
	  <term><literal>gtk.gdk.SOURCE_MOUSE</literal></term>
	  <listitem>
	    <simpara>the device is a mouse. (This will be reported for the
core pointer, even if it is something else, such as a trackball.)</simpara>
	  </listitem>
	</varlistentry>
	<varlistentry>
	  <term><literal>gtk.gdk.SOURCE_PEN</literal></term>
	  <listitem>
	    <simpara>the device is a stylus of a graphics tablet or similar
device.</simpara>
	  </listitem>
	</varlistentry>
	<varlistentry>
	  <term><literal>gtk.gdk.SOURCE_ERASER</literal></term>
	  <listitem>
	    <simpara>the device is an eraser. Typically, this would be the
other end of a stylus on a graphics tablet.</simpara>
	  </listitem>
	</varlistentry>
	<varlistentry>
	  <term><literal>gtk.gdk.SOURCE_CURSOR</literal></term>
	  <listitem>
	    <simpara>the device is a graphics tablet "puck" or similar
device.</simpara>
	  </listitem>
	</varlistentry>
      </variablelist>

      <para></para>

  </refsect2>

    <refsect2 id="method-gdkdevice--set-mode">
      <title>gtk.gdk.Device.set_mode</title>

      <programlisting><methodsynopsis language="python">
	  <methodname>set_mode</methodname>
	  <methodparam><parameter
			 role="keyword">mode</parameter></methodparam>
	</methodsynopsis></programlisting>
      <variablelist>
	<varlistentry>
	  <term><parameter role="keyword">mode</parameter>&nbsp;:</term>
	  <listitem><simpara>the input mode</simpara></listitem>
	</varlistentry>
	<varlistentry>
	  <term><emphasis>Returns</emphasis>&nbsp;:</term>
	  <listitem><simpara><literal>True</literal> if the mode was
successfully changed.</simpara></listitem>
	</varlistentry>
      </variablelist>

      <para>The <methodname>set_mode</methodname>() method sets the input
device mode to the value specified by <parameter>mode</parameter>. The value
of <parameter>mode</parameter> must be one of:</para>

      <variablelist>
	<varlistentry>
	  <term><literal>gtk.gdk.MODE_DISABLED</literal></term>
	  <listitem>
	    <simpara>the device is disabled and will not report any
events.</simpara>
	  </listitem>
	</varlistentry>
	<varlistentry>
	  <term><literal>gtk.gdk.MODE_SCREEN</literal></term>
	  <listitem>
	    <simpara>the device is enabled. The device's coordinate space
maps to the entire screen.</simpara>
	  </listitem>
	</varlistentry>
	<varlistentry>
	  <term><literal>gtk.gdk.MODE_WINDOW</literal></term>
	  <listitem>
	    <simpara>the device is enabled. The device's coordinate space is
mapped to a single window. The manner in which this window is chosen is
undefined, but it will typically be the same way in which the focus window
for key events is determined.</simpara>
	  </listitem>
	</varlistentry>
      </variablelist>

      <para></para>

  </refsect2>

    <refsect2 id="method-gdkdevice--set-key">
      <title>gtk.gdk.Device.set_key</title>

      <programlisting><methodsynopsis language="python">
	  <methodname>set_key</methodname>
	  <methodparam><parameter
			 role="keyword">index</parameter></methodparam>
	  <methodparam><parameter
			 role="keyword">keyval</parameter></methodparam>
	  <methodparam><parameter
			 role="keyword">modifiers</parameter></methodparam>
	</methodsynopsis></programlisting>
      <variablelist>
	<varlistentry>
	  <term><parameter role="keyword">index</parameter>&nbsp;:</term>
	  <listitem><simpara>the index of the macro button to
set.</simpara></listitem>
	</varlistentry>
	<varlistentry>
	  <term><parameter role="keyword">keyval</parameter>&nbsp;:</term>
	  <listitem><simpara>the key value to generate.</simpara></listitem>
	</varlistentry>
	<varlistentry>
	  <term><parameter
role="keyword">modifiers</parameter>&nbsp;:</term>
	  <listitem><simpara>the modifiers to set.</simpara></listitem>
	</varlistentry>
      </variablelist>

      <para>The <methodname>set_key</methodname>() method sets the key event
to generate when a macro button of a device is pressed. The macro button is
specified by <parameter>index</parameter>. The key value and modifiers
generated are specified by <parameter>keyval</parameter> and
<parameter>modifiers</parameter> respectively.</para>

  </refsect2>

    <refsect2 id="method-gdkdevice--set-axis-use">
      <title>gtk.gdk.Device.set_axis_use</title>

      <programlisting><methodsynopsis language="python">
	  <methodname>set_axis_use</methodname>
	  <methodparam><parameter
			 role="keyword">index</parameter></methodparam>
	  <methodparam><parameter
			 role="keyword">use</parameter></methodparam>
	</methodsynopsis></programlisting>
      <variablelist>
	<varlistentry>
	  <term><parameter role="keyword">index</parameter>&nbsp;:</term>
	  <listitem><simpara>the index of the axis.</simpara></listitem>
	</varlistentry>
	<varlistentry>
	  <term><parameter role="keyword">use</parameter>&nbsp;:</term>
	  <listitem><simpara>how the axis is used.</simpara></listitem>
	</varlistentry>
      </variablelist>

      <para>The <methodname>set_axis_use</methodname>() method sets the axis
(specified by <parameter>index</parameter>) of the input device to be used
in the fashion specified by <parameter>use</parameter>. The value of
<parameter>use</parameter> must be one of:</para>

      <variablelist>
	<varlistentry>
	  <term><literal>gtk.gdk.AXIS_IGNORE</literal></term>
	  <listitem>
	    <simpara>the axis is ignored.</simpara>
	  </listitem>
	</varlistentry>
	<varlistentry>
	  <term><literal>gtk.gdk.AXIS_X</literal></term>
	  <listitem>
	    <simpara>the axis is used as the x axis.</simpara>
	  </listitem>
	</varlistentry>
	<varlistentry>
	  <term><literal>gtk.gdk.AXIS_Y</literal></term>
	  <listitem>
	    <simpara>the axis is used as the y axis.</simpara>
	  </listitem>
	</varlistentry>
	<varlistentry>
	  <term><literal>gtk.gdk.AXIS_PRESSURE</literal></term>
	  <listitem>
	    <simpara>the axis is used for pressure information.</simpara>
	  </listitem>
	</varlistentry>
	<varlistentry>
	  <term><literal>gtk.gdk.AXIS_XTILT</literal></term>
	  <listitem>
	    <simpara>the axis is used for x tilt information.</simpara>
	  </listitem>
	</varlistentry>
	<varlistentry>
	  <term><literal>gtk.gdk.AXIS_YTILT</literal></term>
	  <listitem>
	    <simpara>the axis is used for y tilt information.</simpara>
	  </listitem>
	</varlistentry>
	<varlistentry>
	  <term><literal>gtk.gdk.AXIS_WHEEL</literal></term>
	  <listitem>
	    <simpara>the axis is used for wheel information.</simpara>
	  </listitem>
	</varlistentry>
	<varlistentry>
	  <term><literal>gtk.gdk.AXIS_LAST</literal></term>
	  <listitem>
	    <simpara>a constant equal to the numerically highest axis
value.</simpara>
	  </listitem>
	</varlistentry>
      </variablelist>

      <para></para>

    </refsect2>

    <refsect2 id="method-gdkdevice--get-state">
      <title>gtk.gdk.Device.get_state</title>

      <programlisting><methodsynopsis language="python">
	  <methodname>get_state</methodname>
	  <methodparam><parameter
			 role="keyword">window</parameter></methodparam>
	</methodsynopsis></programlisting>
      <variablelist>
	<varlistentry>
	  <term><parameter role="keyword">window</parameter>&nbsp;:</term>
	  <listitem><simpara>a <link
linkend="class-gdkwindow"><classname>gtk.gdk.Window</classname></link></simpara></listitem>
	</varlistentry>
	<varlistentry>
	  <term><emphasis>Returns</emphasis>&nbsp;:</term>
	  <listitem><simpara>a tuple containing: a tuple containing the axes
data; and, the modifiers in effect.</simpara></listitem>
	</varlistentry>
      </variablelist>

      <para>The <methodname>get_state</methodname>() method returns a tuple
containing:</para>

      <itemizedlist>
	<listitem>
	  <simpara>a tuple containing the axes data</simpara>
	</listitem>
	<listitem>
	  <simpara>the bitmask containing the set of key modifiers in
effect</simpara>
	</listitem>
      </itemizedlist>

      <para>The state information is relative to the <link
linkend="class-gdkwindow"><classname>gtk.gdk.Window</classname></link>
specified by <parameter>window</parameter>.</para>

    </refsect2>

    <refsect2 id="method-gdkdevice--get-history">
      <title>gtk.gdk.Device.get_history</title>

      <programlisting><methodsynopsis language="python">
	  <methodname>get_history</methodname>
	  <methodparam><parameter
			 role="keyword">window</parameter></methodparam>
	  <methodparam><parameter
			 role="keyword">start</parameter></methodparam>
	  <methodparam><parameter
			 role="keyword">stop</parameter></methodparam>
	</methodsynopsis></programlisting>
      <variablelist>
	<varlistentry>
	  <term><parameter role="keyword">window</parameter>&nbsp;:</term>
	  <listitem><simpara>a <link
linkend="class-gdkwindow"><classname>gtk.gdk.Window</classname></link></simpara></listitem>
	</varlistentry>
	<varlistentry>
	  <term><parameter role="keyword">start</parameter>&nbsp;:</term>
	  <listitem><simpara>the earliest event time
limit</simpara></listitem>
	</varlistentry>
	<varlistentry>
	  <term><parameter role="keyword">stop</parameter>&nbsp;:</term>
	  <listitem><simpara>the latest event time
limit</simpara></listitem>
	</varlistentry>
	<varlistentry>
	  <term><emphasis>Returns</emphasis>&nbsp;:</term>
	  <listitem><simpara>a tuple containing event tuples each with axes
data and a timestamp</simpara></listitem>
	</varlistentry>
      </variablelist>

      <para>The <methodname>get_history</methodname>() method returns a
tuple containing the motion history for the device with respect to the <link
linkend="class-gdkwindow"><classname>gtk.gdk.Window</classname></link>
specified by window between the time limits specified by
<parameter>start</parameter> and <parameter>stop</parameter>. The motion
history is a tuple containing event motion tuples that each contain a
timestamp for the event and a tuple with the axes data for the event.</para>

  </refsect2>

    <refsect2 id="method-gdkdevice--get-axis">
      <title>gtk.gdk.Device.get_axis</title>

      <programlisting><methodsynopsis language="python">
	  <methodname>get_axis</methodname>
	  <methodparam><parameter
			 role="keyword">axes</parameter></methodparam>
	  <methodparam><parameter
			 role="keyword">use</parameter></methodparam>
	</methodsynopsis></programlisting>
      <variablelist>
	<varlistentry>
	  <term><parameter role="keyword">axes</parameter>&nbsp;:</term>
	  <listitem><simpara>a sequence of axes values</simpara></listitem>
	</varlistentry>
	<varlistentry>
	  <term><parameter role="keyword">use</parameter>&nbsp;:</term>
	  <listitem><simpara>the axis use to match</simpara></listitem>
	</varlistentry>
	<varlistentry>
	  <term><emphasis>Returns</emphasis>&nbsp;:</term>
	  <listitem><simpara>the axis value from <parameter>axes</parameter>
that matches the use type or <literal>None</literal> if there is no
match.</simpara></listitem>
	</varlistentry>
      </variablelist>

      <para>The <methodname>get_axis</methodname>() method returns the value
in <parameter>axes</parameter> whose axis matches the specified
<parameter>use</parameter>.</para>

    </refsect2>

  </refsect1>

  <refsect1>
    <title>Functions</title>

    <refsect2 id="function-gdk--devices-list">
      <title>gtk.gdk.devices_list</title>

      <programlisting><methodsynopsis language="python">
          <methodname>gtk.gdk.devices_list</methodname>
          <methodparam></methodparam>
        </methodsynopsis></programlisting>

      <variablelist>
        <varlistentry>
	  <term><emphasis>Returns</emphasis>&nbsp;:</term>
          <listitem><simpara>a list containing the <link
linkend="class-gdkdevice"><classname>gtk.gdk.Device</classname></link>
objects for the default display</simpara></listitem>
        </varlistentry>
      </variablelist>

      <para>The <function>gtk.gdk.devices_list</function>() function returns
a list containing the <link
linkend="class-gdkdevice"><classname>gtk.gdk.Device</classname></link>
objects fro the default display.</para>

    </refsect2>

    <refsect2 id="function-gdk--device-get-core-pointer">
      <title>gtk.gdk.device_get_core_pointer</title>

      <programlisting><methodsynopsis language="python">
          <methodname>gtk.gdk.device_get_core_pointer</methodname>
          <methodparam></methodparam>
        </methodsynopsis></programlisting>

      <variablelist>
        <varlistentry>
          <term><emphasis>Returns</emphasis>&nbsp;:</term>
          <listitem><simpara>the </simpara></listitem>
        </varlistentry>
      </variablelist>

      <para>The <function>gtk.gdk.device_get_core_pointer</function>()
function returns the device that is used as the core pointer.</para>

    </refsect2>

  </refsect1>

</refentry>
