Commit Graph

842 Commits (9a2b0a5db15a48a0297a4b82665d462361261600)

Author SHA1 Message Date
Sergey Vlasov d00ac5dfb6 Add `st-flash` flash target (#9964)
* Add `st-flash` flash target

Add support for flashing the firmware via the `st-flash` utility from
the STLink Tools package (https://github.com/stlink-org/stlink).

* Add `st-flash` to the `qmk flash -b` output
2020-08-29 14:30:02 -07:00
Ryan 12333b7c5e Fix joystick compile issues (#9949) 2020-08-29 14:30:02 -07:00
Drashna Jaelre e6266b19be Initialize Layer State on startup (#8318)
* Initialize Layer State on startup

Right now, on startup, the default layer state gets called and set, triggering the callback functions for the default layer state. However, the normal layer state never actually gets initialized.  It's set to 0 directly, by default, but the callback functions are never actually called.  This creates some inconsistency in the behavior for end users.  This adds a simple "clear" that triggers the callback on startup.  This should produce more consisten behavior between the two functions and layer masks.

* Stupid hack

* Fix type casting?

* Fix compile issues with magic is disabled
2020-08-29 14:30:02 -07:00
a-chol d4be07dad3 Hid joystick interface (#4226)
* add support for hid gamepad interface
add documentation for HID joystick
Add joystick_task to read analog axes values even when no key is pressed or release. update doc
Update docs/feature_joystick.md
Manage pin setup and read to maintain matrix scan after analog read

* Incorporates patches and changes to HID reporting

There are some patches provided by @a-chol incorporated on this commit,
and also some changes I made to the HID Report structure.

The most interesting is the one dealing with number of buttons: Linux
doesn't seem to care, but Windows requires the HID structure to be byte
aligned (that's in the spec). So if one declares 8/16/32... buttons they
should not have any issues, but this is what happens when you have 9
buttons:

```
 bits |0|1|2|3|4|5|6|7|
      |*|*|*|*|*|*|*|*| axis 0 (report size 8)
      |*|*|*|*|*|*|*|*| ...
      |*|*|*|*|*|*|*|*|
      |*|*|*|*|*|*|*|*|
      |*|*|*|*|*|*|*|*|
      |*|*|*|*|*|*|*|*|
      |*|*|*|*|*|*|*|*| axis 6
      |*|*|*|*|*|*|*|*| first 8 buttons (report size 1)
      |*| | | | | | | | last of 9 buttons, not aligned
```

So for that I added a conditonal that will add a number of reports with
size 1 to make sure it aligns to the next multiple of 8. Those reports
send dummy inputs that don't do anything aside from aligning the data.

Tested on Linux, Windows 10 and Street Fighter (where the joystick is
recognized as direct-input)

* Add save and restore of each pin used in reading joystick (AVR).
Allow output pin to be JS_VIRTUAL_AXIS if the axis is connected to Vcc
instead of an output pin from the MCU.

Fix joystick report id

Fix broken v-usb hid joystick interface. Make it more resilient to unusual settings (none multiple of eight button count, 0 buttons or 0 axes)

Correct adc reading for multiple axes. Piecewise range conversion for uncentered raw value range. Input, output and ground pin configuration per axis.

Documentation fixes

* Fix port addressing for joystick analog read

* The other required set of changes
As per the PR, the changes still holding it up.
Add onekey for testing.
Fix ARM builds.
Fix device descriptor when either axes or buttons is zero.
Add compile-time check for at least one axis or button.
Move definition to try to fix conflict.
PR review comments.
qmk cformat

* avoid float functions to compute range mapping for axis adc reading

* Remove V-USB support for now. Updated docs accordingly.

* Update tmk_core/protocol/lufa/lufa.c

Co-Authored-By: Ryan <fauxpark@gmail.com>

* Update tmk_core/protocol/usb_descriptor.c

Co-Authored-By: Ryan <fauxpark@gmail.com>

* Update tmk_core/protocol/usb_descriptor.c

Co-Authored-By: Ryan <fauxpark@gmail.com>

* Update tmk_core/protocol/usb_descriptor.c

Co-Authored-By: Ryan <fauxpark@gmail.com>

* Add support for joystick adc reading for stm32 MCUs. Fix joystick hid report sending for chibios

* Fix HID joystick report sending for ChibiOS.
Add one analog axis to the onekey:joystick keymap.
Fix pin state save and restore during joystick analog read for STM32
MCUs.

* Update tmk_core/protocol/chibios/usb_main.c

Co-Authored-By: Ryan <fauxpark@gmail.com>

* Update tmk_core/protocol/lufa/lufa.c

Co-Authored-By: Ryan <fauxpark@gmail.com>

* Add missing mcuconf.h and halconf.h to onekey:joystick keymap.
Add suggested fixes from PR.

* Switch saveState and restoreState signature to use pin_t type.
onekey:joystick : add a second axis, virtual and programmatically animated.

* Update docs/feature_joystick.md

Co-Authored-By: Ryan <fauxpark@gmail.com>

* Update docs/feature_joystick.md

Co-Authored-By: Ryan <fauxpark@gmail.com>

* Add PR corrections

* Remove halconf.h and mcuconf.h from onekey keymaps

* Change ADC_PIN to A0

Co-authored-by: achol <allecooll@hotmail.com>
Co-authored-by: José Júnior <jose.junior@gmail.com>
Co-authored-by: a-chol <achol@notamail.com>
Co-authored-by: Nick Brassel <nick@tzarc.org>
Co-authored-by: Ryan <fauxpark@gmail.com>
2020-08-29 14:30:02 -07:00
Drashna Jaelre 3c74edbc69 Disable NKRO on V-USB controllers (#9054)
* Disable NKRO on V-USB controllers

* not _currently_ supported text

Co-authored-by: Ryan <fauxpark@gmail.com>

Co-authored-by: Ryan <fauxpark@gmail.com>
2020-08-29 14:30:02 -07:00
Nick Brassel 686a9d35ff Re-fix the STM32 dual-bank bootloader stuff. (#9738)
* Re-fix the dual-bank bootloader stuff.

* Use wait_ms() instead of using nop's for a delay, as ChibiOS is actually running at the time of bootloader jump.
2020-08-29 14:30:02 -07:00
Nick Brassel 93e7a8f74c Add dual-bank STM32 bootloader support, given GPIO toggle on BOOT0 to charge RC circuit. (#8778) 2020-08-29 14:30:02 -07:00
dhong44 d0abad27ab Fix the mousekey scrolling (#9174)
Mousekey scrolling should have a separate repeat variable
to keep track of scrolling acceleration, instead of being
tied to mouse movement scolling in mousekeys. The send function
should record when the last movement was made since this is
when movement is actually sent. Doing this fixes the bug where
the initial press of a mousekey scroll button causes a double scroll.

Signed-off-by: Daniel Hong <daniel.hong@live.com>
2020-08-29 14:30:02 -07:00
Ryan 8a4a0c25fd Change analogRead calls to analogReadPin (#9023)
* Change analogRead calls to analogReadPin

* Add ChangeLog

* Update docs, remove mention of `analogRead()`

* Retarget changelog for next round
2020-08-29 14:30:02 -07:00
Nick Brassel 60e5733c48 `qmk cformat` on `develop` (#9501) 2020-08-29 14:30:02 -07:00
Ryan 3b34858b77 Don't compile outputselect.c if Bluetooth is disabled (#9356) 2020-08-29 14:30:02 -07:00
Ryan 69e0ad1b2c Additional cleanups for V-USB code (#9310) 2020-08-29 14:30:02 -07:00
Ryan 1193e45bf4 Convert `CONSUMER2BLUEFRUIT()` and `CONSUMER2RN42()` macros to static inline functions (#9055) 2020-08-29 14:30:02 -07:00
Ryan f209f91c7c Various tidyups for USB descriptor code (#9005) 2020-08-29 14:30:02 -07:00
Nick Brassel 385d49cc39 Initial work for consolidation of ChibiOS platform files (#8327)
* Initial work for consolidation of board files and default ChibiOS configs.

* Migrate F401/F411 black pills for testing.

* Add early init bootloader jump flag.

* Add support for I2C in order to use i2c_scanner keymap.

* Add F401/F411 HSE bypass to get things booting.

* Exempt "hooked" ChibiOS conf files from updater script.

* Fix up ordering for bootloader_defs file check.

* Match previous $(KEYBOARD_PATHS) value for Proton-C, updated for all board configs.
2020-08-29 14:30:02 -07:00
Ryan 5cc3ab38c9 Remove iWRAP protocol (#9284) 2020-08-29 14:30:02 -07:00
Ryan d949932c08
Fix ChibiOS backlight not turning off on suspend (#10114)
* Fix ChibiOS backlight not turning off on suspend

* Add missing code for backlight as caps lock too
2020-08-26 11:15:43 -07:00
Nick Brassel 70ce4ba56f
Revert "Add Kiibohd bootloader type to bootloader.mk (#9908)" (#10126)
This reverts commit e2d4cd1a41.
2020-08-21 15:42:28 -07:00
Ryan e2d4cd1a41
Add Kiibohd bootloader type to bootloader.mk (#9908) 2020-08-12 12:28:20 +10:00
Drashna Jaelre c7b56bee96
[Bug] Fix Swap Hands bug introduced by OSH (#9968)
Fixes the handling for the oneshot cleanup, so it only cleans up if it is active.  It should not cleanup of SHO is off (eg using a normal oneshot key), nor if it's actively pressed or used.  

Previous behavior BROKE swap hand key.
2020-08-08 16:41:10 -07:00
QMK Bot 95c742ec27 format code according to conventions [skip ci] 2020-07-25 22:33:55 +00:00
Joel Challis d91987ab9a
Enable OLED support for Teensy 3.2/LC (#7591)
* I2C_TIMEOUT is not defined on arm teensy

* Work round teensy having different ChibiOS config options

* Stash OLED conf files

* update comment

* update comment

* Remove stm32 alias to allow teensy alt mode
2020-07-26 07:50:56 +10:00
QMK Bot 1778858e24 format code according to conventions [skip ci] 2020-07-21 00:09:52 +00:00
nathanvercaemert 19006c9753
Implemented New MK_COMBINED Functionality (#9557)
* implemented new mousekey_combined functionality

* minor formatting change to documentation

* Update tmk_core/common/mousekey.c

Co-authored-by: Ryan <fauxpark@gmail.com>

* Update tmk_core/common/mousekey.c

Co-authored-by: Ryan <fauxpark@gmail.com>

* Update tmk_core/common/mousekey.c

Co-authored-by: Ryan <fauxpark@gmail.com>

* Update tmk_core/common/mousekey.c

Co-authored-by: Ryan <fauxpark@gmail.com>

* Update docs/feature_mouse_keys.md

Co-authored-by: Nick Brassel <nick@tzarc.org>

* Update docs/feature_mouse_keys.md

Co-authored-by: Nick Brassel <nick@tzarc.org>

* Update docs/feature_mouse_keys.md

Co-authored-by: Nick Brassel <nick@tzarc.org>

* Update docs/feature_mouse_keys.md

Co-authored-by: Nick Brassel <nick@tzarc.org>

Co-authored-by: Nathan Vercaemert <nathan.vercaemert@gmail.com>
Co-authored-by: Ryan <fauxpark@gmail.com>
Co-authored-by: Nick Brassel <nick@tzarc.org>
2020-07-21 09:28:38 +10:00
Ryan 72d3270547
Remove `DESCRIPTION` (#9732) 2020-07-16 15:49:18 +10:00
Sven Grunewaldt 03c790a0f2
Add TAP_CODE_DELAY to Mod-Tap (#9422) 2020-07-07 21:47:59 +01:00
Manna Harbour b7dc2eb9ab
Add movement hook to ps2_mouse (#8805)
Process mouse movement in the keymap before it is sent to the host. Example uses
include filtering noise, adding acceleration, and automatically activating a
layer. To use, define the following function in your keymap:

void ps2_mouse_moved_user(report_mouse_t *mouse_report);
2020-07-02 21:54:15 +01:00
Manna Harbour d1819f02df
Fix sharing of mouse button state from mousekeys to ps2_mouse (#9124)
With this change, when ps2_mouse is disabled, mousekeys works as usual. With
ps2_mouse enabled, mousekeys button state is shared with ps2_mouse for clicking,
dragging, and scrolling, mousekeys clicks are produced by ps2_mouse only, and
mouskeys button state is transferred to mousekeys without generating clicks to
enable mousekeys dragging.

Co-authored-by: Drashna Jaelre <drashna@live.com>

Co-authored-by: Drashna Jaelre <drashna@live.com>
2020-07-02 18:04:55 +01:00
AlexOConnorHub 82dc8faaf3
Fixing MIDI for ARM without NKRO enabled (#9466) 2020-06-22 08:43:08 +01:00
Joshua Diamond 9c1097e768
Fix for One Shot Layer not being cleaned up after some actions (#8832) 2020-06-18 08:07:48 +01:00
Tsan-Kuang Lee 437446ba8f
Fix one shot swaphands compiler error when NO_ACTION_ONESHOT is defined (#9296)
* init

* add RETRO_TAP; tap anyway after TAP_TERM, if no interruption

* RETRO_TAP works for other types of taps

* revert to upstream/master

* explain this fork in readme

* use one readme.md file instaed

* fix the error if NO_ACTION_ONESHOT is defined

* restore readme.md to upstream master

Co-authored-by: Tsan-Kuang Lee <tsan.kuang.lee@gmail.com>
2020-06-10 22:40:17 +01:00
itsnoteasy 7aa4cc9603
adds support for the atmega328 (#9043)
Co-authored-by: Ryan <fauxpark@gmail.com>
2020-06-10 22:23:11 +01:00
Joel Challis d17572b125
Move encoder_read to common location (#9003) 2020-06-03 00:54:53 +01:00
Drashna Jaelre 1110fe6c6f
Move dip switch init to back of the init process (#9233) 2020-06-03 00:32:02 +01:00
Nick Brassel 8d3fca57a3
Fix build when using IGNORE_MOD_TAP_INTERRUPT_PER_KEY. (#9258) 2020-06-01 11:53:01 +10:00
James Young fced377ac0
2020 May 30 Breaking Changes Update (#9215)
* Branch point for 2020 May 30 Breaking Change

* Migrate `ACTION_LAYER_TOGGLE` to `TG()` (#8954)

* Migrate `ACTION_MODS_ONESHOT` to `OSM()` (#8957)

* Migrate `ACTION_DEFAULT_LAYER_SET` to `DF()` (#8958)

* Migrate `ACTION_LAYER_MODS` to `LM()` (#8959)

* Migrate `ACTION_MODS_TAP_KEY` to `MT()` (#8968)

* Convert V-USB usbdrv to a submodule (#8321)

* Unify Tap Hold functions and documentation (#8348)

* Changing board names to prevent confusion (#8412)

* Move the Keyboardio Model01 to a keyboardio/ subdir (#8499)

* Move spaceman keyboards (#8830)

* Migrate miscellaneous `fn_actions` entries (#8977)

* Migrate `ACTION_MODS_KEY` to chained mod keycodes (#8979)

* Organizing my keyboards (plaid, tartan, ergoinu) (#8537)

* Refactor Lily58 to use split_common (#6260)

* Refactor zinc to use split_common (#7114)

* Add a message if bin/qmk doesn't work (#9000)

* Fix conflicting types for 'tfp_printf' (#8269)

* Fixed RGB_DISABLE_AFTER_TIMEOUT to be seconds based & small internals cleanup (#6480)

* Refactor and updates to TKC1800 code (#8472)

* Switch to qmk forks for everything (#9019)

* audio refactor: replace deprecated PLAY_NOTE_ARRAY (#8484)

* Audio enable corrections (2/3) (#8903)

* Split HHKB to ANSI and JP layouts and Add VIA support for each (#8582)

* Audio enable corrections (Part 4) (#8974)

* Fix typo from PR7114 (#9171)

* Augment future branch Changelogs (#8978)

* Revert "Branch point for 2020 May 30 Breaking Change"
2020-05-30 13:14:59 -07:00
Ryan e4823aadec
Fix capitalisation of "GitHub" (#9184) 2020-05-25 19:43:14 -07:00
yulei d8f76f9e6d
Added missing shutdown_user() hook (#9180)
* add missing shutdown_user()

* use reset_keyboard() from quantum
2020-05-25 22:16:33 +10:00
Nick Brassel d1df576ece
Allow for overriding RAW endpoint usage page and ID. (#8834)
* Allow for overriding RAW endpoint usage page and ID.

* Move usb_descriptor_common.h.

* Docs update.
2020-05-21 20:31:42 +10:00
Joel Challis b0c780ed32
Fix ChibiOS FPU build logic (#9132) 2020-05-20 16:28:39 +01:00
Drashna Jaelre ef5fad137b
Disable Mousekey Command interface when Constant speed is enabled (#7017) 2020-05-19 07:29:20 -04:00
Erovia 6b54f3ce1c CLI: Tune doctor's udev rule checking to match #8750 2020-05-15 12:59:46 -07:00
yiancar 632285c982
V-USB Interface reorder (#9090) 2020-05-14 10:24:18 +10:00
Zsolt Parragi 805f5cb72b
One shot support for swap hands (#8590)
This commits add the SH_OS keycode, which works similarly to one shot
layers:
* while pressed, the keyboard is swapped
* if no keys were pressed while it was pressed, the next key press is
swapped

SH_OS also supports chaining with one shot layers:
OSL(x) + SH_OS + key interprets the key press on the oneshot layer.

The ONESHOT_TIMEOUT setting used by one shot keys and layers is also
used by oneshot swap hands. In the above chaining scenario the timeout
of the oneshot layer is reset when swap hands is activated.

Resolves #2682
2020-05-14 07:36:55 +10:00
Alex Ong 361ac2f32a
Optimization for scanning less layers. (#8311)
* Optimization for scanning less layers.

* Rename NUM_LAYERS to MAX_LAYER.
2020-05-11 01:04:38 +01:00
Zach White 640d12d070
Improve security of avrdude by eliminating the use of well-known names. (#9026)
* Improve security by eliminating the use of well-known names.

* Add an additional $ so the shell expands $TMP1 and $TMP2

Co-authored-by: Joel Challis <git@zvecr.com>

Co-authored-by: Joel Challis <git@zvecr.com>
2020-05-10 04:08:13 +01:00
Joel Challis adda5d7770
Revert "Use nano specs (#8270)" (#9044)
This reverts commit c775104b9f.
2020-05-08 14:51:00 +01:00
Ryan d646cba72a
Remove Bluefruit protocol (#9008)
* Remove Bluefruit protocol

* Remove dir from doxygen TODO pile
2020-05-04 23:05:45 +01:00
skullY 6f30b402a2 Revert "Fix conflicting types for 'tfp_printf' (#8269)"
This reverts commit e17b55e33a.
2020-05-04 09:25:44 -07:00
QMK Bot 1ff526dac0 format code according to conventions [skip ci] 2020-05-04 06:59:44 +00:00
Joel Challis e17b55e33a
Fix conflicting types for 'tfp_printf' (#8269)
* Refactor to use mpaland/printf

* trim firmware size

* remove keymap changes

* run clang format

* Fixup after rebase

* fix up git-submodule command for printf
2020-05-03 23:19:51 -07:00
Joel Challis 5f82b0782f
Initial vusb console support (#8559) 2020-05-03 01:25:39 +01:00
Joshua Moses Diamond 2e6959ed87
Add some usages needed for ChromeOS hosts (#8996) 2020-05-03 10:24:11 +10:00
Joel Challis c482a2944b
Provide a mechanism for split keyboards to process key press on both halves (#9001) 2020-05-03 00:39:37 +01:00
zvecr 406dc2fb2d Move encoder_read to common location 2020-05-02 22:44:36 +01:00
Joel Challis 374525c995
Allow some usbconfig.h overrides at the keyboard level (#8647) 2020-04-29 00:17:54 +01:00
Ryan 99f7fe6bd4
Clean up ATSAM ifdefs (#8808) 2020-04-20 15:38:34 -07:00
Chris Ko 9b70e53508
[Docs] Fixed minor typos (#8860) 2020-04-19 23:04:26 +01:00
Ryan bc13dcd349
Remove Atmel FLIP from install scripts and documentation (#8822) 2020-04-17 09:50:58 +02:00
Nick Brassel 46e4493761
Fix AVR SPI parameter configuration, remove timeouts due to sync protocol. (#8775) 2020-04-13 17:09:50 +10:00
Nick Brassel 05e9ff6554
Add support for hardware and board initialisation overrides. (#8330)
* Add support for hardware and board initialisation overrides.

* qmk cformat.

* Add some documentation.

* Docs clarity.

* Make early_hardware_init_pre a no-op for now, until migrations occur.

* Doco update

* Make distinction between keyboard and ChibiOS board in docs

* Doc anchors.

* Update tmk_core/protocol/chibios/main.c

Co-Authored-By: Joel Challis <git@zvecr.com>

* Rework bootloader entry to be off by default, allow opting-in.

Co-authored-by: Joel Challis <git@zvecr.com>
2020-04-13 09:39:38 +10:00
Konstantin Đorđević 370577e4ed
Add *OPT aliases for *ALT keycodes and macros (#8714) 2020-04-12 11:37:55 -07:00
Drashna Jaelre 23124b9fd1
Fix bug with layer caching in get_event_keycode (#8693)
* Fix bug with layer caching in get_event_keycode

* Improve naming
2020-04-12 17:27:17 +02:00
QMK Bot cc38627816 format code according to conventions [skip ci] 2020-04-11 00:48:16 +00:00
Purdea Andrei 6c2c3c13e9
Various fixes to how timer differences are calculated (#8585)
* tmk_core/common: Fixing TIMER_DIFF macro to calculate difference correctly after the timer wraps.

Let's go through an example, using the following macro:

If the first timer read is 0xe4 and the second one is 0x32, the timer wrapped.
If the timer would have had more bits, it's new value would have been 0x132,
and the correct difference in time is 0x132 - 0xe4 = 0x4e

old code TIMER_DIFF_8(0x32, 0xe4) = 0xff - 0xe4 + 0x32 = 0x4d, which is wrong.
new code TIMER_DIFF_8(0x32, 0xe4) = 0xff + 1 - 0xe4 + 0x32 = 0x4e, which is correct.

This also gives a chance for a smart compiler to optimize the code using normal
integer overflow.

For example on AVR, the following C code:
uint8_t __attribute__ ((noinline)) test(uint8_t current_timer, uint8_t start_timer)
{
    return TIMER_DIFF_8(current_timer, start_timer);
}
With the original code, it gets translated to the following list of instructions:
00004c6e <test>:
    4c6e:       98 2f           mov     r25, r24
    4c70:       86 1b           sub     r24, r22
    4c72:       96 17           cp      r25, r22
    4c74:       08 f4           brcc    .+2             ; 0x4c78 <test+0xa>
    4c76:       81 50           subi    r24, 0x01       ; 1
    4c78:       08 95           ret
But with this commit, it gets translated to a single instruction:
00004c40 <test>:
    4c40:       86 1b           sub     r24, r22
    4c42:       08 95           ret

This unfortunately doesn't always work so nicely, for example the following C code:
int __attribute__ ((noinline)) test(uint8_t current_timer, uint8_t start_timer)
{
    return TIMER_DIFF_8(current_timer, start_timer);
}
(Note: return type changed to int)
With the original code it gets translated to:
00004c6e <test>:
    4c6e:       28 2f           mov     r18, r24
    4c70:       30 e0           ldi     r19, 0x00       ; 0
    4c72:       46 2f           mov     r20, r22
    4c74:       50 e0           ldi     r21, 0x00       ; 0
    4c76:       86 17           cp      r24, r22
    4c78:       20 f0           brcs    .+8             ; 0x4c82 <test+0x14>
    4c7a:       c9 01           movw    r24, r18
    4c7c:       84 1b           sub     r24, r20
    4c7e:       95 0b           sbc     r25, r21
    4c80:       08 95           ret
    4c82:       c9 01           movw    r24, r18
    4c84:       84 1b           sub     r24, r20
    4c86:       95 0b           sbc     r25, r21
    4c88:       81 50           subi    r24, 0x01       ; 1
    4c8a:       9f 4f           sbci    r25, 0xFF       ; 255
    4c8c:       08 95           ret
Wth this commit it gets translated to:
00004c40 <test>:
    4c40:       28 2f           mov     r18, r24
    4c42:       30 e0           ldi     r19, 0x00       ; 0
    4c44:       46 2f           mov     r20, r22
    4c46:       50 e0           ldi     r21, 0x00       ; 0
    4c48:       86 17           cp      r24, r22
    4c4a:       20 f0           brcs    .+8             ; 0x4c54 <test+0x14>
    4c4c:       c9 01           movw    r24, r18
    4c4e:       84 1b           sub     r24, r20
    4c50:       95 0b           sbc     r25, r21
    4c52:       08 95           ret
    4c54:       c9 01           movw    r24, r18
    4c56:       84 1b           sub     r24, r20
    4c58:       95 0b           sbc     r25, r21
    4c5a:       93 95           inc     r25
    4c5c:       08 95           ret
There is not much performance improvement in this case, however at least with this
commit it functions correctly.

Note: The following commit will improve compiler output for the latter example.

* tmk_core/common: Improve code generation for TIMER_DIFF* macros

Because of integer promotion the compiler is having a hard time generating
efficient code to calculate TIMER_DIFF* macros in some situations.
In the below example, the return value is "int", and this is causing the
trouble.

Example C code:

int __attribute__ ((noinline)) test(uint8_t current_timer, uint8_t start_timer)
{
    return TIMER_DIFF_8(current_timer, start_timer);
}

BEFORE: (with -Os)

00004c40 <test>:
    4c40:       28 2f           mov     r18, r24
    4c42:       30 e0           ldi     r19, 0x00       ; 0
    4c44:       46 2f           mov     r20, r22
    4c46:       50 e0           ldi     r21, 0x00       ; 0
    4c48:       86 17           cp      r24, r22
    4c4a:       20 f0           brcs    .+8             ; 0x4c54 <test+0x14>
    4c4c:       c9 01           movw    r24, r18
    4c4e:       84 1b           sub     r24, r20
    4c50:       95 0b           sbc     r25, r21
    4c52:       08 95           ret
    4c54:       c9 01           movw    r24, r18
    4c56:       84 1b           sub     r24, r20
    4c58:       95 0b           sbc     r25, r21
    4c5a:       93 95           inc     r25
    4c5c:       08 95           ret

AFTER: (with -Os)

00004c40 <test>:
    4c40:       86 1b           sub     r24, r22
    4c42:       90 e0           ldi     r25, 0x00       ; 0
    4c44:       08 95           ret

Note: the example is showing -Os but improvements can be seen at all optimization levels,
including -O0. We never use -O0, but I tested it to make sure that no extra code is
generated in that case.OA

* quantum/debounce: Fix custom wrapping timers in eager_pr and eager_pk debounce algorithms

Please see the below simulated sequence of events:
Column A is the 16-bit value returned by read_timer();
Column B is the value returned by custom_wrap_timer_read();
Column C is the original code: (timer_read() % MAX_DEBOUNCE)

    A,     B,     C
65530,    19,    30
65531,    20,    31
65532,    21,    32
65533,    22,    33
65534,    23,    34
65535,    24,    35
    0     25,     0
    1,    26,     1
    2,    27,     2
    3,    28,     3
    4,    29,     4
    5,    30,     5

read_timer() wraps about every 1.09 seconds, and so debouncing might
fail at these times without this commit.

* quantum/debounce/eager_pr and eager_pk: modifications for code readability according to code review.

* quantum/debounce/eager_pr and eager_pk: modifications for code readability according to code review. (2)
2020-04-11 10:14:28 +10:00
Manna Harbour 07c75feba3
Add PS2_MOUSE_ROTATE to compensate for device orientation (#8650)
* Add PS2_MOUSE_ROTATE to compensate for device orientation

* fixup! Add PS2_MOUSE_ROTATE to compensate for device orientation

* Reformat with IndentPPDirectives: AfterHash as per #6316
2020-04-09 01:29:27 -07:00
Konstantin Đorđević be2f5816b6
Fix compile issues related to NO_ACTION_MACRO/FUNCTION and LTO_ENABLE (#8663)
* Define NO_ACTION_MACRO/FUNCTION in header instead of makefile when LTO is enabled

Currently, boards and keymaps that define NO_ACTION_MACRO/FUNCTION unconditionally
will not compile with LTO_ENABLE (#8604). This fixes the issue by moving the
definitions from common.mk to action.h, which enables us to check for previous
definitions of those macros (this cannot be done in a makefile).

* Remove LTO checks in templates

Since now NO_ACTION_MACRO/FUNCTION are defined as needed in action.h (which is
included by quantum.h), checking for LTO in keyboard and user code is no
longer required.

* Update LTO_ENABLE docs
2020-04-09 00:18:30 +01:00
Ryan 400ca2d035
spi_master for AVR (#8299)
* Change _delay_ms/us() to wait_ms/us()

* Switch to platform-agnostic GPIO macros

* Add AVR spi_master and migrate Adafruit BLE code

* Set verbose back to false

* Add clock divisor, bit order and SPI mode configuration for init

* Add start and stop functions

* Move configuration of mode, endianness and speed to `spi_start()`

* Some breaks here would be good

* Default Adafruit BLE clock divisor to 4 (2MHz on the Feather 32U4)

* Remove mode and divisor enums

* Add some docs

* No hr at EOF

* Add links in sidebar
2020-04-08 11:04:31 +10:00
QMK Bot 7642075fc3 format code according to conventions [skip ci] 2020-04-05 22:57:28 +00:00
Ryan ca91dc594b
V-USB: Remove some stuff from usbconfig.h that should not be configurable (#8656)
* V-USB: Remove some stuff from usbconfig.h that should not be configurable

* Clean up some ifdefs

* And some more

* Even more
2020-04-05 23:25:07 +01:00
Drashna Jaelre 845953cc67
V-USB remote wakeup (#7627)
* V-USB remote wakeup

Backport from tmk/tmk_keyboard@391c979be7

* Change vusb.c remote wake config

as per fauxpark's suggestion
2020-04-05 18:18:19 +10:00
QMK Bot 59188bf29d format code according to conventions [skip ci] 2020-04-02 21:59:37 +00:00
Joel Challis 9c4bf0ac4a
Initial support for ATtiny85 (#8632)
* Initial support for ATtiny85

* Update mcu selection
2020-04-02 22:23:57 +01:00
Ryan 2b427f774a
Fix `pgm_read_ptr()` define for ARM (#8658) 2020-04-02 16:52:16 +01:00
Joel Challis 58a9c84d6b
Strip out features to allow minimum firmware sizes (#8645) 2020-04-01 21:06:22 +01:00
yiancar c217186bea
Updated V-USB template to allow usbFunctionWriteOut (#8634) 2020-04-01 17:11:24 +01:00
Ryan 95c5c11d0b
Miscellaneous cleanups (#8639)
* Miscellaneous cleanups

* Cast NO_PIN
2020-04-01 15:49:45 +01:00
Joel Challis b6a09502c6
Migrate :program logic to :flash (#8631) 2020-04-01 13:27:16 +01:00
Ryan 51a81813b0
V-USB: Consolidate usbconfig.h's into a single file (#8584) 2020-03-31 13:17:04 +01:00
Takuya Urakawa 89a675d57c
add hid_raw feature to VUSB (#8380)
* rewrite usbhid feature on vusb

* Apply suggestions from code review

Co-Authored-By: Ryan <fauxpark@gmail.com>

* fix typo

* fix typo again

* Update tmk_core/protocol/vusb/vusb.c

Co-Authored-By: Ryan <fauxpark@gmail.com>

* clean up defines

Co-authored-by: Ryan <fauxpark@gmail.com>
2020-03-30 21:15:05 +01:00
Casper Weiss Bang 13fff52f6b
fixed problem with implicit declaration in quantum/rgblight.c (#8406)
* Update tmk_core/common/progmem.h

Co-Authored-By: Ryan <fauxpark@gmail.com>

* Update quantum/rgblight.c

Co-Authored-By: Ryan <fauxpark@gmail.com>

* fixed problem with implicit declaration in quantum/rgblight.c (#8381)

Co-authored-by: Ryan <fauxpark@gmail.com>
2020-03-28 23:35:11 +00:00
Ryan 14079ce698
V-USB: Use structs for USB descriptors (#8572)
* V-USB: Use structs for USB descriptors

* Update usbconfigs

* cformat pass
2020-03-28 13:02:25 +11:00
Joel Challis 23e942ae4e
Enable SLEEP_LED on ATmega32A (#8531)
* Port over some AVR backlight logic to SLEEP_LED

* Port over some AVR backlight logic to SLEEP_LED - add timer 3

* Port over some AVR backlight logic to SLEEP_LED - clang format

* Enable SLEEP_LED within vusb protocol
2020-03-26 18:21:33 +00:00
Ryan 4d76d85d7b
V-USB: Use manufacturer and product strings from config.h (#7797)
* V-USB: Use manufacturer and product strings from config.h

* Update board configs
2020-03-26 13:11:32 +00:00
QMK Bot 9fbf17b90e format code according to conventions [skip ci] 2020-03-26 03:10:16 +00:00
foxx1337 96bfce7000
Add RawHID support to ATSAM (Massdrop boards) (#8530)
* Add support for RAW endpoint for arm_atsam

This the excellent work from helluvamatt/qmk_firmware in bb6eeb93b.

* Reformat arm_atsam RAW endpoint code

Co-authored-by: Matt Schneeberger <helluvamatt@gmail.com>
2020-03-26 02:34:57 +00:00
Joel Challis 6ceaae30f5
Run clang-format manually to fix recently changed files (#8552) 2020-03-25 14:39:53 +11:00
Drashna Jaelre 5117dff6a2
Add Post Processing to process_record (#4892)
* Improve process_record system

Code based on @colinta's

* Rename and better handle functions

* Fix incorrect function call to process_record_user

* Add documentation for post_process_record

* Add both get_event_keycode and get_record_keycode functions

And add some comments about these functions

* Update code format

* Cleanup merge artifacts
2020-03-23 00:29:05 +11:00
Joel Challis d8f3c28a37
Align some ChibiOS build logic (#8461)
* Align some ChibiOS build logic

* infer more makefile logic

* Move bootloader logic to chibios file
2020-03-22 20:48:17 +11:00
QMK Bot d511e52c1f format code according to conventions [skip ci] 2020-03-21 23:44:27 +00:00
Joel Challis 789e199450
Add support for Bootmagic lite when using SPLIT_HAND_PIN (#8347)
* Add support for Bootmagic lite when using SPLIT_HAND_PIN

* Deduplicate bootmagic_lite logic from within via

* Revert location of defaults so that user overrides still work for now

* Tidy up code slightly
2020-03-21 23:10:39 +00:00
Ryan f4799481cd
Fix formatting for report.h (#8512) 2020-03-22 06:19:01 +11:00
QMK Bot f9c53ca71a format code according to conventions [skip ci] 2020-03-21 12:58:19 +00:00
Joel Challis d96380e654
Initial arm->chibios pass - simplify some platform logic (#8450) 2020-03-21 16:20:04 +11:00
Ryan 7e80686f1e
Tidy up report.h (#8486)
* Tidy up report.h

* Add link to Review Request 41 for brightness controls
2020-03-21 16:19:15 +11:00
Ryan e967471c4f
Remove ACT_COMMAND (#8487)
* Remove ACT_COMMAND

* And from action_t as well
2020-03-21 16:17:43 +11:00
Joel Challis e34764502f
Remove qmk archive generation (#8462) 2020-03-17 21:28:13 +00:00
QMK Bot c89012566c format code according to conventions [skip ci] 2020-03-16 10:01:22 +00:00
Takeshi ISHII 9dfebb9d67
Remove unnecessary import of rgblight.h in tmk_core/protocol/*/*.c (#8432)
* Remove unnecessary import of rgblight.h in tmk_core/protocol/*/*.c

 * tmk_core/protocol/chibios/main.c
 * tmk_core/protocol/lufa/lufa.c

see #8380 for tmk_core/protocol/vusb/main.c.

* Remove '#include "rgblight.h"' from tmk_core/protocol/vusb/main.c.
2020-03-16 10:26:32 +01:00
QMK Bot 5e98eaaaff format code according to conventions [skip ci] 2020-03-13 18:44:56 +00:00