Files
gotta-scroll-fast/driver/speed.h
T
thomas 5f1254d11a
Tests / test_core_function (push) Failing after 12s
import upstream maccel baseline
2026-03-25 09:32:22 +00:00

35 lines
740 B
C

#ifndef __SPEED_H__
#define __SPEED_H__
#include "dbg.h"
#include "fixedptc.h"
#include "math.h"
/**
* Track this to enable the UI to show the last noted
* input counts/ms (speed).
*/
static fpt LAST_INPUT_MOUSE_SPEED = 0;
static inline fpt input_speed(fpt dx, fpt dy, fpt time_ms) {
fpt distance = magnitude((struct vector){dx, dy});
if (distance == -1) {
dbg("distance calculation failed: t = %s", fptoa(time_ms));
return 0;
}
dbg("distance (in) %s", fptoa(distance));
fpt speed = fpt_div(distance, time_ms);
LAST_INPUT_MOUSE_SPEED = speed;
dbg("time interval %s", fptoa(time_ms));
dbg("speed (in) %s", fptoa(speed));
return speed;
}
#endif // !__SPEED_H__