Class SendHIDEventMessage
- Namespace
- AppleTvControlLibrary.Mrp.Protobuf
- Assembly
- AppleTvControlLibrary.Mrp.dll
public sealed class SendHIDEventMessage : IMessage<SendHIDEventMessage>, IEquatable<SendHIDEventMessage>, IDeepCloneable<SendHIDEventMessage>, IBufferMessage, IMessage
- Inheritance
-
SendHIDEventMessage
- Implements
-
IMessage<SendHIDEventMessage>IDeepCloneable<SendHIDEventMessage>IBufferMessageIMessage
- Inherited Members
Constructors
SendHIDEventMessage()
public SendHIDEventMessage()
SendHIDEventMessage(SendHIDEventMessage)
public SendHIDEventMessage(SendHIDEventMessage other)
Parameters
otherSendHIDEventMessage
Fields
HidEventDataFieldNumber
Field number for the "hidEventData" field.
public const int HidEventDataFieldNumber = 1
Field Value
Properties
Descriptor
public static MessageDescriptor Descriptor { get; }
Property Value
- MessageDescriptor
HasHidEventData
Gets whether the "hidEventData" field is set
public bool HasHidEventData { get; }
Property Value
HidEventData
This data corresponds to a "keyboardEvent" in IOHIDEvent.h encoded as raw data. Here is one source:
https://opensource.apple.com/source/IOHIDFamily/IOHIDFamily-308/IOHIDFamily/IOHIDEvent.h.auto.html
The interesting parts are:
- usagePage (UInt32)
- usage (Uint32)
- down (bool)
The parameters usagePage and usage corresponds to the key being pressed. It is mapped to the USB HID values, which can be found here:
https://github.com/Daij-Djan/DDHidLib/blob/master/usb_hid_usages.txt
Pressing left key would for instance map to usagePage=0x01, usage=0x8B. In the hid data, these values are stored as big endian uint16 values in the mentioned order. So the same example would be: 0x0001008B0001, assuming down = true (key being pressed). For each key press, the same usagePage and usage are sent with down=true and down=false (key down + key up).
There is a bit of magic in the raw data that's just not decoded yet, but that doesn't matter. Just use this and it will work:
438922cf080200000000000000000000010000000000000002000000200000000300000001000000000000<data>0000000000000001000000
<data> corresponds to the values above, e.g. 0001008B0001. The first 8 bytes is a timestamp (mach AbsoluteTime). It's a bit tricky to derive but tvOS seems to accept old timestamps here. So it's probably fine to send anything.
public ByteString HidEventData { get; set; }
Property Value
- ByteString
Parser
public static MessageParser<SendHIDEventMessage> Parser { get; }
Property Value
- MessageParser<SendHIDEventMessage>
Methods
CalculateSize()
Calculates the size of this message in Protocol Buffer wire format, in bytes.
public int CalculateSize()
Returns
- int
The number of bytes required to write this message to a coded output stream.
ClearHidEventData()
Clears the value of the "hidEventData" field
public void ClearHidEventData()
Clone()
Creates a deep clone of this object.
public SendHIDEventMessage Clone()
Returns
- SendHIDEventMessage
A deep clone of this object.
Equals(SendHIDEventMessage)
Indicates whether the current object is equal to another object of the same type.
public bool Equals(SendHIDEventMessage other)
Parameters
otherSendHIDEventMessageAn object to compare with this object.
Returns
Equals(object)
Determines whether the specified object is equal to the current object.
public override bool Equals(object other)
Parameters
otherobject
Returns
GetHashCode()
Serves as the default hash function.
public override int GetHashCode()
Returns
- int
A hash code for the current object.
MergeFrom(SendHIDEventMessage)
Merges the given message into this one.
public void MergeFrom(SendHIDEventMessage other)
Parameters
otherSendHIDEventMessage
Remarks
See the user guide for precise merge semantics.
MergeFrom(CodedInputStream)
Merges the data from the specified coded input stream with the current message.
public void MergeFrom(CodedInputStream input)
Parameters
inputCodedInputStream
Remarks
See the user guide for precise merge semantics.
ToString()
Returns a string that represents the current object.
public override string ToString()
Returns
- string
A string that represents the current object.
WriteTo(CodedOutputStream)
Writes the data to the given coded output stream.
public void WriteTo(CodedOutputStream output)
Parameters
outputCodedOutputStreamCoded output stream to write the data to. Must not be null.