#ifndef DRILL_CLICK_H
#define DRILL_CLICK_H
#include <stdint.h>
#include <stdbool.h>
typedef enum { DC_NONE, DC_TOGGLE_RUN_REQUEST, DC_REVERSE_REQUEST, DC_MODE_REQUEST, DC_REJECTED } dc_command;
typedef enum { DC_MAIN_KEY, DC_HANDPIECE_KEY } dc_source;
typedef struct { uint32_t last_ms; uint8_t count; bool pending; } dc_channel;
typedef struct { uint32_t window_ms; dc_channel channel[2]; } dc_decoder;
/* Input must be debounced RELEASE edges. Window is an engineering choice,
   not specified by the vendor manual. No GPIO, PWM or motor enable here. */
bool dclick_init(dc_decoder *d, uint32_t window_ms);
/* Caller must drain dclick_poll for BOTH sources before admitting a new edge.
   A late edge returns false without discarding the pending command. */
bool dclick_release(dc_decoder *d, dc_source source, uint32_t now_ms);
dc_command dclick_poll(dc_decoder *d, dc_source source, uint32_t now_ms);
void dclick_cancel(dc_decoder *d);
#endif
