Skip to content

Commit

Permalink
Simplify F12 probing, set offset to zero for HID attention reports
Browse files Browse the repository at this point in the history
  • Loading branch information
1Revenger1 committed Oct 20, 2024
1 parent 2ddd0f6 commit c925d87
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 49 deletions.
44 changes: 12 additions & 32 deletions VoodooRMI/Functions/F12.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,53 +79,33 @@ bool F12::attach(IOService *provider)
/*
* Figure out what data is contained in the data registers. HID devices
* may have registers defined, but their data is not reported in the
* HID attention report. Registers which are not reported in the HID
* attention report check to see if the device is receiving data from
* HID attention reports.
* HID attention report. As we don't care about pen or acm data, we can do
* a simplified check for ACM data to get attention size and ignore the data
* offset.
*/
item = rmi_get_register_desc_item(&data_reg_desc, 0);
if (item)
data_offset += item->reg_size;

item = rmi_get_register_desc_item(&data_reg_desc, 1);
if (!item) {
return false;
IOLogError("F12 - No Data1 Reg!");
return false;
}

data1 = item;

data1_offset = data_offset;
data_offset += item->reg_size;
nbr_fingers = item->num_subpackets;
report_abs = 1;
attn_size += item->reg_size;

item = rmi_get_register_desc_item(&data_reg_desc, 2);
if (item)
data_offset += item->reg_size;

item = rmi_get_register_desc_item(&data_reg_desc, 3);
if (item)
data_offset += item->reg_size;

item = rmi_get_register_desc_item(&data_reg_desc, 4);
if (item)
data_offset += item->reg_size;
nbr_fingers = item->num_subpackets;

item = rmi_get_register_desc_item(&data_reg_desc, 5);
if (item) {
data5 = item;
data5_offset = data_offset;
data_offset += item->reg_size;
if (item)
attn_size += item->reg_size;
}

// Skip 6-15 as they do not increase attention size and only gives relative info
// Skip 6-15 as they do not increase attention size

setProperty("Number of fingers", nbr_fingers, 8);
IOLogDebug("F12 - Number of fingers %u", nbr_fingers);


return true;
}

Expand Down Expand Up @@ -269,9 +249,8 @@ int F12::rmi_f12_read_sensor_tuning()

void F12::attention(AbsoluteTime time, UInt8 *data[], size_t *size)
{
if (!data1)
return;

size_t offset = data1_offset;

if (*data) {
if (*size < attn_size) {
IOLogError("F12 attention larger than remaining data");
Expand All @@ -281,6 +260,7 @@ void F12::attention(AbsoluteTime time, UInt8 *data[], size_t *size)
memcpy(data_pkt, *data, attn_size);
(*data) += attn_size;
(*size) -= attn_size;
offset = 0;
} else {
IOReturn error = readBlock(getDataAddr(), data_pkt, pkt_size);

Expand All @@ -301,7 +281,7 @@ void F12::attention(AbsoluteTime time, UInt8 *data[], size_t *size)
#endif // debug

int fingers = min (nbr_fingers, 5);
UInt8 *fingerData = &data_pkt[data1_offset];
UInt8 *fingerData = &data_pkt[offset];

for (int i = 0; i < fingers; i++) {
rmi_2d_sensor_abs_object *obj = &report.objs[i];
Expand Down
17 changes: 3 additions & 14 deletions VoodooRMI/Functions/F12.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,26 +72,15 @@ class F12 : public RMITrackpadFunction {

/* F12 Data */
UInt8 *data_pkt;
size_t pkt_size;
size_t attn_size;
size_t pkt_size {0};
size_t attn_size {0};
bool has_dribble;
size_t data1_offset;

rmi_register_descriptor query_reg_desc;
rmi_register_descriptor control_reg_desc;
rmi_register_descriptor data_reg_desc;

/* F12 Data1 describes sensed objects */
const rmi_register_desc_item *data1 {nullptr};
UInt16 data1_offset;

/* F12 Data5 describes finger ACM */
const rmi_register_desc_item *data5 {nullptr};
UInt16 data5_offset;

/* F12 Data5 describes Pen */
const rmi_register_desc_item *data6 {nullptr};
UInt16 data6_offset;

int rmi_f12_read_sensor_tuning();
int rmi_read_register_desc(UInt16 addr,
rmi_register_descriptor *rdesc);
Expand Down
3 changes: 0 additions & 3 deletions VoodooRMI/Functions/Input/RMITrackpadFunction.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,6 @@ class RMITrackpadFunction : public RMIFunction {
const Rmi2DSensorData &getData() const;

protected:
UInt8 report_abs {0};
UInt8 report_rel {0};

UInt8 nbr_fingers;

void handleReport(RMI2DSensorReport *report);
Expand Down

0 comments on commit c925d87

Please sign in to comment.