2002-08-02 23:57:46 +04:00
|
|
|
/*
|
|
|
|
* synergy -- mouse and keyboard sharing utility
|
|
|
|
* Copyright (C) 2002 Chris Schoeneman
|
|
|
|
*
|
|
|
|
* This package is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* found in the file COPYING that should have accompanied this file.
|
|
|
|
*
|
|
|
|
* This package 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.
|
|
|
|
*/
|
|
|
|
|
2001-10-06 18:13:28 +04:00
|
|
|
#ifndef PROTOCOLTYPES_H
|
|
|
|
#define PROTOCOLTYPES_H
|
|
|
|
|
|
|
|
#include "BasicTypes.h"
|
|
|
|
|
2002-07-29 20:07:26 +04:00
|
|
|
// protocol version number
|
2002-07-31 20:57:26 +04:00
|
|
|
static const SInt16 kProtocolMajorVersion = 1;
|
|
|
|
static const SInt16 kProtocolMinorVersion = 0;
|
2001-10-06 18:13:28 +04:00
|
|
|
|
2002-07-29 20:07:26 +04:00
|
|
|
// default contact port number
|
2002-06-09 20:53:25 +04:00
|
|
|
static const UInt16 kDefaultPort = 24800;
|
|
|
|
|
2002-07-30 22:31:00 +04:00
|
|
|
// maximum total length for greeting returned by client
|
|
|
|
static const UInt32 kMaxHelloLength = 1024;
|
|
|
|
|
2002-07-30 22:49:31 +04:00
|
|
|
// time between heartbeats (in seconds). negative value disables
|
|
|
|
// heartbeat.
|
|
|
|
static const double kHeartRate = -1.0;
|
2002-06-26 20:31:48 +04:00
|
|
|
|
2003-02-22 19:20:23 +03:00
|
|
|
// number of skipped heartbeats that constitutes death
|
|
|
|
static const double kHeartBeatsUntilDeath = 3.0;
|
2002-06-26 20:31:48 +04:00
|
|
|
|
2002-07-15 19:01:36 +04:00
|
|
|
// direction constants
|
|
|
|
enum EDirection {
|
2003-02-23 22:29:08 +03:00
|
|
|
kNoDirection,
|
2002-07-15 19:01:36 +04:00
|
|
|
kLeft,
|
|
|
|
kRight,
|
|
|
|
kTop,
|
|
|
|
kBottom,
|
|
|
|
kFirstDirection = kLeft,
|
2003-02-23 22:29:08 +03:00
|
|
|
kLastDirection = kBottom,
|
|
|
|
kNumDirections = kLastDirection - kFirstDirection + 1
|
2002-07-15 19:01:36 +04:00
|
|
|
};
|
|
|
|
enum EDirectionMask {
|
2003-02-23 22:29:08 +03:00
|
|
|
kNoDirMask = 0,
|
2002-07-15 19:01:36 +04:00
|
|
|
kLeftMask = 1 << kLeft,
|
|
|
|
kRightMask = 1 << kRight,
|
|
|
|
kTopMask = 1 << kTop,
|
|
|
|
kBottomMask = 1 << kBottom
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2002-04-27 18:19:53 +04:00
|
|
|
//
|
|
|
|
// message codes (trailing NUL is not part of code). in comments, $n
|
|
|
|
// refers to the n'th argument (counting from one). message codes are
|
2002-07-30 22:31:00 +04:00
|
|
|
// always 4 bytes optionally followed by message specific parameters
|
|
|
|
// except those for the greeting handshake.
|
2002-04-27 18:19:53 +04:00
|
|
|
//
|
|
|
|
|
2002-06-19 21:03:29 +04:00
|
|
|
//
|
|
|
|
// positions and sizes are signed 16 bit integers.
|
|
|
|
//
|
|
|
|
|
2002-07-30 22:31:00 +04:00
|
|
|
//
|
|
|
|
// greeting handshake messages
|
|
|
|
//
|
|
|
|
|
|
|
|
// say hello to client; primary -> secondary
|
|
|
|
// $1 = protocol major version number supported by server. $2 =
|
|
|
|
// protocol minor version number supported by server.
|
|
|
|
static const char kMsgHello[] = "Synergy%2i%2i";
|
|
|
|
|
|
|
|
// respond to hello from server; secondary -> primary
|
|
|
|
// $1 = protocol major version number supported by client. $2 =
|
|
|
|
// protocol minor version number supported by client. $3 = client
|
|
|
|
// name.
|
|
|
|
static const char kMsgHelloBack[] = "Synergy%2i%2i%s";
|
|
|
|
|
|
|
|
|
2002-04-27 18:19:53 +04:00
|
|
|
//
|
|
|
|
// command codes
|
|
|
|
//
|
|
|
|
|
2002-06-26 20:31:48 +04:00
|
|
|
// no operation; secondary -> primary
|
|
|
|
static const char kMsgCNoop[] = "CNOP";
|
|
|
|
|
2002-04-27 18:19:53 +04:00
|
|
|
// close connection; primary -> secondary
|
|
|
|
static const char kMsgCClose[] = "CBYE";
|
|
|
|
|
|
|
|
// enter screen: primary -> secondary
|
|
|
|
// entering screen at screen position $1 = x, $2 = y. x,y are
|
2002-04-29 17:31:44 +04:00
|
|
|
// absolute screen coordinates. $3 = sequence number, which is
|
|
|
|
// used to order messages between screens. the secondary screen
|
2002-04-30 21:48:11 +04:00
|
|
|
// must return this number with some messages. $4 = modifier key
|
|
|
|
// mask. this will have bits set for each toggle modifier key
|
|
|
|
// that is activated on entry to the screen. the secondary screen
|
|
|
|
// should adjust its toggle modifiers to reflect that state.
|
|
|
|
static const char kMsgCEnter[] = "CINN%2i%2i%4i%2i";
|
2002-04-27 18:19:53 +04:00
|
|
|
|
|
|
|
// leave screen: primary -> secondary
|
2002-04-29 17:31:44 +04:00
|
|
|
// leaving screen. the secondary screen should send clipboard
|
|
|
|
// data in response to this message for those clipboards that
|
|
|
|
// it has grabbed (i.e. has sent a kMsgCClipboard for and has
|
|
|
|
// not received a kMsgCClipboard for with a greater sequence
|
|
|
|
// number) and that were grabbed or have changed since the
|
|
|
|
// last leave.
|
2002-04-27 18:19:53 +04:00
|
|
|
static const char kMsgCLeave[] = "COUT";
|
|
|
|
|
|
|
|
// grab clipboard: primary <-> secondary
|
|
|
|
// sent by screen when some other app on that screen grabs a
|
2002-04-29 17:31:44 +04:00
|
|
|
// clipboard. $1 = the clipboard identifier, $2 = sequence number.
|
|
|
|
// secondary screens must use the sequence number passed in the
|
|
|
|
// most recent kMsgCEnter. the primary always sends 0.
|
|
|
|
static const char kMsgCClipboard[] = "CCLP%1i%4i";
|
2002-04-27 18:19:53 +04:00
|
|
|
|
|
|
|
// screensaver change: primary -> secondary
|
|
|
|
// screensaver on primary has started ($1 == 1) or closed ($1 == 0)
|
|
|
|
static const char kMsgCScreenSaver[] = "CSEC%1i";
|
|
|
|
|
2002-12-23 16:55:21 +03:00
|
|
|
// reset options: primary -> secondary
|
|
|
|
// client should reset all of its options to their defaults.
|
|
|
|
static const char kMsgCResetOptions[] = "CROP";
|
|
|
|
|
2002-05-24 21:54:28 +04:00
|
|
|
// resolution change acknowledgment: primary -> secondary
|
|
|
|
// sent by primary in response to a secondary screen's kMsgDInfo.
|
|
|
|
// this is sent for every kMsgDInfo, whether or not the primary
|
|
|
|
// had sent a kMsgQInfo.
|
2002-07-24 17:01:18 +04:00
|
|
|
static const char kMsgCInfoAck[] = "CIAK";
|
2002-05-24 21:54:28 +04:00
|
|
|
|
2002-04-27 18:19:53 +04:00
|
|
|
|
|
|
|
//
|
|
|
|
// data codes
|
|
|
|
//
|
|
|
|
|
|
|
|
// key pressed: primary -> secondary
|
|
|
|
// $1 = KeyID, $2 = KeyModifierMask
|
|
|
|
static const char kMsgDKeyDown[] = "DKDN%2i%2i";
|
|
|
|
|
|
|
|
// key auto-repeat: primary -> secondary
|
|
|
|
// $1 = KeyID, $2 = KeyModifierMask, $3 = number of repeats
|
|
|
|
static const char kMsgDKeyRepeat[] = "DKRP%2i%2i%2i";
|
|
|
|
|
|
|
|
// key released: primary -> secondary
|
|
|
|
// $1 = KeyID, $2 = KeyModifierMask
|
|
|
|
static const char kMsgDKeyUp[] = "DKUP%2i%2i";
|
|
|
|
|
|
|
|
// mouse button pressed: primary -> secondary
|
|
|
|
// $1 = ButtonID
|
|
|
|
static const char kMsgDMouseDown[] = "DMDN%1i";
|
|
|
|
|
|
|
|
// mouse button released: primary -> secondary
|
|
|
|
// $1 = ButtonID
|
|
|
|
static const char kMsgDMouseUp[] = "DMUP%1i";
|
|
|
|
|
|
|
|
// mouse moved: primary -> secondary
|
|
|
|
// $1 = x, $2 = y. x,y are absolute screen coordinates.
|
|
|
|
static const char kMsgDMouseMove[] = "DMMV%2i%2i";
|
|
|
|
|
|
|
|
// mouse button pressed: primary -> secondary
|
2002-05-24 21:54:28 +04:00
|
|
|
// $1 = delta. the delta should be +120 for one tick forward (away
|
|
|
|
// from the user) and -120 for one tick backward (toward the user).
|
2002-04-27 18:19:53 +04:00
|
|
|
static const char kMsgDMouseWheel[] = "DMWM%2i";
|
|
|
|
|
|
|
|
// clipboard data: primary <-> secondary
|
|
|
|
// $2 = sequence number, $3 = clipboard data. the sequence number
|
2002-04-29 17:31:44 +04:00
|
|
|
// is 0 when sent by the primary. secondary screens should use the
|
|
|
|
// sequence number from the most recent kMsgCEnter. $1 = clipboard
|
|
|
|
// identifier.
|
2002-04-27 18:19:53 +04:00
|
|
|
static const char kMsgDClipboard[] = "DCLP%1i%4i%s";
|
|
|
|
|
2002-04-27 22:06:40 +04:00
|
|
|
// client data: secondary -> primary
|
2002-06-19 21:03:29 +04:00
|
|
|
// $1 = coordinate of leftmost pixel on secondary screen,
|
|
|
|
// $2 = coordinate of topmost pixel on secondary screen,
|
|
|
|
// $3 = width of secondary screen in pixels,
|
|
|
|
// $4 = height of secondary screen in pixels,
|
|
|
|
// $5 = size of warp zone,
|
|
|
|
// $6, $7 = the x,y position of the mouse on the secondary screen.
|
2002-05-24 21:54:28 +04:00
|
|
|
//
|
|
|
|
// the secondary screen must send this message in response to the
|
|
|
|
// kMsgQInfo message. it must also send this message when the
|
|
|
|
// screen's resolution changes. in this case, the secondary screen
|
|
|
|
// should ignore any kMsgDMouseMove messages until it receives a
|
|
|
|
// kMsgCInfoAck in order to prevent attempts to move the mouse off
|
|
|
|
// the new screen area.
|
2002-06-19 21:03:29 +04:00
|
|
|
static const char kMsgDInfo[] = "DINF%2i%2i%2i%2i%2i%2i%2i";
|
2002-04-27 18:19:53 +04:00
|
|
|
|
2002-12-23 16:55:21 +03:00
|
|
|
// set options: primary -> secondary
|
|
|
|
// client should set the given option/value pairs. $1 = option/value
|
|
|
|
// pairs.
|
|
|
|
static const char kMsgDSetOptions[] = "DSOP%4I";
|
|
|
|
|
2002-04-27 18:19:53 +04:00
|
|
|
|
|
|
|
//
|
|
|
|
// query codes
|
|
|
|
//
|
|
|
|
|
|
|
|
// query screen info: primary -> secondary
|
|
|
|
// client should reply with a kMsgDInfo.
|
|
|
|
static const char kMsgQInfo[] = "QINF";
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
// error codes
|
|
|
|
//
|
2001-10-06 18:13:28 +04:00
|
|
|
|
2002-05-23 18:56:03 +04:00
|
|
|
// incompatible versions: primary -> secondary
|
|
|
|
// $1 = major version of primary, $2 = minor version of primary.
|
|
|
|
static const char kMsgEIncompatible[] = "EICV%2i%2i";
|
|
|
|
|
|
|
|
// name provided when connecting is already in use: primary -> secondary
|
2002-07-24 17:01:18 +04:00
|
|
|
static const char kMsgEBusy[] = "EBSY";
|
2002-05-23 18:56:03 +04:00
|
|
|
|
2002-05-31 22:18:29 +04:00
|
|
|
// unknown client: primary -> secondary
|
|
|
|
// name provided when connecting is not in primary's screen
|
|
|
|
// configuration map.
|
2002-07-24 17:01:18 +04:00
|
|
|
static const char kMsgEUnknown[] = "EUNK";
|
2002-05-31 22:18:29 +04:00
|
|
|
|
2002-05-23 18:56:03 +04:00
|
|
|
// protocol violation: primary -> secondary
|
|
|
|
// primary should disconnect after sending this message.
|
2002-07-24 17:01:18 +04:00
|
|
|
static const char kMsgEBad[] = "EBAD";
|
2001-10-06 18:13:28 +04:00
|
|
|
|
2002-07-10 18:15:17 +04:00
|
|
|
|
|
|
|
//
|
|
|
|
// structures
|
|
|
|
//
|
|
|
|
|
2002-07-29 20:07:26 +04:00
|
|
|
//! Screen information
|
|
|
|
/*!
|
|
|
|
This class contains information about a screen.
|
|
|
|
*/
|
2002-07-10 18:15:17 +04:00
|
|
|
class CClientInfo {
|
|
|
|
public:
|
2002-07-29 20:07:26 +04:00
|
|
|
//! Screen position
|
|
|
|
/*!
|
|
|
|
The position of the upper-left corner of the screen. This is
|
|
|
|
typically 0,0.
|
|
|
|
*/
|
2002-07-10 18:15:17 +04:00
|
|
|
SInt32 m_x, m_y;
|
2002-07-29 20:07:26 +04:00
|
|
|
|
|
|
|
//! Screen size
|
|
|
|
/*!
|
|
|
|
The size of the screen in pixels.
|
|
|
|
*/
|
2002-07-10 18:15:17 +04:00
|
|
|
SInt32 m_w, m_h;
|
|
|
|
|
2002-07-29 20:07:26 +04:00
|
|
|
//! Jump zone size
|
|
|
|
/*!
|
|
|
|
This is the size of the jump zone. The cursor jumps to the adjacent
|
|
|
|
screen when it comes within this many pixels of the edge of the screen.
|
|
|
|
*/
|
2002-07-10 18:15:17 +04:00
|
|
|
SInt32 m_zoneSize;
|
|
|
|
|
2002-07-29 20:07:26 +04:00
|
|
|
//! Mouse position
|
|
|
|
/*!
|
|
|
|
The position of the cursor. This is not kept up-to-date so it's
|
|
|
|
only meaningful when receiving an update.
|
|
|
|
*/
|
2002-07-10 18:15:17 +04:00
|
|
|
SInt32 m_mx, m_my;
|
|
|
|
};
|
|
|
|
|
2001-10-06 18:13:28 +04:00
|
|
|
#endif
|
|
|
|
|