116 lines
20 KiB
HTML
116 lines
20 KiB
HTML
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||
<html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>The Be Book - Classes And Methods - The Input Server</title><link rel="stylesheet" href="be_book.css" type="text/css" media="all" /><link rel="shortcut icon" type="image/vnd.microsoft.icon" href="./images/favicon.ico" /><!--[if IE]>
|
||
<link rel="stylesheet" type="text/css" href="be_book_ie.css" />
|
||
<![endif]--><meta name="generator" content="DocBook XSL Stylesheets V1.73.2" /><meta name="keywords" content="Access, BeOS, BeBook, API" /><link rel="start" href="index.html" title="The Be Book" /><link rel="up" href="TheInputServer.html" title="The Input Server" /><link rel="prev" href="TheInputServer.html" title="The Input Server" /><link rel="next" href="BInputServerDevice.html" title="BInputServerDevice" /></head><body><div id="header"><div id="headerT"><div id="headerTL"><a accesskey="p" href="TheInputServer.html" title="The Input Server"><img src="./images/navigation/prev.png" alt="Prev" /></a> <a accesskey="u" href="TheInputServer.html" title="The Input Server"><img src="./images/navigation/up.png" alt="Up" /></a> <a accesskey="n" href="BInputServerDevice.html" title="BInputServerDevice"><img src="./images/navigation/next.png" alt="Next" /></a></div><div id="headerTR"><div id="navigpeople"><a href="http://www.haiku-os.org"><img src="./images/People_24.png" alt="haiku-os.org" title="Visit The Haiku Website" /></a></div><div class="navighome" title="Home"><a accesskey="h" href="index.html"><img src="./images/navigation/home.png" alt="Home" /></a></div><div class="navigboxed" id="navigindex"><a accesskey="i" href="ClassIndex.html" title="Index">I</a></div><div class="navigboxed" id="naviglang" title="English">en</div></div><div id="headerTC">The Be Book - Classes And Methods - The Input Server</div></div><div id="headerB">Prev: <a href="TheInputServer.html">The Input Server</a> Up: <a href="TheInputServer.html">The Input Server</a> Next: <a href="BInputServerDevice.html">BInputServerDevice</a></div><hr /></div><div class="section"><div xmlns="" xmlns:d="http://docbook.org/ns/docbook" class="titlepage"><div><div xmlns:d="http://docbook.org/ns/docbook"><h2 xmlns="http://www.w3.org/1999/xhtml" class="title"><a id="BInputDevice"></a>BInputDevice</h2></div></div></div><a id="id958852" class="indexterm"></a><div class="classheader"><table border="0"><colgroup><col /><col /></colgroup><tbody><tr><td><table width="100%" border="0"><colgroup><col /><col /></colgroup><tbody><tr><td>Derived From:</td><td>–</td></tr><tr><td>Mix-in Classes:</td><td>–</td></tr><tr><td>Declared In:</td><td><code class="filename">interface/Input.h</code></td></tr><tr><td>Library:</td><td><code class="filename">libbe.so</code></td></tr><tr><td>Allocation:</td><td>By the system only. See
|
||
<a class="link" href="BInputDevice.html#find_input_device" title="find_input_device(), get_input_devices()"><code class="function">find_input_device()</code></a>.</td></tr></tbody></table></td><td>
|
||
<a class="link overview" href="BInputDevice_Overview.html" title="BInputDevice">Class Overview</a>
|
||
<div class="toc"><ul><li><span class="section"><a href="BInputDevice.html#BInputDevice_ConstructorDestructor">Constructor and Destructor</a></span></li><li><span class="section"><a href="BInputDevice.html#BInputDevice_MemberFunctions">Member Functions</a></span></li><li><span class="section"><a href="BInputDevice.html#BInputDevice_Functions">C Functions</a></span></li></ul></div>
|
||
</td></tr></tbody></table></div><div class="section"><div xmlns="" xmlns:d="http://docbook.org/ns/docbook" class="titlepage"><div><hr /><div xmlns:d="http://docbook.org/ns/docbook"><h3 xmlns="http://www.w3.org/1999/xhtml" class="title"><a id="BInputDevice_ConstructorDestructor"></a>Constructor and Destructor</h3></div></div></div><div class="section"><div xmlns="" xmlns:d="http://docbook.org/ns/docbook" class="titlepage"><div><div xmlns:d="http://docbook.org/ns/docbook"><h4 xmlns="http://www.w3.org/1999/xhtml" class="title"><a id="BInputDevice_Constructor"></a>BInputDevice()</h4></div></div></div><code class="constructorsynopsis cpp"><span class="methodname">BInputDevice</span>();</code><p>
|
||
The constructor is private. Use
|
||
<a class="link" href="BInputDevice.html#find_input_device" title="find_input_device(), get_input_devices()"><code class="function">find_input_device()</code></a> or
|
||
<a class="link" href="BInputDevice.html#get_input_devices"><code class="function">get_input_devices()</code></a>
|
||
to retrieve a <code class="classname">BInputDevice</code> instance.
|
||
</p></div><div class="section"><div xmlns="" xmlns:d="http://docbook.org/ns/docbook" class="titlepage"><div><div xmlns:d="http://docbook.org/ns/docbook"><h4 xmlns="http://www.w3.org/1999/xhtml" class="title"><a id="BInputDevice_Destructor"></a>~BInputDevice()</h4></div></div></div><code class="destructorsynopsis cpp"><span class="methodname">BInputDevice</span>();</code><p>
|
||
Deletes the <code class="classname">BInputDevice</code> object. Deleting this object doesn't affect the
|
||
device that it represents.
|
||
</p></div></div><div class="section"><div xmlns="" xmlns:d="http://docbook.org/ns/docbook" class="titlepage"><div><hr /><div xmlns:d="http://docbook.org/ns/docbook"><h3 xmlns="http://www.w3.org/1999/xhtml" class="title"><a id="BInputDevice_MemberFunctions"></a>Member Functions</h3></div></div></div><div class="section"><div xmlns="" xmlns:d="http://docbook.org/ns/docbook" class="titlepage"><div><div xmlns:d="http://docbook.org/ns/docbook"><h4 xmlns="http://www.w3.org/1999/xhtml" class="title"><a id="BInputDevice_Control"></a>Control()</h4></div></div></div><div class="synopsisgroup">
|
||
<code class="methodsynopsis cpp"><span class="type">status_t </span><span class="methodname">Control</span>(<span class="methodparam"><span class="type">uint32 </span><span class="parameter">code</span></span>,<br /> <span class="methodparam"><span class="type"><a class="link" href="BMessage.html" title="BMessage"><code class="classname">BMessage</code></a>* </span><span class="parameter">message</span></span>);</code>
|
||
|
||
<code class="methodsynopsis cpp"><span class="type">status_t </span><span class="methodname">Control</span>(<span class="methodparam"><span class="type">input_device_type </span><span class="parameter">type</span></span>,<br /> <span class="methodparam"><span class="type">uint32 </span><span class="parameter">code</span></span>,<br /> <span class="methodparam"><span class="type"><a class="link" href="BMessage.html" title="BMessage"><code class="classname">BMessage</code></a>* </span><span class="parameter">message</span></span>);</code>
|
||
</div><p>Sends an input device control message to the object's input device or, in
|
||
the static version, to all devices of the given type, where, type can be
|
||
<code class="constant">B_POINTING_DEVICE</code>, <code class="constant">B_KEYBOARD_DEVICE</code>,
|
||
or <code class="constant">B_UNDEFINED_DEVICE</code>. Input
|
||
devices receive these messages in their
|
||
<code class="methodname">Control()</code> function.</p><p>The control message is described by the <code class="parameter">code</code> value; it can be
|
||
supplemented or refined by <code class="parameter">message</code>.
|
||
For example, <code class="parameter">code</code> can indicate that a
|
||
certain parameter should be set, and message can supply the requested
|
||
value.</p><div class="admonition note"><div class="title">Note</div><div class="graphic"><img class="icon" alt="Note" width="32" src="./images/admonitions/Info_32.png" /><div class="text"><p>In general, you only use this function to send custom messages to a
|
||
(custom) device. You never use it to send messages to a Be-defined input
|
||
device since the messages that these devices respond to are covered by
|
||
Be-defined functions. See
|
||
"Input Device Control Messages"
|
||
for a list of
|
||
the messages that the Be-defined devices respond to, the functions that
|
||
cover them, and the German women who love them.</p></div></div></div></div><div class="section"><div xmlns="" xmlns:d="http://docbook.org/ns/docbook" class="titlepage"><div><div xmlns:d="http://docbook.org/ns/docbook"><h4 xmlns="http://www.w3.org/1999/xhtml" class="title"><a id="BInputDevice_Name"></a><a id="BInputDevice_Type"></a>
|
||
Name(), Type()</h4></div></div></div><code class="methodsynopsis cpp"><span class="modifier">const </span><span class="type">char* </span><span class="methodname">Name</span>() <span class="modifier">const</span>;</code><code class="methodsynopsis cpp"><span class="type">input_device_type </span><span class="methodname">Type</span>() <span class="modifier">const</span>;</code><p><code class="methodname">Name()</code> returns a pointer to the input device's name. The name,
|
||
which is set when the device is registered, is meant to be human-readable
|
||
and appropriate for use as the label of a UI element (such as a menu
|
||
field). Device names are not unique.</p><p><code class="methodname">Type()</code> returns the input device's type, one of
|
||
<code class="constant">B_POINTING_DEVICE</code>,
|
||
<code class="constant">B_KEYBOARD_DEVICE</code>, and <code class="constant">B_UNDEFINED_DEVICE</code>.</p></div><div class="section"><div xmlns="" xmlns:d="http://docbook.org/ns/docbook" class="titlepage"><div><div xmlns:d="http://docbook.org/ns/docbook"><h4 xmlns="http://www.w3.org/1999/xhtml" class="title"><a id="BInputDevice_Start"></a><a id="BInputDevice_Stop"></a>
|
||
<a id="BInputDevice_IsRunning"></a>
|
||
Start(), Stop(), IsRunning()</h4></div></div></div><div class="synopsisgroup">
|
||
<code class="methodsynopsis cpp"><span class="type">status_t </span><span class="methodname">Start</span>();</code>
|
||
|
||
<code class="methodsynopsis cpp"><span class="modifier">static </span><span class="type">status_t </span><span class="methodname">Start</span>(<span class="methodparam"><span class="type">input_device_type </span><span class="parameter">type</span></span>);</code>
|
||
</div><code class="methodsynopsis cpp"><span class="type">bool </span><span class="methodname">IsRunning</span>() <span class="modifier">const</span>;</code><code class="methodsynopsis cpp"><span class="modifier">static </span><span class="type">status_t </span><span class="methodname">Stop</span>(<span class="methodparam"><span class="type">input_device_type </span><span class="parameter">type</span></span>);</code><p><code class="methodname">Start()</code> tells the object's input device to
|
||
start generating events; <code class="methodname">Stop()</code> tells it to stop
|
||
generating events. <code class="methodname">IsRunning()</code> returns
|
||
<code class="constant">true</code> if the device is currently generating events
|
||
(i.e. if it has been started and hasn't been stopped).</p><p>The static versions of <code class="methodname">Start()</code> and
|
||
<code class="methodname">Stop()</code> start and stop all devices of the given
|
||
type.</p><div class="admonition warning"><div class="title">Warning</div><div class="graphic"><img class="icon" alt="Warning" width="32" src="./images/admonitions/Stop_32.png" /><div class="text"><p>The Input Server tells a device to start and stop without asking the
|
||
device if the operation was successful. This means, for example, that
|
||
<code class="methodname">Start()</code> can return <code class="constant">B_OK</code> (and
|
||
<code class="methodname">IsRunning()</code> can return <code class="constant">true</code>)
|
||
even if the device isn't really running. For the Be-provided devices this
|
||
isn't an issue—starting and stopping always succeeds (as long as the
|
||
device exists).</p></div></div></div><table class="variablelist returncodes"><thead><tr><th>Return Code</th><th>Description</th></tr></thead><tbody><tr><td><p><span class="term"><code class="constant">B_OK</code>.</span></p></td><td><p>The device is now started
|
||
(<code class="methodname">Start()</code>) or stopped
|
||
(<code class="methodname">Stop()</code>)—even if the device was already started
|
||
or stopped.</p></td></tr><tr><td><p><span class="term"><code class="constant">B_ERROR</code>.</span></p></td><td><p>The device couldn't be found.</p></td></tr></tbody></table></div></div><div class="section"><div xmlns="" xmlns:d="http://docbook.org/ns/docbook" class="titlepage"><div><hr /><div xmlns:d="http://docbook.org/ns/docbook"><h3 xmlns="http://www.w3.org/1999/xhtml" class="title"><a id="BInputDevice_Functions"></a>C Functions</h3></div></div></div><div class="section"><div xmlns="" xmlns:d="http://docbook.org/ns/docbook" class="titlepage"><div><div xmlns:d="http://docbook.org/ns/docbook"><h4 xmlns="http://www.w3.org/1999/xhtml" class="title"><a id="find_input_device"></a><a id="get_input_devices"></a>
|
||
find_input_device(), get_input_devices()</h4></div></div></div><a id="id959596" class="indexterm"></a><a id="id959603" class="indexterm"></a><code class="methodsynopsis cpp"><span class="type">BInputDevice* </span><span class="methodname">find_input_device</span>(<span class="methodparam"><span class="modifier">const </span><span class="type">char * </span><span class="parameter">name</span></span>);</code><code class="methodsynopsis cpp"><span class="type">status_t </span><span class="methodname">get_input_devices</span>(<span class="methodparam"><span class="type">BList * </span><span class="parameter">list</span></span>);</code><p>These functions get <code class="classname">BInputDevice</code> objects for you.</p><p><code class="function">find_input_device()</code> creates and hands
|
||
you a <code class="classname">BInputDevice</code> object that
|
||
represents the Input Server device registered as name. If name is
|
||
invalid, the function returns <code class="constant">NULL</code>. The caller is responsible for
|
||
deleting the object. Note that <code class="function">find_input_device()</code> returns a new
|
||
<code class="classname">BInputDevice</code> object for each (valid) call, even if you ask for the same
|
||
device more than once.</p><p><code class="function">get_input_devices()</code> creates a new BInputDevice object for each registered
|
||
device, and puts the objects in your list argument. list must already be
|
||
allocated, and is automatically emptied by the function (even if the
|
||
function fails). If the function succeeds, the caller owns the contents,
|
||
and needs to delete the items in the list:</p><pre class="programlisting example cpp">#include <interface/Input.h>
|
||
#include <support/List.h>
|
||
|
||
...
|
||
|
||
<span class="type">static bool</span> <code class="function">del_InputDevice</code>( <span class="type">void *</span><code class="parameter">ptr</code> )
|
||
{
|
||
if( <code class="parameter">ptr</code> ) {
|
||
<span class="type">BInputDevice *</span><code class="varname">dev</code> = (<span class="type">BInputDevice *</span>)<code class="parameter">ptr</code>;
|
||
delete <code class="varname">dev</code>;
|
||
|
||
return <code class="constant">false</code>;
|
||
}
|
||
|
||
return <code class="constant">true</code>;
|
||
}
|
||
|
||
...
|
||
|
||
<span class="type">void</span> <code class="function">SomeFunc</code>( <span class="type">void</span> )
|
||
{
|
||
<span class="comment">// Get a list of all input devices.</span>
|
||
<code class="classname">BList</code> <code class="varname">list_o_devices</code>;
|
||
|
||
<span class="type">status_t</span> <code class="varname">retval</code> = <code class="function">get_input_devices</code>( &<code class="varname">list_o_devices</code> );
|
||
if( <code class="varname">retval</code> != <code class="constant">B_OK</code> ) return;
|
||
|
||
<span class="comment">// Do something with the input devices.</span>
|
||
...
|
||
|
||
<span class="comment">// Dispose of the device list.</span>
|
||
<code class="varname">list_o_devices</code>.<code class="methodname">DoForEach</code>( <code class="function">del_InputDevice</code> );
|
||
<code class="varname">list_o_devices</code>.<code class="methodname">MakeEmpty</code>();
|
||
}</pre><p><code class="function">get_input_devices()</code> returns:</p><table class="variablelist returncodes"><thead><tr><th>Return Code</th><th>Description</th></tr></thead><tbody><tr><td><p><span class="term"><code class="constant">B_OK</code>.</span></p></td><td><p>Success.</p></td></tr><tr><td><p><span class="term"><code class="constant">B_ERROR</code>.</span></p></td><td><p>General failure.</p></td></tr><tr><td><p><span class="term"><code class="constant">B_BAD_PORT_ID</code>.</span></p></td><td><p>Couldn't talk to the Input Server.</p></td></tr><tr><td><p><span class="term"><code class="constant">B_TIMED_OUT</code>.</span></p></td><td><p>The Input Server is no longer on speaking terms with
|
||
your application.</p></td></tr><tr><td><p><span class="term"><code class="constant">B_WOULD_BLOCK</code>.</span></p></td><td><p>More trouble communicating with the Input Server.</p></td></tr></tbody></table></div><div class="section"><div xmlns="" xmlns:d="http://docbook.org/ns/docbook" class="titlepage"><div><div xmlns:d="http://docbook.org/ns/docbook"><h4 xmlns="http://www.w3.org/1999/xhtml" class="title"><a id="watch_input_devices"></a>watch_input_devices()</h4></div></div></div><a id="id959942" class="indexterm"></a><code class="methodsynopsis cpp"><span class="type">status_t </span><span class="methodname">watch_input_devices</span>(<span class="methodparam"><span class="type">BMessenger </span><span class="parameter">target</span></span>,<br /> <span class="methodparam"><span class="type">bool </span><span class="parameter">start</span></span>);</code><p>Tells the Input Server to start or stop watching (as
|
||
<code class="parameter">start</code> is <code class="constant">true</code> or
|
||
<code class="constant">false</code>) for changes to the set of registered devices.
|
||
Change notifications are sent to <code class="parameter">target</code>. The set of messages that the
|
||
Server may send are listed in Input Server Messages.</p><div class="admonition note"><div class="title">Note</div><div class="graphic"><img class="icon" alt="Note" width="32" src="./images/admonitions/Info_32.png" /><div class="text"><p><code class="function">watch_input_devices()</code> is not currently implemented.</p></div></div></div></div></div></div><div id="footer"><hr /><div id="footerT">Prev: <a href="TheInputServer.html">The Input Server</a> Up: <a href="TheInputServer.html">The Input Server</a> Next: <a href="BInputServerDevice.html">BInputServerDevice</a> </div><div id="footerB"><div id="footerBL"><a href="TheInputServer.html" title="The Input Server"><img src="./images/navigation/prev.png" alt="Prev" /></a> <a href="TheInputServer.html" title="The Input Server"><img src="./images/navigation/up.png" alt="Up" /></a> <a href="BInputServerDevice.html" title="BInputServerDevice"><img src="./images/navigation/next.png" alt="Next" /></a></div><div id="footerBR"><div><a href="http://www.haiku-os.org"><img src="./images/People_24.png" alt="haiku-os.org" title="Visit The Haiku Website" /></a></div><div class="navighome" title="Home"><a accesskey="h" href="index.html"><img src="./images/navigation/home.png" alt="Home" /></a></div></div><div id="footerBC"><a href="http://www.access-company.com/home.html" title="ACCESS Co."><img alt="Access Company" src="./images/access_logo.png" /></a></div></div></div><div id="licenseFooter"><div id="licenseFooterBL"><a rel="license" href="http://creativecommons.org/licenses/by-nc-nd/3.0/" title="Creative Commons License"><img alt="Creative Commons License" style="border-width:0" src="https://licensebuttons.net/l/by-nc-nd/3.0/88x31.png" /></a></div><div id="licenseFooterBR"><a href="./LegalNotice.html">Legal Notice</a></div><div id="licenseFooterBC"><span id="licenseText">This work is licensed under a
|
||
<a rel="license" href="http://creativecommons.org/licenses/by-nc-nd/3.0/">Creative
|
||
Commons Attribution-Non commercial-No Derivative Works 3.0 License</a>.</span></div></div></body></html>
|