Skip to content

Commit

Permalink
Whacky, hacky, axes and scale inversions
Browse files Browse the repository at this point in the history
  • Loading branch information
lazd committed Jan 5, 2020
1 parent 53b3fe2 commit ca1194d
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<key>VoodooI2CGoodix.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>4</integer>
<integer>5</integer>
</dict>
</dict>
</dict>
Expand Down
48 changes: 40 additions & 8 deletions VoodooI2CGoodix/VoodooI2CGoodixTouchDriver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ struct goodix_ts_data {
bool swapped_x_y;
bool inverted_x;
bool inverted_y;
bool swap_x_y_scale;
bool swapped_x_y_values;
unsigned int max_touch_num;
unsigned int int_trigger_type;
UInt16 id;
Expand Down Expand Up @@ -325,15 +327,43 @@ void VoodooI2CGoodixTouchDriver::goodix_ts_report_touch(UInt8 *coor_data, Absolu
int input_y = get_unaligned_le16(&coor_data[3]);
int input_w = get_unaligned_le16(&coor_data[5]);

/* Inversions have to happen before axis swapping */
if (ts->inverted_x)
input_x = ts->abs_x_max - input_x;
if (ts->inverted_y)
input_y = ts->abs_y_max - input_y;
if (ts->swapped_x_y)
IOLog("%s::raw: %d,%d\n", getName(), input_x, input_y);

/* Scale swapping has to happen before everything */
if (ts->swap_x_y_scale) {
input_x = (int)(((float)input_x / ts->abs_x_max) * ts->abs_y_max);
input_y = (int)(((float)input_y / ts->abs_y_max) * ts->abs_x_max);

IOLog("%s::scl: %d,%d\n", getName(), input_x, input_y);

/* Inversions have to happen before axis swapping */
if (ts->inverted_x)
input_x = ts->abs_y_max - input_x;
if (ts->inverted_y)
input_y = ts->abs_x_max - input_y;

if (ts->inverted_x || ts->inverted_y) {
IOLog("%s::inv: %d,%d\n", getName(), input_x, input_y);
}
}
else {
/* Inversions have to happen before axis swapping */
if (ts->inverted_x)
input_x = ts->abs_x_max - input_x;
if (ts->inverted_y)
input_y = ts->abs_y_max - input_y;

if (ts->inverted_x || ts->inverted_y) {
IOLog("%s::inv: %d,%d\n", getName(), input_x, input_y);
}
}

if (ts->swapped_x_y || ts->swapped_x_y_values) {
swap(input_x, input_y);
IOLog("%s::swp: %d,%d\n", getName(), input_x, input_y);
}

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

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

// Hardcoded values for Chuwi Minibook 8
ts->swapped_x_y = false;
ts->inverted_x = false;
ts->inverted_x = true;
ts->inverted_y = false;
ts->swap_x_y_scale = true;
ts->swapped_x_y_values = true;

goodix_read_config();

Expand Down

0 comments on commit ca1194d

Please sign in to comment.