used the arduino standard astyle invocation

pull/18/head
Jesse Vincent 11 years ago
parent 48a21e3492
commit 21d337fd05

@ -48,7 +48,7 @@ void release_keys_not_being_pressed()
// we use charsReportedLastTime to figure out what we might not be holding anymore and can now release. this is destructive to charsReportedLastTime
for (byte i=0; i<KEYS_HELD_BUFFER; i++) {
for (byte i = 0; i < KEYS_HELD_BUFFER; i++) {
// for each key we were holding as of the end of the last cycle
// see if we're still holding it
// if we're not, call an explicit Release
@ -56,7 +56,7 @@ void release_keys_not_being_pressed()
if (charsReportedLastTime[i] != 0x00) {
// if there _was_ a character in this slot, go check the
// currently held characters
for (byte j=0; j<KEYS_HELD_BUFFER; j++) {
for (byte j = 0; j < KEYS_HELD_BUFFER; j++) {
if (charsReportedLastTime[i] == charsBeingReported[j]) {
// if's still held, we don't need to do anything.
charsReportedLastTime[i] = 0x00;
@ -66,7 +66,7 @@ void release_keys_not_being_pressed()
}
}
for (byte i=0; i<KEYS_HELD_BUFFER; i++) {
for (byte i = 0; i < KEYS_HELD_BUFFER; i++) {
if (charsReportedLastTime[i] != 0x00) {
Keyboard.release(charsReportedLastTime[i]);
}
@ -75,7 +75,7 @@ void release_keys_not_being_pressed()
void record_key_being_pressed(byte character)
{
for (byte i=0; i<KEYS_HELD_BUFFER; i++) {
for (byte i = 0; i < KEYS_HELD_BUFFER; i++) {
// todo - deal with overflowing the 12 key buffer here
if (charsBeingReported[i] == 0x00) {
charsBeingReported[i] = character;
@ -91,7 +91,7 @@ void reset_matrix()
matrixState[row][col] <<= 1;
}
}
for (byte i=0; i<KEYS_HELD_BUFFER; i++) {
for (byte i = 0; i < KEYS_HELD_BUFFER; i++) {
charsReportedLastTime[i] = charsBeingReported[i];
charsBeingReported[i] = 0x00;
}
@ -100,18 +100,18 @@ void reset_matrix()
void handle_synthetic_key_press(byte switchState,Key mappedKey) {
if(mappedKey.flags & IS_CONSUMER) {
void handle_synthetic_key_press(byte switchState, Key mappedKey) {
if (mappedKey.flags & IS_CONSUMER) {
if (key_toggled_on (switchState)) {
Keyboard.consumerControl(mappedKey.rawKey);
}
}
else if(mappedKey.flags & IS_SYSCTL) {
else if (mappedKey.flags & IS_SYSCTL) {
if (key_toggled_on (switchState)) {
Keyboard.systemControl(mappedKey.rawKey);
}
}
else if(mappedKey.flags & IS_MACRO) {
else if (mappedKey.flags & IS_MACRO) {
if (key_toggled_on (switchState)) {
if (mappedKey.rawKey == 1) {
Keyboard.print("Keyboard.IO keyboard driver v0.00");
@ -127,25 +127,25 @@ void reset_matrix()
Mouse.release(mappedKey.rawKey);
}
}
}
}
void handle_mouse_key_press(byte switchState, Key mappedKey, char &x, char &y) {
if (key_is_pressed(switchState)) {
if (mappedKey.rawKey & MOUSE_UP) {
y-=1;
y -= 1;
}
if (mappedKey.rawKey & MOUSE_DN) {
y+= 1;
y += 1;
}
if (mappedKey.rawKey & MOUSE_L) {
x-= 1;
x -= 1;
}
if (mappedKey.rawKey & MOUSE_R) {
x+= 1 ;
}
x += 1 ;
}
}
}
void send_key_events(byte layer)
{
@ -165,7 +165,7 @@ void send_key_events(byte layer)
byte switchState = matrixState[row][col];
Key mappedKey = keymaps[layer][row][col];
if (mappedKey.flags & MOUSE_KEY ) {
handle_mouse_key_press(matrixState[row][col], keymaps[layer][row][col],x,y);
handle_mouse_key_press(matrixState[row][col], keymaps[layer][row][col], x, y);
} else if (mappedKey.flags & SYNTHETIC_KEY) {
@ -183,7 +183,7 @@ void send_key_events(byte layer)
}
}
}
handle_mouse_movement(x,y);
handle_mouse_movement(x, y);
release_keys_not_being_pressed();
}
void setup_matrix()
@ -266,8 +266,8 @@ void setup()
Serial.begin(115200);
Keyboard.begin();
Mouse.begin();
//#ifdef DEBUG_SERIAL
//#endif
//#ifdef DEBUG_SERIAL
//#endif
setup_matrix();
Serial.println("loaded the matrix");
current_layer = load_current_layer();

@ -3,10 +3,10 @@
void report_matrix()
{
#ifdef DEBUG_SERIAL
if (reporting_counter++ %100 == 0 ) {
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(matrixState[row][col], HEX);
Serial.print(", ");
}

@ -1,14 +1,14 @@
double mouseActiveForCycles = 0;
float carriedOverX =0;
float carriedOverY =0;
float carriedOverX = 0;
float carriedOverY = 0;
double mouse_accel (double cycles)
{
double accel = atan((cycles/50)-5);
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;
accel = accel * 0.85;
if (accel < 0.25) {
accel = 0.25;
}
return accel;
}
@ -16,24 +16,24 @@ double mouse_accel (double cycles)
void handle_mouse_movement( char x, char y)
{
if (x!=0 || y!=0) {
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;
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;
} else if (x < 0) {
moveX = (x * accel) - carriedOverX;
carriedOverX = ceil(moveX) - moveX;
}
if (y >0) {
moveY = (y*accel) + carriedOverY;
if (y > 0) {
moveY = (y * accel) + carriedOverY;
carriedOverY = moveY - floor(moveY);
} else if (y<0) {
moveY = (y*accel) - carriedOverY;
} else if (y < 0) {
moveY = (y * accel) - carriedOverY;
carriedOverY = ceil(moveY) - moveY;
}
#ifdef DEBUG_SERIAL
@ -51,9 +51,9 @@ void handle_mouse_movement( char x, char y)
Serial.print(" carriedOverY is ");
Serial.println(carriedOverY);
#endif
Mouse.move(moveX,moveY, 0);
Mouse.move(moveX, moveY, 0);
} else {
mouseActiveForCycles=0;
mouseActiveForCycles = 0;
}
}

Loading…
Cancel
Save