/// \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); }
/*------------------------- * Public Methods * -------------------------*/ public void AddNewData(float rd1, float rd2, float rd3, float rd4, float rd5, OutputDataType type) { InputData inData = new InputData(); OutputData outData = new OutputData(); TrainingData newData = new TrainingData(); inData.rayDist1 = rd1; inData.rayDist2 = rd2; inData.rayDist3 = rd3; inData.rayDist4 = rd4; inData.rayDist5 = rd5; outData.left = 1; outData.right = 1; outData.forward = 1; switch (type) { case OutputDataType.Left: outData.left = 0; break; case OutputDataType.Right: outData.right = 0; break; case OutputDataType.Forward: outData.forward = 0; break; default: break; } newData.inData = inData; newData.outData = outData; subTrainingData.Add(newData); }
public void DefaultRawOutputDataHandler(OutputDataType dataType, string line) { if (line == null) { // ignore end of stream if (!PassEndOfStream) { return; } } else { switch (dataType) { case OutputDataType.StdOut: line = string.Concat(StdOutPrefix, line); break; case OutputDataType.StdErr: line = string.Concat(StdErrPrefix, line); break; case OutputDataType.CmdLine: line = string.Concat(CommandLinePrefix, line); break; } ; if (TeeToConsole) { Console.WriteLine(line); } } OutputDataHandler(dataType, line); }
public static string ToString(byte[] r, OutputDataType type) { switch (type) { case OutputDataType.Base64: return ToBase64String(r); case OutputDataType.Hex: return ToHexString(r); } throw new Exception("Unknown output type!"); }
public static String SignHash(string data, HashAlgorithmName algorithmName, X509Certificate2 cert, OutputDataType datatype) { byte[] bData, bHash, bResult; HashAlgorithm ha = GetHashAlgorithm(algorithmName); bData = UnicodeEncoding.UTF8.GetBytes(data); bHash = ha.ComputeHash(bData); RSACryptoServiceProvider rsa = (RSACryptoServiceProvider)cert.PrivateKey; bResult = rsa.SignHash(bHash, CryptoConfig.MapNameToOID(algorithmName.ToString())); return ToString(bResult, datatype); }
/// \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; }
public void StringBuilderOutputDataHandler(OutputDataType dataType, string line) { lock (OutputDataBuffer) OutputDataBuffer.AppendLine(line); }
public ExecuteResponseOutput(OutputDataType o, IfyContext context) { this.context = context; this.o = o; }