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

Adds a default value for IS_COMMAND for COMMAND feature #4301

Merged
merged 18 commits into from
Jan 26, 2019

Conversation

drashna
Copy link
Member

@drashna drashna commented Oct 31, 2018

Fixes #4295

Wasn't sure if I should pull out all of the existing defines for this, but opted against it.

@vomindoraan
Copy link
Contributor

vomindoraan commented Oct 31, 2018

Yeah, I'd remove existing defines that aren't different from the default just because it'd make all the config.h files cleaner.

But in either case, you should definitely remove #undef IS_COMMAND in these three files since it isn't needed anymore.

@drashna
Copy link
Member Author

drashna commented Oct 31, 2018

Well, one of those files doesn't actually need it removed, if you check. :)
And that's mine.

Though as for removing it everywhere else, I'll let @jackhumbert or @skullydazed make the call on that one, and then proceed accordingly. I'm not a fan of touching every keyboard, unless it's a significant change (like the PSM change).

@vomindoraan
Copy link
Contributor

vomindoraan commented Oct 31, 2018

Totally understandable. Even though I can't see anything going wrong if it's done properly, it's still editing every or almost every keyboard's config.h file. This refactor would be most similar to the KEYMAPLAYOUT change in that regard.

Regarding the #undef, your code would be cleaner without it too 😉

@vomindoraan
Copy link
Contributor

Suggestions here: drashna#15

@@ -34,6 +34,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.


/* key combination for magic key command */
#undef IS_COMMAND
Copy link
Contributor

Choose a reason for hiding this comment

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

The keyboard doesn't have #ifndef around its #define IS_COMMAND?

Copy link
Member Author

Choose a reason for hiding this comment

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

Nope, and no other board has.

And I think this should be fine, to be honest.

Copy link
Contributor

@vomindoraan vomindoraan left a comment

Choose a reason for hiding this comment

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

Yeah, in that case the templates should probably be updated to prevent this for future boards.

#define IS_COMMAND() (keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT)))
/* key combination for magic key command */
/* defined by default; to change, uncomment and set to the combination you want */
// #define IS_COMMAND() (keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT)))
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// #define IS_COMMAND() (keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT)))
// #ifndef IS_COMMAND
// #define IS_COMMAND() (keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT)))
// #endif

quantum/template/avr/config.h Show resolved Hide resolved
@@ -18,3 +18,5 @@
#define PERMISSIVE_HOLD
#define TAPPING_TERM 200
#define TAPPING_TOGGLE 2

#define IS_COMMAND() (keyboard_report->mods == (MOD_BIT(KC_LSFT) | MOD_BIT(KC_RCTL)))
Copy link
Contributor

@vomindoraan vomindoraan Nov 9, 2018

Choose a reason for hiding this comment

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

Suggested change
#define IS_COMMAND() (keyboard_report->mods == (MOD_BIT(KC_LSFT) | MOD_BIT(KC_RCTL)))

It's already defined above on lines 5 and 6, so remove these two lines. No idea how this passed CI.

Copy link
Contributor

@vomindoraan vomindoraan Jan 8, 2019

Choose a reason for hiding this comment

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

@drashna 👆

Also remove the #undef IS_COMMAND on line 5, it works without that.
(You also have an undef in your Orthodox keymap, so you can remove that too.)

@@ -6,9 +6,8 @@
// keymap needs oneshot functionality
#undef NO_ACTION_ONESHOT

#undef IS_COMMAND
#define IS_COMMAND() ( \
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
#define IS_COMMAND() ( \

This is the same as the existing definition for the keyboard, so this can be removed.

@drashna drashna force-pushed the default_is_command branch 2 times, most recently from 560d687 to 9de1a6a Compare December 6, 2018 02:35
/* key combination for magic key command */
#define IS_COMMAND() ( \
keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT)) \
)

Copy link
Contributor

Choose a reason for hiding this comment

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

I suggest removing the extra newlines as well so we don't end up with lots of files with double empty lines.

Here's a shell script that will find and replace these extra newlines in the files changed by this PR:

for file in $(git diff --numstat master...HEAD | awk '{print $3}'); do
        tmp="$file.tmp"
        tr '\n' '\f' < "$file" | sed -e 's/\f\f\f/\f\f/g' | tr '\f' '\n' > "$tmp" && mv "$tmp" "$file" &
done

Copy link
Contributor

@vomindoraan vomindoraan left a comment

Choose a reason for hiding this comment

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

LGTM, would be cool to see this merged soon.

Copy link
Contributor

@vomindoraan vomindoraan left a comment

Choose a reason for hiding this comment

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

I always misclick "Request changes" instead of "Approve" 🙄

@vomindoraan
Copy link
Contributor

vomindoraan commented Jan 8, 2019

I found some more candidates for removal:

keyboards/atomic/keymaps/pvc/config.h:91
keyboards/atreus/keymaps/alphadox/config.h:58
keyboards/atreus/keymaps/dvorak_42_key/config.h:84
keyboards/atreus/keymaps/erlandsona/config.h:74
keyboards/comet46/keymaps/satt/config.h:25
keyboards/dz60/keymaps/LEdiodes/config.h:40
keyboards/gh60/keymaps/dbroqua/config.h:100
keyboards/gh60/keymaps/robotmaxtron/config.h:103
keyboards/handwired/downbubble/config.h:134
keyboards/handwired/numbrero/config.h:41
keyboards/handwired/ortho60/config.h:52
keyboards/handwired/tradestation/config.h:41
keyboards/hhkb/keymaps/mjt/config.h:55
keyboards/jd45/keymaps/mjt/config.h:63
keyboards/pinky/3/config.h:135
keyboards/pinky/4/config.h:135
keyboards/planck/keymaps/dodger/config.h:67
keyboards/planck/keymaps/zach/config.h:37
keyboards/preonic/keymaps/kinesis/config.h:60
keyboards/preonic/keymaps/zach/config.h:62
keyboards/rama/m60_a/config.h:55
keyboards/s60_x/keymaps/ansi_qwertz/config.h:9
keyboards/s60_x/keymaps/bluebear/config.h:42
keyboards/satan/keymaps/admiralStrokers/config.h:59
keyboards/satan/keymaps/fakb/config.h:40
keyboards/snagpad/config.h:41
keyboards/whitefox/keymaps/konstantin/config.h:29

@vomindoraan
Copy link
Contributor

I've removed these occurrences here: drashna#22

@vomindoraan
Copy link
Contributor

Removed double empty lines in modified config.h files in drashna#23.

There's one more redundant IS_COMMAND definition on master now, so I suggest rebasing.

@vomindoraan
Copy link
Contributor

vomindoraan commented Jan 26, 2019

Copy link
Contributor

@mechmerlin mechmerlin left a comment

Choose a reason for hiding this comment

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

looks good!

@mechmerlin mechmerlin merged commit b05c0e4 into qmk:master Jan 26, 2019
@drashna drashna deleted the default_is_command branch January 27, 2019 08:10
Shinichi-Ohki added a commit to Shinichi-Ohki/qmk_firmware that referenced this pull request Jan 27, 2019
* 'master' of https://github.com/qmk/qmk_firmware:
  Fix Command feature: use get_mods() instead of keyboard_report->mods (qmk#4955)
  [Keymap] Small improvements to Maxr1998's Contra keymap (qmk#4952)
  [Keymap] Minor updates to my dz60 keymap (qmk#4943)
  [Keyboard] UniGo66 keyboard added (qmk#4913)
  [Keymap] Move Iris via support to Via keymap (qmk#4893)
  Adds a default value for IS_COMMAND for COMMAND feature (qmk#4301)
  [Keyboard] drop unused i2c files (qmk#4948)
  [Keymap] Add Maxim keymap for Fourier (qmk#4534)
  use built-in arm stuff
  [Keymap] Add userspace files for vosechu (qmk#4912)
zer09 pushed a commit to zer09/qmk_firmware that referenced this pull request Feb 2, 2019
* Add default value for IS_COMMAND for COMMAND feature

* Cleanup and consistency

* Update Templates to reflect change

* Fix IS_COMMAND in template

* Fix IS_COMMAND define

* Use consistent IS_COMMAND block in templates

* Remove unnecessary `#undef IS_COMMAND` directives

* Fix compile issue on orthodox

* Reomve IS_COMMAND option for newer boards

* Remove all existing definitions of IS_COMMAND if they use default LSHIFT and RSHIFT setting

* Remove a couple of additional IS_COMMAND defines

* Remove remaining redundant IS_COMMAND definitions

* Remove #undef IS_COMMAND from orthodox:drashna and whitefox:konstantin

* Remove multiple empty lines in modified config.h files

* Update additional boards

* Reomve IS_COMMAND from newer boards

* Update Alice keyboard

* Remove IS_COMMAND from additional boards

Jan 24th edition
@noroadsleft noroadsleft mentioned this pull request Mar 25, 2019
13 tasks
shelaf added a commit to shelaf/qmk_firmware that referenced this pull request Apr 19, 2019
This was referenced Apr 23, 2019
@noroadsleft noroadsleft mentioned this pull request May 3, 2019
13 tasks
foosinn pushed a commit to foosinn/qmk_firmware that referenced this pull request May 6, 2019
dlhextall pushed a commit to dlhextall/qmk_firmware that referenced this pull request May 24, 2019
* Add default value for IS_COMMAND for COMMAND feature

* Cleanup and consistency

* Update Templates to reflect change

* Fix IS_COMMAND in template

* Fix IS_COMMAND define

* Use consistent IS_COMMAND block in templates

* Remove unnecessary `#undef IS_COMMAND` directives

* Fix compile issue on orthodox

* Reomve IS_COMMAND option for newer boards

* Remove all existing definitions of IS_COMMAND if they use default LSHIFT and RSHIFT setting

* Remove a couple of additional IS_COMMAND defines

* Remove remaining redundant IS_COMMAND definitions

* Remove #undef IS_COMMAND from orthodox:drashna and whitefox:konstantin

* Remove multiple empty lines in modified config.h files

* Update additional boards

* Reomve IS_COMMAND from newer boards

* Update Alice keyboard

* Remove IS_COMMAND from additional boards

Jan 24th edition
shimesaba-type0 pushed a commit to shimesaba-type0/qmk_firmware that referenced this pull request Jun 22, 2019
Timbus pushed a commit to Timbus/qmk_firmware that referenced this pull request Jun 23, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants