cleanup phase accumulator approach

This commit is contained in:
2026-01-18 17:35:44 +01:00
parent 7d1f661cf1
commit f2c94e77de

View File

@@ -41,6 +41,9 @@ MODULE_LICENSE("GPL");
#define G29_BTN_R1 0x00000100u #define G29_BTN_R1 0x00000100u
#define G29_BTN_L1 0x00000200u #define G29_BTN_L1 0x00000200u
#define WHEEL_CENTER 32768
#define WHEEL_MAX_DIST 32768
enum g29_mode { enum g29_mode {
G29_MODE_MEDIA = 0, G29_MODE_MEDIA = 0,
}; };
@@ -100,15 +103,13 @@ struct g29_dev {
struct g29_state last; struct g29_state last;
}; };
#define WHEEL_CENTER 32768
#define WHEEL_MAX_DIST 32768
static void g29_steer_timer_fn(struct timer_list *t) { static void g29_steer_timer_fn(struct timer_list *t) {
struct g29_dev *g29 = timer_container_of(g29, t, steer_timer); struct g29_dev *g29 = timer_container_of(g29, t, steer_timer);
const int rot = le16_to_cpu(g29->last.rot_le); const int rot = le16_to_cpu(g29->last.rot_le);
int distance_from_center = abs(rot - WHEEL_CENTER); int distance_from_center = abs(rot - WHEEL_CENTER);
int target_key = (rot < WHEEL_CENTER) ? KEY_A : KEY_D;
bool press_key; bool press_key;
/* Phase accumulator approach: /* Phase accumulator approach: