This is the driver for the petrockblock.com ControlBlock, which is an extension board for the Raspberry Pi (TM). The driver itself is denoted as controlblock in the following. The driver provides a service for interacting with the power button signals as well as for mapping attached game controllers to corresponding game pad devices on the Raspberry Pi.
Please note that this is the driver for revision 1.X of the ControlBlock. If you have a revision 2.X board, you need to use the driver for that revision series.
To be able to successfully build ControlBlockService you need to have certain APT packages installed. You can make sure that you have the latest version of those packages with these commands:
sudo apt-get update
sudo apt-get upgrade -y
sudo apt-get install -y git cmake g++-4.9 doxygenIf you would like to download the latest version of controlblock from its Github repository, you can use this command:
git clone --recursive https://github.com/petrockblog/ControlBlockService.gitNote that the above command also takes care for downloading the included Git submodules.
There comes an installation script with this reposity that does all the steps described below: install.sh This script compiles the driver, installs the binary and configuration files, and installs the ControlBlock service.
To run the quick installation, you just need to call this one line from the Raspbian console
wget -O - https://raw.githubusercontent.com/petrockblog/ControlBlockService/master/install.sh | sudo bashTo build controlblock follow these commands:
cd ControlBlockService
mkdir build
cd build
cmake ..
makeIf everything went fine you can install the driver from within the folder build with the command
sudo make installYou can install controlblock as daemon from within the folder build with this command:
sudo make installserviceIt might be that you need to restart your Raspberry afterwards to have all needed services running.
You can uninstall the daemon from within the folder build with this command:
sudo make uninstallserviceYou can uninstall the binary with this command:
sudo make uninstallThe configuration file of controlblock is located at /etc/controlblockconfig.cfg. It uses JSON syntax for setting the the values of its configuration parameters.
The parameters are explained in detail in the following:
input - gamepadtype: Can be set toarcade: Enables two game pads in the system and maps the GPIOs of the ControlBlock to these game pads.

mame: Enables a virtual keyboard and maps the GPIOs of the ControlBlock to this keyboard with a MAME layout.

snes: Enables two game pads in the system and maps the attached SNES/NES controllers accordingly.

input - singlegamepad: Can be set totrue: Enables only one gamepad in the system (eg if only Player1 buttons are wired to the controlblock in your setup, this prevents a ghost gamepad from being selected as default player 2 in retroarch)false: Enables the two gamepads (default)
powerswitch - activated: Can be set totrue: Activates the handling of the power switch signals of the ControlBlock.false: Deactivates the handling of the power switch signals of the ControlBlock.
Have fun!
-Florian petrockblock.com