#include "input_filter.h"

void input_filter_init(input_filter_t *filter, float alpha) {
    if (filter) {
        filter->alpha = alpha;
        filter->value = 0.0f;
        filter->initialized = 0;
    }
}

float input_filter_update(input_filter_t *filter, float input) {
    if (!filter) return input;

    if (!filter->initialized) {
        filter->value = input;
        filter->initialized = 1;
    } else {
        filter->value = filter->alpha * input + (1.0f - filter->alpha) * filter->value;
    }

    return filter->value;
}
