title: Uinput - Mouse events were not working
body: <p>I was finding a problem in emulating the mouse events via uinput device event files.</p>
  
  <p>I could write the event with 'struct input_event' structure format for keyboard/mouse events but only key events were working fine and mouse events were not working</p>
  
  <p>I enabled all the bits required for uinput</p>
  
  <pre><code>UI_SET_EVBIT - EV_KEY (keyboard/mouse), EV_REP (Repeating events), EV_SYN (Sync report events), EV_REL (Mouse)
  
  UI_SET_RELBIT - REL_X, REL_Y (Mouse)
  
  UI_SET_KEYBIT - All the keys in keyboard, BTN_MOUSE, BTN_LEFT, BTN_RIGHT, BTN_MIDDLE
  </code></pre>
  
  <p>I triggered the events with the below code</p>
  
  <pre><code>gettimeofday(&amp;ev.time,0);
  ev.type = EV_KEY;
  ev.code = BTN_LEFT;
  ev.value = &lt;MOUSE PRESS/RELEASE&gt;; // tbhis wil lbe either 0 or 1
  if(write(uinputfd, &amp;ev, sizeof(ev)) &lt; 0)
  {
      return false;
  }
  
  // Then send the X
  gettimeofday(&amp;ev.time,0);
  ev.type = EV_REL;
  ev.code = REL_X;
  ev.value = x;
  if(write(uinputfd, &amp;ev, sizeof(ev)) &lt; 0)
  {
      return false;
  }
  
  // Then send the Y
  gettimeofday(&amp;ev.time,0);
  ev.type = EV_REL;
  ev.code = REL_Y;
  ev.value = y;
  if(write(uinputfd, &amp;ev, sizeof(ev)) &lt; 0)
  {
      return false;
  }
  
  // Finally send the SYN
  gettimeofday(&amp;ev.time,0);
  ev.type = EV_SYN;
  ev.code = SYN_REPORT;
  ev.value = 0;
  if(write(uinputfd, &amp;ev, sizeof(ev)) &lt; 0)
  {
      return false;
  }
  </code></pre>
  
  <p>Also, I could read/print the Keyboard/Mouse events from the corresponding uinput device input files.</p>
  
  <p>Does anybody have any idea why only mouse events were not working?</p>