mirror of
				https://github.com/qmk/qmk_userspace.git
				synced 2025-11-04 02:40:06 -05:00 
			
		
		
		
	Shift & ODK
This commit is contained in:
		
					parent
					
						
							
								9875370c16
							
						
					
				
			
			
				commit
				
					
						634dd66dee
					
				
			
		
					 7 changed files with 38 additions and 41 deletions
				
			
		| 
						 | 
					@ -52,8 +52,8 @@ void get_clever_keycode(uint16_t* next_keycode, keyrecord_t* record) {
 | 
				
			||||||
              case PG_QUES:
 | 
					              case PG_QUES:
 | 
				
			||||||
              case PG_3PTS:
 | 
					              case PG_3PTS:
 | 
				
			||||||
              case PG_POIN:
 | 
					              case PG_POIN:
 | 
				
			||||||
                // Add OS shift at the beginning of sentences.
 | 
					                // Shift the letter at the beginning of sentences.
 | 
				
			||||||
                if (!is_caps_lock_on()) { set_oneshot_mods(MOD_BIT(KC_LSFT)); }
 | 
					                if (!is_caps_lock_on()) { add_weak_mods(MOD_BIT(KC_LSFT)); }
 | 
				
			||||||
                break;
 | 
					                break;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
| 
						 | 
					@ -131,17 +131,11 @@ void get_clever_keycode(uint16_t* next_keycode, keyrecord_t* record) {
 | 
				
			||||||
    case MAGIC:
 | 
					    case MAGIC:
 | 
				
			||||||
      if (!is_letter(prev_keycode)) {
 | 
					      if (!is_letter(prev_keycode)) {
 | 
				
			||||||
          // "à"
 | 
					          // "à"
 | 
				
			||||||
          bool is_shifted = (get_mods() | get_weak_mods() | get_oneshot_mods()) & MOD_MASK_SHIFT;
 | 
					 | 
				
			||||||
          if (is_shifted) {
 | 
					 | 
				
			||||||
              del_weak_mods(MOD_MASK_SHIFT);
 | 
					 | 
				
			||||||
              del_oneshot_mods(MOD_MASK_SHIFT);
 | 
					 | 
				
			||||||
              unregister_mods(MOD_MASK_SHIFT);
 | 
					 | 
				
			||||||
          }
 | 
					 | 
				
			||||||
          process_key(PG_ODK,record);
 | 
					          process_key(PG_ODK,record);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
          if (is_shifted) {
 | 
					          if (is_shifted) {
 | 
				
			||||||
              //is_shifted = false;
 | 
					              is_shifted = false;
 | 
				
			||||||
              set_oneshot_mods(MOD_BIT(KC_LSFT));
 | 
					              add_weak_mods(MOD_BIT(KC_LSFT));
 | 
				
			||||||
          }
 | 
					          }
 | 
				
			||||||
          return replace_ongoing_key(PG_A, next_keycode, record);
 | 
					          return replace_ongoing_key(PG_A, next_keycode, record);
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -39,7 +39,7 @@ void recent_keys_task(void) {
 | 
				
			||||||
// Handles one event. Returns false if the key was appended to `recent`.
 | 
					// Handles one event. Returns false if the key was appended to `recent`.
 | 
				
			||||||
uint16_t get_ongoing_keycode(uint16_t keycode, keyrecord_t* record) {
 | 
					uint16_t get_ongoing_keycode(uint16_t keycode, keyrecord_t* record) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  uint8_t mods = get_mods() | get_oneshot_mods();
 | 
					  uint8_t mods = get_mods() | get_weak_mods() | get_oneshot_mods();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if (mods & ~(MOD_MASK_SHIFT | MOD_BIT(KC_ALGR))) {
 | 
					  if (mods & ~(MOD_MASK_SHIFT | MOD_BIT(KC_ALGR))) {
 | 
				
			||||||
    clear_recent_keys();  // Avoid interfering with ctrl, left alt and gui.
 | 
					    clear_recent_keys();  // Avoid interfering with ctrl, left alt and gui.
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -82,7 +82,7 @@ bool process_macros(uint16_t keycode, keyrecord_t *record) {
 | 
				
			||||||
                tap_code(PG_ODK);
 | 
					                tap_code(PG_ODK);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                if (is_shifted) {
 | 
					                if (is_shifted) {
 | 
				
			||||||
                    //is_shifted = false;
 | 
					                    is_shifted = false;
 | 
				
			||||||
                    set_oneshot_mods(MOD_BIT(KC_LSFT));
 | 
					                    set_oneshot_mods(MOD_BIT(KC_LSFT));
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
                return true;
 | 
					                return true;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -16,23 +16,26 @@
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include "odk_layer.h"
 | 
					#include "odk_layer.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
//static uint16_t odk_keycode = KC_NO;
 | 
					bool is_shifted = false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
bool process_odk_layer(uint16_t keycode, keyrecord_t *record) {
 | 
					bool process_odk_layer(uint16_t keycode, keyrecord_t *record) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (record->event.pressed) {    // On press
 | 
					    if (record->event.pressed) {    // On press
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        const uint8_t mods = get_mods() | get_weak_mods() | get_oneshot_mods();
 | 
					        const uint8_t mods = get_mods() | get_weak_mods() | get_oneshot_mods();
 | 
				
			||||||
        static bool is_shifted = false;
 | 
					        //const uint8_t mods = get_mods() | get_oneshot_mods();
 | 
				
			||||||
 | 
					        //static bool is_shifted = false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (keycode == OS_ODK) {
 | 
					        if (keycode == OS_ODK) {
 | 
				
			||||||
            // Handle the custom OSL that go with this feature
 | 
					 | 
				
			||||||
            // It's timerless, to avoid problems when rolling with an other key, when shift is on.
 | 
					 | 
				
			||||||
            // Custom behaviour when alt-gr
 | 
					            // Custom behaviour when alt-gr
 | 
				
			||||||
/*             if (mods & MOD_BIT(KC_ALGR)) {
 | 
					            if (mods & MOD_BIT(KC_ALGR)) {
 | 
				
			||||||
                tap_code16(ALGR(PG_ODK));
 | 
					                tap_code16(ALGR(PG_ODK));
 | 
				
			||||||
                return false;
 | 
					                return false;
 | 
				
			||||||
            } */
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        } else if (keycode == PG_ODK) {
 | 
				
			||||||
 | 
					            // Special behaviour of PG_ODK when shifted
 | 
				
			||||||
 | 
					            // Shift must apply to the next keycode
 | 
				
			||||||
            is_shifted = mods & MOD_MASK_SHIFT;
 | 
					            is_shifted = mods & MOD_MASK_SHIFT;
 | 
				
			||||||
            if (is_shifted) {
 | 
					            if (is_shifted) {
 | 
				
			||||||
                del_weak_mods(MOD_MASK_SHIFT);
 | 
					                del_weak_mods(MOD_MASK_SHIFT);
 | 
				
			||||||
| 
						 | 
					@ -40,12 +43,8 @@ bool process_odk_layer(uint16_t keycode, keyrecord_t *record) {
 | 
				
			||||||
                unregister_mods(MOD_MASK_SHIFT);
 | 
					                unregister_mods(MOD_MASK_SHIFT);
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        } else if (keycode == PG_ODK) {
 | 
					        } else {
 | 
				
			||||||
            // Special behaviour of FR_ODK when shifted
 | 
					            if (IS_LAYER_ON(_ODK)) {
 | 
				
			||||||
            // Shift must apply to the next keycode
 | 
					 | 
				
			||||||
            return true;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        } else if (IS_LAYER_ON(_ODK)) {
 | 
					 | 
				
			||||||
                switch (keycode) {
 | 
					                switch (keycode) {
 | 
				
			||||||
                    case PG_3PTS:   // For Clever Keys
 | 
					                    case PG_3PTS:   // For Clever Keys
 | 
				
			||||||
                    case PG_AROB:
 | 
					                    case PG_AROB:
 | 
				
			||||||
| 
						 | 
					@ -60,11 +59,11 @@ bool process_odk_layer(uint16_t keycode, keyrecord_t *record) {
 | 
				
			||||||
                    default:
 | 
					                    default:
 | 
				
			||||||
                        tap_code(PG_ODK);
 | 
					                        tap_code(PG_ODK);
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
            if (is_shifted) {
 | 
					            if (is_shifted) {
 | 
				
			||||||
                is_shifted = false;
 | 
					                is_shifted = false;
 | 
				
			||||||
                //set_mods(mods);
 | 
					                //set_mods(mods);
 | 
				
			||||||
                set_oneshot_mods(MOD_BIT(KC_LSFT));
 | 
					                add_weak_mods(MOD_BIT(KC_LSFT));
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -24,6 +24,8 @@
 | 
				
			||||||
extern "C" {
 | 
					extern "C" {
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					extern bool is_shifted;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
bool process_odk_layer(uint16_t keycode, keyrecord_t *record);
 | 
					bool process_odk_layer(uint16_t keycode, keyrecord_t *record);
 | 
				
			||||||
//void odk_layer_exit_check(uint16_t keycode);
 | 
					//void odk_layer_exit_check(uint16_t keycode);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -68,7 +68,7 @@ bool process_os4a_layers(uint16_t keycode, keyrecord_t *record) {
 | 
				
			||||||
    // to be processed (ex: custom altgr, clever keys).
 | 
					    // to be processed (ex: custom altgr, clever keys).
 | 
				
			||||||
    uint8_t mods = get_mods() | get_oneshot_mods();
 | 
					    uint8_t mods = get_mods() | get_oneshot_mods();
 | 
				
			||||||
    if (!exit_os4a_layer && !pending_OSL && to_be_shifted(keycode, record) && mods == 0) {
 | 
					    if (!exit_os4a_layer && !pending_OSL && to_be_shifted(keycode, record) && mods == 0) {
 | 
				
			||||||
      set_oneshot_mods(MOD_BIT(KC_LSFT));
 | 
					      add_weak_mods(MOD_BIT(KC_LSFT));
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    return true;
 | 
					    return true;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -190,6 +190,8 @@ bool to_be_shifted(uint16_t keycode, keyrecord_t *record) {
 | 
				
			||||||
  if (!IS_KEYEVENT(record->event)) { return true; }
 | 
					  if (!IS_KEYEVENT(record->event)) { return true; }
 | 
				
			||||||
  
 | 
					  
 | 
				
			||||||
  switch (keycode) {
 | 
					  switch (keycode) {
 | 
				
			||||||
 | 
					    case OS_ODK:
 | 
				
			||||||
 | 
					      is_shifted = true;
 | 
				
			||||||
    case KC_CAPS:
 | 
					    case KC_CAPS:
 | 
				
			||||||
    case CAPSWORD:
 | 
					    case CAPSWORD:
 | 
				
			||||||
      return false;
 | 
					      return false;
 | 
				
			||||||
| 
						 | 
					@ -232,7 +234,7 @@ bool is_oneshot_ignored_key(uint16_t keycode) {
 | 
				
			||||||
    case OS_FA:
 | 
					    case OS_FA:
 | 
				
			||||||
    case NUMWORD:
 | 
					    case NUMWORD:
 | 
				
			||||||
    case TT_FA:
 | 
					    case TT_FA:
 | 
				
			||||||
    case NUM_ODK:
 | 
					    //case NUM_ODK:
 | 
				
			||||||
    //case PG_ODK:
 | 
					    //case PG_ODK:
 | 
				
			||||||
        return true;
 | 
					        return true;
 | 
				
			||||||
    default:
 | 
					    default:
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue