flowerlandfilms
Member
Hello there,
I have been working on converting an Alps Glidepoint Numpad and Trackpad to USB with a Teensy++.
So far I have managed to hook up +5V, Ground, CLK, and DATA from the trackpad to the Teensy, and using the attached code I can get it to stream data into the Serial Monitor for the X and Y axis when moving my finger across the Trackpad.
But despite trying to research online I can not seem to figure out how to convert this information to cursor movement.
I tried to use this next sketch but it did not result in any cursor movement.
If there is something obvious that I am missing here, or if there are any helpful resources to point me to I would be rather appreciative.
I have been working on converting an Alps Glidepoint Numpad and Trackpad to USB with a Teensy++.
So far I have managed to hook up +5V, Ground, CLK, and DATA from the trackpad to the Teensy, and using the attached code I can get it to stream data into the Serial Monitor for the X and Y axis when moving my finger across the Trackpad.
But despite trying to research online I can not seem to figure out how to convert this information to cursor movement.
Code:
/*
#include "PS2Mouse.h"
PS2Mouse mouse(22,23);
void setup(){
Serial.begin(9600);
while(!Serial);
Serial.print("Setup...");
mouse.begin();
Serial.println("complete!");
}
void loop(){
uint8_t stat;
int x,y;
mouse.getPosition(stat,x,y);
Serial.print(stat, BIN);
Serial.print("\tx=");
Serial.print(x, DEC);
Serial.print("\ty=");
Serial.println(y, DEC);
delay(2);
}
I tried to use this next sketch but it did not result in any cursor movement.
If there is something obvious that I am missing here, or if there are any helpful resources to point me to I would be rather appreciative.
Code:
/*
#include "Mouse.h"
#include "PS2Mouse.h"
#define PS2_DATA 22
#define PS2_CLK 23
byte mstat1;
byte mstat2;
byte mxy;
byte mx;
byte my;
byte mz;
int msval[2];
int repeatCnt;
PS2Mouse mouse(PS2_CLK, PS2_DATA);
void setup() {
Mouse.begin();
mouse.write(0xff); //reset
mouse.read(); //ack byte
mouse.read(); //blank */
mouse.read(); //blank */
mouse.write(0xf0); // remote mode
mouse.read() ; //ack
delayMicroseconds(100);
mouse.write(0xe8);
mouse.read();
mouse.write(0x03);
mouse.read();
mouse.write(0xe8);
mouse.read();
mouse.write(0x00);
mouse.read();
mouse.write(0xe8);
mouse.read();
mouse.write(0x01);
mouse.read();
mouse.write(0xe8);
mouse.read();
mouse.write(0x00);
mouse.read();
mouse.write(0xf3);
mouse.read();
mouse.write(0x14);
mouse.read();
Serial.begin(9600);
}
void ms_read()
{
mouse.write(0xeb);
mouse.read();
mstat1 = mouse.read();
mxy = mouse.read();
mz = mouse.read();
mstat2 = mouse.read();
mx = mouse.read();
my = mouse.read();
msval[0] = (((mstat2 & 0x10) << 8) | ((mxy & 0x0F) << 8) | mx );
msval[1] = (((mstat2 & 0x20) << 7) | ((mxy & 0xF0) << 4) | my );
msval[2] = int(mz);
}
void loop() {
ms_read();
if (msval[0] > 0 and msval[2] > 10)
{ repeatCnt++; }
else
{ repeatCnt = 0; }
if (repeatCnt > 2)
{
msval[0] = map(msval[0], 580, 5164, -1023, 1023);
msval[1] = map(msval[1], 1120, 5967, 1023, -1023);
Mouse.move(msval[0]/200,msval[1]/200);
}
}