mirror of
https://github.com/portapack-mayhem/mayhem-firmware.git
synced 2024-12-14 12:08:40 +00:00
Merge pull request #945 from bernd-herzog/touchscreen_multiinput_fix
fixed touch handling issue causing multiple inputs
This commit is contained in:
commit
91675e26cb
@ -81,16 +81,21 @@ void Manager::feed(const Frame& frame) {
|
|||||||
const auto touch_raw = frame.touch;
|
const auto touch_raw = frame.touch;
|
||||||
//const auto touch_stable = touch_debounce.state();
|
//const auto touch_stable = touch_debounce.state();
|
||||||
const auto touch_stable = frame.touch;
|
const auto touch_stable = frame.touch;
|
||||||
bool touch_pressure = false;
|
bool touch_down_pressure = false;
|
||||||
|
bool touch_up_pressure = false;
|
||||||
|
|
||||||
// Only feed coordinate averaging if there's a touch.
|
// Only feed coordinate averaging if there's a touch.
|
||||||
// TODO: Separate threshold to gate coordinates for filtering?
|
// TODO: Separate threshold to gate coordinates for filtering?
|
||||||
if( touch_raw ) {
|
if( touch_raw ) {
|
||||||
const auto metrics = calculate_metrics(frame);
|
const auto metrics = calculate_metrics(frame);
|
||||||
|
|
||||||
// TODO: Add touch pressure hysteresis?
|
constexpr float r_touch_down_threshold = 3200.0f;
|
||||||
touch_pressure = (metrics.r < r_touch_threshold);
|
constexpr float r_touch_up_threshold = r_touch_down_threshold * 2.0f;
|
||||||
if( touch_pressure ) {
|
|
||||||
|
touch_down_pressure = (metrics.r < r_touch_down_threshold);
|
||||||
|
touch_up_pressure = (metrics.r < r_touch_up_threshold);
|
||||||
|
|
||||||
|
if( touch_down_pressure ) {
|
||||||
filter_x.feed(metrics.x * 1024);
|
filter_x.feed(metrics.x * 1024);
|
||||||
filter_y.feed(metrics.y * 1024);
|
filter_y.feed(metrics.y * 1024);
|
||||||
}
|
}
|
||||||
@ -101,7 +106,7 @@ void Manager::feed(const Frame& frame) {
|
|||||||
|
|
||||||
switch(state) {
|
switch(state) {
|
||||||
case State::NoTouch:
|
case State::NoTouch:
|
||||||
if( touch_stable && touch_pressure && !persistent_memory::disable_touchscreen()) {
|
if( touch_stable && touch_down_pressure && !persistent_memory::disable_touchscreen()) {
|
||||||
if( point_stable() ) {
|
if( point_stable() ) {
|
||||||
state = State::TouchDetected;
|
state = State::TouchDetected;
|
||||||
touch_started();
|
touch_started();
|
||||||
@ -110,7 +115,7 @@ void Manager::feed(const Frame& frame) {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case State::TouchDetected:
|
case State::TouchDetected:
|
||||||
if( touch_stable && touch_pressure ) {
|
if( touch_stable && touch_up_pressure ) {
|
||||||
touch_moved();
|
touch_moved();
|
||||||
} else {
|
} else {
|
||||||
state = State::NoTouch;
|
state = State::NoTouch;
|
||||||
|
@ -219,7 +219,6 @@ private:
|
|||||||
TouchDetected,
|
TouchDetected,
|
||||||
};
|
};
|
||||||
|
|
||||||
static constexpr float r_touch_threshold = 640;
|
|
||||||
static constexpr size_t touch_count_threshold { 3 };
|
static constexpr size_t touch_count_threshold { 3 };
|
||||||
static constexpr uint32_t touch_stable_bound { 8 };
|
static constexpr uint32_t touch_stable_bound { 8 };
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user