USB_Host_Shield_2.0/_switch_pro_parser_8cpp_source.html
2021-05-09 20:48:09 +00:00

365 lines
64 KiB
HTML

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.17"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>USB Host Shield 2.0: SwitchProParser.cpp Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
<link href="imageStyle.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
<tbody>
<tr style="height: 56px;">
<td id="projectalign" style="padding-left: 0.5em;">
<div id="projectname">USB Host Shield 2.0
</div>
</td>
</tr>
</tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.17 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
var searchBox = new SearchBox("searchBox", "search",false,'Search');
/* @license-end */
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(function() {
initMenu('',true,false,'search.php','Search');
$(document).ready(function() { init_search(); });
});
/* @license-end */</script>
<div id="main-nav"></div>
</div><!-- top -->
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
onmouseover="return searchBox.OnSearchSelectShow()"
onmouseout="return searchBox.OnSearchSelectHide()"
onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>
<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0"
name="MSearchResults" id="MSearchResults">
</iframe>
</div>
<div class="header">
<div class="headertitle">
<div class="title">SwitchProParser.cpp</div> </div>
</div><!--header-->
<div class="contents">
<a href="_switch_pro_parser_8cpp.html">Go to the documentation of this file.</a><div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno"> 1</span>&#160;<span class="comment">/* Copyright (C) 2021 Kristian Sloth Lauszus. All rights reserved.</span></div>
<div class="line"><a name="l00002"></a><span class="lineno"> 2</span>&#160;<span class="comment"></span> </div>
<div class="line"><a name="l00003"></a><span class="lineno"> 3</span>&#160;<span class="comment"> This software may be distributed and modified under the terms of the GNU</span></div>
<div class="line"><a name="l00004"></a><span class="lineno"> 4</span>&#160;<span class="comment"> General Public License version 2 (GPL2) as published by the Free Software</span></div>
<div class="line"><a name="l00005"></a><span class="lineno"> 5</span>&#160;<span class="comment"> Foundation and appearing in the file GPL2.TXT included in the packaging of</span></div>
<div class="line"><a name="l00006"></a><span class="lineno"> 6</span>&#160;<span class="comment"> this file. Please note that GPL2 Section 2[b] requires that all works based</span></div>
<div class="line"><a name="l00007"></a><span class="lineno"> 7</span>&#160;<span class="comment"> on this software must also be made publicly available under the terms of</span></div>
<div class="line"><a name="l00008"></a><span class="lineno"> 8</span>&#160;<span class="comment"> the GPL2 (&quot;Copyleft&quot;).</span></div>
<div class="line"><a name="l00009"></a><span class="lineno"> 9</span>&#160;<span class="comment"></span> </div>
<div class="line"><a name="l00010"></a><span class="lineno"> 10</span>&#160;<span class="comment"> Contact information</span></div>
<div class="line"><a name="l00011"></a><span class="lineno"> 11</span>&#160;<span class="comment"> -------------------</span></div>
<div class="line"><a name="l00012"></a><span class="lineno"> 12</span>&#160;<span class="comment"></span> </div>
<div class="line"><a name="l00013"></a><span class="lineno"> 13</span>&#160;<span class="comment"> Kristian Sloth Lauszus</span></div>
<div class="line"><a name="l00014"></a><span class="lineno"> 14</span>&#160;<span class="comment"> Web : https://lauszus.com</span></div>
<div class="line"><a name="l00015"></a><span class="lineno"> 15</span>&#160;<span class="comment"> e-mail : lauszus@gmail.com</span></div>
<div class="line"><a name="l00016"></a><span class="lineno"> 16</span>&#160;<span class="comment"> */</span></div>
<div class="line"><a name="l00017"></a><span class="lineno"> 17</span>&#160; </div>
<div class="line"><a name="l00018"></a><span class="lineno"> 18</span>&#160;<span class="preprocessor">#include &quot;<a class="code" href="_switch_pro_parser_8h.html">SwitchProParser.h</a>&quot;</span></div>
<div class="line"><a name="l00019"></a><span class="lineno"> 19</span>&#160; </div>
<div class="line"><a name="l00020"></a><span class="lineno"> 20</span>&#160;<span class="comment">// To enable serial debugging see &quot;settings.h&quot;</span></div>
<div class="line"><a name="l00021"></a><span class="lineno"> 21</span>&#160;<span class="comment">//#define PRINTREPORT // Uncomment to print the report send by the Switch Pro Controller</span></div>
<div class="line"><a name="l00022"></a><span class="lineno"> 22</span>&#160; </div>
<div class="line"><a name="l00023"></a><span class="lineno"> 23</span>&#160;int8_t SwitchProParser::getButtonIndexSwitchPro(<a class="code" href="controller_enums_8h.html#a94f7389d205c78830a5441370d7870fd">ButtonEnum</a> b) {</div>
<div class="line"><a name="l00024"></a><span class="lineno"> 24</span>&#160; <span class="keyword">const</span> int8_t index = <a class="code" href="controller_enums_8h.html#a114f266591a03b0eff0f1e6b67d94f85">ButtonIndex</a>(b);</div>
<div class="line"><a name="l00025"></a><span class="lineno"> 25</span>&#160; <span class="keywordflow">if</span> ((uint8_t) index &gt;= (<span class="keyword">sizeof</span>(<a class="code" href="_switch_pro_parser_8h.html#a13c58b19c3e77e1292f9276a69492944">SWITCH_PRO_BUTTONS</a>) / <span class="keyword">sizeof</span>(<a class="code" href="_switch_pro_parser_8h.html#a13c58b19c3e77e1292f9276a69492944">SWITCH_PRO_BUTTONS</a>[0]))) <span class="keywordflow">return</span> -1;</div>
<div class="line"><a name="l00026"></a><span class="lineno"> 26</span>&#160; <span class="keywordflow">return</span> index;</div>
<div class="line"><a name="l00027"></a><span class="lineno"> 27</span>&#160;}</div>
<div class="line"><a name="l00028"></a><span class="lineno"> 28</span>&#160; </div>
<div class="line"><a name="l00029"></a><span class="lineno"><a class="line" href="class_switch_pro_parser.html#a292e664f95d4c5b410ca79a9450c46a3"> 29</a></span>&#160;<span class="keywordtype">bool</span> <a class="code" href="class_switch_pro_parser.html#a292e664f95d4c5b410ca79a9450c46a3">SwitchProParser::getButtonPress</a>(<a class="code" href="controller_enums_8h.html#a94f7389d205c78830a5441370d7870fd">ButtonEnum</a> b) {</div>
<div class="line"><a name="l00030"></a><span class="lineno"> 30</span>&#160; <span class="keyword">const</span> int8_t index = getButtonIndexSwitchPro(b); <span class="keywordflow">if</span> (index &lt; 0) <span class="keywordflow">return</span> 0;</div>
<div class="line"><a name="l00031"></a><span class="lineno"> 31</span>&#160; <span class="keywordflow">return</span> switchProData.<a class="code" href="struct_switch_pro_data.html#aa54d8c465ea7db6ce879cf0ba9795c02">btn</a>.<a class="code" href="union_switch_pro_buttons.html#ab7a6e06bfc026ea58234cab88fa63979">val</a> &amp; (1UL &lt;&lt; <a class="code" href="version__helper_8h.html#a48c60b057902adf805797f183286728d">pgm_read_byte</a>(&amp;<a class="code" href="_switch_pro_parser_8h.html#a13c58b19c3e77e1292f9276a69492944">SWITCH_PRO_BUTTONS</a>[index]));</div>
<div class="line"><a name="l00032"></a><span class="lineno"> 32</span>&#160;}</div>
<div class="line"><a name="l00033"></a><span class="lineno"> 33</span>&#160; </div>
<div class="line"><a name="l00034"></a><span class="lineno"><a class="line" href="class_switch_pro_parser.html#a163612831c3f1f9327f085a3104ed0d4"> 34</a></span>&#160;<span class="keywordtype">bool</span> <a class="code" href="class_switch_pro_parser.html#a163612831c3f1f9327f085a3104ed0d4">SwitchProParser::getButtonClick</a>(<a class="code" href="controller_enums_8h.html#a94f7389d205c78830a5441370d7870fd">ButtonEnum</a> b) {</div>
<div class="line"><a name="l00035"></a><span class="lineno"> 35</span>&#160; <span class="keyword">const</span> int8_t index = getButtonIndexSwitchPro(b); <span class="keywordflow">if</span> (index &lt; 0) <span class="keywordflow">return</span> 0;</div>
<div class="line"><a name="l00036"></a><span class="lineno"> 36</span>&#160; uint32_t mask = 1UL &lt;&lt; <a class="code" href="version__helper_8h.html#a48c60b057902adf805797f183286728d">pgm_read_byte</a>(&amp;<a class="code" href="_switch_pro_parser_8h.html#a13c58b19c3e77e1292f9276a69492944">SWITCH_PRO_BUTTONS</a>[index]);</div>
<div class="line"><a name="l00037"></a><span class="lineno"> 37</span>&#160; <span class="keywordtype">bool</span> click = buttonClickState.<a class="code" href="union_switch_pro_buttons.html#ab7a6e06bfc026ea58234cab88fa63979">val</a> &amp; mask;</div>
<div class="line"><a name="l00038"></a><span class="lineno"> 38</span>&#160; buttonClickState.<a class="code" href="union_switch_pro_buttons.html#ab7a6e06bfc026ea58234cab88fa63979">val</a> &amp;= ~mask; <span class="comment">// Clear &quot;click&quot; event</span></div>
<div class="line"><a name="l00039"></a><span class="lineno"> 39</span>&#160; <span class="keywordflow">return</span> click;</div>
<div class="line"><a name="l00040"></a><span class="lineno"> 40</span>&#160;}</div>
<div class="line"><a name="l00041"></a><span class="lineno"> 41</span>&#160; </div>
<div class="line"><a name="l00042"></a><span class="lineno"><a class="line" href="class_switch_pro_parser.html#a0f87ee43a2313148f9e8376406b0d563"> 42</a></span>&#160;int16_t <a class="code" href="class_switch_pro_parser.html#a0f87ee43a2313148f9e8376406b0d563">SwitchProParser::getAnalogHat</a>(<a class="code" href="controller_enums_8h.html#a34dad8f0a0927471137c403216597093">AnalogHatEnum</a> a) {</div>
<div class="line"><a name="l00043"></a><span class="lineno"> 43</span>&#160; <span class="keywordflow">switch</span>((uint8_t)a) {</div>
<div class="line"><a name="l00044"></a><span class="lineno"> 44</span>&#160; <span class="keywordflow">case</span> 0:</div>
<div class="line"><a name="l00045"></a><span class="lineno"> 45</span>&#160; <span class="keywordflow">return</span> switchProData.<a class="code" href="struct_switch_pro_data.html#af30ab8b84238b402c9fe0a16bf695ebf">leftHatX</a> - 2048; <span class="comment">// Subtract the center value</span></div>
<div class="line"><a name="l00046"></a><span class="lineno"> 46</span>&#160; <span class="keywordflow">case</span> 1:</div>
<div class="line"><a name="l00047"></a><span class="lineno"> 47</span>&#160; <span class="keywordflow">return</span> 2048 - switchProData.<a class="code" href="struct_switch_pro_data.html#afe12932f78674481a90a77e08e896e61">leftHatY</a>; <span class="comment">// Invert, so it follows the same coordinate as the simple report</span></div>
<div class="line"><a name="l00048"></a><span class="lineno"> 48</span>&#160; <span class="keywordflow">case</span> 2:</div>
<div class="line"><a name="l00049"></a><span class="lineno"> 49</span>&#160; <span class="keywordflow">return</span> switchProData.<a class="code" href="struct_switch_pro_data.html#a3fd15c698861164055589a1ad387d7a5">rightHatX</a> - 2048; <span class="comment">// Subtract the center value</span></div>
<div class="line"><a name="l00050"></a><span class="lineno"> 50</span>&#160; <span class="keywordflow">default</span>:</div>
<div class="line"><a name="l00051"></a><span class="lineno"> 51</span>&#160; <span class="keywordflow">return</span> 2048 - switchProData.<a class="code" href="struct_switch_pro_data.html#a157bd387454177580a18a6c9855e053f">rightHatY</a>; <span class="comment">// Invert, so it follows the same coordinate as the simple report</span></div>
<div class="line"><a name="l00052"></a><span class="lineno"> 52</span>&#160; }</div>
<div class="line"><a name="l00053"></a><span class="lineno"> 53</span>&#160;}</div>
<div class="line"><a name="l00054"></a><span class="lineno"> 54</span>&#160; </div>
<div class="line"><a name="l00055"></a><span class="lineno"><a class="line" href="class_switch_pro_parser.html#ae367fa9a7d7246765230473bac09b101"> 55</a></span>&#160;<span class="keywordtype">void</span> <a class="code" href="class_switch_pro_parser.html#ae367fa9a7d7246765230473bac09b101">SwitchProParser::Parse</a>(uint8_t len, uint8_t *buf) {</div>
<div class="line"><a name="l00056"></a><span class="lineno"> 56</span>&#160; <span class="keywordflow">if</span> (len &gt; 0 &amp;&amp; buf) {</div>
<div class="line"><a name="l00057"></a><span class="lineno"> 57</span>&#160;<span class="preprocessor">#ifdef PRINTREPORT</span></div>
<div class="line"><a name="l00058"></a><span class="lineno"> 58</span>&#160; <a class="code" href="message_8h.html#a27117e124c5d66d5512fe8d494fe6338">Notify</a>(<a class="code" href="version__helper_8h.html#a73809107539df84eaf01f6a4dea4fbff">PSTR</a>(<span class="stringliteral">&quot;\r\nLen: &quot;</span>), 0x80); <a class="code" href="message_8h.html#a27117e124c5d66d5512fe8d494fe6338">Notify</a>(len, 0x80);</div>
<div class="line"><a name="l00059"></a><span class="lineno"> 59</span>&#160; <a class="code" href="message_8h.html#a27117e124c5d66d5512fe8d494fe6338">Notify</a>(<a class="code" href="version__helper_8h.html#a73809107539df84eaf01f6a4dea4fbff">PSTR</a>(<span class="stringliteral">&quot;, data: &quot;</span>), 0x80);</div>
<div class="line"><a name="l00060"></a><span class="lineno"> 60</span>&#160; <span class="keywordflow">for</span> (uint8_t i = 0; i &lt; len; i++) {</div>
<div class="line"><a name="l00061"></a><span class="lineno"> 61</span>&#160; D_PrintHex&lt;uint8_t &gt; (buf[i], 0x80);</div>
<div class="line"><a name="l00062"></a><span class="lineno"> 62</span>&#160; <a class="code" href="message_8h.html#a27117e124c5d66d5512fe8d494fe6338">Notify</a>(<a class="code" href="version__helper_8h.html#a73809107539df84eaf01f6a4dea4fbff">PSTR</a>(<span class="stringliteral">&quot; &quot;</span>), 0x80);</div>
<div class="line"><a name="l00063"></a><span class="lineno"> 63</span>&#160; }</div>
<div class="line"><a name="l00064"></a><span class="lineno"> 64</span>&#160;<span class="preprocessor">#endif</span></div>
<div class="line"><a name="l00065"></a><span class="lineno"> 65</span>&#160; </div>
<div class="line"><a name="l00066"></a><span class="lineno"> 66</span>&#160; <span class="comment">// This driver always uses the standard full report that includes the IMU data.</span></div>
<div class="line"><a name="l00067"></a><span class="lineno"> 67</span>&#160; <span class="comment">// The downside is that it requires more processing power, as the data is send contentiously</span></div>
<div class="line"><a name="l00068"></a><span class="lineno"> 68</span>&#160; <span class="comment">// while the simple input report is only send when the button state changes however the simple</span></div>
<div class="line"><a name="l00069"></a><span class="lineno"> 69</span>&#160; <span class="comment">// input report is not available via USB and does not include the IMU data.</span></div>
<div class="line"><a name="l00070"></a><span class="lineno"> 70</span>&#160; </div>
<div class="line"><a name="l00071"></a><span class="lineno"> 71</span>&#160; <span class="keywordflow">if</span> (buf[0] == 0x3F) <span class="comment">// Simple input report via Bluetooth</span></div>
<div class="line"><a name="l00072"></a><span class="lineno"> 72</span>&#160; <a class="code" href="class_switch_pro_parser.html#af381fc1fc4eccfac00e628786d8b7092">switchProOutput</a>.<a class="code" href="struct_switch_pro_output.html#a66a9757ef1189576e57c533a59acaa39">enableFullReportMode</a> = <span class="keyword">true</span>; <span class="comment">// Switch over to the full report</span></div>
<div class="line"><a name="l00073"></a><span class="lineno"> 73</span>&#160; <span class="keywordflow">else</span> <span class="keywordflow">if</span> (buf[0] == 0x30) { <span class="comment">// Standard full mode</span></div>
<div class="line"><a name="l00074"></a><span class="lineno"> 74</span>&#160; <span class="keywordflow">if</span> (len &lt; 3) {</div>
<div class="line"><a name="l00075"></a><span class="lineno"> 75</span>&#160;<span class="preprocessor">#ifdef DEBUG_USB_HOST</span></div>
<div class="line"><a name="l00076"></a><span class="lineno"> 76</span>&#160; <a class="code" href="message_8h.html#a27117e124c5d66d5512fe8d494fe6338">Notify</a>(<a class="code" href="version__helper_8h.html#a73809107539df84eaf01f6a4dea4fbff">PSTR</a>(<span class="stringliteral">&quot;\r\nReport is too short: &quot;</span>), 0x80);</div>
<div class="line"><a name="l00077"></a><span class="lineno"> 77</span>&#160; D_PrintHex&lt;uint8_t &gt; (len, 0x80);</div>
<div class="line"><a name="l00078"></a><span class="lineno"> 78</span>&#160;<span class="preprocessor">#endif</span></div>
<div class="line"><a name="l00079"></a><span class="lineno"> 79</span>&#160; <span class="keywordflow">return</span>;</div>
<div class="line"><a name="l00080"></a><span class="lineno"> 80</span>&#160; }</div>
<div class="line"><a name="l00081"></a><span class="lineno"> 81</span>&#160; memcpy(&amp;switchProData, buf + 2, min((uint8_t)(len - 2), <a class="code" href="settings_8h.html#ab5a06671af5c2f1154fb653956959838">MFK_CASTUINT8T</a> <span class="keyword">sizeof</span>(switchProData)));</div>
<div class="line"><a name="l00082"></a><span class="lineno"> 82</span>&#160; </div>
<div class="line"><a name="l00083"></a><span class="lineno"> 83</span>&#160; <span class="keywordflow">if</span> (switchProData.<a class="code" href="struct_switch_pro_data.html#aa54d8c465ea7db6ce879cf0ba9795c02">btn</a>.<a class="code" href="union_switch_pro_buttons.html#ab7a6e06bfc026ea58234cab88fa63979">val</a> != oldButtonState.<a class="code" href="union_switch_pro_buttons.html#ab7a6e06bfc026ea58234cab88fa63979">val</a>) { <span class="comment">// Check if anything has changed</span></div>
<div class="line"><a name="l00084"></a><span class="lineno"> 84</span>&#160; buttonClickState.<a class="code" href="union_switch_pro_buttons.html#ab7a6e06bfc026ea58234cab88fa63979">val</a> = switchProData.<a class="code" href="struct_switch_pro_data.html#aa54d8c465ea7db6ce879cf0ba9795c02">btn</a>.<a class="code" href="union_switch_pro_buttons.html#ab7a6e06bfc026ea58234cab88fa63979">val</a> &amp; ~oldButtonState.<a class="code" href="union_switch_pro_buttons.html#ab7a6e06bfc026ea58234cab88fa63979">val</a>; <span class="comment">// Update click state variable</span></div>
<div class="line"><a name="l00085"></a><span class="lineno"> 85</span>&#160; oldButtonState.<a class="code" href="union_switch_pro_buttons.html#ab7a6e06bfc026ea58234cab88fa63979">val</a> = switchProData.<a class="code" href="struct_switch_pro_data.html#aa54d8c465ea7db6ce879cf0ba9795c02">btn</a>.<a class="code" href="union_switch_pro_buttons.html#ab7a6e06bfc026ea58234cab88fa63979">val</a>;</div>
<div class="line"><a name="l00086"></a><span class="lineno"> 86</span>&#160; }</div>
<div class="line"><a name="l00087"></a><span class="lineno"> 87</span>&#160; </div>
<div class="line"><a name="l00088"></a><span class="lineno"> 88</span>&#160; message_counter++;</div>
<div class="line"><a name="l00089"></a><span class="lineno"> 89</span>&#160; } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (buf[0] == 0x21) {</div>
<div class="line"><a name="l00090"></a><span class="lineno"> 90</span>&#160; <span class="comment">// Subcommand reply via Bluetooth</span></div>
<div class="line"><a name="l00091"></a><span class="lineno"> 91</span>&#160; } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (buf[0] == 0x81) {</div>
<div class="line"><a name="l00092"></a><span class="lineno"> 92</span>&#160; <span class="comment">// Subcommand reply via USB</span></div>
<div class="line"><a name="l00093"></a><span class="lineno"> 93</span>&#160; } <span class="keywordflow">else</span> {</div>
<div class="line"><a name="l00094"></a><span class="lineno"> 94</span>&#160;<span class="preprocessor">#ifdef DEBUG_USB_HOST</span></div>
<div class="line"><a name="l00095"></a><span class="lineno"> 95</span>&#160; <a class="code" href="message_8h.html#a27117e124c5d66d5512fe8d494fe6338">Notify</a>(<a class="code" href="version__helper_8h.html#a73809107539df84eaf01f6a4dea4fbff">PSTR</a>(<span class="stringliteral">&quot;\r\nUnknown report id: &quot;</span>), 0x80);</div>
<div class="line"><a name="l00096"></a><span class="lineno"> 96</span>&#160; D_PrintHex&lt;uint8_t &gt; (buf[0], 0x80);</div>
<div class="line"><a name="l00097"></a><span class="lineno"> 97</span>&#160; <a class="code" href="message_8h.html#a27117e124c5d66d5512fe8d494fe6338">Notify</a>(<a class="code" href="version__helper_8h.html#a73809107539df84eaf01f6a4dea4fbff">PSTR</a>(<span class="stringliteral">&quot;, len: &quot;</span>), 0x80);</div>
<div class="line"><a name="l00098"></a><span class="lineno"> 98</span>&#160; D_PrintHex&lt;uint8_t &gt; (len, 0x80);</div>
<div class="line"><a name="l00099"></a><span class="lineno"> 99</span>&#160;<span class="preprocessor">#endif</span></div>
<div class="line"><a name="l00100"></a><span class="lineno"> 100</span>&#160; }</div>
<div class="line"><a name="l00101"></a><span class="lineno"> 101</span>&#160; }</div>
<div class="line"><a name="l00102"></a><span class="lineno"> 102</span>&#160; </div>
<div class="line"><a name="l00103"></a><span class="lineno"> 103</span>&#160; <span class="keywordflow">if</span> (<a class="code" href="class_switch_pro_parser.html#af381fc1fc4eccfac00e628786d8b7092">switchProOutput</a>.<a class="code" href="struct_switch_pro_output.html#a154eed768b6f4244759d1dfefa86ba68">sendHandshake</a>)</div>
<div class="line"><a name="l00104"></a><span class="lineno"> 104</span>&#160; <a class="code" href="class_switch_pro_parser.html#ac1a55bb91dff131b50eb3a7ea4543470">sendHandshake</a>();</div>
<div class="line"><a name="l00105"></a><span class="lineno"> 105</span>&#160; <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<a class="code" href="class_switch_pro_parser.html#af381fc1fc4eccfac00e628786d8b7092">switchProOutput</a>.<a class="code" href="struct_switch_pro_output.html#af6dab76d750df99cf0ee1ca6c34d9fa0">disableTimeout</a>)</div>
<div class="line"><a name="l00106"></a><span class="lineno"> 106</span>&#160; <a class="code" href="class_switch_pro_parser.html#a4e853cd5d73f424610f0e78fcbd65b1a">disableTimeout</a>();</div>
<div class="line"><a name="l00107"></a><span class="lineno"> 107</span>&#160; <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<a class="code" href="class_switch_pro_parser.html#af381fc1fc4eccfac00e628786d8b7092">switchProOutput</a>.<a class="code" href="struct_switch_pro_output.html#a35a5023b07d29c04c89c53d19d191b6e">ledReportChanged</a> || <a class="code" href="class_switch_pro_parser.html#af381fc1fc4eccfac00e628786d8b7092">switchProOutput</a>.<a class="code" href="struct_switch_pro_output.html#af375399bee48a7a6cec6308392b26a47">ledHomeReportChanged</a> ||</div>
<div class="line"><a name="l00108"></a><span class="lineno"> 108</span>&#160; <a class="code" href="class_switch_pro_parser.html#af381fc1fc4eccfac00e628786d8b7092">switchProOutput</a>.<a class="code" href="struct_switch_pro_output.html#a66a9757ef1189576e57c533a59acaa39">enableFullReportMode</a> || <a class="code" href="class_switch_pro_parser.html#af381fc1fc4eccfac00e628786d8b7092">switchProOutput</a>.<a class="code" href="struct_switch_pro_output.html#aa101888d4c6de71c8bd95af8990ea5ef">enableImu</a> != -1)</div>
<div class="line"><a name="l00109"></a><span class="lineno"> 109</span>&#160; sendOutputCmd();</div>
<div class="line"><a name="l00110"></a><span class="lineno"> 110</span>&#160; <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<a class="code" href="class_switch_pro_parser.html#af381fc1fc4eccfac00e628786d8b7092">switchProOutput</a>.<a class="code" href="struct_switch_pro_output.html#a973ef286b07e00aab32f32f5e2216bff">leftRumbleOn</a> || <a class="code" href="class_switch_pro_parser.html#af381fc1fc4eccfac00e628786d8b7092">switchProOutput</a>.<a class="code" href="struct_switch_pro_output.html#a2e4c6f857fecb5203044b80f9652f8b5">rightRumbleOn</a>) {</div>
<div class="line"><a name="l00111"></a><span class="lineno"> 111</span>&#160; <span class="comment">// We need to send the rumble report repeatedly to keep it on</span></div>
<div class="line"><a name="l00112"></a><span class="lineno"> 112</span>&#160; uint32_t now = millis();</div>
<div class="line"><a name="l00113"></a><span class="lineno"> 113</span>&#160; <span class="keywordflow">if</span> (now - rumble_on_timer &gt; 1000) {</div>
<div class="line"><a name="l00114"></a><span class="lineno"> 114</span>&#160; rumble_on_timer = now;</div>
<div class="line"><a name="l00115"></a><span class="lineno"> 115</span>&#160; sendRumbleOutputReport();</div>
<div class="line"><a name="l00116"></a><span class="lineno"> 116</span>&#160; }</div>
<div class="line"><a name="l00117"></a><span class="lineno"> 117</span>&#160; }</div>
<div class="line"><a name="l00118"></a><span class="lineno"> 118</span>&#160;}</div>
<div class="line"><a name="l00119"></a><span class="lineno"> 119</span>&#160; </div>
<div class="line"><a name="l00120"></a><span class="lineno"> 120</span>&#160;<span class="keywordtype">void</span> SwitchProParser::sendOutputCmd() {</div>
<div class="line"><a name="l00121"></a><span class="lineno"> 121</span>&#160; <span class="comment">// See: https://github.com/Dan611/hid-procon</span></div>
<div class="line"><a name="l00122"></a><span class="lineno"> 122</span>&#160; <span class="comment">// https://github.com/dekuNukem/Nintendo_Switch_Reverse_Engineering</span></div>
<div class="line"><a name="l00123"></a><span class="lineno"> 123</span>&#160; <span class="comment">// https://github.com/HisashiKato/USB_Host_Shield_Library_2.0_BTXBOX/blob/master/src/SWProBTParser.h#L152-L153</span></div>
<div class="line"><a name="l00124"></a><span class="lineno"> 124</span>&#160; uint8_t buf[14] = { 0 };</div>
<div class="line"><a name="l00125"></a><span class="lineno"> 125</span>&#160; buf[0x00] = 0x01; <span class="comment">// Report ID - PROCON_CMD_AND_RUMBLE</span></div>
<div class="line"><a name="l00126"></a><span class="lineno"> 126</span>&#160; buf[0x01] = output_sequence_counter++; <span class="comment">// Lowest 4-bit is a sequence number, which needs to be increased for every report</span></div>
<div class="line"><a name="l00127"></a><span class="lineno"> 127</span>&#160; </div>
<div class="line"><a name="l00128"></a><span class="lineno"> 128</span>&#160; <span class="comment">// Left rumble data</span></div>
<div class="line"><a name="l00129"></a><span class="lineno"> 129</span>&#160; <span class="keywordflow">if</span> (<a class="code" href="class_switch_pro_parser.html#af381fc1fc4eccfac00e628786d8b7092">switchProOutput</a>.<a class="code" href="struct_switch_pro_output.html#a973ef286b07e00aab32f32f5e2216bff">leftRumbleOn</a>) {</div>
<div class="line"><a name="l00130"></a><span class="lineno"> 130</span>&#160; buf[0x02 + 0] = 0x28;</div>
<div class="line"><a name="l00131"></a><span class="lineno"> 131</span>&#160; buf[0x02 + 1] = 0x88;</div>
<div class="line"><a name="l00132"></a><span class="lineno"> 132</span>&#160; buf[0x02 + 2] = 0x60;</div>
<div class="line"><a name="l00133"></a><span class="lineno"> 133</span>&#160; buf[0x02 + 3] = 0x61;</div>
<div class="line"><a name="l00134"></a><span class="lineno"> 134</span>&#160; } <span class="keywordflow">else</span> {</div>
<div class="line"><a name="l00135"></a><span class="lineno"> 135</span>&#160; buf[0x02 + 0] = 0x00;</div>
<div class="line"><a name="l00136"></a><span class="lineno"> 136</span>&#160; buf[0x02 + 1] = 0x01;</div>
<div class="line"><a name="l00137"></a><span class="lineno"> 137</span>&#160; buf[0x02 + 2] = 0x40;</div>
<div class="line"><a name="l00138"></a><span class="lineno"> 138</span>&#160; buf[0x02 + 3] = 0x40;</div>
<div class="line"><a name="l00139"></a><span class="lineno"> 139</span>&#160; }</div>
<div class="line"><a name="l00140"></a><span class="lineno"> 140</span>&#160; </div>
<div class="line"><a name="l00141"></a><span class="lineno"> 141</span>&#160; <span class="comment">// Right rumble data</span></div>
<div class="line"><a name="l00142"></a><span class="lineno"> 142</span>&#160; <span class="keywordflow">if</span> (<a class="code" href="class_switch_pro_parser.html#af381fc1fc4eccfac00e628786d8b7092">switchProOutput</a>.<a class="code" href="struct_switch_pro_output.html#a2e4c6f857fecb5203044b80f9652f8b5">rightRumbleOn</a>) {</div>
<div class="line"><a name="l00143"></a><span class="lineno"> 143</span>&#160; buf[0x02 + 4] = 0x28;</div>
<div class="line"><a name="l00144"></a><span class="lineno"> 144</span>&#160; buf[0x02 + 5] = 0x88;</div>
<div class="line"><a name="l00145"></a><span class="lineno"> 145</span>&#160; buf[0x02 + 6] = 0x60;</div>
<div class="line"><a name="l00146"></a><span class="lineno"> 146</span>&#160; buf[0x02 + 7] = 0x61;</div>
<div class="line"><a name="l00147"></a><span class="lineno"> 147</span>&#160; } <span class="keywordflow">else</span> {</div>
<div class="line"><a name="l00148"></a><span class="lineno"> 148</span>&#160; buf[0x02 + 4] = 0x00;</div>
<div class="line"><a name="l00149"></a><span class="lineno"> 149</span>&#160; buf[0x02 + 5] = 0x01;</div>
<div class="line"><a name="l00150"></a><span class="lineno"> 150</span>&#160; buf[0x02 + 6] = 0x40;</div>
<div class="line"><a name="l00151"></a><span class="lineno"> 151</span>&#160; buf[0x02 + 7] = 0x40;</div>
<div class="line"><a name="l00152"></a><span class="lineno"> 152</span>&#160; }</div>
<div class="line"><a name="l00153"></a><span class="lineno"> 153</span>&#160; </div>
<div class="line"><a name="l00154"></a><span class="lineno"> 154</span>&#160; <span class="comment">// Sub commands</span></div>
<div class="line"><a name="l00155"></a><span class="lineno"> 155</span>&#160; <span class="keywordflow">if</span> (<a class="code" href="class_switch_pro_parser.html#af381fc1fc4eccfac00e628786d8b7092">switchProOutput</a>.<a class="code" href="struct_switch_pro_output.html#a35a5023b07d29c04c89c53d19d191b6e">ledReportChanged</a>) {</div>
<div class="line"><a name="l00156"></a><span class="lineno"> 156</span>&#160; <a class="code" href="class_switch_pro_parser.html#af381fc1fc4eccfac00e628786d8b7092">switchProOutput</a>.<a class="code" href="struct_switch_pro_output.html#a35a5023b07d29c04c89c53d19d191b6e">ledReportChanged</a> = <span class="keyword">false</span>;</div>
<div class="line"><a name="l00157"></a><span class="lineno"> 157</span>&#160; </div>
<div class="line"><a name="l00158"></a><span class="lineno"> 158</span>&#160; <span class="comment">// See: https://github.com/dekuNukem/Nintendo_Switch_Reverse_Engineering/blob/master/bluetooth_hid_subcommands_notes.md#subcommand-0x30-set-player-lights</span></div>
<div class="line"><a name="l00159"></a><span class="lineno"> 159</span>&#160; buf[0x0A + 0] = 0x30; <span class="comment">// PROCON_CMD_LED</span></div>
<div class="line"><a name="l00160"></a><span class="lineno"> 160</span>&#160; </div>
<div class="line"><a name="l00161"></a><span class="lineno"> 161</span>&#160; buf[0x0A + 1] = <a class="code" href="class_switch_pro_parser.html#af381fc1fc4eccfac00e628786d8b7092">switchProOutput</a>.<a class="code" href="struct_switch_pro_output.html#ad64b3a2141ca723d7494d51b7adb1c32">ledMask</a>; <span class="comment">// Lower 4-bits sets the LEDs constantly on, the higher 4-bits can be used to flash the LEDs</span></div>
<div class="line"><a name="l00162"></a><span class="lineno"> 162</span>&#160; </div>
<div class="line"><a name="l00163"></a><span class="lineno"> 163</span>&#160; <a class="code" href="class_switch_pro_parser.html#a0cb8e11033817f3e8eb968bd8541c052">sendOutputReport</a>(buf, 10 + 2);</div>
<div class="line"><a name="l00164"></a><span class="lineno"> 164</span>&#160; } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<a class="code" href="class_switch_pro_parser.html#af381fc1fc4eccfac00e628786d8b7092">switchProOutput</a>.<a class="code" href="struct_switch_pro_output.html#af375399bee48a7a6cec6308392b26a47">ledHomeReportChanged</a>) {</div>
<div class="line"><a name="l00165"></a><span class="lineno"> 165</span>&#160; <a class="code" href="class_switch_pro_parser.html#af381fc1fc4eccfac00e628786d8b7092">switchProOutput</a>.<a class="code" href="struct_switch_pro_output.html#af375399bee48a7a6cec6308392b26a47">ledHomeReportChanged</a> = <span class="keyword">false</span>;</div>
<div class="line"><a name="l00166"></a><span class="lineno"> 166</span>&#160; </div>
<div class="line"><a name="l00167"></a><span class="lineno"> 167</span>&#160; <span class="comment">// It is possible set up to 15 mini cycles, but we simply just set the LED constantly on/off</span></div>
<div class="line"><a name="l00168"></a><span class="lineno"> 168</span>&#160; <span class="comment">// See: https://github.com/dekuNukem/Nintendo_Switch_Reverse_Engineering/blob/master/bluetooth_hid_subcommands_notes.md#subcommand-0x38-set-home-light</span></div>
<div class="line"><a name="l00169"></a><span class="lineno"> 169</span>&#160; buf[0x0A + 0] = 0x38; <span class="comment">// PROCON_CMD_LED_HOME</span></div>
<div class="line"><a name="l00170"></a><span class="lineno"> 170</span>&#160; </div>
<div class="line"><a name="l00171"></a><span class="lineno"> 171</span>&#160; buf[0x0A + 1] = (0 <span class="comment">/* Number of cycles */</span> &lt;&lt; 4) | (<a class="code" href="class_switch_pro_parser.html#af381fc1fc4eccfac00e628786d8b7092">switchProOutput</a>.<a class="code" href="struct_switch_pro_output.html#a02d0d3fa2a40dae4a81fe41cb54cc9c5">ledHome</a> ? 0xF : 0) <span class="comment">/* Global mini cycle duration */</span>;</div>
<div class="line"><a name="l00172"></a><span class="lineno"> 172</span>&#160; buf[0x0A + 2] = (0xF <span class="comment">/* LED start intensity */</span> &lt;&lt; 4) | 0x0 <span class="comment">/* Number of full cycles */</span>;</div>
<div class="line"><a name="l00173"></a><span class="lineno"> 173</span>&#160; buf[0x0A + 3] = (0xF <span class="comment">/* Mini Cycle 1 LED intensity */</span> &lt;&lt; 4) | 0x0 <span class="comment">/* Mini Cycle 2 LED intensity */</span>;</div>
<div class="line"><a name="l00174"></a><span class="lineno"> 174</span>&#160; </div>
<div class="line"><a name="l00175"></a><span class="lineno"> 175</span>&#160; <a class="code" href="class_switch_pro_parser.html#a0cb8e11033817f3e8eb968bd8541c052">sendOutputReport</a>(buf, 10 + 4);</div>
<div class="line"><a name="l00176"></a><span class="lineno"> 176</span>&#160; } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<a class="code" href="class_switch_pro_parser.html#af381fc1fc4eccfac00e628786d8b7092">switchProOutput</a>.<a class="code" href="struct_switch_pro_output.html#a66a9757ef1189576e57c533a59acaa39">enableFullReportMode</a>) {</div>
<div class="line"><a name="l00177"></a><span class="lineno"> 177</span>&#160; <a class="code" href="class_switch_pro_parser.html#af381fc1fc4eccfac00e628786d8b7092">switchProOutput</a>.<a class="code" href="struct_switch_pro_output.html#a66a9757ef1189576e57c533a59acaa39">enableFullReportMode</a> = <span class="keyword">false</span>;</div>
<div class="line"><a name="l00178"></a><span class="lineno"> 178</span>&#160; </div>
<div class="line"><a name="l00179"></a><span class="lineno"> 179</span>&#160; <span class="comment">// See: https://github.com/dekuNukem/Nintendo_Switch_Reverse_Engineering/blob/master/bluetooth_hid_subcommands_notes.md#subcommand-0x03-set-input-report-mode</span></div>
<div class="line"><a name="l00180"></a><span class="lineno"> 180</span>&#160; buf[0x0A + 0] = 0x03; <span class="comment">// PROCON_CMD_MODE</span></div>
<div class="line"><a name="l00181"></a><span class="lineno"> 181</span>&#160; buf[0x0A + 1] = 0x30; <span class="comment">// PROCON_ARG_INPUT_FULL</span></div>
<div class="line"><a name="l00182"></a><span class="lineno"> 182</span>&#160; </div>
<div class="line"><a name="l00183"></a><span class="lineno"> 183</span>&#160; <a class="code" href="class_switch_pro_parser.html#a0cb8e11033817f3e8eb968bd8541c052">sendOutputReport</a>(buf, 10 + 2);</div>
<div class="line"><a name="l00184"></a><span class="lineno"> 184</span>&#160; } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<a class="code" href="class_switch_pro_parser.html#af381fc1fc4eccfac00e628786d8b7092">switchProOutput</a>.<a class="code" href="struct_switch_pro_output.html#aa101888d4c6de71c8bd95af8990ea5ef">enableImu</a> != -1) {</div>
<div class="line"><a name="l00185"></a><span class="lineno"> 185</span>&#160; <span class="comment">// See: https://github.com/dekuNukem/Nintendo_Switch_Reverse_Engineering/blob/master/bluetooth_hid_subcommands_notes.md#subcommand-0x40-enable-imu-6-axis-sensor</span></div>
<div class="line"><a name="l00186"></a><span class="lineno"> 186</span>&#160; buf[0x0A + 0] = 0x40; <span class="comment">// PROCON_CMD_GYRO</span></div>
<div class="line"><a name="l00187"></a><span class="lineno"> 187</span>&#160; buf[0x0A + 1] = <a class="code" href="class_switch_pro_parser.html#af381fc1fc4eccfac00e628786d8b7092">switchProOutput</a>.<a class="code" href="struct_switch_pro_output.html#aa101888d4c6de71c8bd95af8990ea5ef">enableImu</a> ? 1 : 0; <span class="comment">// The new state is stored in the variable</span></div>
<div class="line"><a name="l00188"></a><span class="lineno"> 188</span>&#160; <a class="code" href="class_switch_pro_parser.html#af381fc1fc4eccfac00e628786d8b7092">switchProOutput</a>.<a class="code" href="struct_switch_pro_output.html#aa101888d4c6de71c8bd95af8990ea5ef">enableImu</a> = -1;</div>
<div class="line"><a name="l00189"></a><span class="lineno"> 189</span>&#160; </div>
<div class="line"><a name="l00190"></a><span class="lineno"> 190</span>&#160; <a class="code" href="class_switch_pro_parser.html#a0cb8e11033817f3e8eb968bd8541c052">sendOutputReport</a>(buf, 12);</div>
<div class="line"><a name="l00191"></a><span class="lineno"> 191</span>&#160; }</div>
<div class="line"><a name="l00192"></a><span class="lineno"> 192</span>&#160;}</div>
<div class="line"><a name="l00193"></a><span class="lineno"> 193</span>&#160; </div>
<div class="line"><a name="l00194"></a><span class="lineno"> 194</span>&#160;<span class="keywordtype">void</span> SwitchProParser::sendRumbleOutputReport() {</div>
<div class="line"><a name="l00195"></a><span class="lineno"> 195</span>&#160; <span class="comment">// See: https://github.com/Dan611/hid-procon</span></div>
<div class="line"><a name="l00196"></a><span class="lineno"> 196</span>&#160; <span class="comment">// https://github.com/dekuNukem/Nintendo_Switch_Reverse_Engineering</span></div>
<div class="line"><a name="l00197"></a><span class="lineno"> 197</span>&#160; <span class="comment">// https://github.com/HisashiKato/USB_Host_Shield_Library_2.0_BTXBOX/blob/master/src/SWProBTParser.h#L152-L153</span></div>
<div class="line"><a name="l00198"></a><span class="lineno"> 198</span>&#160; uint8_t buf[10] = { 0 };</div>
<div class="line"><a name="l00199"></a><span class="lineno"> 199</span>&#160; buf[0x00] = 0x10; <span class="comment">// Report ID - PROCON_CMD_RUMBLE_ONLY</span></div>
<div class="line"><a name="l00200"></a><span class="lineno"> 200</span>&#160; buf[0x01] = output_sequence_counter++; <span class="comment">// Lowest 4-bit is a sequence number, which needs to be increased for every report</span></div>
<div class="line"><a name="l00201"></a><span class="lineno"> 201</span>&#160; </div>
<div class="line"><a name="l00202"></a><span class="lineno"> 202</span>&#160; <span class="comment">// Left rumble data</span></div>
<div class="line"><a name="l00203"></a><span class="lineno"> 203</span>&#160; <span class="keywordflow">if</span> (<a class="code" href="class_switch_pro_parser.html#af381fc1fc4eccfac00e628786d8b7092">switchProOutput</a>.<a class="code" href="struct_switch_pro_output.html#a973ef286b07e00aab32f32f5e2216bff">leftRumbleOn</a>) {</div>
<div class="line"><a name="l00204"></a><span class="lineno"> 204</span>&#160; buf[0x02 + 0] = 0x28;</div>
<div class="line"><a name="l00205"></a><span class="lineno"> 205</span>&#160; buf[0x02 + 1] = 0x88;</div>
<div class="line"><a name="l00206"></a><span class="lineno"> 206</span>&#160; buf[0x02 + 2] = 0x60;</div>
<div class="line"><a name="l00207"></a><span class="lineno"> 207</span>&#160; buf[0x02 + 3] = 0x61;</div>
<div class="line"><a name="l00208"></a><span class="lineno"> 208</span>&#160; } <span class="keywordflow">else</span> {</div>
<div class="line"><a name="l00209"></a><span class="lineno"> 209</span>&#160; buf[0x02 + 0] = 0x00;</div>
<div class="line"><a name="l00210"></a><span class="lineno"> 210</span>&#160; buf[0x02 + 1] = 0x01;</div>
<div class="line"><a name="l00211"></a><span class="lineno"> 211</span>&#160; buf[0x02 + 2] = 0x40;</div>
<div class="line"><a name="l00212"></a><span class="lineno"> 212</span>&#160; buf[0x02 + 3] = 0x40;</div>
<div class="line"><a name="l00213"></a><span class="lineno"> 213</span>&#160; }</div>
<div class="line"><a name="l00214"></a><span class="lineno"> 214</span>&#160; </div>
<div class="line"><a name="l00215"></a><span class="lineno"> 215</span>&#160; <span class="comment">// Right rumble data</span></div>
<div class="line"><a name="l00216"></a><span class="lineno"> 216</span>&#160; <span class="keywordflow">if</span> (<a class="code" href="class_switch_pro_parser.html#af381fc1fc4eccfac00e628786d8b7092">switchProOutput</a>.<a class="code" href="struct_switch_pro_output.html#a2e4c6f857fecb5203044b80f9652f8b5">rightRumbleOn</a>) {</div>
<div class="line"><a name="l00217"></a><span class="lineno"> 217</span>&#160; buf[0x02 + 4] = 0x28;</div>
<div class="line"><a name="l00218"></a><span class="lineno"> 218</span>&#160; buf[0x02 + 5] = 0x88;</div>
<div class="line"><a name="l00219"></a><span class="lineno"> 219</span>&#160; buf[0x02 + 6] = 0x60;</div>
<div class="line"><a name="l00220"></a><span class="lineno"> 220</span>&#160; buf[0x02 + 7] = 0x61;</div>
<div class="line"><a name="l00221"></a><span class="lineno"> 221</span>&#160; } <span class="keywordflow">else</span> {</div>
<div class="line"><a name="l00222"></a><span class="lineno"> 222</span>&#160; buf[0x02 + 4] = 0x00;</div>
<div class="line"><a name="l00223"></a><span class="lineno"> 223</span>&#160; buf[0x02 + 5] = 0x01;</div>
<div class="line"><a name="l00224"></a><span class="lineno"> 224</span>&#160; buf[0x02 + 6] = 0x40;</div>
<div class="line"><a name="l00225"></a><span class="lineno"> 225</span>&#160; buf[0x02 + 7] = 0x40;</div>
<div class="line"><a name="l00226"></a><span class="lineno"> 226</span>&#160; }</div>
<div class="line"><a name="l00227"></a><span class="lineno"> 227</span>&#160; </div>
<div class="line"><a name="l00228"></a><span class="lineno"> 228</span>&#160; <a class="code" href="class_switch_pro_parser.html#a0cb8e11033817f3e8eb968bd8541c052">sendOutputReport</a>(buf, 10);</div>
<div class="line"><a name="l00229"></a><span class="lineno"> 229</span>&#160;}</div>
<div class="line"><a name="l00230"></a><span class="lineno"> 230</span>&#160; </div>
<div class="line"><a name="l00231"></a><span class="lineno"><a class="line" href="class_switch_pro_parser.html#ac2f27f3be01e18845d102bd6f24c87fa"> 231</a></span>&#160;<span class="keywordtype">void</span> <a class="code" href="class_switch_pro_parser.html#ac2f27f3be01e18845d102bd6f24c87fa">SwitchProParser::Reset</a>() {</div>
<div class="line"><a name="l00232"></a><span class="lineno"> 232</span>&#160; <span class="comment">// Center joysticks</span></div>
<div class="line"><a name="l00233"></a><span class="lineno"> 233</span>&#160; switchProData.<a class="code" href="struct_switch_pro_data.html#af30ab8b84238b402c9fe0a16bf695ebf">leftHatX</a> = switchProData.<a class="code" href="struct_switch_pro_data.html#afe12932f78674481a90a77e08e896e61">leftHatY</a> = switchProData.<a class="code" href="struct_switch_pro_data.html#a3fd15c698861164055589a1ad387d7a5">rightHatX</a> = switchProData.<a class="code" href="struct_switch_pro_data.html#a157bd387454177580a18a6c9855e053f">rightHatY</a> = 2048;</div>
<div class="line"><a name="l00234"></a><span class="lineno"> 234</span>&#160; </div>
<div class="line"><a name="l00235"></a><span class="lineno"> 235</span>&#160; <span class="comment">// Reset buttons variables</span></div>
<div class="line"><a name="l00236"></a><span class="lineno"> 236</span>&#160; switchProData.<a class="code" href="struct_switch_pro_data.html#aa54d8c465ea7db6ce879cf0ba9795c02">btn</a>.<a class="code" href="union_switch_pro_buttons.html#ab7a6e06bfc026ea58234cab88fa63979">val</a> = 0;</div>
<div class="line"><a name="l00237"></a><span class="lineno"> 237</span>&#160; oldButtonState.<a class="code" href="union_switch_pro_buttons.html#ab7a6e06bfc026ea58234cab88fa63979">val</a> = 0;</div>
<div class="line"><a name="l00238"></a><span class="lineno"> 238</span>&#160; buttonClickState.<a class="code" href="union_switch_pro_buttons.html#ab7a6e06bfc026ea58234cab88fa63979">val</a> = 0;</div>
<div class="line"><a name="l00239"></a><span class="lineno"> 239</span>&#160; </div>
<div class="line"><a name="l00240"></a><span class="lineno"> 240</span>&#160; output_sequence_counter = 0;</div>
<div class="line"><a name="l00241"></a><span class="lineno"> 241</span>&#160; rumble_on_timer = 0;</div>
<div class="line"><a name="l00242"></a><span class="lineno"> 242</span>&#160; </div>
<div class="line"><a name="l00243"></a><span class="lineno"> 243</span>&#160; <a class="code" href="class_switch_pro_parser.html#af381fc1fc4eccfac00e628786d8b7092">switchProOutput</a>.<a class="code" href="struct_switch_pro_output.html#a973ef286b07e00aab32f32f5e2216bff">leftRumbleOn</a> = <span class="keyword">false</span>;</div>
<div class="line"><a name="l00244"></a><span class="lineno"> 244</span>&#160; <a class="code" href="class_switch_pro_parser.html#af381fc1fc4eccfac00e628786d8b7092">switchProOutput</a>.<a class="code" href="struct_switch_pro_output.html#a2e4c6f857fecb5203044b80f9652f8b5">rightRumbleOn</a> = <span class="keyword">false</span>;</div>
<div class="line"><a name="l00245"></a><span class="lineno"> 245</span>&#160; <a class="code" href="class_switch_pro_parser.html#af381fc1fc4eccfac00e628786d8b7092">switchProOutput</a>.<a class="code" href="struct_switch_pro_output.html#ad64b3a2141ca723d7494d51b7adb1c32">ledMask</a> = 0;</div>
<div class="line"><a name="l00246"></a><span class="lineno"> 246</span>&#160; <a class="code" href="class_switch_pro_parser.html#af381fc1fc4eccfac00e628786d8b7092">switchProOutput</a>.<a class="code" href="struct_switch_pro_output.html#a02d0d3fa2a40dae4a81fe41cb54cc9c5">ledHome</a> = <span class="keyword">false</span>;</div>
<div class="line"><a name="l00247"></a><span class="lineno"> 247</span>&#160; <a class="code" href="class_switch_pro_parser.html#af381fc1fc4eccfac00e628786d8b7092">switchProOutput</a>.<a class="code" href="struct_switch_pro_output.html#a35a5023b07d29c04c89c53d19d191b6e">ledReportChanged</a> = <span class="keyword">false</span>;</div>
<div class="line"><a name="l00248"></a><span class="lineno"> 248</span>&#160; <a class="code" href="class_switch_pro_parser.html#af381fc1fc4eccfac00e628786d8b7092">switchProOutput</a>.<a class="code" href="struct_switch_pro_output.html#af375399bee48a7a6cec6308392b26a47">ledHomeReportChanged</a> = <span class="keyword">false</span>;</div>
<div class="line"><a name="l00249"></a><span class="lineno"> 249</span>&#160; <a class="code" href="class_switch_pro_parser.html#af381fc1fc4eccfac00e628786d8b7092">switchProOutput</a>.<a class="code" href="struct_switch_pro_output.html#a66a9757ef1189576e57c533a59acaa39">enableFullReportMode</a> = <span class="keyword">false</span>;</div>
<div class="line"><a name="l00250"></a><span class="lineno"> 250</span>&#160; <a class="code" href="class_switch_pro_parser.html#af381fc1fc4eccfac00e628786d8b7092">switchProOutput</a>.<a class="code" href="struct_switch_pro_output.html#aa101888d4c6de71c8bd95af8990ea5ef">enableImu</a> = -1;</div>
<div class="line"><a name="l00251"></a><span class="lineno"> 251</span>&#160; <a class="code" href="class_switch_pro_parser.html#af381fc1fc4eccfac00e628786d8b7092">switchProOutput</a>.<a class="code" href="struct_switch_pro_output.html#a154eed768b6f4244759d1dfefa86ba68">sendHandshake</a> = <span class="keyword">false</span>;</div>
<div class="line"><a name="l00252"></a><span class="lineno"> 252</span>&#160; <a class="code" href="class_switch_pro_parser.html#af381fc1fc4eccfac00e628786d8b7092">switchProOutput</a>.<a class="code" href="struct_switch_pro_output.html#af6dab76d750df99cf0ee1ca6c34d9fa0">disableTimeout</a> = <span class="keyword">false</span>;</div>
<div class="line"><a name="l00253"></a><span class="lineno"> 253</span>&#160;}</div>
</div><!-- fragment --></div><!-- contents -->
<div class="ttc" id="aclass_switch_pro_parser_html_a4e853cd5d73f424610f0e78fcbd65b1a"><div class="ttname"><a href="class_switch_pro_parser.html#a4e853cd5d73f424610f0e78fcbd65b1a">SwitchProParser::disableTimeout</a></div><div class="ttdeci">virtual void disableTimeout()</div><div class="ttdef"><b>Definition:</b> <a href="_switch_pro_parser_8h_source.html#l00368">SwitchProParser.h:368</a></div></div>
<div class="ttc" id="astruct_switch_pro_output_html_ad64b3a2141ca723d7494d51b7adb1c32"><div class="ttname"><a href="struct_switch_pro_output.html#ad64b3a2141ca723d7494d51b7adb1c32">SwitchProOutput::ledMask</a></div><div class="ttdeci">uint8_t ledMask</div><div class="ttdef"><b>Definition:</b> <a href="_switch_pro_parser_8h_source.html#l00128">SwitchProParser.h:128</a></div></div>
<div class="ttc" id="asettings_8h_html_ab5a06671af5c2f1154fb653956959838"><div class="ttname"><a href="settings_8h.html#ab5a06671af5c2f1154fb653956959838">MFK_CASTUINT8T</a></div><div class="ttdeci">#define MFK_CASTUINT8T</div><div class="ttdef"><b>Definition:</b> <a href="settings_8h_source.html#l00199">settings.h:199</a></div></div>
<div class="ttc" id="astruct_switch_pro_data_html_aa54d8c465ea7db6ce879cf0ba9795c02"><div class="ttname"><a href="struct_switch_pro_data.html#aa54d8c465ea7db6ce879cf0ba9795c02">SwitchProData::btn</a></div><div class="ttdeci">SwitchProButtons btn</div><div class="ttdef"><b>Definition:</b> <a href="_switch_pro_parser_8h_source.html#l00109">SwitchProParser.h:109</a></div></div>
<div class="ttc" id="aclass_switch_pro_parser_html_ae367fa9a7d7246765230473bac09b101"><div class="ttname"><a href="class_switch_pro_parser.html#ae367fa9a7d7246765230473bac09b101">SwitchProParser::Parse</a></div><div class="ttdeci">void Parse(uint8_t len, uint8_t *buf)</div><div class="ttdef"><b>Definition:</b> <a href="_switch_pro_parser_8cpp_source.html#l00055">SwitchProParser.cpp:55</a></div></div>
<div class="ttc" id="astruct_switch_pro_output_html_a02d0d3fa2a40dae4a81fe41cb54cc9c5"><div class="ttname"><a href="struct_switch_pro_output.html#a02d0d3fa2a40dae4a81fe41cb54cc9c5">SwitchProOutput::ledHome</a></div><div class="ttdeci">bool ledHome</div><div class="ttdef"><b>Definition:</b> <a href="_switch_pro_parser_8h_source.html#l00129">SwitchProParser.h:129</a></div></div>
<div class="ttc" id="a_switch_pro_parser_8h_html"><div class="ttname"><a href="_switch_pro_parser_8h.html">SwitchProParser.h</a></div></div>
<div class="ttc" id="aclass_switch_pro_parser_html_ac2f27f3be01e18845d102bd6f24c87fa"><div class="ttname"><a href="class_switch_pro_parser.html#ac2f27f3be01e18845d102bd6f24c87fa">SwitchProParser::Reset</a></div><div class="ttdeci">void Reset()</div><div class="ttdef"><b>Definition:</b> <a href="_switch_pro_parser_8cpp_source.html#l00231">SwitchProParser.cpp:231</a></div></div>
<div class="ttc" id="astruct_switch_pro_output_html_af375399bee48a7a6cec6308392b26a47"><div class="ttname"><a href="struct_switch_pro_output.html#af375399bee48a7a6cec6308392b26a47">SwitchProOutput::ledHomeReportChanged</a></div><div class="ttdeci">bool ledHomeReportChanged</div><div class="ttdef"><b>Definition:</b> <a href="_switch_pro_parser_8h_source.html#l00133">SwitchProParser.h:133</a></div></div>
<div class="ttc" id="acontroller_enums_8h_html_a114f266591a03b0eff0f1e6b67d94f85"><div class="ttname"><a href="controller_enums_8h.html#a114f266591a03b0eff0f1e6b67d94f85">ButtonIndex</a></div><div class="ttdeci">constexpr int8_t ButtonIndex(ButtonEnum key)</div><div class="ttdef"><b>Definition:</b> <a href="controller_enums_8h_source.html#l00191">controllerEnums.h:191</a></div></div>
<div class="ttc" id="aclass_switch_pro_parser_html_a0cb8e11033817f3e8eb968bd8541c052"><div class="ttname"><a href="class_switch_pro_parser.html#a0cb8e11033817f3e8eb968bd8541c052">SwitchProParser::sendOutputReport</a></div><div class="ttdeci">virtual void sendOutputReport(uint8_t *data, uint8_t len)=0</div></div>
<div class="ttc" id="amessage_8h_html_a27117e124c5d66d5512fe8d494fe6338"><div class="ttname"><a href="message_8h.html#a27117e124c5d66d5512fe8d494fe6338">Notify</a></div><div class="ttdeci">#define Notify(...)</div><div class="ttdef"><b>Definition:</b> <a href="message_8h_source.html#l00051">message.h:51</a></div></div>
<div class="ttc" id="astruct_switch_pro_output_html_a35a5023b07d29c04c89c53d19d191b6e"><div class="ttname"><a href="struct_switch_pro_output.html#a35a5023b07d29c04c89c53d19d191b6e">SwitchProOutput::ledReportChanged</a></div><div class="ttdeci">bool ledReportChanged</div><div class="ttdef"><b>Definition:</b> <a href="_switch_pro_parser_8h_source.html#l00132">SwitchProParser.h:132</a></div></div>
<div class="ttc" id="aclass_switch_pro_parser_html_a163612831c3f1f9327f085a3104ed0d4"><div class="ttname"><a href="class_switch_pro_parser.html#a163612831c3f1f9327f085a3104ed0d4">SwitchProParser::getButtonClick</a></div><div class="ttdeci">bool getButtonClick(ButtonEnum b)</div><div class="ttdef"><b>Definition:</b> <a href="_switch_pro_parser_8cpp_source.html#l00034">SwitchProParser.cpp:34</a></div></div>
<div class="ttc" id="astruct_switch_pro_output_html_aa101888d4c6de71c8bd95af8990ea5ef"><div class="ttname"><a href="struct_switch_pro_output.html#aa101888d4c6de71c8bd95af8990ea5ef">SwitchProOutput::enableImu</a></div><div class="ttdeci">int8_t enableImu</div><div class="ttdef"><b>Definition:</b> <a href="_switch_pro_parser_8h_source.html#l00135">SwitchProParser.h:135</a></div></div>
<div class="ttc" id="aclass_switch_pro_parser_html_ac1a55bb91dff131b50eb3a7ea4543470"><div class="ttname"><a href="class_switch_pro_parser.html#ac1a55bb91dff131b50eb3a7ea4543470">SwitchProParser::sendHandshake</a></div><div class="ttdeci">virtual void sendHandshake()</div><div class="ttdef"><b>Definition:</b> <a href="_switch_pro_parser_8h_source.html#l00362">SwitchProParser.h:362</a></div></div>
<div class="ttc" id="astruct_switch_pro_output_html_a154eed768b6f4244759d1dfefa86ba68"><div class="ttname"><a href="struct_switch_pro_output.html#a154eed768b6f4244759d1dfefa86ba68">SwitchProOutput::sendHandshake</a></div><div class="ttdeci">bool sendHandshake</div><div class="ttdef"><b>Definition:</b> <a href="_switch_pro_parser_8h_source.html#l00136">SwitchProParser.h:136</a></div></div>
<div class="ttc" id="aclass_switch_pro_parser_html_a0f87ee43a2313148f9e8376406b0d563"><div class="ttname"><a href="class_switch_pro_parser.html#a0f87ee43a2313148f9e8376406b0d563">SwitchProParser::getAnalogHat</a></div><div class="ttdeci">int16_t getAnalogHat(AnalogHatEnum a)</div><div class="ttdef"><b>Definition:</b> <a href="_switch_pro_parser_8cpp_source.html#l00042">SwitchProParser.cpp:42</a></div></div>
<div class="ttc" id="astruct_switch_pro_output_html_af6dab76d750df99cf0ee1ca6c34d9fa0"><div class="ttname"><a href="struct_switch_pro_output.html#af6dab76d750df99cf0ee1ca6c34d9fa0">SwitchProOutput::disableTimeout</a></div><div class="ttdeci">bool disableTimeout</div><div class="ttdef"><b>Definition:</b> <a href="_switch_pro_parser_8h_source.html#l00137">SwitchProParser.h:137</a></div></div>
<div class="ttc" id="astruct_switch_pro_data_html_afe12932f78674481a90a77e08e896e61"><div class="ttname"><a href="struct_switch_pro_data.html#afe12932f78674481a90a77e08e896e61">SwitchProData::leftHatY</a></div><div class="ttdeci">uint16_t leftHatY</div><div class="ttdef"><b>Definition:</b> <a href="_switch_pro_parser_8h_source.html#l00113">SwitchProParser.h:113</a></div></div>
<div class="ttc" id="astruct_switch_pro_data_html_a3fd15c698861164055589a1ad387d7a5"><div class="ttname"><a href="struct_switch_pro_data.html#a3fd15c698861164055589a1ad387d7a5">SwitchProData::rightHatX</a></div><div class="ttdeci">uint16_t rightHatX</div><div class="ttdef"><b>Definition:</b> <a href="_switch_pro_parser_8h_source.html#l00114">SwitchProParser.h:114</a></div></div>
<div class="ttc" id="aversion__helper_8h_html_a48c60b057902adf805797f183286728d"><div class="ttname"><a href="version__helper_8h.html#a48c60b057902adf805797f183286728d">pgm_read_byte</a></div><div class="ttdeci">#define pgm_read_byte(addr)</div><div class="ttdef"><b>Definition:</b> <a href="version__helper_8h_source.html#l00161">version_helper.h:161</a></div></div>
<div class="ttc" id="aunion_switch_pro_buttons_html_ab7a6e06bfc026ea58234cab88fa63979"><div class="ttname"><a href="union_switch_pro_buttons.html#ab7a6e06bfc026ea58234cab88fa63979">SwitchProButtons::val</a></div><div class="ttdeci">uint32_t val</div><div class="ttdef"><b>Definition:</b> <a href="_switch_pro_parser_8h_source.html#l00094">SwitchProParser.h:94</a></div></div>
<div class="ttc" id="aversion__helper_8h_html_a73809107539df84eaf01f6a4dea4fbff"><div class="ttname"><a href="version__helper_8h.html#a73809107539df84eaf01f6a4dea4fbff">PSTR</a></div><div class="ttdeci">#define PSTR(str)</div><div class="ttdef"><b>Definition:</b> <a href="version__helper_8h_source.html#l00054">version_helper.h:54</a></div></div>
<div class="ttc" id="aclass_switch_pro_parser_html_af381fc1fc4eccfac00e628786d8b7092"><div class="ttname"><a href="class_switch_pro_parser.html#af381fc1fc4eccfac00e628786d8b7092">SwitchProParser::switchProOutput</a></div><div class="ttdeci">SwitchProOutput switchProOutput</div><div class="ttdef"><b>Definition:</b> <a href="_switch_pro_parser_8h_source.html#l00371">SwitchProParser.h:371</a></div></div>
<div class="ttc" id="astruct_switch_pro_output_html_a66a9757ef1189576e57c533a59acaa39"><div class="ttname"><a href="struct_switch_pro_output.html#a66a9757ef1189576e57c533a59acaa39">SwitchProOutput::enableFullReportMode</a></div><div class="ttdeci">bool enableFullReportMode</div><div class="ttdef"><b>Definition:</b> <a href="_switch_pro_parser_8h_source.html#l00134">SwitchProParser.h:134</a></div></div>
<div class="ttc" id="astruct_switch_pro_output_html_a973ef286b07e00aab32f32f5e2216bff"><div class="ttname"><a href="struct_switch_pro_output.html#a973ef286b07e00aab32f32f5e2216bff">SwitchProOutput::leftRumbleOn</a></div><div class="ttdeci">bool leftRumbleOn</div><div class="ttdef"><b>Definition:</b> <a href="_switch_pro_parser_8h_source.html#l00126">SwitchProParser.h:126</a></div></div>
<div class="ttc" id="aclass_switch_pro_parser_html_a292e664f95d4c5b410ca79a9450c46a3"><div class="ttname"><a href="class_switch_pro_parser.html#a292e664f95d4c5b410ca79a9450c46a3">SwitchProParser::getButtonPress</a></div><div class="ttdeci">bool getButtonPress(ButtonEnum b)</div><div class="ttdef"><b>Definition:</b> <a href="_switch_pro_parser_8cpp_source.html#l00029">SwitchProParser.cpp:29</a></div></div>
<div class="ttc" id="astruct_switch_pro_output_html_a2e4c6f857fecb5203044b80f9652f8b5"><div class="ttname"><a href="struct_switch_pro_output.html#a2e4c6f857fecb5203044b80f9652f8b5">SwitchProOutput::rightRumbleOn</a></div><div class="ttdeci">bool rightRumbleOn</div><div class="ttdef"><b>Definition:</b> <a href="_switch_pro_parser_8h_source.html#l00127">SwitchProParser.h:127</a></div></div>
<div class="ttc" id="a_switch_pro_parser_8h_html_a13c58b19c3e77e1292f9276a69492944"><div class="ttname"><a href="_switch_pro_parser_8h.html#a13c58b19c3e77e1292f9276a69492944">SWITCH_PRO_BUTTONS</a></div><div class="ttdeci">const uint8_t SWITCH_PRO_BUTTONS[]</div><div class="ttdef"><b>Definition:</b> <a href="_switch_pro_parser_8h_source.html#l00041">SwitchProParser.h:41</a></div></div>
<div class="ttc" id="astruct_switch_pro_data_html_a157bd387454177580a18a6c9855e053f"><div class="ttname"><a href="struct_switch_pro_data.html#a157bd387454177580a18a6c9855e053f">SwitchProData::rightHatY</a></div><div class="ttdeci">uint16_t rightHatY</div><div class="ttdef"><b>Definition:</b> <a href="_switch_pro_parser_8h_source.html#l00115">SwitchProParser.h:115</a></div></div>
<div class="ttc" id="acontroller_enums_8h_html_a94f7389d205c78830a5441370d7870fd"><div class="ttname"><a href="controller_enums_8h.html#a94f7389d205c78830a5441370d7870fd">ButtonEnum</a></div><div class="ttdeci">ButtonEnum</div><div class="ttdef"><b>Definition:</b> <a href="controller_enums_8h_source.html#l00078">controllerEnums.h:78</a></div></div>
<div class="ttc" id="astruct_switch_pro_data_html_af30ab8b84238b402c9fe0a16bf695ebf"><div class="ttname"><a href="struct_switch_pro_data.html#af30ab8b84238b402c9fe0a16bf695ebf">SwitchProData::leftHatX</a></div><div class="ttdeci">uint16_t leftHatX</div><div class="ttdef"><b>Definition:</b> <a href="_switch_pro_parser_8h_source.html#l00112">SwitchProParser.h:112</a></div></div>
<div class="ttc" id="acontroller_enums_8h_html_a34dad8f0a0927471137c403216597093"><div class="ttname"><a href="controller_enums_8h.html#a34dad8f0a0927471137c403216597093">AnalogHatEnum</a></div><div class="ttdeci">AnalogHatEnum</div><div class="ttdef"><b>Definition:</b> <a href="controller_enums_8h_source.html#l00218">controllerEnums.h:218</a></div></div>
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.8.17
</small></address>
</body>
</html>