public RegisterReadData(int Offset, int Size, ReadResponder Responder)
 {
     _Offset         = Offset;
     _Size           = Size;
     _Buffer         = new byte[Size];
     _ExpectedOffset = Offset;
     _Responder      = Responder;
 }
 public RegisterReadData(int Offset, int Size, ReadResponder Responder)
 {
     _Offset = Offset;
     _Size = Size;
     _Buffer = new byte[Size];
     _ExpectedOffset = Offset;
     _Responder = Responder;
 }
Esempio n. 3
0
        /// \brief Requests the Wii Remote to report data from its internal registers.
        /// \param type The type of register you would like to read from
        /// \param offset The starting offset of the block of data you would like to read
        /// \param size The size of the block of data you would like to read
        /// \param Responder This will be called when the Wii Remote finishes reporting the requested data.
        /// \return On success, > 0, <= 0 on failure.
        /// \sa SendRegisterWriteRequest(RegisterType, int, byte[])
        ///
        /// \warning Do not attempt to read from the registers when another read is pending (that is, data is being
        ///          recieved by the Wii Remote).  If you attempt to do this, the new read request will be ignored.
        ///
        /// Reading from the Wii Remote's internal registers can give important data not available through normal output reports.
        /// This can, for example, be used to read saved Mii data from the Wii Remote's EEPROM registers.  It is also used by some
        /// of WiimoteApi's setup functions.
        ///
        /// If you use this incorrectly (for example, if you attempt to read from an invalid block of data), \c Responder will not be called.
        public int SendRegisterReadRequest(RegisterType type, int offset, int size, ReadResponder Responder)
        {
            if (CurrentReadData != null)
            {
                Debug.LogWarning("Aborting read request; There is already a read request pending!");
                return(-2);
            }

            CurrentReadData = new RegisterReadData(offset, size, Responder);

            byte address_select = (byte)type;

            byte[] offsetArr = IntToBigEndian(offset, 3);
            byte[] sizeArr   = IntToBigEndian(size, 2);

            byte[] total = new byte[] { address_select, offsetArr[0], offsetArr[1], offsetArr[2],
                                        sizeArr[0], sizeArr[1] };

            return(SendWithType(OutputDataType.READ_MEMORY_REGISTERS, total));
        }
Esempio n. 4
0
    /// \brief Requests the Wii Remote to report data from its internal registers.
    /// \param type The type of register you would like to read from
    /// \param offset The starting offset of the block of data you would like to read
    /// \param size The size of the block of data you would like to read
    /// \param Responder This will be called when the Wii Remote finishes reporting the requested data.
    /// \return On success, > 0, <= 0 on failure.
    /// \sa SendRegisterWriteRequest(RegisterType, int, byte[])
    ///
    /// \warning Do not attempt to read from the registers when another read is pending (that is, data is being
    ///          recieved by the Wii Remote).  If you attempt to do this, the new read request will be ignored.
    /// 
    /// Reading from the Wii Remote's internal registers can give important data not available through normal output reports.
    /// This can, for example, be used to read saved Mii data from the Wii Remote's EEPROM registers.  It is also used by some
    /// of WiimoteApi's setup functions.
    /// 
    /// If you use this incorrectly (for example, if you attempt to read from an invalid block of data), \c Responder will not be called.
    public int SendRegisterReadRequest(RegisterType type, int offset, int size, ReadResponder Responder)
    {
        if (CurrentReadData != null)
        {
            Debug.LogWarning("Aborting read request; There is already a read request pending!");
            return -2;
        }


        CurrentReadData = new RegisterReadData(offset, size, Responder);

        byte address_select = (byte)type;
        byte[] offsetArr = IntToBigEndian(offset, 3);
        byte[] sizeArr = IntToBigEndian(size, 2);

        byte[] total = new byte[] { address_select, offsetArr[0], offsetArr[1], offsetArr[2], 
            sizeArr[0], sizeArr[1] };

        return SendWithType(OutputDataType.READ_MEMORY_REGISTERS, total);
    }