// read the calibration data and undo obfuscation transformation private void ReadCalibrationData() { byte[] buffer = new byte[16]; // 0x04A40020 is the address of the calibration data on the wiimote _Wiimote.ReadMemory(0x04A40020, buffer, 0, 16); for (int i = 0; i < 16; i++) { buffer[i] = (byte)((buffer[i] ^ 0x17) + 0x17 & 0xFF); } AccelerometerCalibration accelerometerCalibration = new AccelerometerCalibration( (ushort)((buffer[0] << 2) + ((buffer[3]) & 0x3)), (ushort)((buffer[4] << 2) + ((buffer[7]) & 0x3)), (ushort)((buffer[1] << 2) + ((buffer[3] >> 2) & 0x3)), (ushort)((buffer[5] << 2) + ((buffer[7] >> 2) & 0x3)), (ushort)((buffer[2] << 2) + ((buffer[3] >> 4) & 0x3)), (ushort)((buffer[6] << 2) + ((buffer[7] >> 4) & 0x3))); _Accelerometer = new Accelerometer(accelerometerCalibration); AnalogStickCalibration stickCalibration = new AnalogStickCalibration(buffer[9], buffer[10], buffer[8], buffer[12], buffer[13], buffer[11]); _Stick = new AnalogStick(stickCalibration); }
private void ThreadDumpMemory(object stateInfo) { if (!(stateInfo is Gtk.FileChooserDialog)) { return; } Gtk.FileChooserDialog dialog = stateInfo as Gtk.FileChooserDialog; using (Stream fileStream = File.Create(dialog.Filename)) { byte[] memoryBuffer = new byte[0x1700]; _Wiimote.ReadMemory(0x000000, memoryBuffer, 0, (short)memoryBuffer.Length); fileStream.Write(memoryBuffer, 0, memoryBuffer.Length); fileStream.Close(); } dialog.Hide(); }
private void ReadCalibrationData() { byte[] buffer = new byte[16]; _Wiimote.ReadMemory(0x04A40020, buffer, 0, 16); for (int i = 0; i < 16; i++) { buffer[i] = (byte)((buffer[i] ^ 0x17) + 0x17 & 0xFF); } AnalogStickCalibration leftStickCalibration = new AnalogStickCalibration((byte)(buffer[1] >> 2), (byte)(buffer[2] >> 2), (byte)(buffer[0] >> 2), (byte)(buffer[4] >> 2), (byte)(buffer[5] >> 2), (byte)(buffer[3] >> 2)); _LeftStick = new AnalogStick(leftStickCalibration); AnalogStickCalibration rightStickCalibration = new AnalogStickCalibration((byte)(buffer[7] >> 3), (byte)(buffer[8] >> 3), (byte)(buffer[6] >> 3), (byte)(buffer[10] >> 3), (byte)(buffer[11] >> 3), (byte)(buffer[9] >> 3)); _RightStick = new AnalogStick(rightStickCalibration); }