1
0
Fork 0

qmk cformat

This commit is contained in:
Nick Brassel 2021-01-18 05:12:15 +11:00 committed by Zach White
parent e702c7f1b4
commit 31c57aab35
9 changed files with 136 additions and 113 deletions

View file

@ -134,9 +134,7 @@ static uint8_t move_unit(void) {
speed = mousekey_accel & (1 << 2) ? mk_accelerated_speed : mk_decelerated_speed;
} else if (mousekey_repeat && mouse_timer) {
const float time_elapsed = timer_elapsed(mouse_timer) / 50;
speed = mk_initial_speed +
MOUSEKEY_MOVE_DELTA * time_elapsed +
MOUSEKEY_MOVE_DELTA * 0.5 * time_elapsed * time_elapsed;
speed = mk_initial_speed + MOUSEKEY_MOVE_DELTA * time_elapsed + MOUSEKEY_MOVE_DELTA * 0.5 * time_elapsed * time_elapsed;
speed = speed > mk_base_speed ? mk_base_speed : speed;
}
@ -158,9 +156,7 @@ static uint8_t wheel_unit(void) {
} else if (mousekey_repeat && mouse_timer) {
if (mk_wheel_interval != MOUSEKEY_WHEEL_BASE_MOVEMENTS) {
const float time_elapsed = timer_elapsed(mouse_timer) / 50;
speed = MOUSEKEY_WHEEL_INITIAL_MOVEMENTS +
1 * time_elapsed +
1 * 0.5 * time_elapsed * time_elapsed;
speed = MOUSEKEY_WHEEL_INITIAL_MOVEMENTS + 1 * time_elapsed + 1 * 0.5 * time_elapsed * time_elapsed;
}
speed = speed > MOUSEKEY_WHEEL_BASE_MOVEMENTS ? MOUSEKEY_WHEEL_BASE_MOVEMENTS : speed;
}

View file

@ -15,44 +15,71 @@ extern "C" {
# define CLOCK_DELAY_NOP8 "nop\n\t nop\n\t nop\n\t nop\n\t nop\n\t nop\n\t nop\n\t nop\n\t"
__attribute__((always_inline))
static inline void wait_cpuclock_allnop(unsigned int n) { /* n: 1..135 */
__attribute__((always_inline)) static inline void wait_cpuclock_allnop(unsigned int n) { /* n: 1..135 */
/* The argument n must be a constant expression.
* That way, compiler optimization will remove unnecessary code. */
if (n < 1) { return; }
if (n < 1) {
return;
}
if (n > 8) {
unsigned int n8 = n / 8;
n = n - n8 * 8;
switch (n8) {
case 16: asm volatile (CLOCK_DELAY_NOP8::: "memory");
case 15: asm volatile (CLOCK_DELAY_NOP8::: "memory");
case 14: asm volatile (CLOCK_DELAY_NOP8::: "memory");
case 13: asm volatile (CLOCK_DELAY_NOP8::: "memory");
case 12: asm volatile (CLOCK_DELAY_NOP8::: "memory");
case 11: asm volatile (CLOCK_DELAY_NOP8::: "memory");
case 10: asm volatile (CLOCK_DELAY_NOP8::: "memory");
case 9: asm volatile (CLOCK_DELAY_NOP8::: "memory");
case 8: asm volatile (CLOCK_DELAY_NOP8::: "memory");
case 7: asm volatile (CLOCK_DELAY_NOP8::: "memory");
case 6: asm volatile (CLOCK_DELAY_NOP8::: "memory");
case 5: asm volatile (CLOCK_DELAY_NOP8::: "memory");
case 4: asm volatile (CLOCK_DELAY_NOP8::: "memory");
case 3: asm volatile (CLOCK_DELAY_NOP8::: "memory");
case 2: asm volatile (CLOCK_DELAY_NOP8::: "memory");
case 1: asm volatile (CLOCK_DELAY_NOP8::: "memory");
case 0: break;
case 16:
asm volatile(CLOCK_DELAY_NOP8::: "memory");
case 15:
asm volatile(CLOCK_DELAY_NOP8::: "memory");
case 14:
asm volatile(CLOCK_DELAY_NOP8::: "memory");
case 13:
asm volatile(CLOCK_DELAY_NOP8::: "memory");
case 12:
asm volatile(CLOCK_DELAY_NOP8::: "memory");
case 11:
asm volatile(CLOCK_DELAY_NOP8::: "memory");
case 10:
asm volatile(CLOCK_DELAY_NOP8::: "memory");
case 9:
asm volatile(CLOCK_DELAY_NOP8::: "memory");
case 8:
asm volatile(CLOCK_DELAY_NOP8::: "memory");
case 7:
asm volatile(CLOCK_DELAY_NOP8::: "memory");
case 6:
asm volatile(CLOCK_DELAY_NOP8::: "memory");
case 5:
asm volatile(CLOCK_DELAY_NOP8::: "memory");
case 4:
asm volatile(CLOCK_DELAY_NOP8::: "memory");
case 3:
asm volatile(CLOCK_DELAY_NOP8::: "memory");
case 2:
asm volatile(CLOCK_DELAY_NOP8::: "memory");
case 1:
asm volatile(CLOCK_DELAY_NOP8::: "memory");
case 0:
break;
}
}
switch (n) {
case 8: asm volatile ("nop"::: "memory");
case 7: asm volatile ("nop"::: "memory");
case 6: asm volatile ("nop"::: "memory");
case 5: asm volatile ("nop"::: "memory");
case 4: asm volatile ("nop"::: "memory");
case 3: asm volatile ("nop"::: "memory");
case 2: asm volatile ("nop"::: "memory");
case 1: asm volatile ("nop"::: "memory");
case 0: break;
case 8:
asm volatile("nop" ::: "memory");
case 7:
asm volatile("nop" ::: "memory");
case 6:
asm volatile("nop" ::: "memory");
case 5:
asm volatile("nop" ::: "memory");
case 4:
asm volatile("nop" ::: "memory");
case 3:
asm volatile("nop" ::: "memory");
case 2:
asm volatile("nop" ::: "memory");
case 1:
asm volatile("nop" ::: "memory");
case 0:
break;
}
}
#endif