comparison src/main/java/com/glavsoft/rfb/client/KeyEventMessage.java @ 0:4689cc86d6cb

create TreeViewer2 Repository
author Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
date Tue, 03 Jul 2012 13:20:49 +0900
parents
children 472a9bcacb21
comparison
equal deleted inserted replaced
-1:000000000000 0:4689cc86d6cb
1 // Copyright (C) 2010, 2011 GlavSoft LLC.
2 // All rights reserved.
3 //
4 //-------------------------------------------------------------------------
5 // This file is part of the TightVNC software. Please visit our Web site:
6 //
7 // http://www.tightvnc.com/
8 //
9 // This program is free software; you can redistribute it and/or modify
10 // it under the terms of the GNU General Public License as published by
11 // the Free Software Foundation; either version 2 of the License, or
12 // (at your option) any later version.
13 //
14 // This program is distributed in the hope that it will be useful,
15 // but WITHOUT ANY WARRANTY; without even the implied warranty of
16 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 // GNU General Public License for more details.
18 //
19 // You should have received a copy of the GNU General Public License along
20 // with this program; if not, write to the Free Software Foundation, Inc.,
21 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22 //-------------------------------------------------------------------------
23 //
24
25 package com.glavsoft.rfb.client;
26
27 import com.glavsoft.exceptions.TransportException;
28 import com.glavsoft.transport.Writer;
29
30 /**
31 * A key press or release. Down-flag is non-zero (true) if the key is now pressed, zero
32 * (false) if it is now released. The key itself is specified using the “keysym” values
33 * defined by the X Window System.
34 * 1 - U8 - message-type
35 * 1 - U8 - down-flag
36 * 2 - - - padding
37 * 4 - U32 - key
38 * For most ordinary keys, the “keysym” is the same as the corresponding ASCII value.
39 * For full details, see The Xlib Reference Manual, published by O’Reilly & Associates,
40 * or see the header file <X11/keysymdef.h> from any X Window System installa-
41 * tion.
42 */
43 public class KeyEventMessage implements ClientToServerMessage {
44
45 private final int key;
46 private final boolean downFlag;
47
48 public KeyEventMessage(int key, boolean downFlag) {
49 this.downFlag = downFlag;
50 this.key = key;
51 }
52
53 @Override
54 public void send(Writer writer) throws TransportException {
55 writer.writeByte(KEY_EVENT);
56 writer.writeByte(downFlag ? 1 : 0);
57 writer.writeInt16(0); // padding
58 writer.write(key);
59 writer.flush();
60 }
61
62 @Override
63 public String toString() {
64 return "[KeyEventMessage: [down-flag: "+downFlag + ", key: " + key +"("+Integer.toHexString(key)+")]";
65 }
66
67 }