Update gamepad touch support with latest protocol changes
This commit is contained in:
@@ -995,9 +995,9 @@ namespace input {
|
|||||||
{ gamepad.id, packet->controllerNumber },
|
{ gamepad.id, packet->controllerNumber },
|
||||||
packet->eventType,
|
packet->eventType,
|
||||||
util::endian::little(packet->pointerId),
|
util::endian::little(packet->pointerId),
|
||||||
from_netfloat(packet->x),
|
from_clamped_netfloat(packet->x, 0.0f, 1.0f),
|
||||||
from_netfloat(packet->y),
|
from_clamped_netfloat(packet->y, 0.0f, 1.0f),
|
||||||
from_netfloat(packet->pressure),
|
from_clamped_netfloat(packet->pressure, 0.0f, 1.0f),
|
||||||
};
|
};
|
||||||
|
|
||||||
platf::gamepad_touch(platf_input, touch);
|
platf::gamepad_touch(platf_input, touch);
|
||||||
|
|||||||
@@ -1439,6 +1439,17 @@ namespace platf {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (touch.eventType == LI_TOUCH_EVENT_CANCEL_ALL) {
|
||||||
|
// Raise both pointers
|
||||||
|
report.sCurrentTouch.bIsUpTrackingNum1 |= 0x80;
|
||||||
|
report.sCurrentTouch.bIsUpTrackingNum2 |= 0x80;
|
||||||
|
|
||||||
|
// Remove all pointer index mappings
|
||||||
|
gamepad.pointer_id_map.clear();
|
||||||
|
|
||||||
|
// All pointers are now available
|
||||||
|
gamepad.available_pointers = 0x3;
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
auto i = gamepad.pointer_id_map.find(touch.pointerId);
|
auto i = gamepad.pointer_id_map.find(touch.pointerId);
|
||||||
if (i == gamepad.pointer_id_map.end()) {
|
if (i == gamepad.pointer_id_map.end()) {
|
||||||
@@ -1448,7 +1459,7 @@ namespace platf {
|
|||||||
|
|
||||||
pointerIndex = (*i).second;
|
pointerIndex = (*i).second;
|
||||||
|
|
||||||
if (touch.eventType == LI_TOUCH_EVENT_UP) {
|
if (touch.eventType == LI_TOUCH_EVENT_UP || touch.eventType == LI_TOUCH_EVENT_CANCEL) {
|
||||||
// Remove the pointer index mapping
|
// Remove the pointer index mapping
|
||||||
gamepad.pointer_id_map.erase(i);
|
gamepad.pointer_id_map.erase(i);
|
||||||
|
|
||||||
@@ -1463,6 +1474,10 @@ namespace platf {
|
|||||||
// Free the pointer index
|
// Free the pointer index
|
||||||
gamepad.available_pointers |= (1 << pointerIndex);
|
gamepad.available_pointers |= (1 << pointerIndex);
|
||||||
}
|
}
|
||||||
|
else if (touch.eventType != LI_TOUCH_EVENT_MOVE) {
|
||||||
|
BOOST_LOG(warning) << "Unsupported touch event for gamepad: "sv << (uint32_t) touch.eventType;
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Touchpad is 1920x943 according to ViGEm
|
// Touchpad is 1920x943 according to ViGEm
|
||||||
@@ -1475,11 +1490,13 @@ namespace platf {
|
|||||||
};
|
};
|
||||||
|
|
||||||
report.sCurrentTouch.bPacketCounter++;
|
report.sCurrentTouch.bPacketCounter++;
|
||||||
if (pointerIndex == 0) {
|
if (touch.eventType != LI_TOUCH_EVENT_CANCEL_ALL) {
|
||||||
memcpy(report.sCurrentTouch.bTouchData1, touchData, sizeof(touchData));
|
if (pointerIndex == 0) {
|
||||||
}
|
memcpy(report.sCurrentTouch.bTouchData1, touchData, sizeof(touchData));
|
||||||
else {
|
}
|
||||||
memcpy(report.sCurrentTouch.bTouchData2, touchData, sizeof(touchData));
|
else {
|
||||||
|
memcpy(report.sCurrentTouch.bTouchData2, touchData, sizeof(touchData));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
auto status = vigem_target_ds4_update_ex(vigem->client.get(), gamepad.gp.get(), gamepad.report.ds4);
|
auto status = vigem_target_ds4_update_ex(vigem->client.get(), gamepad.gp.get(), gamepad.report.ds4);
|
||||||
|
|||||||
Reference in New Issue
Block a user