diff options
author | Robin Haberkorn <robin.haberkorn@googlemail.com> | 2014-07-27 17:26:44 +0200 |
---|---|---|
committer | Robin Haberkorn <robin.haberkorn@googlemail.com> | 2014-07-27 17:38:32 +0200 |
commit | eb902844946f0bda7da76cdb1e9aafae4881b63c (patch) | |
tree | 265bc25c7e143781c991aedb6a9c6094c89054f6 /protocol/serial_mouse_microsoft.c | |
parent | 0bfba7acc4e05e66c8ab448286fc51bc94d03a57 (diff) |
serial_mouse: simplified clipping of X/Y/V/H changes below -127 using a MAX macro
Diffstat (limited to 'protocol/serial_mouse_microsoft.c')
-rw-r--r-- | protocol/serial_mouse_microsoft.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/protocol/serial_mouse_microsoft.c b/protocol/serial_mouse_microsoft.c index f83036a317..54fedae778 100644 --- a/protocol/serial_mouse_microsoft.c +++ b/protocol/serial_mouse_microsoft.c @@ -27,6 +27,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. #include "print.h" #include "debug.h" +#ifdef MAX +#undef MAX +#endif +#define MAX(X, Y) ((X) > (Y) ? (X) : (Y)) + static void print_usb_data(const report_mouse_t *report); void serial_mouse_task(void) @@ -91,8 +96,8 @@ void serial_mouse_task(void) report.y = ((buffer[0] << 4) & 0xC0) | buffer[2]; /* USB HID uses values from -127 to 127 only */ - report.x = report.x < -127 ? -127 : report.x; - report.y = report.y < -127 ? -127 : report.y; + report.x = MAX(report.x, -127); + report.y = MAX(report.y, -127); #if 0 if (!report.buttons && !report.x && !report.y) { |