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

[Core] Added add_oneshot_mods & del_oneshot_mods #10549

Merged
merged 2 commits into from Nov 10, 2020

Conversation

precondition
Copy link
Contributor

@precondition precondition commented Oct 5, 2020

Description

To be consistent with all the other mod functions in action_util that all had a add...mods(mods) and del...mods(mods) function, I added similar functions for one shot mods.

add_oneshot_mods takes a modmask as an argument and adds the modifier passed in argument to the one shot mod state by ORing the two together. The one shot timer gets also updated.

del_oneshot_mods disables the passed modifier(s) in the current one shot mod state in the same fashion as all other del...mods functions in the file. The one shot timer gets reset to 0 if no shot mod is left after the deletion but gets restarted if there still remains a one shot modifier. Please let me know if you find any pitfalls in changing the one shot timer this way.

Aside from adding two new functions, I also:

Deleted undefined and unused prototypes:

  • void oneshot_enable(void)
  • void oneshot_disable(void)
  • void oneshot_toggle(void)

Reordered the oneshot functions to follow the same order as other mod functions,
that is to say : get, add, del, set, clear

Types of Changes

  • Core
  • Bugfix
  • New feature
  • Enhancement/optimization
  • Keyboard (addition or update)
  • Keymap/layout/userspace (addition or update)
  • Documentation (See PS)

Issues Fixed or Closed by This PR

  • N/A

Checklist

  • My code follows the code style of this project: C, Python
  • I have read the PR Checklist document and have made the appropriate changes.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly. (see PS)
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • I have tested the changes and verified that they work and don't break anything (as well as I can manage).

PS: I have opened another PR (#10550) which adds a "Checking modifier state" section to the documentation page on modifiers which lists all mod masks and mod functions such as add_mods() and so on. While it does not currently mention the new functions of this PR, these can be very easily added to the docs of PR #10550.

@drashna drashna requested a review from a team October 8, 2020 00:57
@drashna drashna added the core label Oct 8, 2020
Copy link
Contributor

@kosorin kosorin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think conditions in add_oneshot_mods and del_oneshot_mods should be changed. See suggested changes.

tmk_core/common/action_util.c Outdated Show resolved Hide resolved
tmk_core/common/action_util.c Outdated Show resolved Hide resolved
@tzarc
Copy link
Member

tzarc commented Nov 10, 2020

The two commits that actually make up the PR look fine -- if we can get a rebase we should be good for merge. If you can @ me when it's done I'll give it a once-over and do so.

precondition and others added 2 commits November 10, 2020 09:06
Deleted undefined and unused prototypes:
- void oneshot_enable(void)
- void oneshot_disable(void)
- void oneshot_toggle(void)

Reordered the oneshot functions to follow the same order as other mod
functions, that is to say : get, add, del, set, clear
Prevent extending the one shot timer if the called add_oneshot_mods or del_oneshot_mods do not change anything to the current one shot mod state.

Co-authored-by: David Kosorin <david@kosorin.net>
@precondition
Copy link
Contributor Author

@tzarc I have rebased the PR

@tzarc tzarc merged commit 3dcb046 into qmk:develop Nov 10, 2020
@precondition precondition deleted the oneshot-mods-functions branch November 10, 2020 09:55
tzarc pushed a commit that referenced this pull request Nov 10, 2020
* add support for otg

* update endpoint numbering for stm32f4

* removed testing file

* add DEBUG_MATRIX_SCAN_RATE_ENABLE to common_features.mk (#10824)

Add a Make variable to easily enable DEBUG_MATRIX_SCAN_RATE on the command line.

eg.
```
make DEBUG_MATRIX_SCAN_RATE_ENABLE=yes  KEYBOARD:KEYMAP
```

* [Core] Added `add_oneshot_mods` & `del_oneshot_mods` (#10549)

* Added `add_oneshot_mods` & `del_oneshot_mods`

Deleted undefined and unused prototypes:
- void oneshot_enable(void)
- void oneshot_disable(void)
- void oneshot_toggle(void)

Reordered the oneshot functions to follow the same order as other mod
functions, that is to say : get, add, del, set, clear

* Stricter conditions on add_oneshot_mods & del_oneshot_mods

Prevent extending the one shot timer if the called add_oneshot_mods or del_oneshot_mods do not change anything to the current one shot mod state.

Co-authored-by: David Kosorin <david@kosorin.net>

Co-authored-by: David Kosorin <david@kosorin.net>

* add support for otg

* update endpoint numbering for stm32f4

* removed testing file

* added missing #endif

Co-authored-by: Takeshi ISHII <2170248+mtei@users.noreply.github.com>
Co-authored-by: precondition <57645186+precondition@users.noreply.github.com>
Co-authored-by: David Kosorin <david@kosorin.net>
noroadsleft added a commit that referenced this pull request Nov 28, 2020
* Branch point for 2020 November 28 Breaking Change                                                

* Remove matrix_col_t to allow MATRIX_ROWS > 32 (#10183)                                           

* Add support for soft serial to ATmega32U2 (#10204)                                               

* Change MIDI velocity implementation to allow direct control of velocity value (#9940)            

* Add ability to build a subset of all keyboards based on platform.                                

* Actually use eeprom_driver_init().                                                               

* Make bootloader_jump weak for ChibiOS. (#10417)                                                  

* Joystick 16-bit support (#10439)                                                                 

* Per-encoder resolutions (#10259)                                                                 

* Share button state from mousekey to pointing_device (#10179)                                     

* Add hotfix for chibios keyboards not wake (#10088)                                               

* Add advanced/efficient RGB Matrix Indicators (#8564)                                             

* Naming change.                                                                                   

* Support for STM32 GPIOF,G,H,I,J,K (#10206)                                                       

* Add milc as a dependency and remove the installed milc (#10563)                                  

* ChibiOS upgrade: early init conversions (#10214)                                                 

* ChibiOS upgrade: configuration file migrator (#9952)                                             

* Haptic and solenoid cleanup (#9700)                                                              

* XD75 cleanup (#10524)                                                                            

* OLED display update interval support (#10388)                                                    

* Add definition based on currently-selected serial driver. (#10716)                               

* New feature: Retro Tapping per key (#10622)                                                      

* Allow for modification of output RGB values when using rgblight/rgb_matrix. (#10638)             

* Add housekeeping task callbacks so that keyboards/keymaps are capable of executing code for each main loop iteration. (#10530)

* Rescale both ChibiOS and AVR backlighting.                                                       

* Reduce Helix keyboard build variation (#8669)                                                    

* Minor change to behavior allowing display updates to continue between task ticks (#10750)        

* Some GPIO manipulations in matrix.c change to atomic. (#10491)                                   

* qmk cformat (#10767)                                                                             

* [Keyboard] Update the Speedo firmware for v3.0 (#10657)                                          

* Maartenwut/Maarten namechange to evyd13/Evy (#10274)                                             

* [quantum] combine repeated lines of code (#10837)                                                

* Add step sequencer feature (#9703)                                                               

* aeboards/ext65 refactor (#10820)                                                                 

* Refactor xelus/dawn60 for Rev2 later (#10584)                                                    

* add DEBUG_MATRIX_SCAN_RATE_ENABLE to common_features.mk (#10824)                                 

* [Core] Added `add_oneshot_mods` & `del_oneshot_mods` (#10549)                                    

* update chibios os usb for the otg driver (#8893)                                                 

* Remove HD44780 References, Part 4 (#10735)                                                       

* [Keyboard] Add Valor FRL TKL (+refactor) (#10512)                                                

* Fix cursor position bug in oled_write_raw functions (#10800)                                     

* Fixup version.h writing when using SKIP_VERSION=yes (#10972)                                     

* Allow for certain code in the codebase assuming length of string. (#10974)                       

* Add AT90USB support for serial.c (#10706)                                                        

* Auto shift: support repeats and early registration (#9826)                                       

* Rename ledmatrix.h to match .c file (#7949)                                                      

* Split RGB_MATRIX_ENABLE into _ENABLE and _DRIVER (#10231)                                        

* Split LED_MATRIX_ENABLE into _ENABLE and _DRIVER (#10840)                                        

* Merge point for 2020 Nov 28 Breaking Change
xgnxs pushed a commit to xgnxs/qmk_firmware that referenced this pull request Jan 9, 2021
* Branch point for 2020 November 28 Breaking Change                                                

* Remove matrix_col_t to allow MATRIX_ROWS > 32 (qmk#10183)                                           

* Add support for soft serial to ATmega32U2 (qmk#10204)                                               

* Change MIDI velocity implementation to allow direct control of velocity value (qmk#9940)            

* Add ability to build a subset of all keyboards based on platform.                                

* Actually use eeprom_driver_init().                                                               

* Make bootloader_jump weak for ChibiOS. (qmk#10417)                                                  

* Joystick 16-bit support (qmk#10439)                                                                 

* Per-encoder resolutions (qmk#10259)                                                                 

* Share button state from mousekey to pointing_device (qmk#10179)                                     

* Add hotfix for chibios keyboards not wake (qmk#10088)                                               

* Add advanced/efficient RGB Matrix Indicators (qmk#8564)                                             

* Naming change.                                                                                   

* Support for STM32 GPIOF,G,H,I,J,K (qmk#10206)                                                       

* Add milc as a dependency and remove the installed milc (qmk#10563)                                  

* ChibiOS upgrade: early init conversions (qmk#10214)                                                 

* ChibiOS upgrade: configuration file migrator (qmk#9952)                                             

* Haptic and solenoid cleanup (qmk#9700)                                                              

* XD75 cleanup (qmk#10524)                                                                            

* OLED display update interval support (qmk#10388)                                                    

* Add definition based on currently-selected serial driver. (qmk#10716)                               

* New feature: Retro Tapping per key (qmk#10622)                                                      

* Allow for modification of output RGB values when using rgblight/rgb_matrix. (qmk#10638)             

* Add housekeeping task callbacks so that keyboards/keymaps are capable of executing code for each main loop iteration. (qmk#10530)

* Rescale both ChibiOS and AVR backlighting.                                                       

* Reduce Helix keyboard build variation (qmk#8669)                                                    

* Minor change to behavior allowing display updates to continue between task ticks (qmk#10750)        

* Some GPIO manipulations in matrix.c change to atomic. (qmk#10491)                                   

* qmk cformat (qmk#10767)                                                                             

* [Keyboard] Update the Speedo firmware for v3.0 (qmk#10657)                                          

* Maartenwut/Maarten namechange to evyd13/Evy (qmk#10274)                                             

* [quantum] combine repeated lines of code (qmk#10837)                                                

* Add step sequencer feature (qmk#9703)                                                               

* aeboards/ext65 refactor (qmk#10820)                                                                 

* Refactor xelus/dawn60 for Rev2 later (qmk#10584)                                                    

* add DEBUG_MATRIX_SCAN_RATE_ENABLE to common_features.mk (qmk#10824)                                 

* [Core] Added `add_oneshot_mods` & `del_oneshot_mods` (qmk#10549)                                    

* update chibios os usb for the otg driver (qmk#8893)                                                 

* Remove HD44780 References, Part 4 (qmk#10735)                                                       

* [Keyboard] Add Valor FRL TKL (+refactor) (qmk#10512)                                                

* Fix cursor position bug in oled_write_raw functions (qmk#10800)                                     

* Fixup version.h writing when using SKIP_VERSION=yes (qmk#10972)                                     

* Allow for certain code in the codebase assuming length of string. (qmk#10974)                       

* Add AT90USB support for serial.c (qmk#10706)                                                        

* Auto shift: support repeats and early registration (qmk#9826)                                       

* Rename ledmatrix.h to match .c file (qmk#7949)                                                      

* Split RGB_MATRIX_ENABLE into _ENABLE and _DRIVER (qmk#10231)                                        

* Split LED_MATRIX_ENABLE into _ENABLE and _DRIVER (qmk#10840)                                        

* Merge point for 2020 Nov 28 Breaking Change
drashna pushed a commit to zsa/qmk_firmware that referenced this pull request Jan 13, 2021
* Branch point for 2020 November 28 Breaking Change

* Remove matrix_col_t to allow MATRIX_ROWS > 32 (qmk#10183)

* Add support for soft serial to ATmega32U2 (qmk#10204)

* Change MIDI velocity implementation to allow direct control of velocity value (qmk#9940)

* Add ability to build a subset of all keyboards based on platform.

* Actually use eeprom_driver_init().

* Make bootloader_jump weak for ChibiOS. (qmk#10417)

* Joystick 16-bit support (qmk#10439)

* Per-encoder resolutions (qmk#10259)

* Share button state from mousekey to pointing_device (qmk#10179)

* Add hotfix for chibios keyboards not wake (qmk#10088)

* Add advanced/efficient RGB Matrix Indicators (qmk#8564)

* Naming change.

* Support for STM32 GPIOF,G,H,I,J,K (qmk#10206)

* Add milc as a dependency and remove the installed milc (qmk#10563)

* ChibiOS upgrade: early init conversions (qmk#10214)

* ChibiOS upgrade: configuration file migrator (qmk#9952)

* Haptic and solenoid cleanup (qmk#9700)

* XD75 cleanup (qmk#10524)

* OLED display update interval support (qmk#10388)

* Add definition based on currently-selected serial driver. (qmk#10716)

* New feature: Retro Tapping per key (qmk#10622)

* Allow for modification of output RGB values when using rgblight/rgb_matrix. (qmk#10638)

* Add housekeeping task callbacks so that keyboards/keymaps are capable of executing code for each main loop iteration. (qmk#10530)

* Rescale both ChibiOS and AVR backlighting.

* Reduce Helix keyboard build variation (qmk#8669)

* Minor change to behavior allowing display updates to continue between task ticks (qmk#10750)

* Some GPIO manipulations in matrix.c change to atomic. (qmk#10491)

* qmk cformat (qmk#10767)

* [Keyboard] Update the Speedo firmware for v3.0 (qmk#10657)

* Maartenwut/Maarten namechange to evyd13/Evy (qmk#10274)

* [quantum] combine repeated lines of code (qmk#10837)

* Add step sequencer feature (qmk#9703)

* aeboards/ext65 refactor (qmk#10820)

* Refactor xelus/dawn60 for Rev2 later (qmk#10584)

* add DEBUG_MATRIX_SCAN_RATE_ENABLE to common_features.mk (qmk#10824)

* [Core] Added `add_oneshot_mods` & `del_oneshot_mods` (qmk#10549)

* update chibios os usb for the otg driver (qmk#8893)

* Remove HD44780 References, Part 4 (qmk#10735)

* [Keyboard] Add Valor FRL TKL (+refactor) (qmk#10512)

* Fix cursor position bug in oled_write_raw functions (qmk#10800)

* Fixup version.h writing when using SKIP_VERSION=yes (qmk#10972)

* Allow for certain code in the codebase assuming length of string. (qmk#10974)

* Add AT90USB support for serial.c (qmk#10706)

* Auto shift: support repeats and early registration (qmk#9826)

* Rename ledmatrix.h to match .c file (qmk#7949)

* Split RGB_MATRIX_ENABLE into _ENABLE and _DRIVER (qmk#10231)

* Split LED_MATRIX_ENABLE into _ENABLE and _DRIVER (qmk#10840)

* Merge point for 2020 Nov 28 Breaking Change
hazelweakly pushed a commit to hazelweakly/qmk_firmware that referenced this pull request Sep 23, 2021
* Added `add_oneshot_mods` & `del_oneshot_mods`

Deleted undefined and unused prototypes:
- void oneshot_enable(void)
- void oneshot_disable(void)
- void oneshot_toggle(void)

Reordered the oneshot functions to follow the same order as other mod
functions, that is to say : get, add, del, set, clear

* Stricter conditions on add_oneshot_mods & del_oneshot_mods

Prevent extending the one shot timer if the called add_oneshot_mods or del_oneshot_mods do not change anything to the current one shot mod state.

Co-authored-by: David Kosorin <david@kosorin.net>

Co-authored-by: David Kosorin <david@kosorin.net>
hazelweakly pushed a commit to hazelweakly/qmk_firmware that referenced this pull request Sep 23, 2021
* add support for otg

* update endpoint numbering for stm32f4

* removed testing file

* add DEBUG_MATRIX_SCAN_RATE_ENABLE to common_features.mk (qmk#10824)

Add a Make variable to easily enable DEBUG_MATRIX_SCAN_RATE on the command line.

eg.
```
make DEBUG_MATRIX_SCAN_RATE_ENABLE=yes  KEYBOARD:KEYMAP
```

* [Core] Added `add_oneshot_mods` & `del_oneshot_mods` (qmk#10549)

* Added `add_oneshot_mods` & `del_oneshot_mods`

Deleted undefined and unused prototypes:
- void oneshot_enable(void)
- void oneshot_disable(void)
- void oneshot_toggle(void)

Reordered the oneshot functions to follow the same order as other mod
functions, that is to say : get, add, del, set, clear

* Stricter conditions on add_oneshot_mods & del_oneshot_mods

Prevent extending the one shot timer if the called add_oneshot_mods or del_oneshot_mods do not change anything to the current one shot mod state.

Co-authored-by: David Kosorin <david@kosorin.net>

Co-authored-by: David Kosorin <david@kosorin.net>

* add support for otg

* update endpoint numbering for stm32f4

* removed testing file

* added missing #endif

Co-authored-by: Takeshi ISHII <2170248+mtei@users.noreply.github.com>
Co-authored-by: precondition <57645186+precondition@users.noreply.github.com>
Co-authored-by: David Kosorin <david@kosorin.net>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants