SPICE输入通道主要控制鼠标和键盘的操作
enum { SPICE_MSG_INPUTS_INIT = 101, SPICE_MSG_INPUTS_KEY_MODIFIERS, SPICE_MSG_INPUTS_MOUSE_MOTION_ACK = 111, SPICE_MSG_END_INPUTS };
enum { SPICE_MSGC_INPUTS_KEY_DOWN = 101, SPICE_MSGC_INPUTS_KEY_UP, SPICE_MSGC_INPUTS_KEY_MODIFIERS, SPICE_MSGC_INPUTS_KEY_SCANCODE, SPICE_MSGC_INPUTS_MOUSE_MOTION = 111, SPICE_MSGC_INPUTS_MOUSE_POSITION, SPICE_MSGC_INPUTS_MOUSE_PRESS, SPICE_MSGC_INPUTS_MOUSE_RELEASE, SPICE_MSGC_END_INPUTS };
SPICE协议支持发送键盘事件和同步键盘指示灯功能。客户端发送键盘事件SPICE_MSGC_INPUTS_KEY_UP、SPICE_MSGC_INPUTS_KEY_DOWN消息。键值使用PC AT码表示。键盘指示灯同步是通过客户端发送SPICE_MSGC_INPUTS_KEY_MODIFIERS或者服务器端发送SPICE_MSG_INPUTS_KEY_MODIFIERS消息。这些消息中保存了键盘指示灯的状态。服务器同样可以使用SPICE_MSG_INPUTS_INIT消息发送键盘的修改。这个消息必须是第一个接收到的消息,后续不应该再发送。
typedef enumSpiceKeyboardModifierFlags { SPICE_KEYBOARD_MODIFIER_FLAGS_SCROLL_LOCK =(1 << 0), SPICE_KEYBOARD_MODIFIER_FLAGS_NUM_LOCK = (1<< 1), SPICE_KEYBOARD_MODIFIER_FLAGS_CAPS_LOCK =(1 << 2), SPICE_KEYBOARD_MODIFIER_FLAGS_MASK = 0x7 } SpiceKeyboardModifierFlags;
enum { SPICE_MSGC_INPUTS_KEY_DOWN = 101, SPICE_MSGC_INPUTS_KEY_UP, SPICE_MSGC_INPUTS_KEY_MODIFIERS, SPICE_MSGC_INPUTS_KEY_SCANCODE, SPICE_MSGC_INPUTS_MOUSE_MOTION = 111, SPICE_MSGC_INPUTS_MOUSE_POSITION, SPICE_MSGC_INPUTS_MOUSE_PRESS, SPICE_MSGC_INPUTS_MOUSE_RELEASE, SPICE_MSGC_END_INPUTS };
enum { SPICE_MSG_INPUTS_INIT = 101, SPICE_MSG_INPUTS_KEY_MODIFIERS, SPICE_MSG_INPUTS_MOUSE_MOTION_ACK = 111, SPICE_MSG_END_INPUTS };
typedef structSpiceMsgcKeyDown { uint32_t code; }SpiceMsgcKeyDown; typedef structSpiceMsgcKeyUp { uint32_t code; }SpiceMsgcKeyUp; typedef structSpiceMsgcKeyModifiers { uint32_t modifiers; }SpiceMsgcKeyModifiers;
SPICE 支持鼠标操作的两种模式:服务器和客户端模式。(更多的参见3.4章节)在服务器模式下,客户端发送鼠标运动消息(SPICE_MSGC_INPUTS_MOUSE_MOTION),客户端模式下,发送位置消息(SPICE_MSGC_INPUTS_MOUSE_POSITION)。位置消息保存客户鼠标的显示位置和显示通道的ID(在RedLinkMess.channel_id)。为了防止鼠标运动、位置时间发送频繁,客户端在收到每个SPICE_MSG_INPUTS_KEY_MODIFIERS消息后会回应SPICE_MSG_INPUTS_MOUSE_MOTION_ACK。这种机制允许客户端跟随服务器的信息和改变事件的推送策略。鼠标按钮事件使用SPICE_MSGC_INPUTS_MOUSE_PRESS和SPICE_MSGC_INPUTS_MOUSE_RELEASE消息发送给服务器。
typedef enumSpiceMouseButton { SPICE_MOUSE_BUTTON_INVALID, SPICE_MOUSE_BUTTON_LEFT, SPICE_MOUSE_BUTTON_MIDDLE, SPICE_MOUSE_BUTTON_RIGHT, SPICE_MOUSE_BUTTON_UP, SPICE_MOUSE_BUTTON_DOWN, SPICE_MOUSE_BUTTON_ENUM_END }SpiceMouseButton;
typedef enumSpiceMouseButtonMask { SPICE_MOUSE_BUTTON_MASK_LEFT = (1 <<0), SPICE_MOUSE_BUTTON_MASK_MIDDLE = (1<< 1), SPICE_MOUSE_BUTTON_MASK_RIGHT = (1 <<2), SPICE_MOUSE_BUTTON_MASK_MASK = 0x7 }SpiceMouseButtonMask;
typedef structSpiceMsgcMouseMotion { int32_t dx; //鼠标移动到的X像素点 int32_t dy; //鼠标移动道德Y像素点 uint32_t buttons_state;//鼠标操作的掩码。 }SpiceMsgcMouseMotion;
typedef structSpiceMsgcMousePosition { uint32_t x; //X 坐标位置 uint32_t y;//Y 坐标位置 uint32_t buttons_state; //鼠标操作的掩码 uint8_t display_id;//客户端鼠标显示的ID }SpiceMsgcMousePosition;
typedef structSpiceMsgcMousePress { int32_t button; //鼠标按键的ID号 int32_t buttons_state; //鼠标操作的掩码 }SpiceMsgcMousePress;
typedef structSpiceMsgcMouseRelease { int32_t button;//鼠标按键的ID号 int32_t buttons_state; //鼠标操作的掩码 }SpiceMsgcMouseRelease;
原文地址:http://blog.csdn.net/sjin_1314/article/details/41874881