Sophie

Sophie

distrib > Mageia > 5 > i586 > media > core-release > by-pkgid > 50facae208d4a6f280e44a513b104320 > files > 300

qt-mobility-doc-1.2.0-13.mga5.noarch.rpm

<?xml version="1.0" encoding="UTF-8"?>
<!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" xml:lang="en_US" lang="en_US">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- sensors.qdoc -->
  <title>Qt Mobility 1.2: Determining the default sensor for a type</title>
  <link rel="stylesheet" type="text/css" href="style/offline.css" />
</head>
<body>
<div class="header" id="qtdocheader">
  <div class="content"> 
    <a href="index.html" class="qtref"><span>QtMobility Reference Documentation</span></a>
  </div>
  <div class="breadcrumb toolblock">
    <ul>
      <li class="first"><a href="index.html">Home</a></li>
      <!--  Breadcrumbs go here -->
<li>Determining the default sensor for a type</li>
    </ul>
  </div>
</div>
<div class="content mainContent">
<div class="toc">
<h3><a name="toc">Contents</a></h3>
<ul>
<li class="level1"><a href="#multiple-sensors-can-exist-for-a-type">Multiple sensors can exist for a type</a></li>
<li class="level1"><a href="#default-sensor-for-a-type">Default sensor for a type</a></li>
<li class="level1"><a href="#sensors-conf">Sensors.conf</a></li>
</ul>
</div>
<h1 class="title">Determining the default sensor for a type</h1>
<span class="subtitle"></span>
<!-- $$$determining-the-default-sensor-for-a-type.html-description -->
<div class="descr"> <a name="details"></a>
<a name="multiple-sensors-can-exist-for-a-type"></a>
<h2>Multiple sensors can exist for a type</h2>
<p>Sensors was designed so that multiple sensors could exist for a given type. Why? Consider this example.</p>
<p>The N900 has an accelerometer built-in. It also features bluetooth and can pair with a gaming controller that features an accelerometer. To a developer writing a game these two devices are conceptually the same type.</p>
<a name="default-sensor-for-a-type"></a>
<h2>Default sensor for a type</h2>
<p>To avoid the need to know (or check) what the default sensor for a type is, the system will use the default sensor for a type. Most of the time this is what the app developer wants to do. In cases where the app developer wants to select a specific sensor they must call the <a href="qsensor.html#sensorid-prop">QSensor::setIdentifier</a>() method before they start the sensor so that the appropriate backend is used.</p>
<p>From a system perspective though, selecting which sensor should be the default gets tricky. The sensors library uses the first registered identifier as the default. This means that the order in which sensor backends are registered is important so the system will allow a config file to determine the default instead.</p>
<a name="sensors-conf"></a>
<h2>Sensors.conf</h2>
<p>The config file that determines the default sensor for a type is called Sensors.conf. If present, it is located in /etc/xdg/Nokia. It is read using <a href="http://qt.nokia.com/doc/4.7/qsettings.html">QSettings</a> so it has the standard formatting of a <a href="http://qt.nokia.com/doc/4.7/qsettings.html">QSettings</a> .conf file.</p>
<p>The settings live in the Default group and the general format is:</p>
<pre class="cpp"> type <span class="operator">=</span> identifier</pre>
<p>An example Sensors.conf that ensures the N900 accelerometer is used as the default no matter the order in which backends were registered is presented here.</p>
<pre class="cpp"> <span class="operator">[</span>Default<span class="operator">]</span>
 <span class="type"><a href="qaccelerometer.html">QAccelerometer</a></span> <span class="operator">=</span> n900<span class="operator">.</span>accelerometer</pre>
<p>If Sensors.conf specifies an identifier that is not registered then the system will fall back to the first registered identifier as the default.</p>
<p>Note that there is special case logic to prevent the generic plugin's backends from becoming the default when another backend is registered for the same type. This logic means that a backend identifier starting with <tt>generic.</tt> will only be the default if no other backends have been registered for that type or if it is specified in <tt>Sensors.conf</tt>.</p>
</div>
<!-- @@@determining-the-default-sensor-for-a-type.html -->
  <div class="ft">
    <span></span>
  </div>
</div> 
<div class="footer">
  <p>
     <acronym title="Copyright">&copy;</acronym> 2008-2011 Nokia Corporation and/or its
     subsidiaries. Nokia, Qt and their respective logos are trademarks of Nokia Corporation 
     in Finland and/or other countries worldwide.</p>
  <p>
     All other trademarks are property of their respective owners. <a title="Privacy Policy"
     href="http://qt.nokia.com/about/privacy-policy">Privacy Policy</a></p>
  <br />
  <p>
    Licensees holding valid Qt Commercial licenses may use this document in accordance with the    Qt Commercial License Agreement provided with the Software or, alternatively, in accordance    with the terms contained in a written agreement between you and Nokia.</p>
  <p>
    Alternatively, this document may be used under the terms of the <a href="http://www.gnu.org/licenses/fdl.html">GNU
    Free Documentation License version 1.3</a>
    as published by the Free Software Foundation.</p>
</div>
</body>
</html>