store previous coordinates to report on touch release

This commit is contained in:
Kuratius 2026-05-18 14:13:50 +02:00
parent 55e6c2b220
commit f52e956b8d

View file

@ -103,8 +103,13 @@ typedef struct
Uint16 low_frequency_rumble;
Uint16 high_frequency_rumble;
Uint64 last_rumble_time;
bool left_touch_down;
float left_touch_x;
float left_touch_y;
bool right_touch_down;
float right_touch_x;
float right_touch_y;
} SDL_DriverSteamTriton_Context;
static bool IsProteusDongle(Uint16 product_id)
@ -248,18 +253,27 @@ static void HIDAPI_DriverSteamTriton_HandleState(SDL_HIDAPI_Device *device,
bool downLeft = pTritonReport->buttons & TRITON_LEFT_TOUCHPAD_TOUCH ? true : false;
bool downRight = pTritonReport->buttons & TRITON_RIGHT_TOUCHPAD_TOUCH ? true : false;
if (downLeft || ctx->left_touch_down){
if (downLeft){
ctx->left_touch_x=pTritonReport->sLeftPadX / 65536.0f + 0.5f;
ctx->left_touch_y=-(float)pTritonReport->sLeftPadY / 65536.0f + 0.5f;
}
SDL_SendJoystickTouchpad(timestamp, joystick, 0, 0,
downLeft,
pTritonReport->sLeftPadX / 65536.0f + 0.5f,
-(float)pTritonReport->sLeftPadY / 65536.0f + 0.5f,
ctx->left_touch_x,
ctx->left_touch_y,
pTritonReport->sPressureLeft / 32768.0f);
ctx->left_touch_down=downLeft;
}
if (downRight || ctx->right_touch_down){
if (downRight){
ctx->right_touch_x=pTritonReport->sRightPadX / 65536.0f + 0.5f;
ctx->right_touch_y=-(float)pTritonReport->sRightPadY / 65536.0f + 0.5f;
}
SDL_SendJoystickTouchpad(timestamp, joystick, 1, 0,
downRight,
pTritonReport->sRightPadX / 65536.0f + 0.5f,
-(float)pTritonReport->sRightPadY / 65536.0f + 0.5f,
ctx->right_touch_x,
ctx->right_touch_y,
pTritonReport->sPressureRight / 32768.0f);
ctx->right_touch_down=downRight;
}