Skip to content

Commit 1bf28f5

Browse files
authored
Merge pull request #186 from AndyGozas/bundle-partial-dft-updates
Implement DFT partial update bundling
2 parents a1f02fc + bea7f97 commit 1bf28f5

File tree

5 files changed

+23
-3
lines changed

5 files changed

+23
-3
lines changed

etc/iptsd.conf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,3 +159,4 @@
159159
# PositionExp = -0.7
160160
# ButtonMinMag = 1000
161161
# FreqMinMag = 10000
162+
# AllowSplitEvents = false

src/core/generic/application.hpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -233,8 +233,15 @@ class Application {
233233
if (!m_info.is_touchscreen())
234234
return;
235235

236-
m_dft.input(data);
237-
this->process_stylus(m_dft.get_stylus());
236+
/* Since all DFT packets update only some of the stylus data, sending an
237+
* event each time a DFT packet arrives causes resending of some stale
238+
* info as though it is current. As a result, the same coordinates,
239+
* pressure, etc. are reported to the system several times. This confuses
240+
* the smoothing algorithms in some software (e.g. Krita), which is why
241+
* we hold off reporting new data to the system until ALL of it is updated.
242+
*/
243+
if (m_dft.input(data) || m_config.dft_allow_split_events)
244+
this->process_stylus(m_dft.get_stylus());
238245
}
239246

240247
/*!

src/core/generic/config.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ class Config {
6565
usize dft_mpp2_button_min_mag = 50000;
6666
usize dft_mpp2_contact_min_mag = 50000;
6767
f64 dft_tilt_distance = 0.6;
68+
bool dft_allow_split_events = false;
6869

6970
public:
7071
/*!

src/core/generic/dft.hpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,20 @@ class DftStylus {
5454
* Loads a DFT window and calculates stylus properties from it.
5555
*
5656
* @param[in] dft The dft window received from the IPTS hardware.
57+
* @return Whether an event should be emitted by this packet.
5758
*/
58-
void input(const ipts::samples::DftWindow &dft)
59+
bool input(const ipts::samples::DftWindow &dft)
5960
{
6061
switch (dft.type) {
6162
case ipts::protocol::dft::Type::Position:
6263
this->handle_position(dft);
64+
/* This event type is the most important one. It is the first and
65+
* the last one to arrive. It sets both proximity and lift. It is
66+
* also guaranteed to come regularly whenever we have (or just lost)
67+
* proximity. For all these reasons it MUST ALWAYS be let through
68+
* and it is chosen as THE synchronising event.
69+
*/
70+
return true;
6371
break;
6472
case ipts::protocol::dft::Type::Button:
6573
this->handle_button(dft);
@@ -77,6 +85,8 @@ class DftStylus {
7785
// Ignored
7886
break;
7987
}
88+
// Do not emit an event by default.
89+
return false;
8090
}
8191

8292
/*!

src/core/linux/config-loader.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,7 @@ class ConfigLoader {
188188
this->get(ini, "DFT", "TiltDistance", m_config.dft_tilt_distance);
189189
this->get(ini, "DFT", "Mpp2ContactMinMag", m_config.dft_mpp2_contact_min_mag);
190190
this->get(ini, "DFT", "Mpp2ButtonMinMag", m_config.dft_mpp2_button_min_mag);
191+
this->get(ini, "DFT", "AllowSplitEvents", m_config.dft_allow_split_events);
191192

192193
// Legacy options that are kept for compatibility
193194
this->get(ini, "DFT", "TipDistance", m_config.stylus_tip_distance);

0 commit comments

Comments
 (0)