Jump to content
Sign in to follow this  
Brian Van Den Beuken

minor issues with mouse

Recommended Posts

got my TB2 today, and pleased to say it works pretty much out of the box. But I do have one small issue, my project needs me to get access to the mouse scroll wheel, directly, and normally I do this by putting the mouse into ImPS/2 mode

using this code... however it gives me the the cannot switch error... Is there any known reason for this?

static const size_t        mousedev_seq_len = 6;
static const unsigned char mousedev_imps_seq[] = { 0xf3, 200, 0xf3, 100, 0xf3, 80 };
	unsigned char buffer[4];
	ssize_t       len;
	const char* devpath = "/dev/input/mice";
	int           wasleft, wasmiddle, wasright;

	devfd = open(devpath, O_RDWR | O_NOCTTY);

	/* Switch the mouse to ImPS/2 protocol. */
	if (write(devfd, mousedev_imps_seq, mousedev_seq_len) != (ssize_t)mousedev_seq_len) 
		fprintf(stderr, "Cannot switch to ImPS/2 protocol.\n");
		return (void*)&devfd;; // this is rubbish to give a retun value
	if (read(devfd, buffer, sizeof buffer) != 1 || buffer[0] != 0xFA) {
		fprintf(stderr, "Failed to switch to ImPS/2 protocol.\n");
		return (void*)&devfd;


Edited by Brian Van Den Beuken

Share this post

Link to post
Share on other sites


Please check your devpath. You can use "dmesg" or "udevadm monitor" command to get more information.

root@linaro-alip:/dev/input/by-id# udevadm monitor
monitor will print the received events for:
UDEV - the event which udev sends out after rule processing
KERNEL - the kernel uevent
[  458.189823] usb 5-1.3: new low-speed USB device number 4 using xhci-hcd
[  458.298912] usb 5-1.3: New USB device found, idVendor=0461, idProduct=4e84
[  458.305868] usb 5-1.3: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[  458.313467] usb 5-1.3: Product: USB Optical Mouse
[  458.318335] usb 5-1.3: Manufacturer: PixArt
[  458.324909] usb 5-1.3: ep 0x81 - rounding interval to 64 microframes, ep desc says 80 microframes
KERNEL[458.005759] add      /devices/platform/usb1/fe900000.dwc3/xhci-hcd.11.auto/usb5/5-1/5-1.3 (usb)
KERNEL[458.047247] add      /devices/platform/usb1/fe900000.dwc3/xhci-hcd.11.auto/usb5/5-1/5-1.3/5-1.3:1.0 (usb)
KERNEL[458.054557] add      /devices/platform/usb1/fe900000.dwc3/xhci-hcd.11.auto/usb5/5-1/5-1.3/5-1.3:1.0/0003:0461:4E84.0002 (hid)
[  458.383211] input: PixArt USB Optical Mouse as /devices/platform/usb1/fe900000.dwc3/xhci-hcd.11.auto/usb5/5-1/5-1.3/5-1.3:1.0/0003:0461:4E84.0002/input/input5
KERNEL[458.063876] add      /devices/platform/usb1/fe900000.dwc3/xhci-hcd.11.auto/usb5/5-1/5-1.3/5-1.3:1.0/0003:0461:4E84.0002/input/input5 (input)
KERNEL[458.090385] add      /devices/platform/usb1/fe900000.dwc3/xhci-hcd.11.auto/usb5/5-1/5-1.3/5-1.3:1.0/0003:0461:4E84.0002/input/input5/event3 (input)
[  458.453946] hid-generic 0003:0461:4E84.0002: input,hidraw0: USB HID v1.11 Mouse [PixArt USB Optical Mouse] on usb-xhci-hcd.11.auto-1.3/input0
KERNEL[458.134852] add      /devices/platform/usb1/fe900000.dwc3/xhci-hcd.11.auto/usb5/5-1/5-1.3/5-1.3:1.0/0003:0461:4E84.0002/hidraw/hidraw0 (hidraw)
UDEV  [458.165723] add      /devices/platform/usb1/fe900000.dwc3/xhci-hcd.11.auto/usb5/5-1/5-1.3 (usb)
UDEV  [458.190489] add      /devices/platform/usb1/fe900000.dwc3/xhci-hcd.11.auto/usb5/5-1/5-1.3/5-1.3:1.0 (usb)
UDEV  [458.202123] add      /devices/platform/usb1/fe900000.dwc3/xhci-hcd.11.auto/usb5/5-1/5-1.3/5-1.3:1.0/0003:0461:4E84.0002 (hid)
UDEV  [458.215344] add      /devices/platform/usb1/fe900000.dwc3/xhci-hcd.11.auto/usb5/5-1/5-1.3/5-1.3:1.0/0003:0461:4E84.0002/hidraw/hidraw0 (hidraw)
UDEV  [458.223512] add      /devices/platform/usb1/fe900000.dwc3/xhci-hcd.11.auto/usb5/5-1/5-1.3/5-1.3:1.0/0003:0461:4E84.0002/input/input5 (input)
UDEV  [458.298266] add      /devices/platform/usb1/fe900000.dwc3/xhci-hcd.11.auto/usb5/5-1/5-1.3/5-1.3:1.0/0003:0461:4E84.0002/input/input5/event3 (input)
root@linaro-alip:/dev/input# ls
by-id  by-path  event0  event1  event2  event3


Share this post

Link to post
Share on other sites


Im not sure what your asking me to check with that command, my dev path is correct isnt it? Its listed there

const char* devpath = "/dev/input/mice";

and the mice file is there in place

and I open the mice file ok, it just refuses to switch mode?

Share this post

Link to post
Share on other sites

ok I managed to fix it, it was an access permission issue, the mice file was not allowing access so I had to use sudo chod a+r+w to make it usable. I know this isn't something linux users like to do, is there an elegant way to allow access to a file in C++?


Share this post

Link to post
Share on other sites

oops, I feel a bit silly, while my basic fix is correct I was actually doing in on a different machine connected to my kvm.. which was using ubuntu, sorry 😄 (I thought it was the TB2 it was in fact a Jetson) 


It seems Debian doesn't have /dev/input/mice and instead I need to check which event is controlling the mouse.... sigh. I kinda hate these small variations 😄


But you have put me on the right track, I wasn't  accessing the mice config file (cos there isn't one) and on machines which had it it was indeed a permissions issue, so I need to review how I access my config files for keyboard and mouse.


Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Create New...