So I'm sure this a failure of my math skills, and I've tried to remove(subtract) the oldEncOne from the value coming in encOne.Read() and then the mouse just jumps all over the place, I also don't know how to do a 3'rd axis... as move only takes 2 values. What I'm trying to do is take 3 Encoders as steering wheels for games like Super Sprint, and have each drive a steering wheel, which in Mame needs a separate mouse axis, and Z apparently is a valid axis in mame on a mouse.
The below functionality is: as the encoder is moved the mouse starts accelerating, instead of moving and stopping when the encoder stops.
The below functionality is: as the encoder is moved the mouse starts accelerating, instead of moving and stopping when the encoder stops.
Code:
/* Simple USB Mouse Example
Teensy becomes a USB mouse and moves via an encoder
You must select Mouse from the "Tools > USB Type" menu
*/
#include <Encoder.h>
// Encoder Pin Assignment
Encoder encOne(23, 22);
Encoder encTwo(21, 20);
Encoder encThree(19, 18);
long newEncOne, newEncTwo, newEncThree;
void setup() { } // no setup needed
void loop() {
// Read The Encoders
newEncOne = encOne.read()*.01;
newEncTwo = encTwo.read()*.01;
newEncThree = encThree.read()*.01;
Mouse.move(newEncOne, 0);
Mouse.move(0, newEncTwo);
Mouse.scroll(newEncThree);
}