From 94f6cf38086b82365eaec6dcf588e03aed6363f2 Mon Sep 17 00:00:00 2001 From: saces Date: Wed, 19 Mar 2014 21:28:26 +0100 Subject: [PATCH] add wheel mouse support --- PS2Mouse.cpp | 46 ++++++++++++++++++++++++++++++++++++++++ PS2Mouse.h | 18 +++++++++++++--- examples/Wheel/Wheel.ino | 40 ++++++++++++++++++++++++++++++++++ 3 files changed, 101 insertions(+), 3 deletions(-) create mode 100644 examples/Wheel/Wheel.ino diff --git a/PS2Mouse.cpp b/PS2Mouse.cpp index 9e1e693..cf55ef8 100644 --- a/PS2Mouse.cpp +++ b/PS2Mouse.cpp @@ -213,6 +213,16 @@ int PS2Mouse::read_movement_y(int status) { return y; } +int PS2IMouse::read_movement_z() { + int z = read(); + if (bitRead(z, 5)) { + for(int i = 4; i < 16; ++i) { + z |= (1< + * Updated by Jonathan Oxer + */ + +#include +#define MOUSE_DATA 4 +#define MOUSE_CLOCK 2 + +PS2IMouse mouse(MOUSE_CLOCK, MOUSE_DATA, REMOTE); + +/** + * Setup + */ +void setup() +{ + Serial.begin(38400); + mouse.initialize(); +} + +/** + * Main program loop + */ +void loop() +{ + int data[4]; + mouse.report(data); + Serial.print(data[0]); // Status Byte + Serial.print(":"); + Serial.print(data[1]); // X Movement Data + Serial.print(","); + Serial.print(data[2]); // Y Movement Data + Serial.print(","); + Serial.print(data[3]); // Z Movement Data (wheel) + Serial.println(); + delay(20); +}