parent
1e97fd6684
commit
05e9ff7020
@ -0,0 +1,18 @@
|
||||
//#define DEBUG_SERIAL false
|
||||
|
||||
#define COLS 14
|
||||
#define ROWS 5
|
||||
#define EEPROM_LAYER_LOCATION 0
|
||||
|
||||
|
||||
static const byte colPins[COLS] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, A0 };
|
||||
static const byte rowPins[ROWS] = { A5, A4, A3, A2, A1 };
|
||||
|
||||
//#static const byte colPins[COLS] = { 16, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 };
|
||||
//#static const byte rowPins[ROWS] = { A2, A3, A4, A5, 15 };
|
||||
|
||||
|
||||
// if we're sticking to boot protocol, these could all be 6 + mods
|
||||
// but *mumble*
|
||||
|
||||
#define KEYS_HELD_BUFFER 12
|
@ -0,0 +1,32 @@
|
||||
|
||||
|
||||
void report_matrix()
|
||||
{
|
||||
#ifdef DEBUG_SERIAL
|
||||
if (reporting_counter++ %100 == 0 ) {
|
||||
for (byte row = 0; row < ROWS; row++) {
|
||||
for (byte col = 0; col < COLS; col++) {
|
||||
Serial.print(matrixState[row][col],HEX);
|
||||
Serial.print(", ");
|
||||
|
||||
}
|
||||
Serial.println("");
|
||||
}
|
||||
Serial.println("");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void report(byte row, byte col, boolean value)
|
||||
{
|
||||
#ifdef DEBUG_SERIAL
|
||||
Serial.print("Detected a change on ");
|
||||
Serial.print(col);
|
||||
Serial.print(" ");
|
||||
Serial.print(row);
|
||||
Serial.print(" to ");
|
||||
Serial.print(value);
|
||||
Serial.println(".");
|
||||
#endif
|
||||
}
|
||||
|
@ -0,0 +1,59 @@
|
||||
double mouseActiveForCycles = 0;
|
||||
float carriedOverX =0;
|
||||
float carriedOverY =0;
|
||||
|
||||
double mouse_accel (double cycles)
|
||||
{
|
||||
double accel = atan((cycles/50)-5);
|
||||
accel += 1.5707963267944; // we want the whole s curve, not just the bit that's usually above the x and y axes;
|
||||
accel = accel *0.85;
|
||||
if (accel<0.25) {
|
||||
accel =0.25;
|
||||
}
|
||||
return accel;
|
||||
}
|
||||
|
||||
void handle_mouse_movement( char x, char y)
|
||||
{
|
||||
|
||||
if (x!=0 || y!=0) {
|
||||
mouseActiveForCycles++;
|
||||
double accel = (double) mouse_accel(mouseActiveForCycles);
|
||||
float moveX=0;
|
||||
float moveY=0;
|
||||
if (x>0) {
|
||||
moveX = (x*accel) + carriedOverX;
|
||||
carriedOverX = moveX - floor(moveX);
|
||||
} else if(x<0) {
|
||||
moveX = (x*accel) - carriedOverX;
|
||||
carriedOverX = ceil(moveX) - moveX;
|
||||
}
|
||||
|
||||
if (y >0) {
|
||||
moveY = (y*accel) + carriedOverY;
|
||||
carriedOverY = moveY - floor(moveY);
|
||||
} else if (y<0) {
|
||||
moveY = (y*accel) - carriedOverY;
|
||||
carriedOverY = ceil(moveY) - moveY;
|
||||
}
|
||||
#ifdef DEBUG_SERIAL
|
||||
Serial.println();
|
||||
Serial.print("cycles: ");
|
||||
Serial.println(mouseActiveForCycles);
|
||||
Serial.print("Accel: ");
|
||||
Serial.print(accel);
|
||||
Serial.print(" moveX is ");
|
||||
Serial.print(moveX);
|
||||
Serial.print(" moveY is ");
|
||||
Serial.print(moveY);
|
||||
Serial.print(" carriedoverx is ");
|
||||
Serial.print(carriedOverX);
|
||||
Serial.print(" carriedOverY is ");
|
||||
Serial.println(carriedOverY);
|
||||
#endif
|
||||
Mouse.move(moveX,moveY, 0);
|
||||
} else {
|
||||
mouseActiveForCycles=0;
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in new issue