Mouse.moveTo not working in linux?

Status
Not open for further replies.

tarriel

Member
I have a teensy 3.1 working as a keyboard and I wanted to incorporate a few mouse commands into it, I can get the mouse to move relative but I realy want to click a precise place on the screen. Also if I move the mouse fast in the sample code a delay of 1ms instead of 25 the cursor creeps and when I use the moveto nothing happens. I am running Linux Mint 17 Qiana i686. I Also tried setting Mouse.screenSize(3840, 1080, True); just incase, but that didn't seem to work either, again the mouse moved, but not to an absolute position.

I also tried just moving the mouse too far so it hits the edge (known position) then moving it back to where I want it, but this only moved probably 250 pixels at a time. So I am not sure it this will work. Is there anyone else having this problem? Is there a work around, or is it something stupid that I am doing? Code used is below, but it is basically the example code.

Code:
/* Simple USB Mouse Example
Mouse.move working, Mouse.moveTo ignored
*/

void setup() {
   Mouse.screenSize(3840, 1080);  // configure screen size
} 

void loop() {
  int i;
  for (i=0; i<40; i++) {
    Mouse.move(2, -1);
    delay(25);
  }
  for (i=0; i<40; i++) {
    Mouse.move(2, 2);
    delay(25);
  }
  for (i=0; i<40; i++) {
    Mouse.move(-4, -1);
    delay(25);
  }
  Mouse.moveTo(25, 100);
  delay(5000);
}

Code:
/*Mouse.move only moves about 500 pixels max, Mouse.moveTo ignored
*/
void setup() {
   Mouse.screenSize(3840, 1080);  // configure screen size
} // no setup needed
void loop() {
  int i;
  Mouse.move(-10000, -10000);
  delay(40);
  Mouse.move(100, 100);
  delay(40);
  Mouse.moveTo(25, 100);
  delay(5000);
}
 
I found this in the Xorg.log, of particular relavance might be where it says "ignoring absolute axes"
Code:
[    31.429] (II) config/udev: Adding input device Teensyduino Serial/Keyboard/Mouse/Joystick (/dev/input/event5)
[    31.429] (**) Teensyduino Serial/Keyboard/Mouse/Joystick: Applying InputClass "evdev keyboard catchall"
[    31.429] (II) Using input driver 'evdev' for 'Teensyduino Serial/Keyboard/Mouse/Joystick'
[    31.429] (**) Teensyduino Serial/Keyboard/Mouse/Joystick: always reports core events
[    31.429] (**) evdev: Teensyduino Serial/Keyboard/Mouse/Joystick: Device: "/dev/input/event5"
[    31.429] (--) evdev: Teensyduino Serial/Keyboard/Mouse/Joystick: Vendor 0x16c0 Product 0x487
[    31.429] (--) evdev: Teensyduino Serial/Keyboard/Mouse/Joystick: Found keys
[    31.429] (II) evdev: Teensyduino Serial/Keyboard/Mouse/Joystick: Configuring as keyboard
[    31.429] (**) Option "config_info" "udev:/sys/devices/pci0000:00/0000:00:1a.2/usb5/5-1/5-1:1.2/input/input5/event5"
[    31.429] (II) XINPUT: Adding extended input device "Teensyduino Serial/Keyboard/Mouse/Joystick" (type: KEYBOARD, id 12)
[    31.429] (**) Option "xkb_rules" "evdev"
[    31.429] (**) Option "xkb_model" "pc105"
[    31.429] (**) Option "xkb_layout" "us"
[    31.429] (II) config/udev: Adding input device Teensyduino Serial/Keyboard/Mouse/Joystick (/dev/input/event6)
[    31.429] (**) Teensyduino Serial/Keyboard/Mouse/Joystick: Applying InputClass "evdev pointer catchall"
[    31.429] (II) Using input driver 'evdev' for 'Teensyduino Serial/Keyboard/Mouse/Joystick'
[    31.429] (**) Teensyduino Serial/Keyboard/Mouse/Joystick: always reports core events
[    31.429] (**) evdev: Teensyduino Serial/Keyboard/Mouse/Joystick: Device: "/dev/input/event6"
[    31.429] (--) evdev: Teensyduino Serial/Keyboard/Mouse/Joystick: Vendor 0x16c0 Product 0x487
[    31.429] (--) evdev: Teensyduino Serial/Keyboard/Mouse/Joystick: Found 12 mouse buttons
[    31.429] (--) evdev: Teensyduino Serial/Keyboard/Mouse/Joystick: Found scroll wheel(s)
[    31.429] (--) evdev: Teensyduino Serial/Keyboard/Mouse/Joystick: Found relative axes
[    31.429] (--) evdev: Teensyduino Serial/Keyboard/Mouse/Joystick: Found x and y relative axes
[    31.429] (--) evdev: Teensyduino Serial/Keyboard/Mouse/Joystick: Found absolute axes
[    31.429] (--) evdev: Teensyduino Serial/Keyboard/Mouse/Joystick: Found x and y absolute axes
[    31.429] (II) evdev: Teensyduino Serial/Keyboard/Mouse/Joystick: Configuring as mouse
[    31.429] (II) evdev: Teensyduino Serial/Keyboard/Mouse/Joystick: Adding scrollwheel support
[    31.429] (**) evdev: Teensyduino Serial/Keyboard/Mouse/Joystick: YAxisMapping: buttons 4 and 5
[    31.429] (**) evdev: Teensyduino Serial/Keyboard/Mouse/Joystick: EmulateWheelButton: 4, EmulateWheelInertia: 10, EmulateWheelTimeout: 200
[    31.429] (**) Option "config_info" "udev:/sys/devices/pci0000:00/0000:00:1a.2/usb5/5-1/5-1:1.3/input/input6/event6"
[    31.430] (II) XINPUT: Adding extended input device "Teensyduino Serial/Keyboard/Mouse/Joystick" (type: MOUSE, id 13)
[    31.430] (II) evdev: Teensyduino Serial/Keyboard/Mouse/Joystick: initialized for relative axes.
[    31.430] (WW) evdev: Teensyduino Serial/Keyboard/Mouse/Joystick: ignoring absolute axes.
[    31.430] (**) Teensyduino Serial/Keyboard/Mouse/Joystick: (accel) keeping acceleration scheme 1
[    31.430] (**) Teensyduino Serial/Keyboard/Mouse/Joystick: (accel) acceleration profile 0
[    31.430] (**) Teensyduino Serial/Keyboard/Mouse/Joystick: (accel) acceleration factor: 2.000
[    31.430] (**) Teensyduino Serial/Keyboard/Mouse/Joystick: (accel) acceleration threshold: 4
[    31.430] (II) config/udev: Adding input device Teensyduino Serial/Keyboard/Mouse/Joystick (/dev/input/js0)
[    31.430] (II) No input driver specified, ignoring this device.
[    31.430] (II) This device may have been added with another device file.
[    31.430] (II) config/udev: Adding input device Teensyduino Serial/Keyboard/Mouse/Joystick (/dev/input/mouse1)
[    31.430] (II) No input driver specified, ignoring this device.
[    31.430] (II) This device may have been added with another device file.
[    31.430] (II) config/udev: Adding input device Teensyduino Serial/Keyboard/Mouse/Joystick (/dev/input/event7)
[    31.430] (II) No input driver specified, ignoring this device.
[    31.430] (II) This device may have been added with another device file.
[    31.431] (II) config/udev: Adding input device Teensyduino Serial/Keyboard/Mouse/Joystick (/dev/input/js1)
[    31.431] (II) No input driver specified, ignoring this device.
[    31.431] (II) This device may have been added with another device file.

that lead me to find this, so we can't have both a relative and absolute reference.
Code:
Option "IgnoreRelativeAxes" "Bool"
Option "IgnoreAbsoluteAxes" "Bool"
    Ignore the specified type of axis. Default: unset. The X server cannot deal with devices that have both relative and absolute axes. Evdev tries to guess wich axes to ignore given the device type and disables absolute axes for mice and relative axes for tablets, touchscreens and touchpad. These options allow to forcibly disable an axis type. Mouse wheel axes are exempt and will work even if relative axes are ignored. No property, this configuration must be set in the configuration.
    If either option is set to False, the driver will not ignore the specified axes regardless of the presence of other axes. This may trigger buggy behavior and events from this axis are always forwarded. Users are discouraged from setting this option.

After a bit more I get this error. device 13 is the teensy mouse, not sure where to go from here
Code:
$ xinput set-mode 13 ABSOLUTE 
X Error of failed request:  XI_BadMode (invalid Mode parameter)
  Major opcode of failed request:  131 (XInputExtension)
  Minor opcode of failed request:  5 (X_SetDeviceMode)
  Mode id in failed request: 0x17
  Serial number of failed request:  18
  Current serial number in output stream:  18
 
You'll need to edit the USB descriptors, in usb_desc.c.

In the HID mouse report data, there's some bytes for the relative axes. Probably the simplest thing would be to change those to some other usage numbers which Linux will ignore.

You could also just remove them, but then you've have the change the code in usb_mouse.c to not send those bytes. The length of the packet transmitted to the PC must exactly match the total length of all fields in the report descriptor.
 
Ok, thanks. I think this is a bit beyond me for now. I can see the #ifdef MOUSE_INTERFACE, and it looks like there are three sections, the buttons, the wheel and the position but the position appears to be absolute already?
Code:
0x81, 0x02,                     //   Input (Data, Variable, Absolute)
I tried reading the HID docs for an hour or so but they made little sense to me, I am sure they are wonderful once you already know enough, but not so good for the beginner. the 3rd Bit needs to be 0 for absolute reference as far as I can tell. There is a second section in usb_desc.c from line 513, but none of these numbers seems to be about relative or absolute positioning.
 
Last edited:
Thanks Elmue and Paul

This works for me now! I could never have gotten it by myself. I had set up a python script to trigger on specific key commands as a work around but this will be much cleaner. Perhaps Paul can add tablet support to the list of devices supported when he gets a minute or two free.
 
Status
Not open for further replies.
Back
Top