Added event logging for ainput channel

This commit is contained in:
akallabeth 2022-01-22 12:14:26 +01:00 committed by akallabeth
parent e5592772ce
commit 54259bc37c
3 changed files with 92 additions and 0 deletions

View File

@ -34,6 +34,8 @@
#include <freerdp/client/ainput.h>
#include <freerdp/channels/ainput.h>
#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);

View File

@ -0,0 +1,78 @@
/**
* FreeRDP: A Remote Desktop Protocol Implementation
* Audio Input Redirection Virtual Channel
*
* Copyright 2022 Armin Novak <anovak@thincast.com>
* 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 <winpr/string.h>
#include <freerdp/channels/ainput.h>
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 */

View File

@ -37,6 +37,8 @@
#include <freerdp/channels/ainput.h>
#include <freerdp/channels/log.h>
#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;