title: Parsing /dev/input/mice data
body: <p>I am writing a C program that reads and interprets the mouse position data from /dev/input/mice, and writes it out.  However I am having trouble figuring out how to interpret the data that I read from /dev/input/mice.  When I print out the raw data from reading /dev/input/mice, I get a long list of values.  For instance, this is what I get:</p>
  
  <pre><code>57, 129, 129
  </code></pre>
  
  <p>This data was generated by touching a touchscreen in the lower left hand corner.</p>
  
  <p>Does any one know how to parse this data (or can point to some documentation)?  Is this this raw data from the HID device itself, or is it from the kernel?  I read a few other posts on that there are only three bytes of data: Xpos, Ypos, and click status.  This cannot be true.  Both x and y data contain more resolution than can fit in one byte of data (2^8) and I get way more than only three bytes when I read from the /dev/input/mice file.</p>
  
  <p>Also, I am aware that there are libraries that communicate with the X-server which you can use to read the mouse data.  My question is specifically about the data from /dev/input/mice.</p>
  
  <p>In case it matters, I am running the code on a Raspberry Pi with Raspbian.  The code to read the values is:</p>
  
  <pre><code>char mouse_data[num_mouse_bytes];
  int mouse_directory = open("/dev/input/mice", O_RDONLY);
  int bytes_read = read(mouse_directory, mouse_data, num_mouse_bytes);
  int byte_index = 0;
  while(byte_index &lt; bytes_read){
      printf("%hhu, " mouse_data[byte_index]);
      byte_index++;
  }
  </code></pre>