private void inputUpdate(MouseInteractionType code, int x, int y) { lock (this) { //if (!mouseUpdate) return; //mouseUpdate = false; //if (connectedToLocalPC || isDisposed || uiState != UIStates.Streaming || socket == null || bitmap == null) return; if (rdpSessionPage.skiaCanvasWidth == -1) { Device.BeginInvokeOnMainThread(() => { rdpSessionPage.canvas.InvalidateSurface(); }); // skia canvas のサイズを得てから処理したいので、returnする return; } //Console.WriteLine("inputUpdate: skiaCanvasWidth is OK. so start prrocessing input information."); if (internalCursorPosAppCanvasX == -1) { internalCursorPosAppCanvasX = rdpSessionPage.skiaCanvasWidth / 2; internalCursorPosAppCanvasY = rdpSessionPage.skiaCanvasHeight / 2; } if (code == MouseInteractionType.POSITION_SET) // drag { //lastDragDistanceX = x; //lastDragDistanceY = y; if (orgPosXDragStart == int.MaxValue) { orgPosXDragStart = internalCursorPosAppCanvasX; orgPosYDragStart = internalCursorPosAppCanvasY; } internalCursorPosAppCanvasX = orgPosXDragStart + x; internalCursorPosAppCanvasY = orgPosYDragStart - y; // 画像をフリップしているので方向が逆になる if (internalCursorPosAppCanvasX < 0) { internalCursorPosAppCanvasX = 0; } if (internalCursorPosAppCanvasX > rdpSessionPage.skiaCanvasWidth) { internalCursorPosAppCanvasX = rdpSessionPage.skiaCanvasWidth; } if (internalCursorPosAppCanvasY < 0) { internalCursorPosAppCanvasY = 0; } if (internalCursorPosAppCanvasY > rdpSessionPage.skiaCanvasHeight) { internalCursorPosAppCanvasY = rdpSessionPage.skiaCanvasHeight; } Console.WriteLine("called inputUpdate: {0}x{1}; moveX={2}, moveY={3}; updated cursor {4}, {5}", rdpSessionPage.skiaCanvasWidth, rdpSessionPage.skiaCanvasHeight, x, y, internalCursorPosAppCanvasX, internalCursorPosAppCanvasY); Device.BeginInvokeOnMainThread(() => { rdpSessionPage.canvas.InvalidateSurface(); }); } var task = Task.Run(() => { if (socket.IsConnected() == false) { return; } short[] pos_arr = convetCoodClientPanelToPCScreen(internalCursorPosAppCanvasX, internalCursorPosAppCanvasY); Console.WriteLine("SendCursorPos x={0} y={1}", pos_arr[1], pos_arr[0]); var metaData = new MetaData() { type = MetaDataTypes.UpdateMouse, mouseX = pos_arr[1], // スマホでは画像が90度回転されて表示されているので x と y を入れ替えて渡す mouseY = pos_arr[0], mouseInteractionType = code, dataSize = -1 }; socket.SendMetaData(metaData); }); } }