• Main Page
  • Classes
  • Files
  • File List

ProtocolTypes.h

00001 /*
00002  * synergy -- mouse and keyboard sharing utility
00003  * Copyright (C) 2012 Bolton Software Ltd.
00004  * Copyright (C) 2002 Chris Schoeneman
00005  * 
00006  * This package is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU General Public License
00008  * found in the file COPYING that should have accompanied this file.
00009  * 
00010  * This package is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  * GNU General Public License for more details.
00014  *
00015  * You should have received a copy of the GNU General Public License
00016  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
00017  */
00018 
00019 #ifndef PROTOCOLTYPES_H
00020 #define PROTOCOLTYPES_H
00021 
00022 #include "BasicTypes.h"
00023 
00024 // protocol version number
00025 // 1.0:  initial protocol
00026 // 1.1:  adds KeyCode to key press, release, and repeat
00027 // 1.2:  adds mouse relative motion
00028 // 1.3:  adds keep alive and deprecates heartbeats,
00029 //       adds horizontal mouse scrolling
00030 // 1.4:  adds game device support
00031 static const SInt16     kProtocolMajorVersion = 1;
00032 static const SInt16     kProtocolMinorVersion = 4;
00033 
00034 // default contact port number
00035 static const UInt16     kDefaultPort = 24800;
00036 
00037 // maximum total length for greeting returned by client
00038 static const UInt32     kMaxHelloLength = 1024;
00039 
00040 // time between kMsgCKeepAlive (in seconds).  a non-positive value disables
00041 // keep alives.  this is the default rate that can be overridden using an
00042 // option.
00043 static const double     kKeepAliveRate = 3.0;
00044 
00045 // number of skipped kMsgCKeepAlive messages that indicates a problem
00046 static const double     kKeepAlivesUntilDeath = 3.0;
00047 
00048 // obsolete heartbeat stuff
00049 static const double     kHeartRate = -1.0;
00050 static const double     kHeartBeatsUntilDeath = 3.0;
00051 
00052 // direction constants
00053 enum EDirection {
00054     kNoDirection,
00055     kLeft,
00056     kRight,
00057     kTop,
00058     kBottom,
00059     kFirstDirection = kLeft,
00060     kLastDirection = kBottom,
00061     kNumDirections = kLastDirection - kFirstDirection + 1
00062 };
00063 enum EDirectionMask {
00064     kNoDirMask  = 0,
00065     kLeftMask   = 1 << kLeft,
00066     kRightMask  = 1 << kRight,
00067     kTopMask    = 1 << kTop,
00068     kBottomMask = 1 << kBottom
00069 };
00070 
00071 
00072 //
00073 // message codes (trailing NUL is not part of code).  in comments, $n
00074 // refers to the n'th argument (counting from one).  message codes are
00075 // always 4 bytes optionally followed by message specific parameters
00076 // except those for the greeting handshake.
00077 //
00078 
00079 //
00080 // positions and sizes are signed 16 bit integers.
00081 //
00082 
00083 //
00084 // greeting handshake messages
00085 //
00086 
00087 // say hello to client;  primary -> secondary
00088 // $1 = protocol major version number supported by server.  $2 =
00089 // protocol minor version number supported by server.
00090 extern const char*      kMsgHello;
00091 
00092 // respond to hello from server;  secondary -> primary
00093 // $1 = protocol major version number supported by client.  $2 =
00094 // protocol minor version number supported by client.  $3 = client
00095 // name.
00096 extern const char*      kMsgHelloBack;
00097 
00098 
00099 //
00100 // command codes
00101 //
00102 
00103 // no operation;  secondary -> primary
00104 extern const char*      kMsgCNoop;
00105 
00106 // close connection;  primary -> secondary
00107 extern const char*      kMsgCClose;
00108 
00109 // enter screen:  primary -> secondary
00110 // entering screen at screen position $1 = x, $2 = y.  x,y are
00111 // absolute screen coordinates.  $3 = sequence number, which is
00112 // used to order messages between screens.  the secondary screen
00113 // must return this number with some messages.  $4 = modifier key
00114 // mask.  this will have bits set for each toggle modifier key
00115 // that is activated on entry to the screen.  the secondary screen
00116 // should adjust its toggle modifiers to reflect that state.
00117 extern const char*      kMsgCEnter;
00118 
00119 // leave screen:  primary -> secondary
00120 // leaving screen.  the secondary screen should send clipboard
00121 // data in response to this message for those clipboards that
00122 // it has grabbed (i.e. has sent a kMsgCClipboard for and has
00123 // not received a kMsgCClipboard for with a greater sequence
00124 // number) and that were grabbed or have changed since the
00125 // last leave.
00126 extern const char*      kMsgCLeave;
00127 
00128 // grab clipboard:  primary <-> secondary
00129 // sent by screen when some other app on that screen grabs a
00130 // clipboard.  $1 = the clipboard identifier, $2 = sequence number.
00131 // secondary screens must use the sequence number passed in the
00132 // most recent kMsgCEnter.  the primary always sends 0.
00133 extern const char*      kMsgCClipboard;
00134 
00135 // screensaver change:  primary -> secondary
00136 // screensaver on primary has started ($1 == 1) or closed ($1 == 0)
00137 extern const char*      kMsgCScreenSaver;
00138 
00139 // reset options:  primary -> secondary
00140 // client should reset all of its options to their defaults.
00141 extern const char*      kMsgCResetOptions;
00142 
00143 // resolution change acknowledgment:  primary -> secondary
00144 // sent by primary in response to a secondary screen's kMsgDInfo.
00145 // this is sent for every kMsgDInfo, whether or not the primary
00146 // had sent a kMsgQInfo.
00147 extern const char*      kMsgCInfoAck;
00148 
00149 // keep connection alive:  primary <-> secondary
00150 // sent by the server periodically to verify that connections are still
00151 // up and running.  clients must reply in kind on receipt.  if the server
00152 // gets an error sending the message or does not receive a reply within
00153 // a reasonable time then the server disconnects the client.  if the
00154 // client doesn't receive these (or any message) periodically then it
00155 // should disconnect from the server.  the appropriate interval is
00156 // defined by an option.
00157 extern const char*      kMsgCKeepAlive;
00158 
00159 // game device timing:  primary -> secondary
00160 // periodically, sent from primary to secondary when game device device is polled.
00161 // this causes a game timing response to be queued, which is dequeued when
00162 // the device is next faked.
00163 extern const char*      kMsgCGameTimingReq;
00164 
00165 // game device timing:  primary <- secondary
00166 // in response, sent from secondary to primary when game device device is faked.
00167 // the difference between when the message was sent and received is a
00168 // measurement of time it took for the game device device state to reach the
00169 // game device device user. a timing request is not retransmitted until after 
00170 // the pending timing response is received.
00171 extern const char*      kMsgCGameTimingResp;
00172 
00173 //
00174 // data codes
00175 //
00176 
00177 // key pressed:  primary -> secondary
00178 // $1 = KeyID, $2 = KeyModifierMask, $3 = KeyButton
00179 // the KeyButton identifies the physical key on the primary used to
00180 // generate this key.  the secondary should note the KeyButton along
00181 // with the physical key it uses to generate the key press.  on
00182 // release, the secondary can then use the primary's KeyButton to
00183 // find its corresponding physical key and release it.  this is
00184 // necessary because the KeyID on release may not be the KeyID of
00185 // the press.  this can happen with combining (dead) keys or if
00186 // the keyboard layouts are not identical and the user releases
00187 // a modifier key before releasing the modified key.
00188 extern const char*      kMsgDKeyDown;
00189 
00190 // key pressed 1.0:  same as above but without KeyButton
00191 extern const char*      kMsgDKeyDown1_0;
00192 
00193 // key auto-repeat:  primary -> secondary
00194 // $1 = KeyID, $2 = KeyModifierMask, $3 = number of repeats, $4 = KeyButton
00195 extern const char*      kMsgDKeyRepeat;
00196 
00197 // key auto-repeat 1.0:  same as above but without KeyButton
00198 extern const char*      kMsgDKeyRepeat1_0;
00199 
00200 // key released:  primary -> secondary
00201 // $1 = KeyID, $2 = KeyModifierMask, $3 = KeyButton
00202 extern const char*      kMsgDKeyUp;
00203 
00204 // key released 1.0:  same as above but without KeyButton
00205 extern const char*      kMsgDKeyUp1_0;
00206 
00207 // mouse button pressed:  primary -> secondary
00208 // $1 = ButtonID
00209 extern const char*      kMsgDMouseDown;
00210 
00211 // mouse button released:  primary -> secondary
00212 // $1 = ButtonID
00213 extern const char*      kMsgDMouseUp;
00214 
00215 // mouse moved:  primary -> secondary
00216 // $1 = x, $2 = y.  x,y are absolute screen coordinates.
00217 extern const char*      kMsgDMouseMove;
00218 
00219 // relative mouse move:  primary -> secondary
00220 // $1 = dx, $2 = dy.  dx,dy are motion deltas.
00221 extern const char*      kMsgDMouseRelMove;
00222 
00223 // mouse scroll:  primary -> secondary
00224 // $1 = xDelta, $2 = yDelta.  the delta should be +120 for one tick forward
00225 // (away from the user) or right and -120 for one tick backward (toward
00226 // the user) or left.
00227 extern const char*      kMsgDMouseWheel;
00228 
00229 // mouse vertical scroll:  primary -> secondary
00230 // like as kMsgDMouseWheel except only sends $1 = yDelta.
00231 extern const char*      kMsgDMouseWheel1_0;
00232 
00233 // game device buttons:  primary -> secondary
00234 // $1 = device id
00235 // $2 = buttons bit mask
00236 extern const char*      kMsgDGameButtons;
00237 
00238 // game device sticks:  primary -> secondary
00239 // $1 = device id
00240 // $2 = x1
00241 // $3 = y1
00242 // $4 = x2
00243 // $5 = y2
00244 extern const char*      kMsgDGameSticks;
00245 
00246 // game device triggers:  primary -> secondary
00247 // $1 = device id
00248 // $2 = t1
00249 // $3 = t2
00250 extern const char*      kMsgDGameTriggers;
00251 
00252 // game device feedback: secondary -> primary
00253 // $1 = device id
00254 // $2 = motor 1
00255 // $3 = motor 2
00256 extern const char*      kMsgDGameFeedback;
00257 
00258 // clipboard data:  primary <-> secondary
00259 // $2 = sequence number, $3 = clipboard data.  the sequence number
00260 // is 0 when sent by the primary.  secondary screens should use the
00261 // sequence number from the most recent kMsgCEnter.  $1 = clipboard
00262 // identifier.
00263 extern const char*      kMsgDClipboard;
00264 
00265 // client data:  secondary -> primary
00266 // $1 = coordinate of leftmost pixel on secondary screen,
00267 // $2 = coordinate of topmost pixel on secondary screen,
00268 // $3 = width of secondary screen in pixels,
00269 // $4 = height of secondary screen in pixels,
00270 // $5 = size of warp zone, (obsolete)
00271 // $6, $7 = the x,y position of the mouse on the secondary screen.
00272 //
00273 // the secondary screen must send this message in response to the
00274 // kMsgQInfo message.  it must also send this message when the
00275 // screen's resolution changes.  in this case, the secondary screen
00276 // should ignore any kMsgDMouseMove messages until it receives a
00277 // kMsgCInfoAck in order to prevent attempts to move the mouse off
00278 // the new screen area.
00279 extern const char*      kMsgDInfo;
00280 
00281 // set options:  primary -> secondary
00282 // client should set the given option/value pairs.  $1 = option/value
00283 // pairs.
00284 extern const char*      kMsgDSetOptions;
00285 
00286 // crypto iv:  primary -> secondary
00287 // sends a new iv (initialization vector) to the client for the
00288 // cryptography stream.
00289 extern const char*      kMsgDCryptoIv;
00290 
00291 //
00292 // query codes
00293 //
00294 
00295 // query screen info:  primary -> secondary
00296 // client should reply with a kMsgDInfo.
00297 extern const char*      kMsgQInfo;
00298 
00299 
00300 //
00301 // error codes
00302 //
00303 
00304 // incompatible versions:  primary -> secondary
00305 // $1 = major version of primary, $2 = minor version of primary.
00306 extern const char*      kMsgEIncompatible;
00307 
00308 // name provided when connecting is already in use:  primary -> secondary
00309 extern const char*      kMsgEBusy;
00310 
00311 // unknown client:  primary -> secondary
00312 // name provided when connecting is not in primary's screen
00313 // configuration map.
00314 extern const char*      kMsgEUnknown;
00315 
00316 // protocol violation:  primary -> secondary
00317 // primary should disconnect after sending this message.
00318 extern const char*      kMsgEBad;
00319 
00320 
00321 //
00322 // structures
00323 //
00324 
00326 
00329 class CClientInfo {
00330 public:
00332 
00336     SInt32              m_x, m_y;
00337 
00339 
00342     SInt32              m_w, m_h;
00343 
00345     SInt32              obsolete1;
00346 
00348 
00351     SInt32              m_mx, m_my;
00352 };
00353 
00354 #endif
00355 

Generated on Thu May 23 2013 00:00:04 for Synergy by  doxygen 1.7.1