<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>README.md - fork/GramFirmware @ gram</title>
<meta name="description" content="README.md in fork/GramFirmware at gram.">
<meta property="og:title" content="README.md - fork/GramFirmware @ gram">
<meta property="og:description" content="README.md in fork/GramFirmware at gram.">
<meta property="og:type" content="website">
<meta property="og:site_name" content="git.julia.blue">
<link rel="stylesheet" href="/css/style.css?v=62">
<script type="module" src="/js/main.js?v=62"></script>
</head>
<body>
<main data-ref="gram" data-tip="dccae31f54c3ca3cb9f8f5f7de128cd5e564fdd1">
<noscript>
  <div class="callout">
    <p>
      hey! this is a static git repo viewer. commit diffs, file history,
      older commits and other revisions won't load without javascript.
    </p>
    <p>
      you are still able to view source files on branch/tag tips,
      but the experience is degraded.
    </p>
  </div>
</noscript>
<header class="repo"><div>
<h1>fork/GramFirmware</h1>
</div>
<pre class="clone">git clone https://git.julia.blue/fork/GramFirmware</pre>
</header>
<p class="snapshot-commit"><span class="commit-author">CarVac</span><span class="commit-message" data-commit="f06c76bea95d912944674bed93c71abfdfd19b58">remove parasol dash coordinate</span><span class="snapshot-sha sha" data-commit="f06c76bea95d912944674bed93c71abfdfd19b58">f06c76b</span><time datetime="2024-08-31T19:20:10-04:00" title="2024-08-31 19:20:10 -0400">2024-08-31</time></p>
<header class="topbar"><details class="switcher"><summary>gram</summary><div class="menu"><strong>branches</strong><a href="/fork/GramFirmware/ref/WASD_NeutralSOCD/">WASD_NeutralSOCD</a><a href="/fork/GramFirmware/ref/codespace-scaling-space-guide-56rpxqvxpg2v57v/">codespace-scaling-space-guide-56rpxqvxpg2v57v</a><a class="current" href="/fork/GramFirmware/ref/gram/">gram</a><a href="/fork/GramFirmware/ref/master/">master</a><strong>tags</strong><a href="/fork/GramFirmware/ref/v0.1.0/">v0.1.0</a><a href="/fork/GramFirmware/ref/v0.1.1/">v0.1.1</a><a href="/fork/GramFirmware/ref/v0.1.2/">v0.1.2</a><a class="all" href="/fork/GramFirmware/refs">all refs →</a></div></details><nav class="crumbs"><a href="/fork/GramFirmware/">GramFirmware</a> / <span class="cur">README.md</span></nav>
<span class="view-stats"><span>35.8 KiB</span><span>560 lines</span></span><span class="actions"><a class="raw" href="/fork/GramFirmware/raw/b39004d0511d62656ab10df73e40c3f199129108/README.md">raw</a></span></header>
<div class="markdown-view"><input type="radio" name="markdown-view" id="markdown-rendered" checked><label for="markdown-rendered">rendered</label><input type="radio" name="markdown-view" id="markdown-code"><label for="markdown-code">code</label><section class="readme rendered"><h1>HayBox Limited Edition</h1>
<p>Configurator: cdown</p>
<p>This is a firmware designed for experimenting with travel time and other subframe nerfs for Melee based on Haystack's HayBox.</p>
<p>We believe that digital controllers, when used for Melee, are a little overtuned relative to GCC.</p>
<p>Our goal is to make it so that box users and GCC users have a level playing field without doing this by buffing custom motherboard GCCs to the level of boxes, so that the barrier to entry for new players isn't a PhobGCC or a rectangle, or by changing the game to be significantly easier than it currently is.</p>
<p>Particular strengths of rectangle controllers we had in mind when designing the initial set of nerfs:</p>
<ul>
<li>Dashdancing: GCC players perceive that it's more difficult to hit a dashdancing box player because of their increased ability to react to a threat and dash away.</li>
<li>SDI: While GCCs can produce tremendous sustained SDI using the "wank" technique, boxes have much more consistency for short SDI windows and we want to reduce their ability to produce many SDI inputs in a very short time.
<ul>
<li>Note: it will probably never be possible to make it more difficult to do two consecutive SDI inputs on a box.</li>
</ul>
</li>
<li>Pivot tilts: While empty pivoting is somewhat less consistent on rectangles, they are able to pinpoint tilt inputs after an empty pivot much more quickly and consistently than a GCC player can reasonably do without overshooting.</li>
<li>Crouch uptilts: Reactionary crouching uptilts and run cancel uptilts, both strong options, are significantly easier on rectangles than on stick because a fast stick motion is likely to overshoot and result in an upsmash or tap jump.</li>
</ul>
<p>Current nerfs (<strong>SUBJECT TO CHANGE</strong>)</p>
<ul>
<li>Neutral SOCD
<ul>
<li>Neutral SOCD helps mitigate easy three-consecutive-input SDI, though not completely.</li>
<li>Neutral SOCD also helps make long-distance dashdancing a little riskier, because there are two motions required to turn around when you want to change direction. Thus you have an increased risk of getting stuck in a skidding turnaround when you try to turn around right at the end of initial dash. Alternatively, you can release the forward direction early, but that sacrifices distance.</li>
<li>Many consider this to be slightly better than 2ip no-reactivation for controlling aerial drift, because you can never lock yourself out of drift.</li>
<li>It affects away-then-in ledgedashes, making them much harder to be frame-perfect similar to on sticks.
<ul>
<li>However, it is pointed out that c-stick ledgedrops still exist, just people would need to practice them (and they may be less ergonomic on rectangles with large button spacing).</li>
<li>Some players, depending on the character, want wider ModX wavedash angles to make held-modX down-then-in ledgedashes have the same timing. Is this just Fox?</li>
</ul>
</li>
<li>However, it is generally riskier for vertical recovery mixups like fastfall up-b.</li>
<li>Additionally, if you're not used to lifting fingers up it may take time to get used to.</li>
<li>Will we stick with this? There are potential alternatives that have been suggested, though they are significantly harder to implement:
<ul>
<li>2ip no reactivation that has significantly increased travel time when both directions are pressed</li>
<li>2ip no reactivation vertically, but not horizontally. (possibly with the above); this would need an additional SDI nerf similar to the B0XX ones.</li>
</ul>
</li>
</ul>
</li>
<li>Left stick travel time to the center or diagonal rim coordinates: 6ms (just over 1/3 frame)
<ul>
<li>Travel time exists to add some reaction time parity between sticks and buttons, and to also make digital inputs subject to at least some of the same polling timing considerations as sticks.</li>
<li>This value is based off measured center-to-rim stick speeds from various players, as well as a little bit of rectangle testing before where a player remarked that even slightly longer travel time felt worse.</li>
<li>Because the travel is linear, this delays inputs by 3 ms on average, but it may be slightly more depending on where the threshold is along the travel distance. For dashdancing turnarounds, this is more like a 5ms delay, but for dashing from standing it's more like 2ms.</li>
</ul>
</li>
<li><del>Left stick movements to rim coordinates delayed by 4ms (1/4 frame).</del>
<ul>
<li>This removes the risk of polling errors for rising edges but slightly slows reaction time.</li>
</ul>
</li>
<li>Left stick travel time to <del>non-center</del> non-cardinal or diagonal rim coordinates including the center: 12ms (2/3 frame)
<ul>
<li>This is longer than the rim travel times because it takes longer, on a stick, to pinpoint a non-rim position.</li>
<li>This used to be 16 ms, a whole frame, but users noted that it made timing button inputs for tilts harder. On a stick, even if it takes longer to get to a tilt location, you get feedback from your senses of when the motion is completed, but that's not true of button presses with simulated travel time.</li>
</ul>
</li>
<li>4 frame travel time for cardinal tapping SDI (numpad notation: 5656...) faster than 10 presses/s, but not for taps shorter than half a frame for switch bounce leniency.
<ul>
<li>This is implemented because with neutral SOCD it's relatively easy to get double-rate mashing. To mash right with one full cycle per press AND per release, press right, press left, release left, release right (and repeat).</li>
<li>By merely increasing the travel time and not locking out, this mitigates SDI without significantly affecting aerial drift control via rapid tapping.</li>
<li>We need to do SDI testing to check whether this is needed at all for short SDI windows (Fox upair 1) and whether it can achieve more distance than wank SDI on long SDI windows (knee).</li>
</ul>
</li>
<li><del>Lockout for diagonal tapping SDI (numpad notation: 636<strong>3</strong>...) faster than 10 presses/s (6f)</del> Currently Disabled
<ul>
<li>This was implemented for the same reasons as cardinal tap SDI.</li>
<li>However, at the moment it's disabled because it affects shield drop fastfall.</li>
<li>We would like users to test whether abusing diagonal tap SDI is noticeably impactful in game.</li>
<li>In the future this may be re-enabled with a different time window.</li>
</ul>
</li>
<li>Lockout for cardinal + diagonal tapping SDI (numpad notation: 56356<strong>3</strong>) faster than 7.5 presses/s (5.5f)
<ul>
<li>The last remaining SDI method gets you a cardinal and a diagonal SDI pulse for every press, by plinking two adjacent cardinals.</li>
<li>This is basically repeated quarter-circle SDI in a way that's not really doable on a stick.</li>
<li>It is occasionally impactful in game: one person reported that their ledgedash technique, which involves dropping from ledge with down then in, releasing, and pressing diagonal again to airdodge, was impacted.</li>
</ul>
</li>
<li>Lockout for cardinal-diagonal-opposite diagonal (numpad notation: 563<strong>9</strong>) with less than 5.5 frames between cardinal and second diagonal.
<ul>
<li>Even with neutral SOCD it's not too hard to get three consecutive SDI inputs without this.</li>
</ul>
</li>
<li>Moving from a crouching coordinate to an upward tilt in &lt; 3 frames will move the stick to a tap jump coordinate
<ul>
<li>This prevents users from continuously holding crouch and uptilting on reaction in a single motion.</li>
<li>Additionally, it affects the speed of run cancel uptilt.</li>
<li>Neutral SOCD does not compound with this: time spent in neutral counts towards the two frames you have to wait.</li>
<li>This is a fairly non-controversial new nerf, because it's something that is a strong option in game that is extremely difficult to execute on a stick.</li>
<li>The 3 frame window was initially determined by asking top GCC controller modders what they thought would be a reasonable limit.</li>
<li>In early testing, players have said that it feels reasonable. The limit is easy enough to avoid but at the same time holds back degenerate options.</li>
<li>NOTE: earlier this said 2 frames. I checked the code and it had been 3 frames all along.</li>
</ul>
</li>
<li>Tilt stick inputs less than 8.0 frames after an empty pivot will move the stick to a smash coordinate.
<ul>
<li>This detects an empty pivot that is &gt;50% probability of success: a 0.5 to 1.5 frame tap opposite of the last direction pressed.</li>
<li>Any upward or downward tilt input becomes full magnitude, as long as &lt; 8 frames have elapsed since the empty pivot.</li>
<li>This corresponds with the difficulty of controlling the stick after an empty pivot movement.</li>
<li>For upward directions, a minimum angle of 45 degrees is enforced to prevent up-angled ftilt and produce a tap jump regardless of the original angle. Otherwise, it attempts to preserve the angle so wavedashes are not randomly affected.</li>
</ul>
</li>
</ul>
<p>In addition to nerfs, it offers several features:</p>
<p>Arduino-based boxes will work at the same latency regardless of polling rate, as long as the poll spacing is constant.
Users no longer need to hold A on plugin to optimize latency on console, and it'll have slightly less lag on adapters.</p>
<p>Instead, the A press on plugin disables all timing based nerfs.</p>
<p>Additionally, you can hold B on plugin to get the shorter recovery coordinates that all have magnitudes about 0.8, for use with teleport recovery characters, and you can hold Down on plugin to get the crouch-walk option select.</p>
<p>It also currently has built-in support for a handful more boards than mainline Haybox, notably B0XX R4, Htangl, and Rana Digital.</p>
<p>Limitations: Any console polling that does not have uniform space between polls will trip up the connection. Notably, the Homebrew Menu, Nintendont, SmashScope on console, and third-party GCC to USB adapters can work either poorly or not at all.</p>
<h1>HayBox</h1>
<p>HayBox is a modular, cross-platform firmware for digital or mixed analog/digital controllers, primarily targeted at <a href="https://b0xx.com">B0XX</a>-style controllers.</p>
<p><a href="https://github.com/JonnyHaystack/HayBox/issues"><img src="https://img.shields.io/github/issues/JonnyHaystack/HayBox" alt="GitHub issues" /></a>
<a href="https://github.com/JonnyHaystack/HayBox/pulls"><img src="https://img.shields.io/github/issues-pr/JonnyHaystack/HayBox" alt="GitHub pull requests" /></a></p>
<h2>Table of Contents</h2>
<ul>
<li><a href="#features">Features</a></li>
<li><a href="#getting-started">Getting Started</a>
<ul>
<li><a href="#requirements">Requirements</a></li>
<li><a href="#installation">Installation</a></li>
</ul>
</li>
<li><a href="#usage">Usage</a>
<ul>
<li><a href="#default-button-holds">Default button holds</a></li>
<li><a href="#dolphin-setup">Dolphin setup</a></li>
</ul>
</li>
<li><a href="#customisation">Customisation</a>
<ul>
<li><a href="#consolegamemode-selection-bindings">Console/gamemode selection bindings</a></li>
<li><a href="#creating-custom-input-modes">Creating custom input modes</a></li>
<li><a href="#mod-x-lightshield-and-r-shield-tilt">Mod X lightshield and R shield tilt</a></li>
<li><a href="#mode-specific-optional-features">Mode-specific optional features</a>
<ul>
<li><a href="#melee-modes">Melee modes</a></li>
<li><a href="#project-mproject-mode">Project M/Project+ mode</a></li>
</ul>
</li>
<li><a href="#input-sources">Input sources</a></li>
<li><a href="#using-the-picos-second-core">Using the Pico's second core</a></li>
</ul>
</li>
<li><a href="#troubleshooting">Troubleshooting</a></li>
<li><a href="#contributing">Contributing</a></li>
<li><a href="#contributors">Contributors</a></li>
<li><a href="#license">License</a></li>
</ul>
<h2>Features</h2>
<p>Features include:</p>
<ul>
<li>Cross platform support:
<ul>
<li>RP2040 (e.g. Raspberry Pi Pico)</li>
<li>16MHz AVR MCUs (e.g. ATMega32U4 which several Arduinos are based on)</li>
</ul>
</li>
<li>Supports many existing controllers/PCBs, e.g. B0XX, LBX, Smash Box, Crane's
GCCPCB/Model S</li>
<li>Supports a variety of communication backends which can be used either separately or in conjunction with each other:
<ul>
<li>XInput</li>
<li>DInput</li>
<li>GameCube console</li>
<li>Nintendo 64 console</li>
<li>Nintendo Switch console</li>
<li>B0XX input viewer</li>
</ul>
</li>
<li>Supports a variety of "input sources" which can be used in conjunction to create mixed input controllers:
<ul>
<li>Buttons/switches wired directly to GPIO pins</li>
<li>Switch matrix (as typically found in keyboards)</li>
<li>Wii Nunchuk</li>
<li>GameCube controller</li>
</ul>
</li>
<li>Melee mode up to date with B0XX V3 specifications</li>
<li>Existing modes for popular games (e.g. Melee, Project M, Ultimate, Rivals of Aether, traditional fighting games)</li>
<li>Easy to create new controller modes (or keyboard modes) for different games</li>
<li>USB keyboard game modes for games that lack gamepad support</li>
<li>Fully customisable SOCD cleaning, allowing you to configure SOCD button pairs (e.g. left/right, up/down) for each controller/keyboard mode, and also easily change the SOCD resolution method for each SOCD pair</li>
<li>Switch modes on the fly without unplugging your controller</li>
<li>Automatically detects whether plugged into console or USB</li>
<li>Game modes and communication backends are independent entities, meaning you can use any game mode with any supported console without extra work</li>
<li>Easily switch between different GameCube/N64 polling rates in order to have optimal latency on console, overclocked adapter, etc. (not necessary for Pico/RP2040)</li>
</ul>
<h2>Getting Started</h2>
<h3>Requirements</h3>
<ul>
<li><a href="https://git-scm.com/downloads">Git</a> - required only if you are using a Pico. May become unnecessary at some point in the future.</li>
<li><a href="https://platformio.org/install/ide?install=vscode">PlatformIO IDE for VSCode</a></li>
</ul>
<h3>Installation</h3>
<p>Download and extract the
<a href="https://github.com/JonnyHaystack/HayBox/releases">latest HayBox release</a>,
or clone the repository if you have git installed (which makes it easier for you
to pull updates).</p>
<p>After that:</p>
<ol>
<li>Open Visual Studio Code</li>
<li>Click File -&gt; <strong>Open Folder</strong> and choose the HayBox folder (the one containing platformio.ini, not the folder above that)</li>
<li>Choose the appropriate build environment for your controller's PCB by
clicking the environment selection button near the bottom left of the window</li>
</ol>
<p><img src="https://user-images.githubusercontent.com/1266473/187039372-485c5f0d-60b3-4534-befb-e713f138a7c8.png" alt="image" />
<img src="https://user-images.githubusercontent.com/1266473/187039585-cea18994-fd12-45fb-b43f-427eb7affb81.png" alt="image" /></p>
<ol start="4">
<li>If your controller has a different pinout than any of the existing configs, you may edit the button mappings and other pins at the top of the config (<code>config/&lt;environment&gt;/config.cpp</code>). Any buttons that your controller doesn't have can simply be deleted from the list.</li>
<li>If you see a message in the bottom bar saying "Rebuilding IntelliSense Index" or "Loading Project Tasks", wait for it to disappear. For Pico especially it may take quite a while the first time because it has to download 2-3GB of dependencies.</li>
<li>Click <strong>Build</strong> (in the bottom left) and make sure everything compiles without
errors</li>
<li>This  next step differs depending on the microcontroller used in your controller.
<ul>
<li><strong>For Pico-based controllers</strong>: hold the bootsel button while plugging it in (or your Start button if you already have HayBox installed) and then drag and drop the file <code>HayBox/.pio/build/&lt;environment&gt;/firmware.uf2</code> onto the RPI-RP2 drive that comes up.</li>
<li><strong>For Arduino-based controllers</strong>: Plug in your controller via USB and click <strong>Upload</strong> (next to the Build button)</li>
</ul>
</li>
</ol>
<h2>Usage</h2>
<h3>Default button holds</h3>
<h4>Pico bootsel mode</h4>
<p>To reboot Pico-based controllers into bootsel mode, hold Start on plugin.</p>
<h4>Brook board passthrough mode</h4>
<p>To switch to Brook board mode on GCCPCB2, GCCMX, B0XX R2, or LBX, hold B and R on
plugin.</p>
<h4>Communication backends (console selection)</h4>
<p>Communication backends are selected slightly differently depending on the type
of microcontroller used in the controller.</p>
<p>On Pico/RP2040, USB vs GameCube vs Nintendo 64 is detected automatically. If
not plugged into a console, the default is <strong>XInput</strong>, which should work
plug-and-play with most PC games.
Other backends are selected by holding one of the following buttons on plugin:</p>
<ul>
<li>X - Nintendo Switch USB mode (also sets initial game mode to Ultimate mode)</li>
<li>Z - DInput mode (only recommended for games which don't support XInput)</li>
</ul>
<p>On Arduino/AVR, the <strong>DInput</strong> backend is selected if a USB connection is detected.
Otherwise, it defaults to GameCube backend, unless another backend is manually
selected by holding one of the following buttons on plugin:</p>
<ul>
<li>A - GameCube backend with polling rate fix disabled (used for GCC adapters)</li>
<li>C-Left - Nintendo 64 backend (60Hz polling rate)</li>
</ul>
<h4>Game mode selection</h4>
<p>Unlike other similar firmwares, HayBox by default allows you to switch
modes on the fly without unplugging your controller. This is mainly useful on
PC, as opposed to console where you usually have to restart the console to
switch game anyway. It also serves the purpose of reducing the number of buttons
you have to hold with one hand while plugging in.</p>
<p>The default controller mode button combinations are:</p>
<ul>
<li>Mod X + Start + L - Melee mode (default)</li>
<li>Mod X + Start + Left - Project M/Project+ mode</li>
<li>Mod X + Start + Down - Ultimate mode</li>
<li>Mod X + Start + Right - FGC mode (Hitbox style fighting game layout)</li>
<li>Mod X + Start + B - Rivals of Aether mode</li>
</ul>
<p>Default keyboard mode button combinations (only available when using DInput backend, <strong>not</strong> with XInput):</p>
<ul>
<li>Mod Y + Start + L - Default keyboard mode</li>
</ul>
<h3>Dolphin setup</h3>
<p>HayBox needs a different Dolphin controller profile than the official B0XX firmware, as it
uses different DInput mappings that make more sense for use across multiple games. These
can be found in the <code>dolphin</code> folder in the HayBox repo. The profile files are named to
indicate what communication backend and operating system they are for:</p>
<ul>
<li>For Windows:
<ul>
<li>HayBox_XInput.ini - For Pico/RP2040-based controllers (e.g. B0XX R4)</li>
<li>HayBox_DInput.ini - For Arduino/AVR-based controllers (e.g. B0XX R1-3, LBX)</li>
</ul>
</li>
<li>For Linux:
<ul>
<li>HayBox_XInput_Linux.ini - For Pico/RP2040-based controllers (e.g. B0XX R4)</li>
<li>HayBox_DInput_Linux.ini - For Arduino/AVR-based controllers (e.g. B0XX R1-3, LBX)</li>
</ul>
</li>
<li>For macOS (unsupported*):
<ul>
<li>HayBox_DInput_macOS.ini</li>
</ul>
</li>
</ul>
<p>To install the profile:</p>
<ol>
<li>Copy the appropriate .ini file from the <code>dolphin</code> folder within HayBox to the folder <code>&lt;YourDolphinInstallation&gt;\User\Config\Profiles\GCPad\</code> (create it if it does not exist)</li>
</ol>
<ul>
<li>For Slippi this should be
<ul>
<li>On Windows: <code>%appdata%\Slippi Launcher\netplay\User\Config\Profiles\GCPad\</code> (if this doesn't work, try <code>...\netplay\Sys\User\...</code>)</li>
<li>On Linux: <code>~/.config/SlippiOnline/Config/Profiles/GCPad/</code></li>
<li>On Mac: <code>Cmd + Shift + G</code> and enter the path <code>/Users/&lt;USER&gt;/Library/Application Support/Slippi Launcher/netplay/Slippi Dolphin.app/Contents/Resources/User/Config/Profiles/GCPad</code></li>
</ul>
</li>
<li>For vanilla Dolphin:
<ul>
<li>On Windows: <code>%userprofile%\Documents\Dolphin Emulator\Config\Profiles\GCPad\</code></li>
<li>On Linux: <code>~/.config/dolphin-emu/Profiles/GCPad/</code></li>
</ul>
</li>
</ul>
<ol start="2">
<li>Plug in your controller, and configure a "Standard Controller" in Dolphin</li>
<li>Click <strong>Refresh</strong> next to the Device dropdown</li>
<li>Select the HayBox profile from the profile dropdown, and click <strong>Load</strong> (NOT Save)</li>
<li>Make sure the correct device is selected in the device dropdown</li>
<li>Click <strong>Close</strong></li>
</ol>
<p>* macOS only supports DInput (and not very well), so if using a Pico/RP2040-based controller you will have to force DInput mode by holding Z on plugin, and even then it may not work. I can't really do anything about Apple's poor controller support (which they seem to break with every other update) and I don't own any Apple devices, so this will also be considered unsupported usage of HayBox.</p>
<h2>Customisation</h2>
<h3>Console/gamemode selection bindings</h3>
<h4>Communication backends (console selection)</h4>
<p>The communication backend (e.g. DInput, GameCube, or N64) is selected partly
through auto detection and partly based on the buttons held on plugin. This is
handled in <code>config/&lt;environment&gt;/config.cpp</code>, in the <code>setup()</code> function.
The logic is fairly simple, and even if you don't have programming experience it
shouldn't be too hard to see what's going on and change things if you wish.</p>
<p>The config folders corresponding to the Arduino environments are:</p>
<ul>
<li><code>config/arduino_nativeusb/</code> for Arduino with native USB support (e.g. Leonardo, Micro)</li>
<li><code>config/arduino/</code> for Arduino without native USB support (e.g. Uno, Nano, Mega 2560)</li>
</ul>
<p>For Arduino device configs you may notice that the number 125 is passed into
<code>GamecubeBackend()</code>. This lets you change the polling rate e.g. if your DIY
doesn't support native USB and you want to use it with an overclocked GameCube
controller adapter. In that example, you could pass in 1000 to sync up to the
1000Hz polling rate, or 0 to disable this lag fix completely.
Polling rate can be passed into the N64Backend constructor in the same way as this.</p>
<p>You may notice that 1000Hz polling rate works on console as well. Be aware
that while this works, it will result in more input lag. The point of setting
the polling rate here is so that the GameCube backend can delay until right
before the next poll before reading the inputs, so that the inputs are fresh and
not outdated.</p>
<p>For Pico/RP2040, it is not necessary to pass in a console polling rate, because
the Pico has enough processing power to read/process inputs after receiving the
console poll, so there is no need to predict when the poll will arrive and
prepare things in advance.</p>
<h4>Input modes</h4>
<p>To configure the button holds for input modes (controller/keyboard modes), edit
the <code>select_mode()</code> function in <code>config/mode_selection.hpp</code>. Each <code>if</code>
statement is a button combination to select an input mode.</p>
<p>Most input modes support passing in an SOCD cleaning mode, e.g.
<code>socd::2IP_NO_REAC</code>. See <a href="#socd">here</a> for the other available modes.</p>
<h3>Creating custom input modes</h3>
<p>For creating new input modes, it helps if you know some C++, or at least have
some programming experience. That said, you should be able to get by even
without prior experience if you just base your new mode off the existing ones
and refer to them as examples.</p>
<p>There are two types of input modes: ControllerMode and KeyboardMode</p>
<h4>Keyboard modes</h4>
<p>Keyboard modes are a little bit simpler so let's start there.</p>
<p>A KeyboardMode behaves as a standard keyboard and should work with any device
that supports keyboards.</p>
<p>You are free to use whatever logic and programming tricks you like in the
<code>UpdateKeys()</code> function to decide the outputs based on the input state. You could
create input layers (like the D-Pad layer in Melee mode that is activated when
holding Mod X and Mod Y), or other types of conditional inputs.</p>
<p>The list of available keycodes can be found <a href="https://github.com/JonnyHaystack/ArduinoKeyboard/blob/master/include/keycodes.h">here</a>.</p>
<p>Remember that keyboard modes can only be activated when using the <strong>DInput</strong> communication backend (<strong>not</strong> XInput).</p>
<h4>Controller modes</h4>
<p>A ControllerMode takes a digital button input state and transforms it into an
output state corresponding to a standard gamepad. Any ControllerMode will work
with any CommunicationBackend. A CommunicationBackend simply reads inputs from one or more input sources, uses the current ControllerMode to update the outputs based on those inputs, and handles the sending of the outputs to the console or PC.</p>
<p>To create a ControllerMode, you just need to implement the functions
<code>UpdateDigitalOutputs()</code> and <code>UpdateAnalogOutputs()</code>.</p>
<p><code>UpdateDigitalOutputs()</code> is very similar to the <code>UpdateKeys()</code> function in keyboard
modes, with the difference that rather than calling a <code>Press()</code> function to
immediately send inputs, we are simply setting the output state for this
iteration. As the name indicates, we will only deal with the digital outputs in
this function.</p>
<p><code>UpdateAnalogOutputs()</code> is a bit more complicated. Firstly, it has to call
<code>UpdateDirections()</code> before doing anything else. This function takes in values
indicating whether your left and right sticks are pointing left/right/up/down.
You also pass in the minimum, neutral (centre), and maximum stick analog values,
so you can configure these on a per-mode basis. All this information is used to
automatically set the stick analog values based on the inputs you passed in. This
is all you need to do unless you want to implement modifiers.</p>
<p><code>UpdateDirections()</code> also populates the variable <code>directions</code> with values
indicating current stick direction, which can be 1, 0, or -1 for the X and Y
axes for both sticks. These values make it much easier to write modifier logic.</p>
<p>After calling <code>UpdateDirections()</code>, add any modifier handling logic that you want.
Remember that <code>UpdateDirections()</code> already set the default analog stick values,
so when handling modifiers you only need to manually set the values for the axes
that are actually being modified. Other than this, I can't teach how to write
your modifier logic, so just look at the examples and play around.</p>
<p>Finally, set any analog trigger values that you need.</p>
<p>Note: Analog trigger outputs could just as well be handled in
<code>UpdateDigitalOutputs()</code>, but I think it usually looks cleaner to keep them
along with the other analog outputs.</p>
<p>Also note: You don't need to worry about resetting the output state or clearing
anything from it. This is done automatically at the start of each iteration.</p>
<h3>SOCD</h3>
<p>In the constructor of each mode (for controller modes <em>and</em> keyboard modes), you
can configure pairs of opposing direction inputs to apply SOCD cleaning to.</p>
<p>For example, in <code>src/modes/Melee20Button.cpp</code>:</p>
<pre>_socd_pair_count = 4;
_socd_pairs = new socd::SocdPair[_socd_pair_count]{
    socd::SocdPair{&amp;InputState::left,    &amp;InputState::right,   socd_type},
    socd::SocdPair{ &amp;InputState::down,   &amp;InputState::up,      socd_type},
    socd::SocdPair{ &amp;InputState::c_left, &amp;InputState::c_right, socd_type},
    socd::SocdPair{ &amp;InputState::c_down, &amp;InputState::c_up,    socd_type},
};
</pre>
<p>This sets up left/right, down/up, C-Left/C-Right, and C-Down/C-Up as pairs of
opposing cardinal directions for which SOCD cleaning will be applied. The SOCD
cleaning is automatically done before <code>UpdateDigitalOutputs()</code> and
<code>UpdateAnalogOutputs()</code>, and you do not need to worry about it any further than
that.</p>
<p>For each <code>SocdPair</code> you can pass in an <code>SocdType</code> of your choosing. By default
for most modes this is passed in as a single constructor parameter, but it is
possible to pass in multiple parameters, or simply use a hardcoded value. Both
of these approaches are exemplified in <code>src/modes/FgcMode.cpp</code>.</p>
<table><thead><tr><th><code>SocdType</code></th><th>Description</th></tr></thead><tbody>
<tr><td><code>SOCD_NEUTRAL</code></td><td>Left + right = neutral - the default if no <code>SocdType</code> specified in the <code>SocdPair</code></td></tr>
<tr><td><code>SOCD_2IP</code></td><td>Second input priority - left -&gt; left + right = right, and vice versa. Releasing the second direction gives the original direction</td></tr>
<tr><td><code>SOCD_2IP_NO_REAC</code></td><td>Second input priority without reactivation - same as above, except releasing the second direction results in neutral. The original direction must be physically reactuated.</td></tr>
<tr><td><code>SOCD_DIR1_PRIORITY</code></td><td>The first button in the <code>SocdPair</code> always takes priority over the second</td></tr>
<tr><td><code>SOCD_DIR2_PRIORITY</code></td><td>The second button in the <code>SocdPair</code> always takes priority over the first</td></tr>
<tr><td><code>SOCD_NONE</code></td><td>No SOCD resolution - the game decides</td></tr>
</tbody></table>
<p>Note that you do not have to implement a <code>HandleSocd()</code> function like in the
Melee20Button and Melee18Button modes. It is only overridden in these modes
so that we can check if left and right are both held <em>before</em> SOCD cleaning,
because when they are both held (without a vertical direction being held) we
need to override all modifiers.</p>
<h3>Mod X lightshield and R shield tilt</h3>
<p>If your controller has no lightshield buttons, you may want to use Mod X for
lightshield and put shield tilt on R instead. You can do this by using the
Melee18Button mode instead of Melee20Button.</p>
<h3>Mode-specific optional features</h3>
<h4>Melee modes</h4>
<p>The Melee20Button and Melee18Button modes provide a choice of which coordinates to use
when pressing down + right. By default, holding down + back will allow you to do automatic
jab-cancels, which is a useful technique for some characters.</p>
<p>Another popular technique that uses the down + right diagonal is the so-called crouch/walk
option-select. This technique involves holding down + forward at a certain angle while
crouching, such that after crouch-cancelling an attack you will automatically start
walking towards your opponent instead of going back into crouch. This can be very useful
for tech-chasing, but the coordinates used for this technique do not allow you to auto
jab-cancel.</p>
<p>This can be configured as seen in <code>config/mode_selection.hpp</code> by setting the <code>crouch_walk_os</code> option to true:</p>
<pre>new Melee20Button(socd::SOCD_2IP_NO_REAC, { .crouch_walk_os = false })
</pre>
<p>You will also have to change this in your <code>config/&lt;environment&gt;/config.cpp</code> in order for it to be applied on plugin, as <code>mode_selection.hpp</code> only controls what happens when you <em>switch</em> mode.</p>
<h4>Project M/Project+ mode</h4>
<p>The ProjectM mode has some extra options to configure certain behaviours. As seen
in <code>config/mode_selection.hpp</code>:</p>
<pre>new ProjectM(
    socd::SOCD_2IP_NO_REAC,
    { .true_z_press = false, .ledgedash_max_jump_traj = true }
)
</pre>
<p>Firstly, the <code>ledgedash_max_jump_traj</code> option allows you to enable or disable the behaviour
borrowed from Melee mode where holding left and right (and no vertical directions)
will give a 1.0 cardinal regardless of modifiers being held.</p>
<p>If you change the SOCD mode to 2IP (with reactivation), you should also change
this option to false if you want a smooth gameplay experience.</p>
<p>Secondly, the <code>true_z_press</code> option exists because Project M/Project+ do not handle
Z presses the same way Melee does.
Melee interprets a Z press as lightshield + A, and thus it can be used for L
cancelling without locking you out of techs. In PM/P+, a Z press will trigger a
tech and thus cause unwanted tech lockouts if used to L cancel.
By default in HayBox, the ProjectM mode is set to use a macro of lightshield + A
in order to preserve expected behaviour from Melee. However, this macro does not
enable you to use tether/grapple attacks or grab items. To workaround this, you
can press Mod X + Z to send a true Z input.</p>
<p>If this bothers you, and you just want to send a true Z input by default when
pressing Z, you can set the <code>true_z_press</code> option to true.</p>
<h3>Input sources</h3>
<p>HayBox supports several input sources that can be read from to update the input
state:</p>
<ul>
<li><code>GpioButtonInput</code> - The most commonly used, for reading switches/buttons connected directly to GPIO pins. The input mappings are defined by an array of <code>GpioButtonMapping</code> as can be seen in almost all existing configs.</li>
<li><code>SwitchMatrixInput</code> - Similar to the above, but scans a keyboard style switch matrix instead of individual switches. A config for Crane's Model C&lt;=53 is included at <code>config/c53/config.cpp</code> which serves as an example of how to define and use a switch matrix input source.</li>
<li><code>NunchukInput</code> - Reads inputs from a Wii Nunchuk using i2c. This can be used for mixed input controllers (e.g. left hand uses a Nunchuk for movement, and right hand uses buttons for other controls)</li>
<li><code>GamecubeControllerInput</code> - Similar to the above, but reads from a GameCube controller. Can be instantiated similarly to GamecubeBackend. Currently only implemented for Pico, and you must either run it on a different pio instance (pio0 or pio1) than any instances of GamecubeBackend, or make sure that both use the same PIO instruction memory offset.</li>
</ul>
<p>Each input source has a "scan speed" value which indicates roughly how long it takes for it to read inputs. Fast input sources are always read at the last possible moment (at least on Pico), resulting in very low latency. Conversely, slow input sources are typically read quite long before they are needed, as they are too slow to be read in response to poll. Because of this, it is more ideal to be constantly reading those inputs on a separate core. This is not possible on AVR MCUs as they are all single core, but it is possible (and easy) on the Pico/RP2040. The bottom of the default Pico config <code>config/pico/config.cpp</code> illustrates this by using core1 to read Nunchuk inputs while core0 handles everything else. See <a href="#using-the-picos-second-core">the next section</a> for more information about using core1.</p>
<p>In each config's <code>setup()</code> function, we build up an array of input sources, and then pass it into a communication backend. The communication backend decides when to read which input sources, because inputs need to be read at different points in time for different backends. We also build an array of communication backends, allowing more than one backend to be used at once. For example, in most configs, the B0XX input viewer backend is used as a secondary backend whenever the DInput backend is used. In each iteration, the main loop tells each of the backends to send their respective reports. In future, there could be more backends for things like writing information to an OLED display.</p>
<h3>Using the Pico's second core</h3>
<p>In each config, there are the functions <code>setup()</code> and <code>loop()</code>, where <code>setup()</code> runs first, and then <code>loop()</code> runs repeatedly until the device is powered off.</p>
<p>On Pico/RP2040, the <code>setup()</code> and <code>loop()</code> functions execute on core0, and you can add the functions <code>setup1()</code> and <code>loop1()</code> in order to run tasks on core1.</p>
<p>For example, to read GameCube controller inputs on core1:</p>
<pre>GamecubeControllerInput *gcc = nullptr;

void setup1() {
    while (backends == nullptr) {
        tight_loop_contents();
    }

    gcc = new GamecubeControllerInput(gcc_pin, 2500, pio1);
}

void loop1() {
    if (backends != nullptr) {
        gcc-&gt;UpdateInputs(backends[0]-&gt;GetInputs());
    }
}
</pre>
<p>The <code>while</code> loop makes sure we wait until <code>setup()</code> on core0 has finished setting up the communication backends. We then create a GameCube controller input source with a polling rate of 2500Hz. We also run it on <code>pio1</code> as an easy way to avoid interfering with any GameCube/N64 backends, which use <code>pio0</code> unless otherwise specified. In <code>loop1()</code> we make the assumption that the primary backend is the first element of the <code>backends</code> array (which is configured in the same file anyway, so we aren't truly assuming anything we don't know) and directly scan the GameCube controller inputs into the backend's input state.</p>
<p>As a slightly crazier hypothetical example, one could even power all the controls for a two person arcade cabinet using a single Pico by creating two switch matrix input sources using say 10 pins each, and two GameCube backends, both on separate cores. The possibilities are endless.</p>
<h2>Troubleshooting</h2>
<h3>Controller not working with console or GameCube adapter</h3>
<p>If you are using an official adapter with an Arduino-based controller you will likely have to hold A on plugin which disables the polling latency optimisation by passing in a polling rate of 0 to the GamecubeBackend constructor.</p>
<p>If you are using an Arduino-based controller without a boost circuit, you will need 5V power so for Mayflash adapter you need both USB cables plugged in, and on console the rumble line needs to be intact. Pico works natively with 3.3V power so this isn't an issue.</p>
<h2>Contributing</h2>
<p>I welcome contributions and if you make an input mode that you want to share,
feel free to make a pull request. Please install the clang-format plugin for
VS Code and use it to format any code you want added.</p>
<h3>Versioning</h3>
<p>We use <a href="http://semver.org/">SemVer</a> for versioning. For the versions available,
see the <a href="https://github.com/JonnyHaystack/HayBox/tags">tags on this repository</a>.</p>
<h2>Built With</h2>
<ul>
<li><a href="/fork/GramFirmware/ref/gram/">https://github.com/MHeironimus/ArduinoJoystickLibrary</a> - Used for DInput support for AVR</li>
<li><a href="/fork/GramFirmware/ref/gram/">https://github.com/NicoHood/Nintendo</a> - Used for GameCube and Nintendo 64 support for AVR</li>
<li><a href="/fork/GramFirmware/ref/gram/">https://github.com/JonnyHaystack/ArduinoKeyboard</a> - Used for keyboard modes on AVR</li>
<li><a href="/fork/GramFirmware/ref/gram/">https://github.com/JonnyHaystack/arduino-nunchuk</a> - Used for Nunchuk support</li>
<li><a href="/fork/GramFirmware/ref/gram/">https://github.com/JonnyHaystack/joybus-pio</a> - Used for GameCube and Nintendo 64 support for RP2040</li>
<li><a href="/fork/GramFirmware/ref/gram/">https://github.com/earlephilhower/arduino-pico</a> - Used for Arduino framework/PlatformIO support for Pico</li>
</ul>
<h2>Contributors</h2>
<ul>
<li><strong>Jonathan Haylett</strong> - <em>Creator</em> - <a href="https://github.com/JonnyHaystack">@JonnyHaystack</a></li>
<li><strong>Crane</strong> - <em>Creator of the DIYB0XX firmware, which served as a great reference/starting point</em> - <a href="https://github.com/Crane1195">@Crane1195</a></li>
</ul>
<p>See also the list of <a href="https://github.com/JonnyHaystack/HayBox/contributors">contributors</a> who participated in this project.</p>
<h3>Acknowledgments</h3>
<ul>
<li>The B0XX team, for designing and creating an incredible controller</li>
<li><a href="https://github.com/Crane1195">@Crane1195</a> - for his DIYB0XX and GCCPCB projects, and for hours of answering my questions when I was first writing this</li>
<li><a href="https://github.com/MHeironimus">@MHeironimus</a> - for the Arduino Joystick library</li>
<li><a href="https://github.com/NicoHood">@NicoHood</a> - for the Nintendo library</li>
<li><a href="https://github.com/GabrielBianconi">@GabrielBianconi</a> - for the Arduino Nunchuk library</li>
<li><a href="https://github.com/earlephilhower">@earlephilhower</a> - for the arduino-pico core</li>
<li><a href="https://github.com/maxgerhardt">@maxgerhardt</a> - for adding PlatformIO support for arduino-pico</li>
<li>The Arduino project and the Raspberry Pi Foundation - for all their open-source hardware and software</li>
</ul>
<h2>License</h2>
<p>This project is licensed under the GNU GPL Version 3 - see the <a href="/fork/GramFirmware/ref/gram/blob/LICENSE">LICENSE</a> file for details</p>
</section><div class="code-panel"><pre class="code src language-markdown"><span class="code-line"><a class="ln" id="L1" href="#L1">1</a><span class="code-text"><a-p>#</a-p> <a-tt>HayBox Limited Edition</a-tt></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L2" href="#L2">2</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L3" href="#L3">3</a><span class="code-text">Configurator: cdown</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L4" href="#L4">4</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L5" href="#L5">5</a><span class="code-text">This is a firmware designed for experimenting with travel time and other subframe nerfs for Melee based on Haystack&#39;s HayBox.</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L6" href="#L6">6</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L7" href="#L7">7</a><span class="code-text">We believe that digital controllers, when used for Melee, are a little overtuned relative to GCC.</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L8" href="#L8">8</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L9" href="#L9">9</a><span class="code-text">Our goal is to make it so that box users and GCC users have a level playing field without doing this by buffing custom motherboard GCCs to the level of boxes, so that the barrier to entry for new players isn&#39;t a PhobGCC or a rectangle, or by changing the game to be significantly easier than it currently is.</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L10" href="#L10">10</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L11" href="#L11">11</a><span class="code-text">Particular strengths of rectangle controllers we had in mind when designing the initial set of nerfs:</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L12" href="#L12">12</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L13" href="#L13">13</a><span class="code-text"><a-p>* </a-p>Dashdancing: GCC players perceive that it&#39;s more difficult to hit a dashdancing box player because of their increased ability to react to a threat and dash away.</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L14" href="#L14">14</a><span class="code-text"><a-p>* </a-p>SDI: While GCCs can produce tremendous sustained SDI using the &quot;wank&quot; technique, boxes have much more consistency for short SDI windows and we want to reduce their ability to produce many SDI inputs in a very short time.</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L15" href="#L15">15</a><span class="code-text"><a-p>  * </a-p>Note: it will probably never be possible to make it more difficult to do two consecutive SDI inputs on a box.</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L16" href="#L16">16</a><span class="code-text"><a-p>* </a-p>Pivot tilts: While empty pivoting is somewhat less consistent on rectangles, they are able to pinpoint tilt inputs after an empty pivot much more quickly and consistently than a GCC player can reasonably do without overshooting.</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L17" href="#L17">17</a><span class="code-text"><a-p>* </a-p>Crouch uptilts: Reactionary crouching uptilts and run cancel uptilts, both strong options, are significantly easier on rectangles than on stick because a fast stick motion is likely to overshoot and result in an upsmash or tap jump.</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L18" href="#L18">18</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L19" href="#L19">19</a><span class="code-text"><a-p>Current nerfs (**SUBJECT TO CHANGE**)</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L20" href="#L20">20</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L21" href="#L21">21</a><span class="code-text"><a-p>* Neutral SOCD</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L22" href="#L22">22</a><span class="code-text"><a-p>  * Neutral SOCD helps mitigate easy three-consecutive-input SDI, though not completely.</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L23" href="#L23">23</a><span class="code-text"><a-p>  * Neutral SOCD also helps make long-distance dashdancing a little riskier, because there are two motions required to turn around when you want to change direction. Thus you have an increased risk of getting stuck in a skidding turnaround when you try to turn around right at the end of initial dash. Alternatively, you can release the forward direction early, but that sacrifices distance.</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L24" href="#L24">24</a><span class="code-text"><a-p>  * Many consider this to be slightly better than 2ip no-reactivation for controlling aerial drift, because you can never lock yourself out of drift.</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L25" href="#L25">25</a><span class="code-text"><a-p>  * It affects away-then-in ledgedashes, making them much harder to be frame-perfect similar to on sticks.</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L26" href="#L26">26</a><span class="code-text"><a-p>    * However, it is pointed out that c-stick ledgedrops still exist, just people would need to practice them (and they may be less ergonomic on rectangles with large button spacing).</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L27" href="#L27">27</a><span class="code-text"><a-p>    * Some players, depending on the character, want wider ModX wavedash angles to make held-modX down-then-in ledgedashes have the same timing. Is this just Fox?</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L28" href="#L28">28</a><span class="code-text"><a-p>  * However, it is generally riskier for vertical recovery mixups like fastfall up-b.</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L29" href="#L29">29</a><span class="code-text"><a-p>  * Additionally, if you&#39;re not used to lifting fingers up it may take time to get used to.</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L30" href="#L30">30</a><span class="code-text"><a-p>  * Will we stick with this? There are potential alternatives that have been suggested, though they are significantly harder to implement:</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L31" href="#L31">31</a><span class="code-text"><a-p>    * 2ip no reactivation that has significantly increased travel time when both directions are pressed</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L32" href="#L32">32</a><span class="code-text"><a-p>    * 2ip no reactivation vertically, but not horizontally. (possibly with the above); this would need an additional SDI nerf similar to the B0XX ones.</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L33" href="#L33">33</a><span class="code-text"><a-p>* Left stick travel time to the center or diagonal rim coordinates: 6ms (just over 1/3 frame)</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L34" href="#L34">34</a><span class="code-text"><a-p>  * Travel time exists to add some reaction time parity between sticks and buttons, and to also make digital inputs subject to at least some of the same polling timing considerations as sticks.</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L35" href="#L35">35</a><span class="code-text"><a-p>  * This value is based off measured center-to-rim stick speeds from various players, as well as a little bit of rectangle testing before where a player remarked that even slightly longer travel time felt worse.</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L36" href="#L36">36</a><span class="code-text"><a-p>  * Because the travel is linear, this delays inputs by 3 ms on average, but it may be slightly more depending on where the threshold is along the travel distance. For dashdancing turnarounds, this is more like a 5ms delay, but for dashing from standing it&#39;s more like 2ms.</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L37" href="#L37">37</a><span class="code-text"><a-p>* ~~Left stick movements to rim coordinates delayed by 4ms (1/4 frame).~~</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L38" href="#L38">38</a><span class="code-text"><a-p>  * This removes the risk of polling errors for rising edges but slightly slows reaction time.</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L39" href="#L39">39</a><span class="code-text"><a-p>* Left stick travel time to ~~non-center~~ non-cardinal or diagonal rim coordinates including the center: 12ms (2/3 frame)</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L40" href="#L40">40</a><span class="code-text"><a-p>  * This is longer than the rim travel times because it takes longer, on a stick, to pinpoint a non-rim position.</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L41" href="#L41">41</a><span class="code-text"><a-p>  * This used to be 16 ms, a whole frame, but users noted that it made timing button inputs for tilts harder. On a stick, even if it takes longer to get to a tilt location, you get feedback from your senses of when the motion is completed, but that&#39;s not true of button presses with simulated travel time.</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L42" href="#L42">42</a><span class="code-text"><a-p>* 4 frame travel time for cardinal tapping SDI (numpad notation: 5656...) faster than 10 presses/s, but not for taps shorter than half a frame for switch bounce leniency.</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L43" href="#L43">43</a><span class="code-text"><a-p>  * This is implemented because with neutral SOCD it&#39;s relatively easy to get double-rate mashing. To mash right with one full cycle per press AND per release, press right, press left, release left, release right (and repeat).</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L44" href="#L44">44</a><span class="code-text"><a-p>  * By merely increasing the travel time and not locking out, this mitigates SDI without significantly affecting aerial drift control via rapid tapping.</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L45" href="#L45">45</a><span class="code-text"><a-p>  * We need to do SDI testing to check whether this is needed at all for short SDI windows (Fox upair 1) and whether it can achieve more distance than wank SDI on long SDI windows (knee).</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L46" href="#L46">46</a><span class="code-text"><a-p>* ~~Lockout for diagonal tapping SDI (numpad notation: 636**3**...) faster than 10 presses/s (6f)~~ Currently Disabled</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L47" href="#L47">47</a><span class="code-text"><a-p>  * This was implemented for the same reasons as cardinal tap SDI.</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L48" href="#L48">48</a><span class="code-text"><a-p>  * However, at the moment it&#39;s disabled because it affects shield drop fastfall.</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L49" href="#L49">49</a><span class="code-text"><a-p>  * We would like users to test whether abusing diagonal tap SDI is noticeably impactful in game.</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L50" href="#L50">50</a><span class="code-text"><a-p>  * In the future this may be re-enabled with a different time window.</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L51" href="#L51">51</a><span class="code-text"><a-p>* Lockout for cardinal + diagonal tapping SDI (numpad notation: 56356**3**) faster than 7.5 presses/s (5.5f)</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L52" href="#L52">52</a><span class="code-text"><a-p>  * The last remaining SDI method gets you a cardinal and a diagonal SDI pulse for every press, by plinking two adjacent cardinals.</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L53" href="#L53">53</a><span class="code-text"><a-p>  * This is basically repeated quarter-circle SDI in a way that&#39;s not really doable on a stick.</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L54" href="#L54">54</a><span class="code-text"><a-p>  * It is occasionally impactful in game: one person reported that their ledgedash technique, which involves dropping from ledge with down then in, releasing, and pressing diagonal again to airdodge, was impacted.</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L55" href="#L55">55</a><span class="code-text"><a-p>* Lockout for cardinal-diagonal-opposite diagonal (numpad notation: 563**9**) with less than 5.5 frames between cardinal and second diagonal.</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L56" href="#L56">56</a><span class="code-text"><a-p>  * Even with neutral SOCD it&#39;s not too hard to get three consecutive SDI inputs without this.</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L57" href="#L57">57</a><span class="code-text"><a-p>* Moving from a crouching coordinate to an upward tilt in &lt; 3 frames will move the stick to a tap jump coordinate</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L58" href="#L58">58</a><span class="code-text"><a-p>  * This prevents users from continuously holding crouch and uptilting on reaction in a single motion.</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L59" href="#L59">59</a><span class="code-text"><a-p>  * Additionally, it affects the speed of run cancel uptilt.</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L60" href="#L60">60</a><span class="code-text"><a-p>  * Neutral SOCD does not compound with this: time spent in neutral counts towards the two frames you have to wait.</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L61" href="#L61">61</a><span class="code-text"><a-p>  * This is a fairly non-controversial new nerf, because it&#39;s something that is a strong option in game that is extremely difficult to execute on a stick.</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L62" href="#L62">62</a><span class="code-text"><a-p>  * The 3 frame window was initially determined by asking top GCC controller modders what they thought would be a reasonable limit.</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L63" href="#L63">63</a><span class="code-text"><a-p>  * In early testing, players have said that it feels reasonable. The limit is easy enough to avoid but at the same time holds back degenerate options.</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L64" href="#L64">64</a><span class="code-text"><a-p>  * NOTE: earlier this said 2 frames. I checked the code and it had been 3 frames all along.</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L65" href="#L65">65</a><span class="code-text"><a-p>* Tilt stick inputs less than 8.0 frames after an empty pivot will move the stick to a smash coordinate.</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L66" href="#L66">66</a><span class="code-text"><a-p>  * This detects an empty pivot that is &gt;50% probability of success: a 0.5 to 1.5 frame tap opposite of the last direction pressed.</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L67" href="#L67">67</a><span class="code-text"><a-p>  * Any upward or downward tilt input becomes full magnitude, as long as &lt; 8 frames have elapsed since the empty pivot.</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L68" href="#L68">68</a><span class="code-text"><a-p>  * This corresponds with the difficulty of controlling the stick after an empty pivot movement.</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L69" href="#L69">69</a><span class="code-text"><a-p>  * For upward directions, a minimum angle of 45 degrees is enforced to prevent up-angled ftilt and produce a tap jump regardless of the original angle. Otherwise, it attempts to preserve the angle so wavedashes are not randomly affected.</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L70" href="#L70">70</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L71" href="#L71">71</a><span class="code-text"><a-p>In addition to nerfs, it offers several features:</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L72" href="#L72">72</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L73" href="#L73">73</a><span class="code-text"><a-p>Arduino-based boxes will work at the same latency regardless of polling rate, as long as the poll spacing is constant.</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L74" href="#L74">74</a><span class="code-text"><a-p>Users no longer need to hold A on plugin to optimize latency on console, and it&#39;ll have slightly less lag on adapters.</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L75" href="#L75">75</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L76" href="#L76">76</a><span class="code-text"><a-p>Instead, the A press on plugin disables all timing based nerfs.</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L77" href="#L77">77</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L78" href="#L78">78</a><span class="code-text"><a-p>Additionally, you can hold B on plugin to get the shorter recovery coordinates that all have magnitudes about 0.8, for use with teleport recovery characters, and you can hold Down on plugin to get the crouch-walk option select.</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L79" href="#L79">79</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L80" href="#L80">80</a><span class="code-text"><a-p>It also currently has built-in support for a handful more boards than mainline Haybox, notably B0XX R4, Htangl, and Rana Digital.</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L81" href="#L81">81</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L82" href="#L82">82</a><span class="code-text"><a-p>Limitations: Any console polling that does not have uniform space between polls will trip up the connection. Notably, the Homebrew Menu, Nintendont, SmashScope on console, and third-party GCC to USB adapters can work either poorly or not at all.</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L83" href="#L83">83</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L84" href="#L84">84</a><span class="code-text"><a-p># </a-p><a-tt>HayBox</a-tt></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L85" href="#L85">85</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L86" href="#L86">86</a><span class="code-text"><a-p>HayBox is a modular, cross-platform firmware for digital or mixed analog/digital controllers, primarily targeted at [B0XX](https://b0xx.com)-style controllers.</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L87" href="#L87">87</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L88" href="#L88">88</a><span class="code-text"><a-p>[![GitHub issues](https://img.shields.io/github/issues/JonnyHaystack/HayBox)](https://github.com/JonnyHaystack/HayBox/issues)</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L89" href="#L89">89</a><span class="code-text"><a-p>[![GitHub pull requests](https://img.shields.io/github/issues-pr/JonnyHaystack/HayBox)](https://github.com/JonnyHaystack/HayBox/pulls)</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L90" href="#L90">90</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L91" href="#L91">91</a><span class="code-text"><a-p>## </a-p><a-tt>Table of Contents</a-tt></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L92" href="#L92">92</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L93" href="#L93">93</a><span class="code-text"><a-p>* [Features](#features)</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L94" href="#L94">94</a><span class="code-text"><a-p>* [Getting Started](#getting-started)</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L95" href="#L95">95</a><span class="code-text"><a-p>  * [Requirements](#requirements)</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L96" href="#L96">96</a><span class="code-text"><a-p>  * [Installation](#installation)</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L97" href="#L97">97</a><span class="code-text"><a-p>* [Usage](#usage)</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L98" href="#L98">98</a><span class="code-text"><a-p>  * [Default button holds](#default-button-holds)</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L99" href="#L99">99</a><span class="code-text"><a-p>  * [Dolphin setup](#dolphin-setup)</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L100" href="#L100">100</a><span class="code-text"><a-p>* [Customisation](#customisation)</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L101" href="#L101">101</a><span class="code-text"><a-p>  * [Console/gamemode selection bindings](#consolegamemode-selection-bindings)</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L102" href="#L102">102</a><span class="code-text"><a-p>  * [Creating custom input modes](#creating-custom-input-modes)</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L103" href="#L103">103</a><span class="code-text"><a-p>  * [Mod X lightshield and R shield tilt](#mod-x-lightshield-and-r-shield-tilt)</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L104" href="#L104">104</a><span class="code-text"><a-p>  * [Mode-specific optional features](#mode-specific-optional-features)</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L105" href="#L105">105</a><span class="code-text"><a-p>    * [Melee modes](#melee-modes)</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L106" href="#L106">106</a><span class="code-text"><a-p>    * [Project M/Project+ mode](#project-mproject-mode)</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L107" href="#L107">107</a><span class="code-text"><a-p>  * [Input sources](#input-sources)</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L108" href="#L108">108</a><span class="code-text"><a-p>  * [Using the Pico&#39;s second core](#using-the-picos-second-core)</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L109" href="#L109">109</a><span class="code-text"><a-p>* [Troubleshooting](#troubleshooting)</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L110" href="#L110">110</a><span class="code-text"><a-p>* [Contributing](#contributing)</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L111" href="#L111">111</a><span class="code-text"><a-p>* [Contributors](#contributors)</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L112" href="#L112">112</a><span class="code-text"><a-p>* [License](#license)</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L113" href="#L113">113</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L114" href="#L114">114</a><span class="code-text"><a-p>## </a-p><a-tt>Features</a-tt></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L115" href="#L115">115</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L116" href="#L116">116</a><span class="code-text"><a-p>Features include:</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L117" href="#L117">117</a><span class="code-text"><a-p>- Cross platform support:</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L118" href="#L118">118</a><span class="code-text"><a-p>  - RP2040 (e.g. Raspberry Pi Pico)</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L119" href="#L119">119</a><span class="code-text"><a-p>  - 16MHz AVR MCUs (e.g. ATMega32U4 which several Arduinos are based on)</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L120" href="#L120">120</a><span class="code-text"><a-p>- Supports many existing controllers/PCBs, e.g. B0XX, LBX, Smash Box, Crane&#39;s</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L121" href="#L121">121</a><span class="code-text"><a-p>  GCCPCB/Model S</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L122" href="#L122">122</a><span class="code-text"><a-p>- Supports a variety of communication backends which can be used either separately or in conjunction with each other:</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L123" href="#L123">123</a><span class="code-text"><a-p>  - XInput</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L124" href="#L124">124</a><span class="code-text"><a-p>  - DInput</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L125" href="#L125">125</a><span class="code-text"><a-p>  - GameCube console</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L126" href="#L126">126</a><span class="code-text"><a-p>  - Nintendo 64 console</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L127" href="#L127">127</a><span class="code-text"><a-p>  - Nintendo Switch console</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L128" href="#L128">128</a><span class="code-text"><a-p>  - B0XX input viewer</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L129" href="#L129">129</a><span class="code-text"><a-p>- Supports a variety of &quot;input sources&quot; which can be used in conjunction to create mixed input controllers:</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L130" href="#L130">130</a><span class="code-text"><a-p>  - Buttons/switches wired directly to GPIO pins</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L131" href="#L131">131</a><span class="code-text"><a-p>  - Switch matrix (as typically found in keyboards)</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L132" href="#L132">132</a><span class="code-text"><a-p>  - Wii Nunchuk</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L133" href="#L133">133</a><span class="code-text"><a-p>  - GameCube controller</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L134" href="#L134">134</a><span class="code-text"><a-p>- Melee mode up to date with B0XX V3 specifications</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L135" href="#L135">135</a><span class="code-text"><a-p>- Existing modes for popular games (e.g. Melee, Project M, Ultimate, Rivals of Aether, traditional fighting games)</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L136" href="#L136">136</a><span class="code-text"><a-p>- Easy to create new controller modes (or keyboard modes) for different games</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L137" href="#L137">137</a><span class="code-text"><a-p>- USB keyboard game modes for games that lack gamepad support</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L138" href="#L138">138</a><span class="code-text"><a-p>- Fully customisable SOCD cleaning, allowing you to configure SOCD button pairs (e.g. left/right, up/down) for each controller/keyboard mode, and also easily change the SOCD resolution method for each SOCD pair</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L139" href="#L139">139</a><span class="code-text"><a-p>- Switch modes on the fly without unplugging your controller</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L140" href="#L140">140</a><span class="code-text"><a-p>- Automatically detects whether plugged into console or USB</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L141" href="#L141">141</a><span class="code-text"><a-p>- Game modes and communication backends are independent entities, meaning you can use any game mode with any supported console without extra work</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L142" href="#L142">142</a><span class="code-text"><a-p>- Easily switch between different GameCube/N64 polling rates in order to have optimal latency on console, overclocked adapter, etc. (not necessary for Pico/RP2040)</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L143" href="#L143">143</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L144" href="#L144">144</a><span class="code-text"><a-p>## </a-p><a-tt>Getting Started</a-tt></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L145" href="#L145">145</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L146" href="#L146">146</a><span class="code-text"><a-p>### </a-p><a-tt>Requirements</a-tt></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L147" href="#L147">147</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L148" href="#L148">148</a><span class="code-text"><a-p>- [Git](https://git-scm.com/downloads) - required only if you are using a Pico. May become unnecessary at some point in the future.</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L149" href="#L149">149</a><span class="code-text"><a-p>- [PlatformIO IDE for VSCode](https://platformio.org/install/ide?install=vscode)</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L150" href="#L150">150</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L151" href="#L151">151</a><span class="code-text"><a-p>### </a-p><a-tt>Installation</a-tt></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L152" href="#L152">152</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L153" href="#L153">153</a><span class="code-text"><a-p>Download and extract the</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L154" href="#L154">154</a><span class="code-text"><a-p>[latest HayBox release](https://github.com/JonnyHaystack/HayBox/releases),</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L155" href="#L155">155</a><span class="code-text"><a-p>or clone the repository if you have git installed (which makes it easier for you</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L156" href="#L156">156</a><span class="code-text"><a-p>to pull updates).</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L157" href="#L157">157</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L158" href="#L158">158</a><span class="code-text"><a-p>After that:</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L159" href="#L159">159</a><span class="code-text"><a-p>1. Open Visual Studio Code</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L160" href="#L160">160</a><span class="code-text"><a-p>2. Click File -&gt; **Open Folder** and choose the HayBox folder (the one containing platformio.ini, not the folder above that)</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L161" href="#L161">161</a><span class="code-text"><a-p>3. Choose the appropriate build environment for your controller&#39;s PCB by</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L162" href="#L162">162</a><span class="code-text"><a-p>  clicking the environment selection button near the bottom left of the window</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L163" href="#L163">163</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L164" href="#L164">164</a><span class="code-text"><a-p>  ![image](https://user-images.githubusercontent.com/1266473/187039372-485c5f0d-60b3-4534-befb-e713f138a7c8.png)</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L165" href="#L165">165</a><span class="code-text"><a-p>  ![image](https://user-images.githubusercontent.com/1266473/187039585-cea18994-fd12-45fb-b43f-427eb7affb81.png)</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L166" href="#L166">166</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L167" href="#L167">167</a><span class="code-text"><a-p>4. If your controller has a different pinout than any of the existing configs, you may edit the button mappings and other pins at the top of the config (`config/&lt;environment&gt;/config.cpp`). Any buttons that your controller doesn&#39;t have can simply be deleted from the list.</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L168" href="#L168">168</a><span class="code-text"><a-p>5. If you see a message in the bottom bar saying &quot;Rebuilding IntelliSense Index&quot; or &quot;Loading Project Tasks&quot;, wait for it to disappear. For Pico especially it may take quite a while the first time because it has to download 2-3GB of dependencies.</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L169" href="#L169">169</a><span class="code-text"><a-p>6. Click **Build** (in the bottom left) and make sure everything compiles without</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L170" href="#L170">170</a><span class="code-text"><a-p>  errors</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L171" href="#L171">171</a><span class="code-text"><a-p>7. This  next step differs depending on the microcontroller used in your controller.</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L172" href="#L172">172</a><span class="code-text"><a-p>    - **For Pico-based controllers**: hold the bootsel button while plugging it in (or your Start button if you already have HayBox installed) and then drag and drop the file `HayBox/.pio/build/&lt;environment&gt;/firmware.uf2` onto the RPI-RP2 drive that comes up.</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L173" href="#L173">173</a><span class="code-text"><a-p>    - **For Arduino-based controllers**: Plug in your controller via USB and click **Upload** (next to the Build button)</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L174" href="#L174">174</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L175" href="#L175">175</a><span class="code-text"><a-p>## </a-p><a-tt>Usage</a-tt></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L176" href="#L176">176</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L177" href="#L177">177</a><span class="code-text"><a-p>### </a-p><a-tt>Default button holds</a-tt></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L178" href="#L178">178</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L179" href="#L179">179</a><span class="code-text"><a-p>#### </a-p><a-tt>Pico bootsel mode</a-tt></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L180" href="#L180">180</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L181" href="#L181">181</a><span class="code-text"><a-p>To reboot Pico-based controllers into bootsel mode, hold Start on plugin.</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L182" href="#L182">182</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L183" href="#L183">183</a><span class="code-text"><a-p>#### </a-p><a-tt>Brook board passthrough mode</a-tt></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L184" href="#L184">184</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L185" href="#L185">185</a><span class="code-text"><a-p>To switch to Brook board mode on GCCPCB2, GCCMX, B0XX R2, or LBX, hold B and R on</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L186" href="#L186">186</a><span class="code-text"><a-p>plugin.</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L187" href="#L187">187</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L188" href="#L188">188</a><span class="code-text"><a-p>#### </a-p><a-tt>Communication backends (console selection)</a-tt></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L189" href="#L189">189</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L190" href="#L190">190</a><span class="code-text"><a-p>Communication backends are selected slightly differently depending on the type</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L191" href="#L191">191</a><span class="code-text"><a-p>of microcontroller used in the controller.</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L192" href="#L192">192</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L193" href="#L193">193</a><span class="code-text"><a-p>On Pico/RP2040, USB vs GameCube vs Nintendo 64 is detected automatically. If</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L194" href="#L194">194</a><span class="code-text"><a-p>not plugged into a console, the default is **XInput**, which should work</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L195" href="#L195">195</a><span class="code-text"><a-p>plug-and-play with most PC games.</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L196" href="#L196">196</a><span class="code-text"><a-p>Other backends are selected by holding one of the following buttons on plugin:</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L197" href="#L197">197</a><span class="code-text"><a-p>- X - Nintendo Switch USB mode (also sets initial game mode to Ultimate mode)</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L198" href="#L198">198</a><span class="code-text"><a-p>- Z - DInput mode (only recommended for games which don&#39;t support XInput)</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L199" href="#L199">199</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L200" href="#L200">200</a><span class="code-text"><a-p>On Arduino/AVR, the **DInput** backend is selected if a USB connection is detected.</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L201" href="#L201">201</a><span class="code-text"><a-p>Otherwise, it defaults to GameCube backend, unless another backend is manually</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L202" href="#L202">202</a><span class="code-text"><a-p>selected by holding one of the following buttons on plugin:</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L203" href="#L203">203</a><span class="code-text"><a-p>- A - GameCube backend with polling rate fix disabled (used for GCC adapters)</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L204" href="#L204">204</a><span class="code-text"><a-p>- C-Left - Nintendo 64 backend (60Hz polling rate)</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L205" href="#L205">205</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L206" href="#L206">206</a><span class="code-text"><a-p>#### </a-p><a-tt>Game mode selection</a-tt></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L207" href="#L207">207</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L208" href="#L208">208</a><span class="code-text"><a-p>Unlike other similar firmwares, HayBox by default allows you to switch</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L209" href="#L209">209</a><span class="code-text"><a-p>modes on the fly without unplugging your controller. This is mainly useful on</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L210" href="#L210">210</a><span class="code-text"><a-p>PC, as opposed to console where you usually have to restart the console to</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L211" href="#L211">211</a><span class="code-text"><a-p>switch game anyway. It also serves the purpose of reducing the number of buttons</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L212" href="#L212">212</a><span class="code-text"><a-p>you have to hold with one hand while plugging in.</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L213" href="#L213">213</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L214" href="#L214">214</a><span class="code-text"><a-p>The default controller mode button combinations are:</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L215" href="#L215">215</a><span class="code-text"><a-p>- Mod X + Start + L - Melee mode (default)</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L216" href="#L216">216</a><span class="code-text"><a-p>- Mod X + Start + Left - Project M/Project+ mode</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L217" href="#L217">217</a><span class="code-text"><a-p>- Mod X + Start + Down - Ultimate mode</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L218" href="#L218">218</a><span class="code-text"><a-p>- Mod X + Start + Right - FGC mode (Hitbox style fighting game layout)</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L219" href="#L219">219</a><span class="code-text"><a-p>- Mod X + Start + B - Rivals of Aether mode</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L220" href="#L220">220</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L221" href="#L221">221</a><span class="code-text"><a-p>Default keyboard mode button combinations (only available when using DInput backend, **not** with XInput):</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L222" href="#L222">222</a><span class="code-text"><a-p>- Mod Y + Start + L - Default keyboard mode</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L223" href="#L223">223</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L224" href="#L224">224</a><span class="code-text"><a-p>### </a-p><a-tt>Dolphin setup</a-tt></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L225" href="#L225">225</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L226" href="#L226">226</a><span class="code-text"><a-p>HayBox needs a different Dolphin controller profile than the official B0XX firmware, as it</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L227" href="#L227">227</a><span class="code-text"><a-p>uses different DInput mappings that make more sense for use across multiple games. These</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L228" href="#L228">228</a><span class="code-text"><a-p>can be found in the `dolphin` folder in the HayBox repo. The profile files are named to</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L229" href="#L229">229</a><span class="code-text"><a-p>indicate what communication backend and operating system they are for:</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L230" href="#L230">230</a><span class="code-text"><a-p>- For Windows:</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L231" href="#L231">231</a><span class="code-text"><a-p>  - HayBox_XInput.ini - For Pico/RP2040-based controllers (e.g. B0XX R4)</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L232" href="#L232">232</a><span class="code-text"><a-p>  - HayBox_DInput.ini - For Arduino/AVR-based controllers (e.g. B0XX R1-3, LBX)</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L233" href="#L233">233</a><span class="code-text"><a-p>- For Linux:</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L234" href="#L234">234</a><span class="code-text"><a-p>  - HayBox_XInput_Linux.ini - For Pico/RP2040-based controllers (e.g. B0XX R4)</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L235" href="#L235">235</a><span class="code-text"><a-p>  - HayBox_DInput_Linux.ini - For Arduino/AVR-based controllers (e.g. B0XX R1-3, LBX)</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L236" href="#L236">236</a><span class="code-text"><a-p>- For macOS (unsupported*):</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L237" href="#L237">237</a><span class="code-text"><a-p>  - HayBox_DInput_macOS.ini</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L238" href="#L238">238</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L239" href="#L239">239</a><span class="code-text"><a-p>To install the profile:</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L240" href="#L240">240</a><span class="code-text"><a-p>1. Copy the appropriate .ini file from the `dolphin` folder within HayBox to the folder `&lt;YourDolphinInstallation&gt;\User\Config\Profiles\GCPad\` (create it if it does not exist)</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L241" href="#L241">241</a><span class="code-text"><a-p>- For Slippi this should be</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L242" href="#L242">242</a><span class="code-text"><a-p>  - On Windows: `%appdata%\Slippi Launcher\netplay\User\Config\Profiles\GCPad\` (if this doesn&#39;t work, try `...\netplay\Sys\User\...`)</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L243" href="#L243">243</a><span class="code-text"><a-p>  - On Linux: `~/.config/SlippiOnline/Config/Profiles/GCPad/`</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L244" href="#L244">244</a><span class="code-text"><a-p>  - On Mac: `Cmd + Shift + G` and enter the path `/Users/&lt;USER&gt;/Library/Application Support/Slippi Launcher/netplay/Slippi Dolphin.app/Contents/Resources/User/Config/Profiles/GCPad`</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L245" href="#L245">245</a><span class="code-text"><a-p>- For vanilla Dolphin:</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L246" href="#L246">246</a><span class="code-text"><a-p>  - On Windows: `%userprofile%\Documents\Dolphin Emulator\Config\Profiles\GCPad\`</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L247" href="#L247">247</a><span class="code-text"><a-p>  - On Linux: `~/.config/dolphin-emu/Profiles/GCPad/`</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L248" href="#L248">248</a><span class="code-text"><a-p>2. Plug in your controller, and configure a &quot;Standard Controller&quot; in Dolphin</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L249" href="#L249">249</a><span class="code-text"><a-p>3. Click **Refresh** next to the Device dropdown</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L250" href="#L250">250</a><span class="code-text"><a-p>4. Select the HayBox profile from the profile dropdown, and click **Load** (NOT Save)</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L251" href="#L251">251</a><span class="code-text"><a-p>5. Make sure the correct device is selected in the device dropdown</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L252" href="#L252">252</a><span class="code-text"><a-p>6. Click **Close**</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L253" href="#L253">253</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L254" href="#L254">254</a><span class="code-text"><a-p>\* macOS only supports DInput (and not very well), so if using a Pico/RP2040-based controller you will have to force DInput mode by holding Z on plugin, and even then it may not work. I can&#39;t really do anything about Apple&#39;s poor controller support (which they seem to break with every other update) and I don&#39;t own any Apple devices, so this will also be considered unsupported usage of HayBox.</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L255" href="#L255">255</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L256" href="#L256">256</a><span class="code-text"><a-p>## </a-p><a-tt>Customisation</a-tt></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L257" href="#L257">257</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L258" href="#L258">258</a><span class="code-text"><a-p>### </a-p><a-tt>Console/gamemode selection bindings</a-tt></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L259" href="#L259">259</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L260" href="#L260">260</a><span class="code-text"><a-p>#### </a-p><a-tt>Communication backends (console selection)</a-tt></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L261" href="#L261">261</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L262" href="#L262">262</a><span class="code-text"><a-p>The communication backend (e.g. DInput, GameCube, or N64) is selected partly</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L263" href="#L263">263</a><span class="code-text"><a-p>through auto detection and partly based on the buttons held on plugin. This is</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L264" href="#L264">264</a><span class="code-text"><a-p>handled in `config/&lt;environment&gt;/config.cpp`, in the `setup()` function.</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L265" href="#L265">265</a><span class="code-text"><a-p>The logic is fairly simple, and even if you don&#39;t have programming experience it</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L266" href="#L266">266</a><span class="code-text"><a-p>shouldn&#39;t be too hard to see what&#39;s going on and change things if you wish.</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L267" href="#L267">267</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L268" href="#L268">268</a><span class="code-text"><a-p>The config folders corresponding to the Arduino environments are:</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L269" href="#L269">269</a><span class="code-text"><a-p>- `config/arduino_nativeusb/` for Arduino with native USB support (e.g. Leonardo, Micro)</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L270" href="#L270">270</a><span class="code-text"><a-p>- `config/arduino/` for Arduino without native USB support (e.g. Uno, Nano, Mega 2560)</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L271" href="#L271">271</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L272" href="#L272">272</a><span class="code-text"><a-p>For Arduino device configs you may notice that the number 125 is passed into</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L273" href="#L273">273</a><span class="code-text"><a-p>`GamecubeBackend()`. This lets you change the polling rate e.g. if your DIY</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L274" href="#L274">274</a><span class="code-text"><a-p>doesn&#39;t support native USB and you want to use it with an overclocked GameCube</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L275" href="#L275">275</a><span class="code-text"><a-p>controller adapter. In that example, you could pass in 1000 to sync up to the</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L276" href="#L276">276</a><span class="code-text"><a-p>1000Hz polling rate, or 0 to disable this lag fix completely.</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L277" href="#L277">277</a><span class="code-text"><a-p>Polling rate can be passed into the N64Backend constructor in the same way as this.</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L278" href="#L278">278</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L279" href="#L279">279</a><span class="code-text"><a-p>You may notice that 1000Hz polling rate works on console as well. Be aware</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L280" href="#L280">280</a><span class="code-text"><a-p>that while this works, it will result in more input lag. The point of setting</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L281" href="#L281">281</a><span class="code-text"><a-p>the polling rate here is so that the GameCube backend can delay until right</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L282" href="#L282">282</a><span class="code-text"><a-p>before the next poll before reading the inputs, so that the inputs are fresh and</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L283" href="#L283">283</a><span class="code-text"><a-p>not outdated.</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L284" href="#L284">284</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L285" href="#L285">285</a><span class="code-text"><a-p>For Pico/RP2040, it is not necessary to pass in a console polling rate, because</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L286" href="#L286">286</a><span class="code-text"><a-p>the Pico has enough processing power to read/process inputs after receiving the</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L287" href="#L287">287</a><span class="code-text"><a-p>console poll, so there is no need to predict when the poll will arrive and</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L288" href="#L288">288</a><span class="code-text"><a-p>prepare things in advance.</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L289" href="#L289">289</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L290" href="#L290">290</a><span class="code-text"><a-p>#### </a-p><a-tt>Input modes</a-tt></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L291" href="#L291">291</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L292" href="#L292">292</a><span class="code-text"><a-p>To configure the button holds for input modes (controller/keyboard modes), edit</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L293" href="#L293">293</a><span class="code-text"><a-p>the `select_mode()` function in `config/mode_selection.hpp`. Each `if`</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L294" href="#L294">294</a><span class="code-text"><a-p>statement is a button combination to select an input mode.</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L295" href="#L295">295</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L296" href="#L296">296</a><span class="code-text"><a-p>Most input modes support passing in an SOCD cleaning mode, e.g.</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L297" href="#L297">297</a><span class="code-text"><a-p>`socd::2IP_NO_REAC`. See [here](#socd) for the other available modes.</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L298" href="#L298">298</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L299" href="#L299">299</a><span class="code-text"><a-p>### </a-p><a-tt>Creating custom input modes</a-tt></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L300" href="#L300">300</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L301" href="#L301">301</a><span class="code-text"><a-p>For creating new input modes, it helps if you know some C++, or at least have</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L302" href="#L302">302</a><span class="code-text"><a-p>some programming experience. That said, you should be able to get by even</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L303" href="#L303">303</a><span class="code-text"><a-p>without prior experience if you just base your new mode off the existing ones</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L304" href="#L304">304</a><span class="code-text"><a-p>and refer to them as examples.</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L305" href="#L305">305</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L306" href="#L306">306</a><span class="code-text"><a-p>There are two types of input modes: ControllerMode and KeyboardMode</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L307" href="#L307">307</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L308" href="#L308">308</a><span class="code-text"><a-p>#### </a-p><a-tt>Keyboard modes</a-tt></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L309" href="#L309">309</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L310" href="#L310">310</a><span class="code-text"><a-p>Keyboard modes are a little bit simpler so let&#39;s start there.</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L311" href="#L311">311</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L312" href="#L312">312</a><span class="code-text"><a-p>A KeyboardMode behaves as a standard keyboard and should work with any device</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L313" href="#L313">313</a><span class="code-text"><a-p>that supports keyboards.</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L314" href="#L314">314</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L315" href="#L315">315</a><span class="code-text"><a-p>You are free to use whatever logic and programming tricks you like in the</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L316" href="#L316">316</a><span class="code-text"><a-p>`UpdateKeys()` function to decide the outputs based on the input state. You could</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L317" href="#L317">317</a><span class="code-text"><a-p>create input layers (like the D-Pad layer in Melee mode that is activated when</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L318" href="#L318">318</a><span class="code-text"><a-p>holding Mod X and Mod Y), or other types of conditional inputs.</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L319" href="#L319">319</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L320" href="#L320">320</a><span class="code-text"><a-p>The list of available keycodes can be found [here](https://github.com/JonnyHaystack/ArduinoKeyboard/blob/master/include/keycodes.h).</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L321" href="#L321">321</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L322" href="#L322">322</a><span class="code-text"><a-p>Remember that keyboard modes can only be activated when using the **DInput** communication backend (**not** XInput).</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L323" href="#L323">323</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L324" href="#L324">324</a><span class="code-text"><a-p>#### </a-p><a-tt>Controller modes</a-tt></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L325" href="#L325">325</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L326" href="#L326">326</a><span class="code-text"><a-p>A ControllerMode takes a digital button input state and transforms it into an</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L327" href="#L327">327</a><span class="code-text"><a-p>output state corresponding to a standard gamepad. Any ControllerMode will work</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L328" href="#L328">328</a><span class="code-text"><a-p>with any CommunicationBackend. A CommunicationBackend simply reads inputs from one or more input sources, uses the current ControllerMode to update the outputs based on those inputs, and handles the sending of the outputs to the console or PC.</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L329" href="#L329">329</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L330" href="#L330">330</a><span class="code-text"><a-p>To create a ControllerMode, you just need to implement the functions</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L331" href="#L331">331</a><span class="code-text"><a-p>`UpdateDigitalOutputs()` and `UpdateAnalogOutputs()`.</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L332" href="#L332">332</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L333" href="#L333">333</a><span class="code-text"><a-p>`UpdateDigitalOutputs()` is very similar to the `UpdateKeys()` function in keyboard</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L334" href="#L334">334</a><span class="code-text"><a-p>modes, with the difference that rather than calling a `Press()` function to</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L335" href="#L335">335</a><span class="code-text"><a-p>immediately send inputs, we are simply setting the output state for this</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L336" href="#L336">336</a><span class="code-text"><a-p>iteration. As the name indicates, we will only deal with the digital outputs in</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L337" href="#L337">337</a><span class="code-text"><a-p>this function.</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L338" href="#L338">338</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L339" href="#L339">339</a><span class="code-text"><a-p>`UpdateAnalogOutputs()` is a bit more complicated. Firstly, it has to call</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L340" href="#L340">340</a><span class="code-text"><a-p>`UpdateDirections()` before doing anything else. This function takes in values</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L341" href="#L341">341</a><span class="code-text"><a-p>indicating whether your left and right sticks are pointing left/right/up/down.</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L342" href="#L342">342</a><span class="code-text"><a-p>You also pass in the minimum, neutral (centre), and maximum stick analog values,</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L343" href="#L343">343</a><span class="code-text"><a-p>so you can configure these on a per-mode basis. All this information is used to</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L344" href="#L344">344</a><span class="code-text"><a-p>automatically set the stick analog values based on the inputs you passed in. This</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L345" href="#L345">345</a><span class="code-text"><a-p>is all you need to do unless you want to implement modifiers.</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L346" href="#L346">346</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L347" href="#L347">347</a><span class="code-text"><a-p>`UpdateDirections()` also populates the variable `directions` with values</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L348" href="#L348">348</a><span class="code-text"><a-p>indicating current stick direction, which can be 1, 0, or -1 for the X and Y</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L349" href="#L349">349</a><span class="code-text"><a-p>axes for both sticks. These values make it much easier to write modifier logic.</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L350" href="#L350">350</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L351" href="#L351">351</a><span class="code-text"><a-p>After calling `UpdateDirections()`, add any modifier handling logic that you want.</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L352" href="#L352">352</a><span class="code-text"><a-p>Remember that `UpdateDirections()` already set the default analog stick values,</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L353" href="#L353">353</a><span class="code-text"><a-p>so when handling modifiers you only need to manually set the values for the axes</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L354" href="#L354">354</a><span class="code-text"><a-p>that are actually being modified. Other than this, I can&#39;t teach how to write</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L355" href="#L355">355</a><span class="code-text"><a-p>your modifier logic, so just look at the examples and play around.</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L356" href="#L356">356</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L357" href="#L357">357</a><span class="code-text"><a-p>Finally, set any analog trigger values that you need.</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L358" href="#L358">358</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L359" href="#L359">359</a><span class="code-text"><a-p>Note: Analog trigger outputs could just as well be handled in</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L360" href="#L360">360</a><span class="code-text"><a-p>`UpdateDigitalOutputs()`, but I think it usually looks cleaner to keep them</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L361" href="#L361">361</a><span class="code-text"><a-p>along with the other analog outputs.</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L362" href="#L362">362</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L363" href="#L363">363</a><span class="code-text"><a-p>Also note: You don&#39;t need to worry about resetting the output state or clearing</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L364" href="#L364">364</a><span class="code-text"><a-p>anything from it. This is done automatically at the start of each iteration.</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L365" href="#L365">365</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L366" href="#L366">366</a><span class="code-text"><a-p>### </a-p><a-tt>SOCD</a-tt></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L367" href="#L367">367</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L368" href="#L368">368</a><span class="code-text"><a-p>In the constructor of each mode (for controller modes *and* keyboard modes), you</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L369" href="#L369">369</a><span class="code-text"><a-p>can configure pairs of opposing direction inputs to apply SOCD cleaning to.</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L370" href="#L370">370</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L371" href="#L371">371</a><span class="code-text"><a-p>For example, in `src/modes/Melee20Button.cpp`:</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L372" href="#L372">372</a><span class="code-text"><a-p>```</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L373" href="#L373">373</a><span class="code-text"><a-p>_socd_pair_count = 4;</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L374" href="#L374">374</a><span class="code-text"><a-p>_socd_pairs = new socd::SocdPair[_socd_pair_count]{</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L375" href="#L375">375</a><span class="code-text"><a-p>    socd::SocdPair{&amp;InputState::left,    &amp;InputState::right,   socd_type},</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L376" href="#L376">376</a><span class="code-text"><a-p>    socd::SocdPair{ &amp;InputState::down,   &amp;InputState::up,      socd_type},</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L377" href="#L377">377</a><span class="code-text"><a-p>    socd::SocdPair{ &amp;InputState::c_left, &amp;InputState::c_right, socd_type},</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L378" href="#L378">378</a><span class="code-text"><a-p>    socd::SocdPair{ &amp;InputState::c_down, &amp;InputState::c_up,    socd_type},</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L379" href="#L379">379</a><span class="code-text"><a-p>};</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L380" href="#L380">380</a><span class="code-text"><a-p>```</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L381" href="#L381">381</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L382" href="#L382">382</a><span class="code-text"><a-p>This sets up left/right, down/up, C-Left/C-Right, and C-Down/C-Up as pairs of</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L383" href="#L383">383</a><span class="code-text"><a-p>opposing cardinal directions for which SOCD cleaning will be applied. The SOCD</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L384" href="#L384">384</a><span class="code-text"><a-p>cleaning is automatically done before `UpdateDigitalOutputs()` and</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L385" href="#L385">385</a><span class="code-text"><a-p>`UpdateAnalogOutputs()`, and you do not need to worry about it any further than</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L386" href="#L386">386</a><span class="code-text"><a-p>that.</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L387" href="#L387">387</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L388" href="#L388">388</a><span class="code-text"><a-p>For each `SocdPair` you can pass in an `SocdType` of your choosing. By default</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L389" href="#L389">389</a><span class="code-text"><a-p>for most modes this is passed in as a single constructor parameter, but it is</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L390" href="#L390">390</a><span class="code-text"><a-p>possible to pass in multiple parameters, or simply use a hardcoded value. Both</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L391" href="#L391">391</a><span class="code-text"><a-p>of these approaches are exemplified in `src/modes/FgcMode.cpp`.</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L392" href="#L392">392</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L393" href="#L393">393</a><span class="code-text"><a-p>| `SocdType` | Description |</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L394" href="#L394">394</a><span class="code-text"><a-p>| ---------- | ----------- |</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L395" href="#L395">395</a><span class="code-text"><a-p>| `SOCD_NEUTRAL` | Left + right = neutral - the default if no `SocdType` specified in the `SocdPair` |</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L396" href="#L396">396</a><span class="code-text"><a-p>| `SOCD_2IP` | Second input priority - left -&gt; left + right = right, and vice versa. Releasing the second direction gives the original direction |</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L397" href="#L397">397</a><span class="code-text"><a-p>| `SOCD_2IP_NO_REAC` | Second input priority without reactivation - same as above, except releasing the second direction results in neutral. The original direction must be physically reactuated. |</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L398" href="#L398">398</a><span class="code-text"><a-p>| `SOCD_DIR1_PRIORITY` | The first button in the `SocdPair` always takes priority over the second |</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L399" href="#L399">399</a><span class="code-text"><a-p>| `SOCD_DIR2_PRIORITY` | The second button in the `SocdPair` always takes priority over the first |</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L400" href="#L400">400</a><span class="code-text"><a-p>| `SOCD_NONE` | No SOCD resolution - the game decides |</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L401" href="#L401">401</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L402" href="#L402">402</a><span class="code-text"><a-p>Note that you do not have to implement a `HandleSocd()` function like in the</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L403" href="#L403">403</a><span class="code-text"><a-p>Melee20Button and Melee18Button modes. It is only overridden in these modes</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L404" href="#L404">404</a><span class="code-text"><a-p>so that we can check if left and right are both held *before* SOCD cleaning,</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L405" href="#L405">405</a><span class="code-text"><a-p>because when they are both held (without a vertical direction being held) we</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L406" href="#L406">406</a><span class="code-text"><a-p>need to override all modifiers.</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L407" href="#L407">407</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L408" href="#L408">408</a><span class="code-text"><a-p>### </a-p><a-tt>Mod X lightshield and R shield tilt</a-tt></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L409" href="#L409">409</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L410" href="#L410">410</a><span class="code-text"><a-p>If your controller has no lightshield buttons, you may want to use Mod X for</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L411" href="#L411">411</a><span class="code-text"><a-p>lightshield and put shield tilt on R instead. You can do this by using the</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L412" href="#L412">412</a><span class="code-text"><a-p>Melee18Button mode instead of Melee20Button.</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L413" href="#L413">413</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L414" href="#L414">414</a><span class="code-text"><a-p>### </a-p><a-tt>Mode-specific optional features</a-tt></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L415" href="#L415">415</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L416" href="#L416">416</a><span class="code-text"><a-p>#### </a-p><a-tt>Melee modes</a-tt></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L417" href="#L417">417</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L418" href="#L418">418</a><span class="code-text"><a-p>The Melee20Button and Melee18Button modes provide a choice of which coordinates to use</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L419" href="#L419">419</a><span class="code-text"><a-p>when pressing down + right. By default, holding down + back will allow you to do automatic</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L420" href="#L420">420</a><span class="code-text"><a-p>jab-cancels, which is a useful technique for some characters.</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L421" href="#L421">421</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L422" href="#L422">422</a><span class="code-text"><a-p>Another popular technique that uses the down + right diagonal is the so-called crouch/walk</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L423" href="#L423">423</a><span class="code-text"><a-p>option-select. This technique involves holding down + forward at a certain angle while</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L424" href="#L424">424</a><span class="code-text"><a-p>crouching, such that after crouch-cancelling an attack you will automatically start</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L425" href="#L425">425</a><span class="code-text"><a-p>walking towards your opponent instead of going back into crouch. This can be very useful</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L426" href="#L426">426</a><span class="code-text"><a-p>for tech-chasing, but the coordinates used for this technique do not allow you to auto</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L427" href="#L427">427</a><span class="code-text"><a-p>jab-cancel.</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L428" href="#L428">428</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L429" href="#L429">429</a><span class="code-text"><a-p>This can be configured as seen in `config/mode_selection.hpp` by setting the `crouch_walk_os` option to true:</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L430" href="#L430">430</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L431" href="#L431">431</a><span class="code-text"><a-p>```</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L432" href="#L432">432</a><span class="code-text"><a-p>new Melee20Button(socd::SOCD_2IP_NO_REAC, { .crouch_walk_os = false })</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L433" href="#L433">433</a><span class="code-text"><a-p>```</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L434" href="#L434">434</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L435" href="#L435">435</a><span class="code-text"><a-p>You will also have to change this in your `config/&lt;environment&gt;/config.cpp` in order for it to be applied on plugin, as `mode_selection.hpp` only controls what happens when you *switch* mode.</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L436" href="#L436">436</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L437" href="#L437">437</a><span class="code-text"><a-p>#### </a-p><a-tt>Project M/Project+ mode</a-tt></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L438" href="#L438">438</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L439" href="#L439">439</a><span class="code-text"><a-p>The ProjectM mode has some extra options to configure certain behaviours. As seen</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L440" href="#L440">440</a><span class="code-text"><a-p>in `config/mode_selection.hpp`:</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L441" href="#L441">441</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L442" href="#L442">442</a><span class="code-text"><a-p>```</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L443" href="#L443">443</a><span class="code-text"><a-p>new ProjectM(</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L444" href="#L444">444</a><span class="code-text"><a-p>    socd::SOCD_2IP_NO_REAC,</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L445" href="#L445">445</a><span class="code-text"><a-p>    { .true_z_press = false, .ledgedash_max_jump_traj = true }</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L446" href="#L446">446</a><span class="code-text"><a-p>)</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L447" href="#L447">447</a><span class="code-text"><a-p>```</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L448" href="#L448">448</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L449" href="#L449">449</a><span class="code-text"><a-p>Firstly, the `ledgedash_max_jump_traj` option allows you to enable or disable the behaviour</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L450" href="#L450">450</a><span class="code-text"><a-p>borrowed from Melee mode where holding left and right (and no vertical directions)</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L451" href="#L451">451</a><span class="code-text"><a-p>will give a 1.0 cardinal regardless of modifiers being held.</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L452" href="#L452">452</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L453" href="#L453">453</a><span class="code-text"><a-p>If you change the SOCD mode to 2IP (with reactivation), you should also change</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L454" href="#L454">454</a><span class="code-text"><a-p>this option to false if you want a smooth gameplay experience.</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L455" href="#L455">455</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L456" href="#L456">456</a><span class="code-text"><a-p>Secondly, the `true_z_press` option exists because Project M/Project+ do not handle</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L457" href="#L457">457</a><span class="code-text"><a-p>Z presses the same way Melee does.</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L458" href="#L458">458</a><span class="code-text"><a-p>Melee interprets a Z press as lightshield + A, and thus it can be used for L</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L459" href="#L459">459</a><span class="code-text"><a-p>cancelling without locking you out of techs. In PM/P+, a Z press will trigger a</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L460" href="#L460">460</a><span class="code-text"><a-p>tech and thus cause unwanted tech lockouts if used to L cancel.</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L461" href="#L461">461</a><span class="code-text"><a-p>By default in HayBox, the ProjectM mode is set to use a macro of lightshield + A</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L462" href="#L462">462</a><span class="code-text"><a-p>in order to preserve expected behaviour from Melee. However, this macro does not</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L463" href="#L463">463</a><span class="code-text"><a-p>enable you to use tether/grapple attacks or grab items. To workaround this, you</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L464" href="#L464">464</a><span class="code-text"><a-p>can press Mod X + Z to send a true Z input.</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L465" href="#L465">465</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L466" href="#L466">466</a><span class="code-text"><a-p>If this bothers you, and you just want to send a true Z input by default when</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L467" href="#L467">467</a><span class="code-text"><a-p>pressing Z, you can set the `true_z_press` option to true.</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L468" href="#L468">468</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L469" href="#L469">469</a><span class="code-text"><a-p>### </a-p><a-tt>Input sources</a-tt></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L470" href="#L470">470</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L471" href="#L471">471</a><span class="code-text"><a-p>HayBox supports several input sources that can be read from to update the input</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L472" href="#L472">472</a><span class="code-text"><a-p>state:</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L473" href="#L473">473</a><span class="code-text"><a-p>- `GpioButtonInput` - The most commonly used, for reading switches/buttons connected directly to GPIO pins. The input mappings are defined by an array of `GpioButtonMapping` as can be seen in almost all existing configs.</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L474" href="#L474">474</a><span class="code-text"><a-p>- `SwitchMatrixInput` - Similar to the above, but scans a keyboard style switch matrix instead of individual switches. A config for Crane&#39;s Model C&lt;=53 is included at `config/c53/config.cpp` which serves as an example of how to define and use a switch matrix input source.</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L475" href="#L475">475</a><span class="code-text"><a-p>- `NunchukInput` - Reads inputs from a Wii Nunchuk using i2c. This can be used for mixed input controllers (e.g. left hand uses a Nunchuk for movement, and right hand uses buttons for other controls)</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L476" href="#L476">476</a><span class="code-text"><a-p>- `GamecubeControllerInput` - Similar to the above, but reads from a GameCube controller. Can be instantiated similarly to GamecubeBackend. Currently only implemented for Pico, and you must either run it on a different pio instance (pio0 or pio1) than any instances of GamecubeBackend, or make sure that both use the same PIO instruction memory offset.</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L477" href="#L477">477</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L478" href="#L478">478</a><span class="code-text"><a-p>Each input source has a &quot;scan speed&quot; value which indicates roughly how long it takes for it to read inputs. Fast input sources are always read at the last possible moment (at least on Pico), resulting in very low latency. Conversely, slow input sources are typically read quite long before they are needed, as they are too slow to be read in response to poll. Because of this, it is more ideal to be constantly reading those inputs on a separate core. This is not possible on AVR MCUs as they are all single core, but it is possible (and easy) on the Pico/RP2040. The bottom of the default Pico config `config/pico/config.cpp` illustrates this by using core1 to read Nunchuk inputs while core0 handles everything else. See [the next section](#using-the-picos-second-core) for more information about using core1.</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L479" href="#L479">479</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L480" href="#L480">480</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L481" href="#L481">481</a><span class="code-text"><a-p>In each config&#39;s `setup()` function, we build up an array of input sources, and then pass it into a communication backend. The communication backend decides when to read which input sources, because inputs need to be read at different points in time for different backends. We also build an array of communication backends, allowing more than one backend to be used at once. For example, in most configs, the B0XX input viewer backend is used as a secondary backend whenever the DInput backend is used. In each iteration, the main loop tells each of the backends to send their respective reports. In future, there could be more backends for things like writing information to an OLED display.</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L482" href="#L482">482</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L483" href="#L483">483</a><span class="code-text"><a-p>### </a-p><a-tt>Using the Pico&#39;s second core</a-tt></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L484" href="#L484">484</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L485" href="#L485">485</a><span class="code-text"><a-p>In each config, there are the functions `setup()` and `loop()`, where `setup()` runs first, and then `loop()` runs repeatedly until the device is powered off.</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L486" href="#L486">486</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L487" href="#L487">487</a><span class="code-text"><a-p>On Pico/RP2040, the `setup()` and `loop()` functions execute on core0, and you can add the functions `setup1()` and `loop1()` in order to run tasks on core1.</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L488" href="#L488">488</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L489" href="#L489">489</a><span class="code-text"><a-p>For example, to read GameCube controller inputs on core1:</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L490" href="#L490">490</a><span class="code-text"><a-p>```</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L491" href="#L491">491</a><span class="code-text"><a-p>GamecubeControllerInput *gcc = nullptr;</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L492" href="#L492">492</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L493" href="#L493">493</a><span class="code-text"><a-p>void setup1() {</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L494" href="#L494">494</a><span class="code-text"><a-p>    while (backends == nullptr) {</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L495" href="#L495">495</a><span class="code-text"><a-p>        tight_loop_contents();</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L496" href="#L496">496</a><span class="code-text"><a-p>    }</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L497" href="#L497">497</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L498" href="#L498">498</a><span class="code-text"><a-p>    gcc = new GamecubeControllerInput(gcc_pin, 2500, pio1);</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L499" href="#L499">499</a><span class="code-text"><a-p>}</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L500" href="#L500">500</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L501" href="#L501">501</a><span class="code-text"><a-p>void loop1() {</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L502" href="#L502">502</a><span class="code-text"><a-p>    if (backends != nullptr) {</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L503" href="#L503">503</a><span class="code-text"><a-p>        gcc-&gt;UpdateInputs(backends[0]-&gt;GetInputs());</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L504" href="#L504">504</a><span class="code-text"><a-p>    }</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L505" href="#L505">505</a><span class="code-text"><a-p>}</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L506" href="#L506">506</a><span class="code-text"><a-p>```</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L507" href="#L507">507</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L508" href="#L508">508</a><span class="code-text"><a-p>The `while` loop makes sure we wait until `setup()` on core0 has finished setting up the communication backends. We then create a GameCube controller input source with a polling rate of 2500Hz. We also run it on `pio1` as an easy way to avoid interfering with any GameCube/N64 backends, which use `pio0` unless otherwise specified. In `loop1()` we make the assumption that the primary backend is the first element of the `backends` array (which is configured in the same file anyway, so we aren&#39;t truly assuming anything we don&#39;t know) and directly scan the GameCube controller inputs into the backend&#39;s input state.</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L509" href="#L509">509</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L510" href="#L510">510</a><span class="code-text"><a-p>As a slightly crazier hypothetical example, one could even power all the controls for a two person arcade cabinet using a single Pico by creating two switch matrix input sources using say 10 pins each, and two GameCube backends, both on separate cores. The possibilities are endless.</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L511" href="#L511">511</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L512" href="#L512">512</a><span class="code-text"><a-p>## </a-p><a-tt>Troubleshooting</a-tt></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L513" href="#L513">513</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L514" href="#L514">514</a><span class="code-text"><a-p>### </a-p><a-tt>Controller not working with console or GameCube adapter</a-tt></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L515" href="#L515">515</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L516" href="#L516">516</a><span class="code-text"><a-p>If you are using an official adapter with an Arduino-based controller you will likely have to hold A on plugin which disables the polling latency optimisation by passing in a polling rate of 0 to the GamecubeBackend constructor.</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L517" href="#L517">517</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L518" href="#L518">518</a><span class="code-text"><a-p>If you are using an Arduino-based controller without a boost circuit, you will need 5V power so for Mayflash adapter you need both USB cables plugged in, and on console the rumble line needs to be intact. Pico works natively with 3.3V power so this isn&#39;t an issue.</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L519" href="#L519">519</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L520" href="#L520">520</a><span class="code-text"><a-p>## </a-p><a-tt>Contributing</a-tt></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L521" href="#L521">521</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L522" href="#L522">522</a><span class="code-text"><a-p>I welcome contributions and if you make an input mode that you want to share,</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L523" href="#L523">523</a><span class="code-text"><a-p>feel free to make a pull request. Please install the clang-format plugin for</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L524" href="#L524">524</a><span class="code-text"><a-p>VS Code and use it to format any code you want added.</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L525" href="#L525">525</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L526" href="#L526">526</a><span class="code-text"><a-p>### </a-p><a-tt>Versioning</a-tt></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L527" href="#L527">527</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L528" href="#L528">528</a><span class="code-text"><a-p>We use [SemVer](http://semver.org/) for versioning. For the versions available,</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L529" href="#L529">529</a><span class="code-text"><a-p>see the [tags on this repository](https://github.com/JonnyHaystack/HayBox/tags).</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L530" href="#L530">530</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L531" href="#L531">531</a><span class="code-text"><a-p>## </a-p><a-tt>Built With</a-tt></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L532" href="#L532">532</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L533" href="#L533">533</a><span class="code-text"><a-p>* [https://github.com/MHeironimus/ArduinoJoystickLibrary]() - Used for DInput support for AVR</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L534" href="#L534">534</a><span class="code-text"><a-p>* [https://github.com/NicoHood/Nintendo]() - Used for GameCube and Nintendo 64 support for AVR</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L535" href="#L535">535</a><span class="code-text"><a-p>* [https://github.com/JonnyHaystack/ArduinoKeyboard]() - Used for keyboard modes on AVR</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L536" href="#L536">536</a><span class="code-text"><a-p>* [https://github.com/JonnyHaystack/arduino-nunchuk]() - Used for Nunchuk support</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L537" href="#L537">537</a><span class="code-text"><a-p>* [https://github.com/JonnyHaystack/joybus-pio]() - Used for GameCube and Nintendo 64 support for RP2040</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L538" href="#L538">538</a><span class="code-text"><a-p>* [https://github.com/earlephilhower/arduino-pico]() - Used for Arduino framework/PlatformIO support for Pico</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L539" href="#L539">539</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L540" href="#L540">540</a><span class="code-text"><a-p>## </a-p><a-tt>Contributors</a-tt></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L541" href="#L541">541</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L542" href="#L542">542</a><span class="code-text"><a-p>* **Jonathan Haylett** - *Creator* - [@JonnyHaystack](https://github.com/JonnyHaystack)</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L543" href="#L543">543</a><span class="code-text"><a-p>* **Crane** - *Creator of the DIYB0XX firmware, which served as a great reference/starting point* - [@Crane1195](https://github.com/Crane1195)</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L544" href="#L544">544</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L545" href="#L545">545</a><span class="code-text"><a-p>See also the list of [contributors](https://github.com/JonnyHaystack/HayBox/contributors) who participated in this project.</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L546" href="#L546">546</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L547" href="#L547">547</a><span class="code-text"><a-p>### </a-p><a-tt>Acknowledgments</a-tt></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L548" href="#L548">548</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L549" href="#L549">549</a><span class="code-text"><a-p>* The B0XX team, for designing and creating an incredible controller</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L550" href="#L550">550</a><span class="code-text"><a-p>* [@Crane1195](https://github.com/Crane1195) - for his DIYB0XX and GCCPCB projects, and for hours of answering my questions when I was first writing this</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L551" href="#L551">551</a><span class="code-text"><a-p>* [@MHeironimus](https://github.com/MHeironimus) - for the Arduino Joystick library</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L552" href="#L552">552</a><span class="code-text"><a-p>* [@NicoHood](https://github.com/NicoHood) - for the Nintendo library</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L553" href="#L553">553</a><span class="code-text"><a-p>* [@GabrielBianconi](https://github.com/GabrielBianconi) - for the Arduino Nunchuk library</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L554" href="#L554">554</a><span class="code-text"><a-p>* [@earlephilhower](https://github.com/earlephilhower) - for the arduino-pico core</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L555" href="#L555">555</a><span class="code-text"><a-p>* [@maxgerhardt](https://github.com/maxgerhardt) - for adding PlatformIO support for arduino-pico</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L556" href="#L556">556</a><span class="code-text"><a-p>* The Arduino project and the Raspberry Pi Foundation - for all their open-source hardware and software</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L557" href="#L557">557</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L558" href="#L558">558</a><span class="code-text"><a-p>## </a-p><a-tt>License</a-tt></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L559" href="#L559">559</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L560" href="#L560">560</a><span class="code-text">This project is licensed under the GNU GPL Version 3 - see the [LICENSE](LICENSE) file for details</span></span></pre></div></div>
</main>
</body>
</html>
