Commit graph

126 commits

Author SHA1 Message Date
tmk
06d354c06b core: Fix is_tap_key() #673
System and media control keys work well with
ACTION_MODS_TAP_KEY and ACTION_LAYER_TAP_KEY now.
2021-02-08 16:28:59 +09:00
tmk
1460fbcf1c core: Update comments in keycode.h 2021-01-24 15:44:03 +09:00
tmk
02664fe72a core: Fix TAP_KEY(CapsLock) for MacOS #659 2020-11-07 17:18:18 +09:00
tmk
ab083c7ecf core: Clean up code of Locking key support 2020-11-07 17:17:13 +09:00
tmk
6271878a02 vusb: Fix keyboard_protocol and keyboard_idle #547 2020-07-27 10:02:38 +09:00
tmk
5c45beb89e core: Fix matrix_print() 2020-06-02 00:57:37 +09:00
tmk
3208b7e447 core: Add default impl for led_set() 2020-05-30 15:20:05 +09:00
tmk
0ab0ebf8cb core: Make TIMER0 ISR noblock
The TIMER0 ISR takes 1.5us and can affect IBMPC protocol ISR.
Add ISR_NOBLOCK to allow interrupt during TIMER0 ISR.
2020-05-22 11:52:44 +09:00
tmk
dd316b990f core: Add HID usage for Display Brightness Control 2020-05-11 21:58:50 +09:00
Purdea Andrei
061e662345 tmk_core/common/timer.h: 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.
2020-04-01 07:46:18 +03:00
Purdea Andrei
338a1506dc tmk_core/common/timer.h: 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.
2020-04-01 07:45:05 +03:00
tmk
01477b7ef2 core: Fix unimap translation range 2020-02-03 12:47:01 +09:00
tmk
37a452f7c9 core: Fix bootloader for 128KB flash
Got warning on bootloader address calculation when MCU has 128KB flash
2019-12-04 15:09:36 +09:00
tmk
698c957cad core: Add short name for keycode KP_00 and KP_000 2019-11-12 15:38:31 +09:00
tmk
bc821b79d0 core: Remove unneeded code in bootloader_jump 2019-09-18 14:14:25 +09:00
tmk
83b90f4b6f core: Add AC_BTLD to actionmap and unimap
Now that it can jump to bootloader with AC_BTLD
2019-09-17 20:55:35 +09:00
tmk
c09600b56b core: Read bootloader size from AVR fuse bits
This makes defining BOOTLOADER_SIZE macro optional.
2019-09-17 16:19:52 +09:00
tmk
b3980122bb core: Fix comment and remove unused code 2019-09-16 18:43:38 +09:00
tmk
19350e3ee5 core: Add bootkey of Caterina bootloader
The bootkey set in bootloader_jump() works with Pro Micro and Leonardo.
This fix doesn't seem to prevent other bootloaders, however, it can be
disabled by defining NO_BOOTLOADER_CATERINA_BOOTKEY.
2019-09-16 17:49:38 +09:00
tmk
814eaa2dff core:adb_usb: Add Extended Mouse Protocol support #274
Also add Kensington Turbo Mouse 5 specific initialization
2019-06-23 15:04:35 +09:00
tmk
2b83b9a8f9 core: Add hook_process_action() 2019-05-29 23:57:51 +09:00
tmk
8449ad385b lufa: Print TMK version to console 2019-05-29 23:42:56 +09:00
tmk
f3e498590c core: Add hook_usb_startup_wait_loop 2019-05-29 14:50:56 +09:00
tmk
55443fabb7 core: Avoid deadlock when uart.c is used in ISR 2019-05-07 00:07:19 +09:00
tmk
c41e48a0ab core: Fix uart.c for ATmega32U4 2019-04-21 11:55:47 +09:00
rxy0424
8345571e1d make some change to complie stm32_f103_onekey with new version of Chibios (#583) 2018-11-07 08:08:08 +09:00
Konstantin Đorđević
a159172951 Fix header guard in tmk_core/common/command.h (#581) 2018-10-31 09:34:01 +09:00
tmk
6632802c79 core: Add ring buffer file 2018-09-23 12:36:18 +09:00
Øystein Bech Gadmar
9a9b8edfa9 core: Add utility macros in action_macro.h (#532) 2018-01-29 08:10:35 +09:00
tmk
d415e99f0c core: Add utility type_code() in aciton.h #528 2018-01-28 16:17:20 +09:00
alex-ong
f9e3bf7f38 core: Typo (mantrix -> matrix) 2018-01-26 16:53:27 +09:00
Alex Ong
ad6059adc7 core: Saved 60~ bytes (and possible performance) by storing col_mask when iterating through columns (#522) 2018-01-24 12:15:56 +09:00
alex-ong
8770269e1e core: Fix for un-defined function when compiling without MOUSEKEY_ENABLE 2018-01-22 14:50:38 +11:00
alex-ong
8c91a997b3 core: Fix for unused function when compiling without MOUSEKEY_ENABLE 2018-01-22 13:55:11 +11:00
tmk
01b881e87e core: Fix for warning of unused function standby() 2018-01-14 08:14:16 +09:00
tmk
8fd2cef441 core: Fix for warning of unused label. #515 2018-01-14 07:54:31 +09:00
tmk
df7ce59d1c core: Fix out-of-bounds access by TICK event #487
The error is caused in layer_swtich_get_action() and fails to access layer_pressed[][]
2017-10-22 03:43:04 +09:00
tmk
45f6e5cb97 core: Fix for build option NO_ACTION_LAYER 2017-09-14 12:58:06 +09:00
tmk
956f806644 core: Fix for ATtiny85 2017-09-14 12:56:35 +09:00
tmk
ba2883fd9a core: Fix for stuck key problem #441
- Idea form https://github.com/qmk/qmk_firmware/pull/182
- Define NO_TRACK_KEY_PRESS to get old behaviour
- This should resolve #105, #248, #397, #441 and FAQ entry: https://github.com/tmk/tmk_keyboard/wiki/FAQ-Keymap#modifierlayer-stuck
2017-05-30 15:25:26 +09:00
tmk
792074f49b core: Fix typo 2017-04-11 15:54:35 +09:00
tmk
a71a0ef9d5 core: Change MOD_* definition to make OR(|) usable
https://github.com/tmk/tmk_keyboard/issues/448#issuecomment-285066234
2017-04-11 15:50:19 +09:00
tmk
44fc56a869 core: Fix for missing key on fc660c 2017-04-11 04:36:38 +09:00
tmk
300628e5dc core: Add MOD_NONE to mods_bit enum 2017-02-03 08:54:17 +09:00
tmk
c0f0909051 core: Fix LAYER_MODS() and LAYER_TAP()
- LAYER_MODS() accepts either left or right modifiers
- LAYER_TAP() can use modifier as tap key, related to #422
2017-01-11 10:30:47 +09:00
tmk
be80ed2ef3 core: Cancel removing IS_ANY() at c98e89f
IS_ANY() is used in usb_usb
2017-01-05 21:17:29 +09:00
tmk
c98e89f2d5 core: Modifiers can be used as tap key Fix #422 2017-01-04 12:51:13 +09:00
tmk
74019c8e41 Merge commit '22b6e15a179031afb7c3534cf7b109b0668b602c' 2016-12-10 10:29:51 +09:00
tmk
a88ad58342 core: Swap position of PEQL and PENT in unimap 2016-11-30 00:15:12 +09:00
Aldo Gunsing
54a1934607 core: Fix typo in definition AC_g 2016-11-14 23:30:06 +01:00