Actions

Raspberry Pi Pikeyd165 keylogging

From falz.net


I ran in to a few issues where ghost button presses were happing on my Neo Geo Arcade Cabinet so resorted to debugging with a the logkeys keylogger. Here's how to install it on a Rapsberry pi and debug the pikeyd165 driver (binary can be found in the Retropie or Regamebox packages for pi2jamma):


Install required packages to build logkeys. You may already have some of these installed:

sudo apt-get install autoconf automake libtool autotools-dev git


Download and compile logkeys. If the autogen.sh command gives an error I may have missed a package above.

git clone https://github.com/kernc/logkeys.git
cd logkeys
./autogen.sh
cd build
../configure
make
sudo make install


Now you must determine which input device pikeyd165 is showing up as, this will depend on if you have a keyboard and some other things. Look at the file /proc/bus/input/devices and find the event handler named "uinput-sample". Mine is event4:

less /proc/bus/input/devices

<snip removed the real keyboard stuff>

I: Bus=0003 Vendor=0001 Product=0001 Version=0001
N: Name="uinput-sample"
P: Phys=
S: Sysfs=/devices/virtual/input/input4
U: Uniq=
H: Handlers=sysrq kbd event4 rfkill 
B: PROP=0
B: EV=100003
B: KEY=ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe


SSH in to the pi and start logkeys. Be sure to modify event4 to whatever yours is:

sudo logkeys --start --device /dev/input/event4 --output /var/log/logkeys.log


All output from pikeyd165 should now be logged to /var/log/logkeys.log. Press some joystick directions to ensure it's logging. Launch a game and let it idle for a while.


In my case it was sensing random ghost inputs of all buttons mapped in pikeyd165.conf. sometimes it took a few minutes,to sometime it took 15 minutes or so, it's random. Note that the log shows a few oddities due to the shift key being virtually pressed. ! is 1, " is 2, % is 5, ^ is 6.

<F2><Esc> <LShft>ZXIKWQ<Left><Right><LCtrl><LAlt>SAGd%!<Up><Down>FR"^


I'm currently working to determine what is actually causing this. It doesn't seem to happen while idling at the input menu, only while in a game. It happens in both Advmame as well as libretro FBA. Advmame sees the F2 and Escape and acts accordingly - escapes the game or goes to VTY2. Libretro seems to ignore everything, perhaps due to it being 24 characters at once.