-
-
Notifications
You must be signed in to change notification settings - Fork 7k
Absolute coordinates for HID mouse #3020
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@ArduinoBot build this please |
I have checked the test build and it is working. |
@@ -110,11 +110,15 @@ class Mouse_ | |||
Mouse_(void); | |||
void begin(void); | |||
void end(void); | |||
#ifdef MOUSE_ABS_ENABLED | |||
void moveAbs(unsigned int x, unsigned int y, signed char wheel, unsigned char buttons); // x and y have the range of 0 to 4095 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For consistency with the Arduino API style guide (http://www.arduino.cc/en/Reference/APIStyleGuide), this should probably be "moveAbsolute()" not "moveAbs()".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or moveTo() as Paul has named it.
When I tried this on Teensy, a few unexpected issues came up. The main one was absolute positioning is incompatible with nearly all games. Desktop usage works fine, but apparently most game software requires relative. The other problem, still unresolved, was incompatibility with most Linux systems if both relative and absolute are in use. Windows and Mac seem to handle that fine, but there are problems with X11. |
We are using the mouse device with absolute positioning on our HDMI displays. It is a board with a TFP401A HDMI to RGB converter and ATmega32u4 as touch and backlight controller. The only problem we found is that some systems (e.g. OpenELEC) want the position data in screen coordinates and not in the range of 0...4095. On our display adapters we know the display resolution so it is no problem to send screen coordinates. |
I can report the same issues. I also noticed that the absolute mouse doesnt work under windows server 2012. And for some weird reasons it only worked if another consumer device is also in the same multireport. But I never found a reason. But I found a report combination that seemed to work fine on most systems. @awatterott try this: https://github.com/NicoHood/HID Edit: and as stated in many other usb related PRs: If you change the descriptors the device might not be recognized correct under Windows. And if you dont know why this happens and how this can be solved, people will be really confused. There are some solutions though. The whole USB core should be reworked, but noone is willing to do this sadly. |
@NicoHood Do you refer to my code or your code? Have you tried to test screen coordinates if it did not work? |
I tested with my own core. USB can cause so many problems, it would be very critical to add this PR like this. They should think of different USB options the user can choose and keep the default setting to not kill the windows driver recognition. |
I found no real problems with the absolute mouse and coordinates in the range of 0 to 4095 (see my descriptor). This is also what Microchips AR1100 touch controllers use. I have tested it with the following Windows versions: XP, 7 and 8.1 |
@awatterott Andreas, the problem is, that if you change the USB HID Descriptor some things could be broken on several OS. I've tested a lot of USB stuff and Paul Stoffregen will aggree that very fast with a few changes things can go really wrong. I could give you a lot of examples. But here is a simple one: I've added Media keys to a report. Everything seems to work pretty good. And someone else reported that it doesnt work at all under MAC. Even the keyboard was dead. Simply because a single line in the descriptor was wrong so the OS didnt accept it. Not sure if it was technically wrong because it worked under the other OS. Well now you dont use Media keys. But still there is this driver problem. If you now switch back to the old core, Windows might throw errors. And also it might not work under all OS, maybe the 2nd Mouse breaks the whole function. Its not that I dont support your idea. I am not even one from the Arduino team. I've created a lot of custom stuff with USB and the Arduino IDE if you've clicked the link above. Your idea is great and really useful! But simply adding this stuff to the Core HID files isnt a good idea. The user should be aware what he is doing, if he wants additional absolute mouse positioning. There are to many untested scenarios where bugs can occur with this addition. The Arduino team wont accept any USB PR I bet. They should redevelop the whole core and take some time to get it done better. What you could do for your shield users are two things: |
I see no problems, why the changes should not be included in the official core. The code is tested and the absolute mouse will only be activated, if the user does it via the define statement. |
Your HID report contains Buttons and a scroll wheel. You can do 3 things:
Also I see no reason why to use abs mouse without buttons (right/left click)? |
We use the mouse for a touchpanel and there is only one button... I have changed it, so that the absolute mouse API is compatible with the normal mouse API. |
m[3] = LSB(y); | ||
m[4] = MSB(y); | ||
m[5] = wheel; | ||
HID_SendReport(1,m,6); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use sizeof(m) here
@awatterott , this PR can be an extremely useful test case for PR #3304 . |
Closed with #1803 |
@facchinm I have tested the new USB core with our absolute mouse changes and everything is working. The patching without changing core files is really good. |
Absolute Mouse is also available here: |
The define
MOUSE_ABS_ENABLED
enables absolute instead of relative coordinates for the HID mouse device. This can be used for a touch panel driver.