Skip to content

Echomouse

Géry Casiez edited this page Sep 1, 2019 · 10 revisions

Pseudo mouse used to obtain transfer functions

Different methods

There are different ways to obtain a pointing transfer function:

  • Finding the source code for the transfer functions in a given system and include into our own code. In libpointing, transfer functions for Mac OS X 10.6 and Xorg were obtained in this way.
  • Implementing it from scratch, however, in this case, its description should be known. Windows transfer functions in libpointing were obtained in this way.
  • Yet another way is to use EchoMouse, which sends the data in pointing space, then the response in display space is observed. Repeating this for sufficient number of points and conditions, the whole transfer function can be obtained. With EchoMouse we can obtain the model of the transfer function numerically.

EchoMouse is an electronic device that is designed to measure a system's response to pointing movements received from an HID equipment (typically a computer mouse). In 2011, we developed EchoMouse based on a Microchip PIC (18LF14K50), which is described in details here. Since then, Arduino Leonardo boards appeared on the market allowing a straightforward use of EchoMouse. Both methods are described below.

Methodology

To construct EchoMouse we used a few devices. Microchip PIC (18LF14K50), STM32, Arduino Leonardo. The simplest Echomouse can be built with Arduino Leonardo. In the case of Arduino, EchoMouse receives the number of counts to move by serial port and sends it by HID (as a simple mouse).

Here is the main algorithm used to do that:

  • Write mouse and display hardware settings (Resolution and update rate)
  • For each available configuration of the mouse speed or acceleration in the system:
    • Perform the following for N_points = 1 to 127:
      • Move cursor position to the position (0, disp_height / 2)
      • Receive the N_points by a serial port.
      • Repeat this until we hit the border of the display (remember N_times):
        • Send this number by HID Mouse (usually only horizontal direction, since the transfer function is the same in both directions).
      • Measure the N_pixels / N_times corresponding to the N_points.
  • At the end we can have full acceleration profile and can plot the transfer function.

From the obtained results we can approximate a transfer function of any system. However, the results may differ depending on many other parameters, like:

  • Subpixel processing (how the remainders are handled in the system).
  • Correlation between dx and dy. Since, the transfer functions are computed for a single direction, when there are 2D motions, the gain of the transfer function may take into account only the biggest, or a combination of the two. In many cases, the gain is applied to the norm of the displacements (dd = sqrt(dx^2 + dy^2)).
  • Rounding of the gains

Since using Echomouse we approximate the transfer functions and make assumptions, there are small errors, but they are negligible, the overall shape of the transfer function is always perceptible. In libpointing, Logitech transfer functions, and latest Mac OS X transfer functions are obtained by EchoMouse.

Integration with libpointing

Using Echomouse we can construct a table containing one-to-one correspondance of points-pixels. In libpointing, a special subclass of TransferFunction class was implemented to read the data files obtained by EchoMouse. This class is called Interpolation, because it can interpolate for the missing values using the closest neighbor values. To use the interpolation, interp:foldername transfer function must be used, where foldername is the folder containing the data. The folder contains config.dict file describing the input and output conditions which were used by Echomouse and different acceleration or speed profiles. Then for each of the acceleration or speed profiles there is a .dat file in the same folder containing the point - pixel correspondences.

Build your own EchoMouse using Arduino Leonardo

Here is the code which receives the messages from serial port and sends the command to move the Mouse:

#include <Mouse.h>

int incomingByte = 0;   // for incoming serial data

void setup() {
    Serial.begin(57600); // The speed of the serial device
    Mouse.begin();       // Initialize mouse
}

void loop() {
    if (Serial.available() > 0) { // If there are incoming bytes
        incomingByte = Serial.read();
        Mouse.move(incomingByte, 0); // Move mouse in x-direction
    }
}

So, all you need to do is to send the displacement values by serial port.

Build your own EchoMouse using a PIC

Based on a Microchip PIC (18LF14K50), it includes two switches and two LEDs for debugging purposes. Its program uses a mouse firmware, so it appears as an ordinary HID mouse to the system. It has no motion sensor, though. We instead added an output and a feature report to the firmware to which a program can send an HID report to be echoed by the device on its input report. Reports are expected and echoed in HID boot format. They are thus indistinguishable from genuine mouse reports and handled as such by the system. EchoMouse was designed to retrieve transfer functions used on modern operating systems.

Reports are sent to EchoMouse using HID API which was modified to work on Windows. The PIC18LF14K50 can be programmed using the followings programmers: MPLAB PM3, MPLAB REAL ICE, MPLAB ICD 2, MPLAB ICD 3, PICKIT 2, PICkit 3.

EchoMouse Schematic EchoMouse inside EchoMouse leds side EchoMouse pickit pins side

Author

Géry Casiez

Licence

Most of the code is adapted from Microchip examples + additional code coming from Jan Axelson for feature reports. It is provided as is.

Download

The EchoMouse firmware source code and the source code to communicate with the device on OS X, Linux and Windows is available for download: EchoMouse.zip, version 0.9