diff --git a/channels/ainput/client/ainput_main.c b/channels/ainput/client/ainput_main.c index e3e2d9cb3..4d51ae3f5 100644 --- a/channels/ainput/client/ainput_main.c +++ b/channels/ainput/client/ainput_main.c @@ -34,6 +34,8 @@ #include #include +#include "../common/ainput_common.h" + #define TAG CHANNELS_TAG("ainput.client") typedef struct AINPUT_CHANNEL_CALLBACK_ AINPUT_CHANNEL_CALLBACK; @@ -128,6 +130,12 @@ static UINT ainput_send_input_event(AInputClientContext* context, UINT64 flags, callback = ainput->listener_callback->channel_callback; WINPR_ASSERT(callback); + { + char buffer[128] = { 0 }; + WLog_VRB(TAG, "[%s] sending flags=%s, %" PRId32 "x%" PRId32, __FUNCTION__, + ainput_flags_to_string(flags, buffer, sizeof(buffer)), x, y); + } + /* Message type */ Stream_Write_UINT16(s, MSG_AINPUT_MOUSE); diff --git a/channels/ainput/common/ainput_common.h b/channels/ainput/common/ainput_common.h new file mode 100644 index 000000000..021178006 --- /dev/null +++ b/channels/ainput/common/ainput_common.h @@ -0,0 +1,78 @@ +/** + * FreeRDP: A Remote Desktop Protocol Implementation + * Audio Input Redirection Virtual Channel + * + * Copyright 2022 Armin Novak + * Copyright 2022 Thincast Technologies GmbH + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef FREERDP_INT_AINPUT_COMMON_H +#define FREERDP_INT_AINPUT_COMMON_H + +#include + +#include + +static INLINE void ainput_append(char* buffer, size_t size, const char* what, BOOL separator) +{ + size_t have; + size_t toadd; + + WINPR_ASSERT(buffer || (size == 0)); + WINPR_ASSERT(what); + + have = strnlen(buffer, size); + toadd = strlen(what); + if (have > 0) + toadd += 1; + + if (size - have < toadd + 1) + return; + + if (have > 0) + strcat(buffer, separator ? "|" : " "); + strcat(buffer, what); +} + +static INLINE const char* ainput_flags_to_string(UINT64 flags, char* buffer, size_t size) +{ + char number[32] = { 0 }; + + if (flags & AINPUT_FLAGS_WHEEL) + ainput_append(buffer, size, "AINPUT_FLAGS_WHEEL", TRUE); + if (flags & AINPUT_FLAGS_MOVE) + ainput_append(buffer, size, "AINPUT_FLAGS_MOVE", TRUE); + if (flags & AINPUT_FLAGS_DOWN) + ainput_append(buffer, size, "AINPUT_FLAGS_DOWN", TRUE); + if (flags & AINPUT_FLAGS_REL) + ainput_append(buffer, size, "AINPUT_FLAGS_REL", TRUE); + if (flags & AINPUT_FLAGS_BUTTON1) + ainput_append(buffer, size, "AINPUT_FLAGS_BUTTON1", TRUE); + if (flags & AINPUT_FLAGS_BUTTON2) + ainput_append(buffer, size, "AINPUT_FLAGS_BUTTON2", TRUE); + if (flags & AINPUT_FLAGS_BUTTON3) + ainput_append(buffer, size, "AINPUT_FLAGS_BUTTON3", TRUE); + if (flags & AINPUT_XFLAGS_BUTTON1) + ainput_append(buffer, size, "AINPUT_XFLAGS_BUTTON1", TRUE); + if (flags & AINPUT_XFLAGS_BUTTON2) + ainput_append(buffer, size, "AINPUT_XFLAGS_BUTTON2", TRUE); + + _snprintf(number, sizeof(number), "[0x%08" PRIx64 "]", flags); + ainput_append(buffer, size, number, FALSE); + + return buffer; +} + +#endif /* FREERDP_INT_AINPUT_COMMON_H */ diff --git a/channels/ainput/server/ainput_main.c b/channels/ainput/server/ainput_main.c index 122379cfb..a74bfc137 100644 --- a/channels/ainput/server/ainput_main.c +++ b/channels/ainput/server/ainput_main.c @@ -37,6 +37,8 @@ #include #include +#include "../common/ainput_common.h" + #define TAG CHANNELS_TAG("ainput.server") typedef struct ainput_server_ @@ -146,6 +148,7 @@ static UINT ainput_server_recv_mouse_event(ainput_server* ainput, wStream* s) UINT error = CHANNEL_RC_OK; UINT64 flags; INT32 x, y; + char buffer[128] = { 0 }; WINPR_ASSERT(ainput); WINPR_ASSERT(s); @@ -156,6 +159,9 @@ static UINT ainput_server_recv_mouse_event(ainput_server* ainput, wStream* s) Stream_Read_UINT64(s, flags); Stream_Read_INT32(s, x); Stream_Read_INT32(s, y); + + WLog_VRB(TAG, "[%s] received: flags=%s, %" PRId32 "x%" PRId32, __FUNCTION__, + ainput_flags_to_string(flags, buffer, sizeof(buffer)), x, y); IFCALLRET(ainput->context.MouseEvent, error, &ainput->context, flags, x, y); return error;