Skip to content

Commit

Permalink
process KC_MS_BTN1~8 keycodes
Browse files Browse the repository at this point in the history
  • Loading branch information
koron committed Jul 13, 2021
1 parent 5ffe0e0 commit fa08f61
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 220 deletions.
45 changes: 1 addition & 44 deletions keyboards/keyball/keymaps/default/keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,6 @@ enum custom_keycodes {
QWERTY = SAFE_RANGE,
LOWER,
RAISE,
KC_MBTN1,
KC_MBTN2,
KC_MBTN3
};

// layer
Expand Down Expand Up @@ -81,7 +78,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
//,-----------------------------------------------------. ,-----------------------------------------------------.
KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_LPRN, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11,
//|--------+--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------+--------|
KC_HASH, KC_EXLM, KC_AMPR, KC_PIPE, KC_AT, KC_RPRN, _______,KC_MBTN1, KC_PGUP,KC_MBTN2,KC_MBTN3, KC_F12,
KC_HASH, KC_EXLM, KC_AMPR, KC_PIPE, KC_AT, KC_RPRN, _______, KC_BTN1, KC_PGUP, KC_BTN2, KC_BTN3, KC_F12,
//|--------+--------+--------+--------+--------+--------' |--------+--------+--------+--------+--------+--------|
KC_GRV, KC_DQT, KC_QUOT, KC_CIRC, KC_TILD, _______, _______, KC_PGDN, _______, _______, _______,
//|--------+--------+--------+--------+--------+-------+--------. `--------+--------+--------+--------+--------+--------|
Expand All @@ -103,46 +100,6 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {

};

bool process_record_user(uint16_t keycode, keyrecord_t *record) {
report_mouse_t currentReport = {};

switch (keycode) {
case KC_MBTN1:
currentReport = pointing_device_get_report();
if (record->event.pressed) {
currentReport.buttons |= MOUSE_BTN1;
}
else {
currentReport.buttons &= ~MOUSE_BTN1;
}
pointing_device_set_report(currentReport);
return false;

case KC_MBTN2:
currentReport = pointing_device_get_report();
if (record->event.pressed) {
currentReport.buttons |= MOUSE_BTN2;
}
else {
currentReport.buttons &= ~MOUSE_BTN2;
}
pointing_device_set_report(currentReport);
return false;

case KC_MBTN3:
currentReport = pointing_device_get_report();
if (record->event.pressed) {
currentReport.buttons |= MOUSE_BTN3;
}
else {
currentReport.buttons &= ~MOUSE_BTN3;
}
pointing_device_set_report(currentReport);
return false;
}
return true;
}

layer_state_t layer_state_set_user(layer_state_t state) {
switch (get_highest_layer(state)) {
case _BALL:
Expand Down
44 changes: 1 addition & 43 deletions keyboards/keyball/keymaps/kaoriya/keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,6 @@ enum custom_keycodes {
QWERTY = SAFE_RANGE,
LOWER,
RAISE,
KC_MBTN1,
KC_MBTN2,
KC_MBTN3
};

// layer
Expand Down Expand Up @@ -82,7 +79,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
//,-----------------------------------------------------. ,-----------------------------------------------------.
KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_LPRN, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11,
//|--------+--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------+--------|
KC_HASH, KC_EXLM, KC_AMPR, KC_PIPE, KC_AT, KC_RPRN, _______,KC_MBTN1, KC_PGUP,KC_MBTN2,KC_MBTN3, KC_F12,
KC_HASH, KC_EXLM, KC_AMPR, KC_PIPE, KC_AT, KC_RPRN, _______, KC_BTN1, KC_PGUP, KC_BTN2, KC_BTN3, KC_F12,
//|--------+--------+--------+--------+--------+--------' |--------+--------+--------+--------+--------+--------|
KC_GRV, KC_DQT, KC_QUOT, KC_CIRC, KC_TILD, _______, _______, KC_PGDN, _______, _______, _______,
//|--------+--------+--------+--------+--------+-------+--------. `--------+--------+--------+--------+--------+--------|
Expand All @@ -104,45 +101,6 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {

};


bool process_record_user(uint16_t keycode, keyrecord_t *record) {
report_mouse_t currentReport = {};

switch (keycode) {
case KC_MBTN1:
currentReport = pointing_device_get_report();
if (record->event.pressed) {
currentReport.buttons |= MOUSE_BTN1;
}
else {
currentReport.buttons &= ~MOUSE_BTN1;
}
pointing_device_set_report(currentReport);
return false;
case KC_MBTN2:
currentReport = pointing_device_get_report();
if (record->event.pressed) {
currentReport.buttons |= MOUSE_BTN2;
}
else {
currentReport.buttons &= ~MOUSE_BTN2;
}
pointing_device_set_report(currentReport);
return false;
case KC_MBTN3:
currentReport = pointing_device_get_report();
if (record->event.pressed) {
currentReport.buttons |= MOUSE_BTN3;
}
else {
currentReport.buttons &= ~MOUSE_BTN3;
}
pointing_device_set_report(currentReport);
return false;
}
return true;
}

void keyboard_post_init_user() {
#ifdef RGBLIGHT_ENABLE
rgblight_disable_noeeprom();
Expand Down
45 changes: 1 addition & 44 deletions keyboards/keyball/keymaps/via/keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,6 @@ enum custom_keycodes {
QWERTY = SAFE_RANGE,
LOWER,
RAISE,
KC_MBTN1,
KC_MBTN2,
KC_MBTN3
};

// layer
Expand Down Expand Up @@ -81,7 +78,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
//,-----------------------------------------------------. ,-----------------------------------------------------.
KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_LPRN, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11,
//|--------+--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------+--------|
KC_HASH, KC_EXLM, KC_AMPR, KC_PIPE, KC_AT, KC_RPRN, _______,KC_MBTN1, KC_PGUP,KC_MBTN2,KC_MBTN3, KC_F12,
KC_HASH, KC_EXLM, KC_AMPR, KC_PIPE, KC_AT, KC_RPRN, _______, KC_BTN1, KC_PGUP, KC_BTN2, KC_BTN3, KC_F12,
//|--------+--------+--------+--------+--------+--------' |--------+--------+--------+--------+--------+--------|
KC_GRV, KC_DQT, KC_QUOT, KC_CIRC, KC_TILD, _______, _______, KC_PGDN, _______, _______, _______,
//|--------+--------+--------+--------+--------+-------+--------. `--------+--------+--------+--------+--------+--------|
Expand All @@ -103,46 +100,6 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {

};

bool process_record_user(uint16_t keycode, keyrecord_t *record) {
report_mouse_t currentReport = {};

switch (keycode) {
case KC_MBTN1:
currentReport = pointing_device_get_report();
if (record->event.pressed) {
currentReport.buttons |= MOUSE_BTN1;
}
else {
currentReport.buttons &= ~MOUSE_BTN1;
}
pointing_device_set_report(currentReport);
return false;

case KC_MBTN2:
currentReport = pointing_device_get_report();
if (record->event.pressed) {
currentReport.buttons |= MOUSE_BTN2;
}
else {
currentReport.buttons &= ~MOUSE_BTN2;
}
pointing_device_set_report(currentReport);
return false;

case KC_MBTN3:
currentReport = pointing_device_get_report();
if (record->event.pressed) {
currentReport.buttons |= MOUSE_BTN3;
}
else {
currentReport.buttons &= ~MOUSE_BTN3;
}
pointing_device_set_report(currentReport);
return false;
}
return true;
}

layer_state_t layer_state_set_user(layer_state_t state) {
switch (get_highest_layer(state)) {
case _BALL:
Expand Down
45 changes: 1 addition & 44 deletions keyboards/keyball/keymaps/via_Both/keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,6 @@ enum custom_keycodes {
QWERTY = SAFE_RANGE,
LOWER,
RAISE,
KC_MBTN1,
KC_MBTN2,
KC_MBTN3
};

// layer
Expand Down Expand Up @@ -81,7 +78,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
//,-----------------------------------------------------. ,-----------------------------------------------------.
KC_TAB, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11,
//|--------+--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------+--------|
KC_LCTL, _______, KC_LEFT, KC_UP, KC_RGHT, _______, _______,KC_MBTN1, KC_PGUP,KC_MBTN2,KC_MBTN3, KC_F12,
KC_LCTL, _______, KC_LEFT, KC_UP, KC_RGHT, _______, _______, KC_BTN1, KC_PGUP, KC_BTN2, KC_BTN3, KC_F12,
//|--------+--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------+--------|
KC_LSFT, _______, _______, KC_DOWN, _______, _______, _______, _______, KC_PGDN, _______, _______, KC_RSFT,
//|--------+--------+--------+--------+--------+--------' `--------+--------+--------+--------+--------+--------|
Expand All @@ -103,46 +100,6 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {

};

bool process_record_user(uint16_t keycode, keyrecord_t *record) {
report_mouse_t currentReport = {};

switch (keycode) {
case KC_MBTN1:
currentReport = pointing_device_get_report();
if (record->event.pressed) {
currentReport.buttons |= MOUSE_BTN1;
}
else {
currentReport.buttons &= ~MOUSE_BTN1;
}
pointing_device_set_report(currentReport);
return false;

case KC_MBTN2:
currentReport = pointing_device_get_report();
if (record->event.pressed) {
currentReport.buttons |= MOUSE_BTN2;
}
else {
currentReport.buttons &= ~MOUSE_BTN2;
}
pointing_device_set_report(currentReport);
return false;

case KC_MBTN3:
currentReport = pointing_device_get_report();
if (record->event.pressed) {
currentReport.buttons |= MOUSE_BTN3;
}
else {
currentReport.buttons &= ~MOUSE_BTN3;
}
pointing_device_set_report(currentReport);
return false;
}
return true;
}

layer_state_t layer_state_set_user(layer_state_t state) {
switch (get_highest_layer(state)) {
case _BALL:
Expand Down
45 changes: 1 addition & 44 deletions keyboards/keyball/keymaps/via_Left/keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,6 @@ enum custom_keycodes {
QWERTY = SAFE_RANGE,
LOWER,
RAISE,
KC_MBTN1,
KC_MBTN2,
KC_MBTN3
};

// layer
Expand Down Expand Up @@ -81,7 +78,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
//,-----------------------------------------------------. ,-----------------------------------------------------.
KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_LPRN, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11,
//|--------+--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------+--------|
_______, KC_HASH, KC_EXLM, KC_AMPR, KC_PIPE, KC_AT, KC_RPRN,KC_MBTN1, KC_PGUP,KC_MBTN2,KC_MBTN3, KC_F12,
_______, KC_HASH, KC_EXLM, KC_AMPR, KC_PIPE, KC_AT, KC_RPRN, KC_BTN1, KC_PGUP, KC_BTN2, KC_BTN3, KC_F12,
//|--------+--------+--------+--------+--------+--------| `--------+--------+--------+--------+--------+--------|
_______, KC_GRV, KC_DQT, KC_QUOT, KC_CIRC, KC_TILD, _______, KC_PGDN, _______, _______, _______,
//|--------+--------+--------+--------+--------+--------' ,--------+-------+--------+--------+--------+--------+--------|
Expand All @@ -103,46 +100,6 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {

};

bool process_record_user(uint16_t keycode, keyrecord_t *record) {
report_mouse_t currentReport = {};

switch (keycode) {
case KC_MBTN1:
currentReport = pointing_device_get_report();
if (record->event.pressed) {
currentReport.buttons |= MOUSE_BTN1;
}
else {
currentReport.buttons &= ~MOUSE_BTN1;
}
pointing_device_set_report(currentReport);
return false;

case KC_MBTN2:
currentReport = pointing_device_get_report();
if (record->event.pressed) {
currentReport.buttons |= MOUSE_BTN2;
}
else {
currentReport.buttons &= ~MOUSE_BTN2;
}
pointing_device_set_report(currentReport);
return false;

case KC_MBTN3:
currentReport = pointing_device_get_report();
if (record->event.pressed) {
currentReport.buttons |= MOUSE_BTN3;
}
else {
currentReport.buttons &= ~MOUSE_BTN3;
}
pointing_device_set_report(currentReport);
return false;
}
return true;
}

layer_state_t layer_state_set_user(layer_state_t state) {
switch (get_highest_layer(state)) {
case _BALL:
Expand Down
16 changes: 15 additions & 1 deletion keyboards/keyball/rev1/rev1.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,21 @@ bool process_record_kb(uint16_t keycode, keyrecord_t *record) {
last_keycode = keycode;
last_row = record->event.key.row;
last_col = record->event.key.col;
return process_record_user(keycode, record);
if (!process_record_user(keycode, record)) {
return false;
}
if (IS_MOUSEKEY_BUTTON(keycode)) {
report_mouse_t r = {};
r = pointing_device_get_report();
if (record->event.pressed) {
r.buttons |= 1 << (keycode - KC_MS_BTN1);
} else {
r.buttons &= ~(1 << (keycode - KC_MS_BTN1));
}
pointing_device_set_report(r);
return false;
}
return true;
}

#ifdef OLED_DRIVER_ENABLE
Expand Down

0 comments on commit fa08f61

Please sign in to comment.