Skip to content

Commit

Permalink
fix: Build without ZMK_TRACKPAD enabled.
Browse files Browse the repository at this point in the history
  • Loading branch information
petejohanson committed Apr 7, 2024
1 parent e41fe73 commit 671e29e
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions app/src/mouse/input_listener.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,13 @@ struct input_listener_xy_data {
int16_t y;
};

#if IS_ENABLED(CONFIG_ZMK_TRACKPAD)
struct input_listener_ptp_finger {
int16_t x;
int16_t y;
bool active;
};
#endif // IS_ENABLED(CONFIG_ZMK_TRACKPAD)

struct input_listener_data {
union {
Expand All @@ -47,12 +49,14 @@ struct input_listener_data {
uint8_t button_clear;
} mouse;

#if IS_ENABLED(CONFIG_ZMK_TRACKPAD)
struct {
bool pending_data;
struct input_listener_xy_data data;
uint8_t finger_idx;
bool touched;
} ptp;
#endif // IS_ENABLED(CONFIG_ZMK_TRACKPAD)
};
};

Expand Down Expand Up @@ -93,6 +97,8 @@ static void handle_rel_code(struct input_listener_data *data, struct input_event
}
}

#if IS_ENABLED(CONFIG_ZMK_TRACKPAD)

static int send_ptp_finger_to_hid(struct input_listener_data *data) {
struct zmk_ptp_finger finger = {.contact_id = data->ptp.finger_idx};
finger.x = data->ptp.data.x;
Expand All @@ -109,9 +115,12 @@ static int send_ptp_finger_to_hid(struct input_listener_data *data) {
return err;
}

#endif // IS_ENABLED(CONFIG_ZMK_TRACKPAD)

static void handle_abs_code(const struct input_listener_config *config,
struct input_listener_data *data, struct input_event *evt) {
if (config->mode == INPUT_LISTENER_MODE_PTP) {
#if IS_ENABLED(CONFIG_ZMK_TRACKPAD)
switch (evt->code) {
case INPUT_ABS_MT_SLOT:
if (data->ptp.pending_data) {
Expand All @@ -134,6 +143,9 @@ static void handle_abs_code(const struct input_listener_config *config,
default:
break;
}
#else
LOG_ERR("ZMK_TRACKPAD not enabled");
#endif // IS_ENABLED(CONFIG_ZMK_TRACKPAD)
}
}

Expand All @@ -155,10 +167,12 @@ static void handle_key_code(const struct input_listener_config *config,
WRITE_BIT(data->mouse.button_clear, btn, 1);
}
break;
#if IS_ENABLED(CONFIG_ZMK_TRACKPAD)
case INPUT_BTN_TOUCH:
if (config->mode == INPUT_LISTENER_MODE_PTP) {
data->ptp.touched = evt->value > 0;
}
#endif // IS_ENABLED(CONFIG_ZMK_TRACKPAD)
default:
break;
}
Expand Down

0 comments on commit 671e29e

Please sign in to comment.