From 551743b026f8caf54b944e22a191188c3fe09e7e Mon Sep 17 00:00:00 2001 From: GiWoong Kim Date: Wed, 24 Dec 2014 17:15:11 +0900 Subject: [PATCH] communication: add rotary protocol between Qemu and SWT Change-Id: If0d89bb8a6b227e33941573e9054b50227e3f407 Signed-off-by: GiWoong Kim --- .../tizen/emulator/skin/comm/ICommunicator.java | 1 + .../skin/comm/sock/data/RotaryEventData.java | 63 ++++++++++++++++++++++ .../skin/layout/ProfileRotarySkinComposer.java | 3 +- .../src/org/tizen/emulator/skin/layout/Rotary.java | 14 +++-- tizen/src/skin/maruskin_server.c | 27 ++++++++++ 5 files changed, 104 insertions(+), 4 deletions(-) create mode 100644 tizen/src/skin/client/src/org/tizen/emulator/skin/comm/sock/data/RotaryEventData.java diff --git a/tizen/src/skin/client/src/org/tizen/emulator/skin/comm/ICommunicator.java b/tizen/src/skin/client/src/org/tizen/emulator/skin/comm/ICommunicator.java index e0c4662..daaf6bc 100644 --- a/tizen/src/skin/client/src/org/tizen/emulator/skin/comm/ICommunicator.java +++ b/tizen/src/skin/client/src/org/tizen/emulator/skin/comm/ICommunicator.java @@ -179,6 +179,7 @@ public interface ICommunicator extends Runnable { SEND_RAM_DUMP((short) 18), SEND_GUEST_DUMP((short) 19), SEND_INTERPOLATION_STATE((short) 21), + SEND_ROTARY_EVENT((short) 30), RESPONSE_HEART_BEAT((short) 900), RESPONSE_DRAW_FRAME((short) 901), diff --git a/tizen/src/skin/client/src/org/tizen/emulator/skin/comm/sock/data/RotaryEventData.java b/tizen/src/skin/client/src/org/tizen/emulator/skin/comm/sock/data/RotaryEventData.java new file mode 100644 index 0000000..a1780c4 --- /dev/null +++ b/tizen/src/skin/client/src/org/tizen/emulator/skin/comm/sock/data/RotaryEventData.java @@ -0,0 +1,63 @@ +/** + * Rotary Event Data + * + * Copyright (C) 2011 - 2014 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * GiWoong Kim + * SangHo Park + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributors: + * - S-Core Co., Ltd + * + */ + +package org.tizen.emulator.skin.comm.sock.data; + +import java.io.IOException; + +/** + * + * + */ +public class RotaryEventData extends AbstractSendData { + int eventType; + int delta; + + public RotaryEventData(int eventType, int delta) { + this.eventType = eventType; + this.delta = delta; + } + + @Override + protected void write() throws IOException { + writeInt(eventType); + writeInt(delta); + } + + @Override + public String toString() { + StringBuilder builder = new StringBuilder(); + builder.append("RotaryEventData [eventType="); + builder.append(eventType); + builder.append(", delta="); + builder.append(delta); + builder.append("]"); + + return builder.toString(); + } +} diff --git a/tizen/src/skin/client/src/org/tizen/emulator/skin/layout/ProfileRotarySkinComposer.java b/tizen/src/skin/client/src/org/tizen/emulator/skin/layout/ProfileRotarySkinComposer.java index 9f120c8..226d1ee 100644 --- a/tizen/src/skin/client/src/org/tizen/emulator/skin/layout/ProfileRotarySkinComposer.java +++ b/tizen/src/skin/client/src/org/tizen/emulator/skin/layout/ProfileRotarySkinComposer.java @@ -49,7 +49,8 @@ public class ProfileRotarySkinComposer extends ProfileSpecificSkinComposer { EmulatorConfig config, EmulatorSkin skin) { super(config, skin); - rotary = new Rotary(shell, SWT.DOUBLE_BUFFERED, imageRegistry); + rotary = new Rotary(shell, SWT.DOUBLE_BUFFERED, + imageRegistry, communicator); } @Override diff --git a/tizen/src/skin/client/src/org/tizen/emulator/skin/layout/Rotary.java b/tizen/src/skin/client/src/org/tizen/emulator/skin/layout/Rotary.java index 38f4d89..d771658 100644 --- a/tizen/src/skin/client/src/org/tizen/emulator/skin/layout/Rotary.java +++ b/tizen/src/skin/client/src/org/tizen/emulator/skin/layout/Rotary.java @@ -41,6 +41,9 @@ import org.eclipse.swt.graphics.Point; import org.eclipse.swt.graphics.Transform; import org.eclipse.swt.widgets.Canvas; import org.eclipse.swt.widgets.Shell; +import org.tizen.emulator.skin.comm.ICommunicator.SendCommand; +import org.tizen.emulator.skin.comm.sock.SocketCommunicator; +import org.tizen.emulator.skin.comm.sock.data.RotaryEventData; import org.tizen.emulator.skin.image.ProfileSkinImageRegistry; import org.tizen.emulator.skin.image.ProfileSkinImageRegistry.SkinImageType; import org.tizen.emulator.skin.log.SkinLogger; @@ -51,6 +54,8 @@ public class Rotary extends Canvas { private Shell parent; private ProfileSkinImageRegistry imageRegistry; + private SocketCommunicator communicator; + private Image image; private int degrees; /* absolute */ private int angleDelta; @@ -59,11 +64,13 @@ public class Rotary extends Canvas { /** * Constructor */ - Rotary(final Shell parent, int style, ProfileSkinImageRegistry imageRegistry) { + Rotary(final Shell parent, int style, + ProfileSkinImageRegistry imageRegistry, SocketCommunicator communicator) { super(parent, style); this.parent = parent; this.imageRegistry = imageRegistry; + this.communicator = communicator; this.image = null; this.degrees = 0; this.angleDelta = 0; @@ -143,8 +150,9 @@ public class Rotary extends Canvas { delta -= 360; } - // TODO: send to qemu - logger.info("rotary : " + delta); + /* send to qemu */ + communicator.sendToQEMU(SendCommand.SEND_ROTARY_EVENT, + new RotaryEventData(0, delta), false); redraw(); } diff --git a/tizen/src/skin/maruskin_server.c b/tizen/src/skin/maruskin_server.c index 67bc455..10d10e6 100644 --- a/tizen/src/skin/maruskin_server.c +++ b/tizen/src/skin/maruskin_server.c @@ -98,6 +98,7 @@ enum { RECV_RAM_DUMP = 18, RECV_GUESTMEMORY_DUMP = 19, RECV_INTERPOLATION_STATE = 21, + RECV_ROTARY_EVENT = 30, RECV_RESPONSE_HEART_BEAT = 900, RECV_RESPONSE_DRAW_FRAME = 901, @@ -1108,6 +1109,32 @@ static void* run_skin_server(void* args) break; } + case RECV_ROTARY_EVENT: { + log_cnt += sprintf(log_buf + log_cnt, "RECV_ROTARY_EVENT ==\n"); + TRACE(log_buf); + + if (0 >= length) { + ERR("there is no data looking at 0 length."); + continue; + } + + /* keep it consistent with emulator-skin definition */ + int event_type = 0; + int delta = 0; + + char* p = recvbuf; + memcpy(&event_type, p, sizeof(event_type)); + p += sizeof(event_type); + memcpy(&delta, p, sizeof(delta)); + + event_type = ntohl(event_type); + delta = ntohl(delta); + + // TODO: + INFO("rotary event : %d\n", delta); + + break; + } case RECV_RESPONSE_DRAW_FRAME: { qemu_mutex_lock(&mutex_draw_display); draw_display_state = 0; /* framebuffer has been drawn */ -- 2.7.4