Skip to content

Commit ca1194d

Browse files
committed
Whacky, hacky, axes and scale inversions
1 parent 53b3fe2 commit ca1194d

File tree

2 files changed

+41
-9
lines changed

2 files changed

+41
-9
lines changed

VoodooI2CGoodix.xcodeproj/xcuserdata/lazd.xcuserdatad/xcschemes/xcschememanagement.plist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<key>VoodooI2CGoodix.xcscheme_^#shared#^_</key>
88
<dict>
99
<key>orderHint</key>
10-
<integer>4</integer>
10+
<integer>5</integer>
1111
</dict>
1212
</dict>
1313
</dict>

VoodooI2CGoodix/VoodooI2CGoodixTouchDriver.cpp

Lines changed: 40 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ struct goodix_ts_data {
2525
bool swapped_x_y;
2626
bool inverted_x;
2727
bool inverted_y;
28+
bool swap_x_y_scale;
29+
bool swapped_x_y_values;
2830
unsigned int max_touch_num;
2931
unsigned int int_trigger_type;
3032
UInt16 id;
@@ -325,15 +327,43 @@ void VoodooI2CGoodixTouchDriver::goodix_ts_report_touch(UInt8 *coor_data, Absolu
325327
int input_y = get_unaligned_le16(&coor_data[3]);
326328
int input_w = get_unaligned_le16(&coor_data[5]);
327329

328-
/* Inversions have to happen before axis swapping */
329-
if (ts->inverted_x)
330-
input_x = ts->abs_x_max - input_x;
331-
if (ts->inverted_y)
332-
input_y = ts->abs_y_max - input_y;
333-
if (ts->swapped_x_y)
330+
IOLog("%s::raw: %d,%d\n", getName(), input_x, input_y);
331+
332+
/* Scale swapping has to happen before everything */
333+
if (ts->swap_x_y_scale) {
334+
input_x = (int)(((float)input_x / ts->abs_x_max) * ts->abs_y_max);
335+
input_y = (int)(((float)input_y / ts->abs_y_max) * ts->abs_x_max);
336+
337+
IOLog("%s::scl: %d,%d\n", getName(), input_x, input_y);
338+
339+
/* Inversions have to happen before axis swapping */
340+
if (ts->inverted_x)
341+
input_x = ts->abs_y_max - input_x;
342+
if (ts->inverted_y)
343+
input_y = ts->abs_x_max - input_y;
344+
345+
if (ts->inverted_x || ts->inverted_y) {
346+
IOLog("%s::inv: %d,%d\n", getName(), input_x, input_y);
347+
}
348+
}
349+
else {
350+
/* Inversions have to happen before axis swapping */
351+
if (ts->inverted_x)
352+
input_x = ts->abs_x_max - input_x;
353+
if (ts->inverted_y)
354+
input_y = ts->abs_y_max - input_y;
355+
356+
if (ts->inverted_x || ts->inverted_y) {
357+
IOLog("%s::inv: %d,%d\n", getName(), input_x, input_y);
358+
}
359+
}
360+
361+
if (ts->swapped_x_y || ts->swapped_x_y_values) {
334362
swap(input_x, input_y);
363+
IOLog("%s::swp: %d,%d\n", getName(), input_x, input_y);
364+
}
335365

336-
IOLog("%s::Touch %d at %d, %d with width %d\n", getName(), id, input_x, input_y, input_w);
366+
IOLog("%s::Touch %d with width %d at %d,%d\n", getName(), id, input_x, input_y, input_w);
337367

338368
if (!transducers) {
339369
IOLog("%s::No transducers, cannot report", getName());
@@ -548,8 +578,10 @@ IOReturn VoodooI2CGoodixTouchDriver::goodix_configure_dev() {
548578

549579
// Hardcoded values for Chuwi Minibook 8
550580
ts->swapped_x_y = false;
551-
ts->inverted_x = false;
581+
ts->inverted_x = true;
552582
ts->inverted_y = false;
583+
ts->swap_x_y_scale = true;
584+
ts->swapped_x_y_values = true;
553585

554586
goodix_read_config();
555587

0 commit comments

Comments
 (0)