Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mouse & NKRO support #28

Closed
wants to merge 12 commits into from
Prev Previous commit
Next Next commit
nkro enable function
  • Loading branch information
Gyuri Horak committed Jul 25, 2013
commit ccc2c352064e313e862c7d0e61fc6ee2896b76a5
7 changes: 7 additions & 0 deletions firmware/keyboard/ergodox/layout/common/keys.c.h
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,13 @@ void R(btldr) (void) {}
void P(MclkL) (void) { KF(mouse_buttons)(1, 0, 0); }
void R(MclkL) (void) { KF(mouse_buttons)(0, 0, 0); }

/**
* nkro toggle
*/

void P(tnkro) (void) { KF(toggle_nkro)(); }
void R(tnkro) (void) {}

// ----------------------------------------------------------------------------
// --- layer ------------------------------------------------------------------

Expand Down
2 changes: 1 addition & 1 deletion firmware/keyboard/ergodox/layout/repa.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ shL2kcap, semicol, q, j, k, x, lpupo1l1,
btldr, 6, 7, 8, 9, 0, dash,
MclkL, f, g, c, r, l, brktR,
d, h, t, n, s, slash,
lpupo1l1, b, m, w, v, z, shR2kcap,
tnkro, b, m, w, v, z, shR2kcap,
arrowL, arrowD, arrowU, arrowR, guiR,
altR, ctrlR,
pageU, nop, nop,
Expand Down
3 changes: 3 additions & 0 deletions firmware/lib/layout/key-functions.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ void key_functions__toggle_capslock (void);
void key_functions__type_byte_hex (uint8_t byte);
void key_functions__type_string (const char * string);

// nkro
void key_functions__toggle_nkro (void);

// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
#endif // ERGODOX_FIRMWARE__FIRMWARE__LIB__LAYOUT__KEY_FUNCTIONS__H
Expand Down
6 changes: 6 additions & 0 deletions firmware/lib/layout/key-functions/special.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@ void key_functions__toggle_capslock(void) {
usb__kb__send_report();
}

// nkro toggle

void key_functions__toggle_nkro(void) {
usb__kb__toggle_nkro();
}

/*
* TODO: try using number pad numbers; see how it works
*/
Expand Down
6 changes: 0 additions & 6 deletions firmware/lib/layout/mouse/mouse.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,6 @@ void key_functions__mouse_buttons(uint8_t left, uint8_t middle, uint8_t right)
if (middle) mask |= 4;
if (right) mask |= 2;

if (mask > 0) {
kb__led__on(6);
} else {
kb__led__off(6);
}

usb__m__buttons(mask);
}

Expand Down
2 changes: 2 additions & 0 deletions firmware/lib/usb.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ bool usb__kb__read_key (uint8_t keycode);
bool usb__kb__read_led (char led);
uint8_t usb__kb__send_report (void);

void usb__kb__toggle_nkro (void);

// --- mouse ---
#define MOUSE_BTN1 (1<<0)
#define MOUSE_BTN2 (1<<1)
Expand Down
10 changes: 10 additions & 0 deletions firmware/lib/usb/atmega32u4/keyboard.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include <stdbool.h>
#include <stdint.h>
#include "../usage-page/keyboard.h"
#include "../../../../firmware/keyboard.h"
#include "./keyboard/from-pjrc/usb.h"
#include "../../usb.h"

Expand Down Expand Up @@ -115,3 +116,12 @@ uint8_t usb__kb__send_report(void) {
return usb_keyboard_send();
}

void usb__kb__toggle_nkro(void) {
if (keyboard_nkro_enabled == 0) {
keyboard_nkro_enabled = 1;
kb__led__on(6);
} else {
keyboard_nkro_enabled = 0;
kb__led__off(6);
}
}