예제 #1
0
        /// <summary>
        /// Patch app file to map D-Pad directions. This assumes the app file is decompressed.
        /// </summary>
        /// <param name="config">D-Pad configuration</param>
        /// <param name="VCDir">VC directory</param>
        private static void PatchApp1(DPadConfig config, string VCDir)
        {
            using (var app1 = new BinaryWriter(File.OpenWrite(Path.Combine(VCDir, "00000001.app"))))
            {
                var used    = config.InUse;
                var buttons = new VCControllerButton[]
                {
                    VCControllerButton.DPadUp,
                    VCControllerButton.DPadDown,
                    VCControllerButton.DPadLeft,
                    VCControllerButton.DPadRight,
                };

                // Fix array for ordering of the fields in app file: Up, Down, Left, Right
                used = new bool[] { used[0], used[2], used[3], used[1] };

                for (int i = 0; i < used.Length; i++)
                {
                    int offset = DPAD_MAPPING_OFFSET + (i * 4);
                    app1.Seek(offset, SeekOrigin.Begin);

                    if (used[i])
                    {
                        // If using this D-Pad direction, write its button flag
                        ReadWriteUtils.WriteU32(app1, (uint)buttons[i]);
                    }
                    else
                    {
                        // Otherwise write the button flag for the L button
                        ReadWriteUtils.WriteU32(app1, (uint)VCControllerButton.L);
                    }
                }
            }
        }