/************************************************************************/ /* SendButton - Payload format */ /* %i - button code */ /* %i - flags 0x01 => use button map/name instead of code */ /* 0x02 => btn down */ /* 0x04 => btn up */ /* 0x08 => use amount */ /* 0x10 => queue event */ /* 0x20 => do not repeat */ /* 0x40 => virtual key */ /* 0x80 => axis key */ /* %i - amount ( 0 => 65k maps to -1 => 1 ) */ /* %s - device map (case sensitive and required if flags & 0x01) */ /* "KB" - Standard keyboard map */ /* "XG" - Xbox Gamepad */ /* "R1" - Xbox Remote */ /* "R2" - Xbox Universal Remote */ /* "LI:devicename" - valid LIRC device map where 'devicename' */ /* is the actual name of the LIRC device */ /* "JS<num>:joyname" - valid Joystick device map where */ /* 'joyname' is the name specified in */ /* the keymap. JS only supports button code */ /* and not button name currently (!0x01). */ /* %s - button name (required if flags & 0x01) */ /************************************************************************/ private bool SendButton(string Button, ushort ButtonCode, string DeviceMap, ButtonFlagsType Flags, short Amount) { if (Button.Length != 0) { if ((Flags & ButtonFlagsType.BTN_USE_NAME) == 0) { Flags |= ButtonFlagsType.BTN_USE_NAME; } ButtonCode = 0; } else { Button = ""; } if (Amount > 0) { if ((Flags & ButtonFlagsType.BTN_USE_AMOUNT) == 0) { Flags |= ButtonFlagsType.BTN_USE_AMOUNT; } } if ((Flags & ButtonFlagsType.BTN_DOWN) == 0 && (Flags & ButtonFlagsType.BTN_UP) == 0) { Flags |= ButtonFlagsType.BTN_DOWN; } byte[] payload = new byte[Button.Length + DeviceMap.Length + 8]; int offset = 0; payload[offset++] = (byte)((ButtonCode & 0xff00) >> 8); payload[offset++] = (byte)(ButtonCode & 0x00ff); payload[offset++] = (byte)(((ushort)Flags & 0xff00) >> 8); payload[offset++] = (byte)((ushort)Flags & 0x00ff); payload[offset++] = (byte)((Amount & 0xff00) >> 8); payload[offset++] = (byte)(Amount & 0x00ff); for (int i = 0; i < DeviceMap.Length; i++) { payload[offset++] = (byte)DeviceMap[i]; } payload[offset++] = (byte)'\0'; for (int i = 0; i < Button.Length; i++) { payload[offset++] = (byte)Button[i]; } payload[offset++] = (byte)'\0'; return(Send(PacketType.PT_BUTTON, payload)); }
public bool SendButton(ushort ButtonCode, ButtonFlagsType Flags) { return(SendButton("", ButtonCode, "", Flags, 0)); }
public bool SendButton(ushort ButtonCode, ButtonFlagsType Flags, short Amount) { return(SendButton("", ButtonCode, "", Flags, Amount)); }
public bool SendButton(ushort ButtonCode, string DeviceMap, ButtonFlagsType Flags) { return(SendButton("", ButtonCode, DeviceMap, Flags, 0)); }
public bool SendButton(string Button, string DeviceMap, ButtonFlagsType Flags) { return(SendButton(Button, 0, DeviceMap, Flags, 0)); }
public bool SendButton(string Button, string DeviceMap, ButtonFlagsType Flags, short Amount) { return(SendButton(Button, 0, DeviceMap, Flags, Amount)); }
/************************************************************************/ /* SendButton - Payload format */ /* %i - button code */ /* %i - flags 0x01 => use button map/name instead of code */ /* 0x02 => btn down */ /* 0x04 => btn up */ /* 0x08 => use amount */ /* 0x10 => queue event */ /* 0x20 => do not repeat */ /* 0x40 => virtual key */ /* 0x80 => axis key */ /* %i - amount ( 0 => 65k maps to -1 => 1 ) */ /* %s - device map (case sensitive and required if flags & 0x01) */ /* "KB" - Standard keyboard map */ /* "XG" - Xbox Gamepad */ /* "R1" - Xbox Remote */ /* "R2" - Xbox Universal Remote */ /* "LI:devicename" - valid LIRC device map where 'devicename' */ /* is the actual name of the LIRC device */ /* "JS<num>:joyname" - valid Joystick device map where */ /* 'joyname' is the name specified in */ /* the keymap. JS only supports button code */ /* and not button name currently (!0x01). */ /* %s - button name (required if flags & 0x01) */ /************************************************************************/ private bool SendButton(string Button, ushort ButtonCode, string DeviceMap, ButtonFlagsType Flags, short Amount) { if (Button.Length != 0) { if ((Flags & ButtonFlagsType.BTN_USE_NAME) == 0) Flags |= ButtonFlagsType.BTN_USE_NAME; ButtonCode = 0; } else Button = ""; if (Amount > 0) { if ((Flags & ButtonFlagsType.BTN_USE_AMOUNT) == 0) Flags |= ButtonFlagsType.BTN_USE_AMOUNT; } if ((Flags & ButtonFlagsType.BTN_DOWN) == 0 || (Flags & ButtonFlagsType.BTN_UP) == 0) Flags |= ButtonFlagsType.BTN_DOWN; byte[] payload = new byte[Button.Length + DeviceMap.Length + 8]; int offset = 0; payload[offset++] = (byte)((ButtonCode & 0xff00) >> 8); payload[offset++] = (byte)(ButtonCode & 0x00ff); payload[offset++] = (byte)(((ushort)Flags & 0xff00) >> 8); payload[offset++] = (byte)((ushort)Flags & 0x00ff); payload[offset++] = (byte)((Amount & 0xff00) >> 8); payload[offset++] = (byte)(Amount & 0x00ff); for (int i = 0; i < DeviceMap.Length; i++) payload[offset++] = (byte)DeviceMap[i]; payload[offset++] = (byte)'\0'; for (int i = 0; i < Button.Length; i++) payload[offset++] = (byte)Button[i]; payload[offset++] = (byte)'\0'; return Send(PacketType.PT_BUTTON, payload); }
public bool SendButton(ushort ButtonCode, ButtonFlagsType Flags, short Amount) { return SendButton("", ButtonCode, "", Flags, Amount); }
public bool SendButton(ushort ButtonCode, ButtonFlagsType Flags) { return SendButton("", ButtonCode, "", Flags, 0); }
public bool SendButton(string Button, string DeviceMap, ButtonFlagsType Flags) { return SendButton(Button, 0, DeviceMap, Flags, 0); }
public bool SendButton(ushort ButtonCode, string DeviceMap, ButtonFlagsType Flags) { return SendButton("", ButtonCode, DeviceMap, Flags, 0); }
public bool SendButton(string Button, string DeviceMap, ButtonFlagsType Flags, short Amount) { return SendButton(Button, 0, DeviceMap, Flags, Amount); }
public void SendButton(string Button, string DeviceMap, ButtonFlagsType Flags) { SendButton(Button, 0, DeviceMap, Flags, 0); }
public void SendButton(string Button, string DeviceMap, ButtonFlagsType Flags, short Amount) { SendButton(Button, 0, DeviceMap, Flags, Amount); }