/***************************************************************************
*
*  simplified.h
*
*  Simplified interfaces to internal client functions.
*
*  $Id$
*
*  Copyright 2010-2015 Citrix Systems, Inc. All Rights Reserved.
*
****************************************************************************/

#ifndef __SIMPLIFIED_H__
#define __SIMPLIFIED_H__

/* Send a key-down or key-up event to the server.  The first argument
 * is either a 16-bit Unicode value, or if WND_UNICODECHAR_SPECIAL is set,
 * one of the special key values listed in xkeytran.h (typedef SpecialKeys).
 * If WND_UNICODECHAR_INSERT is set, the other flags must be clear and the
 * Unicode value is passed directly to the application on Windows servers.
 * Some Windows applications do not support that.
 */

void Send_unicode(unsigned short uc, int flags);

/* Values for flags argument.   See also src/inc/keytypes.h. */

#ifndef WND_UNICODECHAR_KEYUP
#define WND_UNICODECHAR_KEYUP   0x01
#define WND_UNICODECHAR_SPECIAL 0x02
#endif /*  WND_UNICODECHAR_KEYUP */
#define WND_UNICODECHAR_INSERT  0x04

/* It is also possible to send keyboard events as raw IBM PC scancodes.
 * Return value is 0, or an error code.   This is recommended only for
 * special keys on non-standard keyboards.
 */

int Send_scancodes(unsigned char *codes, unsigned int count);

/* Unix servers also accept keysyms: flags is WND_UNICODECHAR_KEYUP or 0.
 * Return value is 0, or an error code.
 */

int Send_keysym(UINT32 keysym, int flags);

/* Send updated mouse position and/or button state to the server.
 * The position will be modfied, if necessary, to keep it within the session.
 */

void Mouse_changed(int *x, int *y, unsigned int buttons);

#ifndef MOU_STATUS_MOVED
#define MOU_STATUS_MOVED           0x01
#define MOU_STATUS_B1DOWN          0x02
#define MOU_STATUS_B1UP            0x04
#define MOU_STATUS_B2DOWN          0x08
#define MOU_STATUS_B2UP            0x10
#define MOU_STATUS_B3DOWN          0x20 /* This is the middle button! */
#define MOU_STATUS_B3UP            0x40
#endif /* MOU_STATUS_MOVED */

/* The following definitions are unique to this header file. */

#define MOU_STATUS_XB4DOWN        0x100
#define MOU_STATUS_XB4UP          0x200
#define MOU_STATUS_XB5DOWN        0x400
#define MOU_STATUS_XB5UP          0x800

#define MOU_STATUS_XVWUP        0x10000 /* Vertical scroll wheel. */
#define MOU_STATUS_XVWDOWN      0x20000

/* Horizontal scroll support and relative mouse motion require
 * Plugin interface version 1.4 or later and use must be negotiated.
 *
 * Once relative motion is negotiated, button and wheel events without
 * the MOU_STATUS_RELATIVE are ignored.  That allows use of separate
 * relative and absolute paths in systems that provide it, such as X11.
 * Some absolute motion events may be interspersed with relative motion events
 * to maintain synchronisation of the visible cursor position.
 */

#define MOU_STATUS_XHWLEFT      0x40000 /* Horizontal scroll wheel. */
#define MOU_STATUS_XHWRIGHT     0x80000

#define MOU_STATUS_RELATIVE  0x10000000 /* x and y are increments
                                         * when MOU_STATUS_MOVED is set.
                                         */

/* Given a button number and a down/up change indicator,
 * perform any user-specified remapping or special actions and return
 * a set of flag values suitable for input to Mouse_changed().
 * Callers are expected to add the MOU_STATUS_MOVED flag where appropriate.
 * If the no flags are set, Mouse_changed() should not be called.
 *
 * Button numbers are Unix-style (1,2,3, with 2 in the middle), not
 * Windows-style (1,3,2) as above.
 */

unsigned int Map_button(unsigned int button, BOOLEAN down);

/* Pause and resume Thinwire generation on the server. */

void WD_pause_TW(void);
void WD_resume_TW(void);

#endif /*  __SIMPLIFIED_H__ */

