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

Shift to custom key #1495

Closed
Yatreyu opened this issue Jul 13, 2017 · 7 comments
Closed

Shift to custom key #1495

Yatreyu opened this issue Jul 13, 2017 · 7 comments

Comments

@Yatreyu
Copy link

Yatreyu commented Jul 13, 2017

This is really similar to #108 but I'm still having issues.
I used http://kbfirmware.com/ to make my ".hex".
In my situation I want to shift to "!" from the base layer "?"
I'm using OSM(MOD_LSFT) as my only shift key so I don't know how to put the pieces together here.
Thanks in advance.

@fredizzimo
Copy link
Contributor

I'm working on a making a general solution for this, and I will probably have something ready in a few days.

The idea is that you will be able to define a complete key with all different modifier levels, none, shift, alt gr, and alt gr+shift. This includes the support for sending for example unshifted keys, even if you have the shift key pressed.

I have a very basic version of this in my personal keymap, but I want to make something thing that is generic and included in QMK.

@Yatreyu
Copy link
Author

Yatreyu commented Jul 16, 2017

I'll watch out for it. I think I've always used "+" more than "=" so being able to switch those would be really great, same with "?" being much more common than "/".

Following the philosophy of Dvorak I'm really excited to switch the "?" to the unshift layer and then switch out "!" and "/".

I imagine several people are pretty keen on this. Thanks for working on this!!!

@fredizzimo
Copy link
Contributor

fredizzimo commented Jul 17, 2017

I was thinking of implementing the following API

  • void send_keydown(uint16_t kc)- Alias for register_code16
  • void send_keyup(uint16_t kc) - Alias for unregister_code16
  • void send_keypress(uint16_t kc, ...) - Sends key down, followed by key up. You can add extra KC_ modifiers passed as varags, for example KC_LSFT. Note that only one modifier per argument is allowed. These modifiers are always sent verbatim, meaning that if you for example have specified KC_LSFT as a verbatim modifier, shift is already pressed and want to send and unshifted key, the shift will temporarily be released during the key press. Any modifier that is not specified as verbatim works as normal, so previously held modifiers are kept, and additional modifiers specified by the kc argument are held down during the key press.
  • void send_modified_keypress(uint16_t unshifted_kc, uint16_t shifted_kc, uint16_t altgr_kc, uint16_t altgr_shifted_kc) - Sends the keycode depending on which modifiers are held down, for example unshifted_kc if neither shift nor alt gr is pressed and altgr_shifted_kc when both shift and alt gr are pressed. KC_NO can be used to not send anything for that particular combination. The function internally calls send_keypress(kc, KC_LSFT, KC_RSFT, KC_RALT)

This means that you can define and use a custom keycode in your keymap like this

enum my_keycodes {
   PLUS_EQL=SAFE_RANGE
};

const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
    KEYMAP(..., PLUS_EQL, ...)
}

bool process_record_user(uint16_t keycode, keyrecord_t *record) {
    switch(keycode) {
    case PLUS_EQL:
        send_modified_keypress(LSFT(KC_EQL), KC_EQL, KC_NO, KC_NO);
        return true;
        break;
    }
    return false;
}

@tamlyn
Copy link

tamlyn commented Jan 28, 2018

Did anything come of this? If not, was it due to technical issues or lack of time?

@drashna
Copy link
Member

drashna commented Mar 25, 2018

@tamlyn I believe that fredizzimo didn't add this yet.

However, you can see his keymap here:
https://github.com/fredizzimo/qmk_firmware/blob/18d83e5c98dd3a9dbf5a5e0f1579e86bee2d924f/layouts/community/ergodox/fredizzimo/keymap.c

@AdyaAdya
Copy link

AdyaAdya commented May 5, 2018

@Yatreyu @fredizzimo @tamlyn @drashna
I emitted the Pull Request #2900 to solve this issue. Until it is merged IF it is merged, you can clone my fork on which the branch cmv-feature contains the code supplied in that Pull Request. You can also have a look at my personal keymap as an example on how to use this feature.

@drashna
Copy link
Member

drashna commented Oct 21, 2018

Since this is a PR, I'm going to close this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants