Beispiel #1
0
        /// \brief Sends a generic block of data to the Wii Remote using the specified Output Report.
        /// \param type The output report type you would like to send
        /// \param data The raw data you would like to send using the specified \c type.
        /// \return On success, the total size of the data written, -1 if HIDApi reports an error, or < -1 if there is an invalid input.
        ///
        /// This should only be used to send custom data to the Wii Remote that is currently unimplemented by WiimoteApi.
        /// In any average use case you can use any of the higher-level output functions provided by WiimoteApi.
        ///
        /// The Wii Remote rumble settings are also updated based on RumbleOn.
        public int SendWithType(OutputDataType type, byte[] data)
        {
            byte[] final = new byte[data.Length + 1];
            final[0] = (byte)type;

            for (int x = 0; x < data.Length; x++)
            {
                final[x + 1] = data[x];
            }

            if (RumbleOn)
            {
                final[1] |= 0x01;
            }

            int res = WiimoteManager.SendRaw(hidapi_handle, final);

            if (res < -1)
            {
                Debug.LogError("Incorrect Input to HIDAPI.  No data has been sent.");
            }


            return(res);
        }