Split controller motion events onto their own channels

This commit is contained in:
Cameron Gutman
2023-07-04 16:18:52 -05:00
parent 53c29f11ba
commit 377d37503f
3 changed files with 7 additions and 6 deletions

View File

@@ -1422,7 +1422,7 @@ int startControlStream(void) {
enet_address_set_port(&address, ControlPortNumber);
// Create a client
client = enet_host_create(address.address.ss_family, NULL, 1, CTRL_CHANNEL_MAX + 1, 0, 0);
client = enet_host_create(address.address.ss_family, NULL, 1, CTRL_CHANNEL_COUNT, 0, 0);
if (client == NULL) {
stopping = true;
return -1;
@@ -1431,7 +1431,7 @@ int startControlStream(void) {
client->intercept = ignoreDisconnectIntercept;
// Connect to the host
peer = enet_host_connect(client, &address, CTRL_CHANNEL_MAX + 1, 0);
peer = enet_host_connect(client, &address, CTRL_CHANNEL_COUNT, 0);
if (peer == NULL) {
stopping = true;
enet_host_destroy(client);

View File

@@ -1421,8 +1421,8 @@ int LiSendControllerMotionEvent(uint8_t controllerNumber, uint8_t motionType, fl
return -1;
}
// Send each controller on a separate channel
holder->channelId = CTRL_CHANNEL_GAMEPAD_BASE + controllerNumber;
// Send each controller on a separate channel specific to motion sensors
holder->channelId = CTRL_CHANNEL_SENSOR_BASE + controllerNumber;
// Motion events are so rapid that we can just drop any events that are lost in transit
holder->enetPacketFlags = 0;

View File

@@ -60,8 +60,9 @@ extern uint32_t SunshineFeatureFlags;
#define CTRL_CHANNEL_PEN 0x04
#define CTRL_CHANNEL_TOUCH 0x05
#define CTRL_CHANNEL_UTF8 0x06
#define CTRL_CHANNEL_GAMEPAD_BASE 0x10 // 0x10 to 0x20 by controller index
#define CTRL_CHANNEL_MAX 0x20
#define CTRL_CHANNEL_GAMEPAD_BASE 0x10 // 0x10 to 0x1F by controller index
#define CTRL_CHANNEL_SENSOR_BASE 0x20 // 0x20 to 0x2F by controller index
#define CTRL_CHANNEL_COUNT 0x30
#ifndef UINT24_MAX
#define UINT24_MAX 0xFFFFFF