rg_input: Made filter code match PR#180 again
Filter is now always enabled. If a device wants to opt out they should set it to >4096, or INT_MAX.
This commit is contained in:
parent
4136437c9d
commit
c65932fa8f
@ -128,9 +128,9 @@
|
||||
#ifndef RG_GAMEPAD_DEBOUNCE_RELEASE
|
||||
#define RG_GAMEPAD_DEBOUNCE_RELEASE (2)
|
||||
#endif
|
||||
// Wait for ADC value to be stable before registering it
|
||||
// Wait for ADC value to be stable before registering it (values of 50 - 250 are typically good)
|
||||
#ifndef RG_GAMEPAD_ADC_FILTER_WINDOW
|
||||
// #define RG_GAMEPAD_ADC_FILTER_WINDOW (150)
|
||||
#define RG_GAMEPAD_ADC_FILTER_WINDOW (150)
|
||||
#endif
|
||||
|
||||
#ifndef RG_LOG_COLORS
|
||||
|
||||
@ -115,14 +115,12 @@ bool rg_input_read_gamepad_raw(uint32_t *out)
|
||||
int value = adc_get_raw(mapping->unit, mapping->channel);
|
||||
if (value >= mapping->min && value <= mapping->max)
|
||||
{
|
||||
#ifdef RG_GAMEPAD_ADC_FILTER_WINDOW
|
||||
if (abs(old_adc_values[i] - value) < RG_GAMEPAD_ADC_FILTER_WINDOW)
|
||||
state |= mapping->key;
|
||||
#else
|
||||
state |= mapping->key;
|
||||
#endif
|
||||
// else
|
||||
// RG_LOGD("Rejected input: %d", old_adc_values[i] - value);
|
||||
old_adc_values[i] = value;
|
||||
}
|
||||
old_adc_values[i] = value;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user