{"id":28944,"date":"2020-05-30T22:43:33","date_gmt":"2020-05-30T22:43:33","guid":{"rendered":"http:\/\/pcbjunkie.net\/?page_id=28944"},"modified":"2023-05-11T10:14:08","modified_gmt":"2023-05-11T10:14:08","slug":"pj-troubleshooting-controls","status":"publish","type":"page","link":"https:\/\/pcbjunkie.net\/index.php\/pj-troubleshooting-controls\/","title":{"rendered":"PJ &#8211; Troubleshooting Controls"},"content":{"rendered":"\n<h4 class=\"wp-block-heading\">Overview:<\/h4>\n\n\n\n<p>On the PJ JAMMA adapter board, a joystick event is detected when the COMM LED stops flashing and stays on. The LED should stay lit when a joystick is pushed, a switch is activated or a button is pressed, and resume blinking when it&#8217;s released.<\/p>\n\n\n\n<p>If the LED continues to flash and is not staying ON when a button is held, the PJ board is not detecting the button press. If the LED stays on with no buttons or switches being active, you may have a stuck switch, a short in the wiring, or the adapter&#8217;s input section may be bad. <\/p>\n\n\n\n<p>Try using the adapter in a different cabinet. Check your wiring. Check the four 74(HC)165 ICs on the PJ board. These chips normally stay cold to the touch. If one or more appear unusualy warm, it&#8217;s a dead giveaway that one of the chip&#8217;s inputs got blown. If found faulty, replace the four socketed ICs. <\/p>\n\n\n\n<p>During initial start up, the COMM LED on the adapter flashes quickly, off and on approximately twice per second. Once the OS drivers are loaded and successful communication with the Raspberry Pi is estabilished, the flashing will slow down to approximately once per second. <\/p>\n\n\n\n<p>If the speed of the LED flashing doesn&#8217;t change after Linux fully boots, please ensure that the PJ adapter drivers are loaded. If loaded, either the GPIO on the Pi, or the MSP430 microcontroller on the PJ board may be faulty.<\/p>\n\n\n\n<p>Check to logs in \/var\/log\/debug <\/p>\n\n\n\n<p><strong>Input Event Chain<\/strong><\/p>\n\n\n\n<p>Once the pjjoy driver is loaded, the udev driver manager loads the necessary joydev (standard linux) and evdev (event) driver modules. The SDL library which emulationstation and retroarch uses, reads events from the evdev driver, assuming the evdev device is a joystick \/ gamepad. Here&#8217;s how the control events are passed from the drivers to the emulators.<\/p>\n\n\n\n<p><strong>pjjoy <\/strong>(joydev linux driver) &lt;-&gt; <strong>evdev <\/strong>(event driver) &lt;-&gt; <strong>SDL2 <\/strong>(media library) &lt;-&gt; <strong>emulationstation <\/strong>(retropie front end)<\/p>\n\n\n\n<p><strong>Reading the state of the joystick, button and switch controls:<\/strong><\/p>\n\n\n\n<p>The <strong>joydev<\/strong> driver module <em>pjjoy <\/em>provides standard joystick interface devices for use in Linux. The best way to troubleshoot these controls it to use the joystick test utility <em>jstest<\/em> against device driver files<em> \/dev\/input\/js0<\/em> (player 1) and <em>\/dev\/input\/js1<\/em> (player 2). These device files will not be present unless j4b and pjjoy modules are loaded (in that order).<\/p>\n\n\n\n<p>To monitor the state of the controls run:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">sudo jstest \/dev\/input\/js0 (or js1)<\/pre>\n\n\n\n<p>You should get something that resembles what is below:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">Driver version is 2.1.0.<br>Joystick (PJ 2-axis 12-button digital controls) has 2 axes (X, Y)<br>and 12 buttons (BtnSelect, BtnStart, BtnMode, Btn1, Btn2, Btn3, Btn4, Btn5, Btn6, Btn7, Btn8, ExtraBtn).<br>Testing ... (interrupt to exit)<br>Axes: &nbsp;0: &nbsp; &nbsp; 0 &nbsp;1: &nbsp; &nbsp; 0 Buttons: &nbsp;0:off &nbsp;1:off &nbsp;2:off &nbsp;3:off &nbsp;4:off &nbsp;5:off &nbsp;6:off &nbsp;7:off &nbsp;8:off &nbsp;9:off 10:off 11:off<\/pre>\n\n\n\n<p>The <strong>evdev <\/strong>device can be tested using the <em>evtest <\/em>test utility:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">sudo evdev \/dev\/input\/event0 (or event1)<\/pre>\n\n\n\n<p>You should get something that resembles what is below:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">Input driver version is 1.0.0\nInput device ID: bus 0x6 vendor 0x4147 product 0x5046 version 0x101\nInput device name: \"PJ Arcade Controls\"\nSupported events: ...<\/pre>\n\n\n\n<p>Finally, the controls can be tested from SDL, the way the emulator would receive them. For that the utility <em>sdljoytest <\/em>has been provided. The utility can be found in <em>\/home\/pi\/utilities\/sdljoytest <\/em>and may need to be compiled (run &#8220;<em>make clean<\/em>&#8220;, then &#8220;<em>make<\/em>&#8221; as usual). The following example retrieves joystick info, with other options the utility can display controller events.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">\/home\/pi\/utilities\/sdljoytest \u2013t 0<\/pre>\n\n\n\n<p>You should get something that resembles what is below:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">&nbsp;\nNote: using sdljoytest \u2013l will return joystick properties from the PJ drivers:\nFound 2 joystick(s)\n&nbsp;\nJoystick Name:&nbsp;&nbsp;&nbsp;&nbsp; 'PJ arcade controls'\nJoystick GUID:&nbsp;&nbsp;&nbsp;&nbsp; 06000000474100004a50000000010000\nJoystick Number:&nbsp;&nbsp;&nbsp; 0\nNumber of Axes:&nbsp;&nbsp;&nbsp;&nbsp; 2\nNumber of Buttons: 12\nNumber of Hats:&nbsp;&nbsp;&nbsp;&nbsp; 0\nNumber of Balls:&nbsp;&nbsp;&nbsp; 0\nGameController:\n&nbsp; not a gamepad\n&nbsp;\nJoystick Name:&nbsp;&nbsp;&nbsp;&nbsp; 'PJ arcade controls'\nJoystick GUID:&nbsp;&nbsp;&nbsp;&nbsp; 06000000474100004a50000000010000\nJoystick Number:&nbsp;&nbsp;&nbsp; 1\nNumber of Axes:&nbsp;&nbsp;&nbsp;&nbsp; 2\nNumber of Buttons: 12\nNumber of Hats:&nbsp;&nbsp;&nbsp;&nbsp; 0\nNumber of Balls:&nbsp;&nbsp;&nbsp; 0\nGameController:\n&nbsp; not a gamepad\n&nbsp;<\/pre>\n\n\n\n<p>The GUID from the SDL joystick definition must match the GUID in the emulationstation <em>es_config <\/em>file. If joystick doesn\u2019t show up in SDL but exists as a <strong>linux <\/strong>and as a <strong>evdev <\/strong>device, check if ID_INPUT_JOYSTICK=1 property is set using <em>udevadm<\/em>.<\/p>\n\n\n\n<p><strong>Simulating joystick events using the keyboard:<\/strong><\/p>\n\n\n\n<p>It&#8217;s possible to insert joystick and button events using <em>joytest <\/em>utility. This can be used for troubleshooting the driver and emulation configuration by passing the controller hardware on the PJ.<\/p>\n\n\n\n<p>Compile the utility:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">cd \/home\/pi\/utilities\/joytest\/<br>make clean<br>make<\/pre>\n\n\n\n<p>Run the joytest utility as follows:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">cd \/home\/pi\/utilities\/joytest<br>sudo .\/joytest \/dev\/j4binput0<\/pre>\n\n\n\n<p>The utility should display the following control options. Either player 1 or player 2 controls can be tested by selecting the appropriate joystick device (<em>\/dev\/j4binput0<\/em> or <em>\/dev\/j4binput1<\/em>).<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">Using queue: \/dev\/j4binput0\nPress ~ to quit\nUse W,S,A,D for UP,DOWN,LEFT,RIGHT\nUse I,O,P,J,K,L for BUTTON 1,2,3,4,5,6\nUse Z,X,C,V for SELECT,START,EXTRA,MODE\nch = 0032 ' ', val = 0000, msg = 8.0.0.0, wrote = 1\nPress \"~\" to quit the utility.<\/pre>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Overview: On the PJ JAMMA adapter board, a joystick event is detected when the COMM LED stops flashing and stays on. The LED should stay lit when a joystick is pushed, a switch is activated or a button is pressed, and resume blinking when it&#8217;s released. If the LED continues to flash and is not &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/pcbjunkie.net\/index.php\/pj-troubleshooting-controls\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;PJ &#8211; Troubleshooting Controls&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-28944","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/pcbjunkie.net\/index.php\/wp-json\/wp\/v2\/pages\/28944","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/pcbjunkie.net\/index.php\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/pcbjunkie.net\/index.php\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/pcbjunkie.net\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/pcbjunkie.net\/index.php\/wp-json\/wp\/v2\/comments?post=28944"}],"version-history":[{"count":4,"href":"https:\/\/pcbjunkie.net\/index.php\/wp-json\/wp\/v2\/pages\/28944\/revisions"}],"predecessor-version":[{"id":35734,"href":"https:\/\/pcbjunkie.net\/index.php\/wp-json\/wp\/v2\/pages\/28944\/revisions\/35734"}],"wp:attachment":[{"href":"https:\/\/pcbjunkie.net\/index.php\/wp-json\/wp\/v2\/media?parent=28944"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}