Instructables
Make an awesomely playable mini pinball, out of an Android tablet, real arcade buttons, some wood and some software!

There are some very good Android pinball applications. But I do not like to play using the touchscreen (I always end up hitting the home or menu icons).

I just needed real buttons, so I built this cabinet. The result is really reactive, and give full justice to these amazing pinball simulators!


 
Remove these adsRemove these ads by Signing Up

Step 1: Technical Considerations

Picture of Technical Considerations
Before undertaking the job of building a cabinet, it is necessary to check that all conditions are met.

Events principle
The principle I chose is to simulate finger touches. This will insure a perfect compatibility with all pinball applications (and not only the seldom ones supporting an external keyboard).

The buttons are connected to an USB keyboard controller. The SHIFT keys are detected and converted to touch events.

Tablet connectors
The tablet must have USB host capability, with an USB (or USB-on-the-go) connector. BTW, Android well supports external USB peripherals such as hard drives, keyboards, mice, hubs, etc.

Alternatively, Bluetooth keyboard may work, but I bet that the lag will badly impact the reactivity.

Also, an Arduino with an USB host controller, and directly connected to pinball buttons, may work. It would require ADK support.

Rooting
In order to read and send raw events, the application requires the tablet to be permanently rooted.

IT IS VERY DANGEROUS TO USE A ROOTED TABLET, as malware could virtually access anything, including your personal data and online accounts. Do not run apps requiring rooting, except if you know exactly what they're doing.

Evaluate!
Anyway, make a test before undertaking the project.

Step 2: The Software Architecture

Picture of The Software Architecture
Studies
Before ending up with the current design, a few studies have been made:
  • Reading raw keyboard events from the PC, using adb and getevent.
  • Generating multitouch events (*) from a small program written in C.
  • Doing the above from Java (requiring only rooting, but no daemon). This proved slightly too slow and introduced a noticeable lag, so I opted for a daemon written in C, and configured by a Java app.

(*) see http://www.mjmwired.net/kernel/Documentation/input/multi-touch-protocol.txt

Architecture
The final architecture is based on a daemon, that is, a small standalone program (written in C and hence very fast) communicating with a Java service.

The diagram in this step is an UML class diagram, showing the principal classes and entities, and their relations.

pinball_buttons_mapper (aka the daemon) - this is the standalone C program, actually doing all the "real" job: it waits for keyboard events, and generates multitouch events (simulating finger touches on the screen). It reads all its parameters from the compact settings file. The daemon is started by the Java app as root, because it needs such permissions to read/write events directly from /dev/input/eventN device drivers from the underlying Linux OS. The demon is not able to determine the devices to use, screen size and orientation, etc, so it reads these parameters from the settings.cnf file, that was prepared by the Java part. The daemon is able to detect that the settings file has changed and to re-read it automatically.

SettingsActivity - this is the main screen that is shown when starting the program. It lets you set all parameters, and stores them as preferences. It also (re)starts the service, and calls the CompactSettings upon settings changes.

CompactSettings (aka settings.cnf) - writes a copy of the settings, in a very compact format that the daemon can easily read. The settings are in XML, but the compact copy is very much simpler.

TheService - this is Java code running in background, even when no screen of the app is visible. It makes an icon always visible in the Android notification area, and cares for (re) starting the daemon (its role is merely to monitor the daemon, and call the settings screen).

Mapper - this is a Java class designed to install the daemon, and (re)start it.

BroadcastReceiver - this is needed to make the app automatically start when the tablet boots.

Logs - provides a screen showing debug logs, useful when developing the software.

UncaughtExceptionHandler - normally, when a Java apps encounters a bug leading to a creash, it stops. This handler instead displays some technical information (the stack trace) to help locating the problem without a debugger attached via a PC.

Compiling and building
The Java part was developed under Eclipse. The daemon is cross-compiled, and stored into the Java app as a raw resource.

To build all, run the build_all.sh script. Its final product is the APK file in bin/. The build script works under Linux and Mac OSX, and requires the Android SDK to be installed, as well as the C cross-compiler (arm-linux-gnueabi-gcc). To develop the Java part, and if build_all.sh was run once before in order to compile the C daemon, everything can be done from within Eclipse as usual.

The archive for source code can be found in step 10.

Step 3: Scavenging the Keyboard

My USB keyboard controller has, additionally, an USB hub, which is very convenient for connecting a second (unscavenged) keyboard.

With an ohmmeter, I found the tracks to the both shift keys. Then I removed the keyboard membrane, and soldered two arcade buttons in place of the shift keys.

Step 4: Building the Cabinet

The cabinet is custom built for the tablet I dedicate to this project. The tablet can be easily detached from it, so it is still usable for any other purposes.

I will not describe the making of the cabinet in much details; you are seasoned makers and crafters!

I just made a cardboard model to evaluate the size, angles, the handling, etc, then made drawings with a 2D sketching program.

Step 5: Artwork

Artwork is an important aspect of pinballs.

As a fan of BTTF, I located some related pictures and printed them on printable A4 sticker sheets, then laminated them.

I applied some spray glue on the cabinet to improve the adhesion force, then affixed the sheets.

Finally, I installed the legs, with the help of a spacing tool made of Lego.

Step 6: PinballButtons Application Setup

Picture of PinballButtons Application Setup
device-2013-04-30-024031.png
device-2013-04-30-025832.png
device-2013-04-30-024133.png
Installation of the PinballButtons application
I will make my app available on the Google Play Store, but in the mean time you can do the following:
  1. Download, from step 10, the PinballButtons-rNNN-apk.zip file
  2. Extract it. It contains one file, PinballButtons.apk: copy it on a flash SD card.
  3. Insert the card in your tablet.
  4. On the tablet, start a file manager, locate the apk file and install it.
Setup of the PinballButtons application
Once the Pinball Buttons app is installed, you can bring its screen by clicking its icon in the notification area. Or clicking its icon on the apps list or on the desktop.

Then set the parameters as shown in the 4 screen shots.

Step 7: More Tablet Settings

Picture of More Tablet Settings
device-2013-04-30-024608.png
Forcing the screen orientation
Given the slight slant, my tablet orientation wans changing all the time. To freeze the orientation, use for instance Set Orientation app.

Settings: Seeing finger touches
A very practical system setting is Developer Options -> Show Touches. For each finger touch on the screen, this displays a spot.
Our simulated touches produced by the Pinball Buttons app will be visible, if all works as expected.

Step 8: Pinball apps! Pinball apps!

Picture of Pinball apps! Pinball apps!
device-2013-04-30-024724.png
device-2013-04-30-024808.png
There are many cools 2D and 3D pinball apps.
  • 2D: Pinball Deluxe and Pinball Classic,
  • 3D: The king of apps: Pinball Arcade. Simulates many famous tables. Fast! Realistic! Fun!!!

Step 9: Enjoy!

Picture of Enjoy!
IMG_0579.JPG
Many advanced pinball maneuver are possible.

With the Pinball Arcade app, you can play a huge collection of legacy tables, with the same feel as before. I tried Black Knight, Black Hole, etc. with the same feel as decades ago!

Step 10: Downloads and Updates

This steps provides these download files:
  • PinballButtons-rNNN-src.zip  -- archive containing the project source files -- Use this to study/modify the project (see step 2).
  • PinballButtons-rNNN-apk.zip  -- archive containing the APK file, i.e. the Android app install package -- Use this to install the app (see step 6).
Updates:
  • Initial release (Apr 29, 2013)
  • r343 (May 16, 2013) - Fixed issue found by mwheeler3: releasing buttons generated improper touchscreen events.
lmowry17 hours ago
I have been doing some tests and hardware examples...

I have a 8" by 5" android tablet running android 4.04... (Screen size at 6" by 3 1/2") it's a phone operating system stretched to make a "phone tablet"... I bought it from china a year back.

It's pretty good for the $60 I paid for it, good graphics card, poor touch screen...

Anyway I am working on making a pinball machine using it. I am able to avoid rooting it.

I just wanted to let you know the apps I am using.

To hide the menus bar on the bottom, (the one that has the back button and time) I am using "full!screen+"

To keep the orientation I am using what you said, "set orientation"

For the touches on the screen from a hacked keyboard, (by hacked I mean modded physically with the arcade buttons) I am using "game keyboard"

And finally to start the pinball arcade on startup with everything else I am using an app called, "auto start".

The touch buttons and menus for the android operating system is all set to auto set to the setting I chose in the apps on startup and I have them set to be fully transparent.

I am in the middle of working on this project now and was happy to find I can jump right in withought rooting or actually programming anything:)

One last note, I am building the pinball machine to enclose this tablet. (It will not be taken out).

I would like to thank you for this awesome idea, I will have pics when I finish!
trouble017 months ago
is it a 10" tablet pc?
laxap (author)  trouble017 months ago
10 inches Android tablet.
Colleen46149 months ago
This is really cool
mwheeler311 months ago
All issues resolved on an HP Touchpad running Tenderloin CM10 ROM. PinballButtons does track all button events into accurate screen touches. You can see my build here. This uses an Ultimarc iPac as the keyboard controller.
mwheeler311 months ago
PinballButtons APK seems to be stuck in a loop for me. It keeps giving me the SuperUser prompt. I click Allow, but it just keeps asking over and over.
laxap (author)  mwheeler311 months ago
I need the logs. Click menu -> Show Logs and scroll down.

Take a screenshot of the logs screen. If you have the Android development environment installed on your computer, then:
  1. be sure to have USB debugging enabled on the tablet
  2. connect your tablet to the PC via USB
  3. on the PC start monitor (or DDMS from Eclipse)
  4. select the tablet in the devices list, and click the screenshot icon
  5. Finally attach the screenshot as a reply. to this thread.
If the above is problematic, I will add the feature of copying the logs to a file on the sdcard.
mwheeler3 laxap11 months ago
(removed by author or community request)
(removed by author or community request)
Can you also add two more buttons? Start and Plunger?
laxap (author)  mwheeler311 months ago
Plunger is tricky because it should simulate a swipe. Where is a good screen location for it? It is very pinball-dependant.

For start, what should it do?
mwheeler3 laxap11 months ago
OK. Wasn't sure how those were handled. I was thinking of adding two additional buttons. One that would just send the ball and a Start button just mapped to the Start button in the GUI.
laxap (author)  mwheeler311 months ago
Please download the new APK at http://www.instructables.com/file/F2LL703HGIEUWI0/
It should allow the screen to display even if there is a background error.
Then you can display the logs (please scroll down) and make a screenshot.
Edgar11 months ago
Yes, you can make some bucks building this...
You could even go Crowdfunding!
Went to my Blog:
http://faz-voce-mesmo.blogspot.pt/2013/05/a-newsletter-da-cncking-e-carradas-de.html
ncaap11 months ago
Ok thanks when you willing to start making them I would pay you for your time I think that this is the coolest thing out there
ncaap11 months ago
Would you be willing to make one for me.we can work out a cost?
laxap (author)  ncaap11 months ago
No, but I can give you plenty of advice if you build your own.
DoxxRoxx11 months ago
You've done a fantastic job on the build!
I agree, using the screen for the flipper buttons is annoying and frustrating. 
Having seen a few full size versions, I applaud the small scale version you've designed, as it's obviously quite portable.  I'd love to try it, just don't have a tablet I can afford to root.

'Pinball Arcade' is OK, as far as Android apps go.
However, I would suggest using 'Zen Pinball', as the game physics are spot on.  
The physics are so nuanced, that the ball can bang the glass top and also get stuck, requiring nudges to dislodge, just as a real table will occasionally do!
The Android version includes the first table free.
I'm not affiliated ... just a pinball connoisseur.

If you were so inclined to make a full-sized machine, I'd go with their XBox 360 version, 'Pinball FX2'. All tables also incorporate tilt control. Company name: 'Zen Studios'
laxap (author)  DoxxRoxx11 months ago
Thank you.

Yes, I know Zen Pinball, and like it too. In addition to probably having the best physics, it also shows "smoke trails" behind the ball, helping a lot to locate the ball, which can be easy lost in all these 3D details.

We also love to play Pinball Deluxe. It's easier for kids, and nevertheless a lot of fun to play. The advantage of 2D is that it does not add any perspective, which is looking strange on a cabinet.

Therefore it's good to have a versatile cabinet with plenty of choice!
denis197611 months ago
Great Scott!!!!
Greasetattoo11 months ago
GREAT job...
I am making a full size version!
42" flat screen and 27" flat screen for the back!

Thanks for the GREAT instructable!
laxap (author)  Greasetattoo11 months ago
I'm looking forward to seeing your version
Me too!!!!
foobear11 months ago
This is totally amazing. What sw did you use to draw that uml diagram - it's beautiful
laxap (author)  foobear11 months ago
Thank you.

I used yEd (www.yworks.com/en/products_yed_about.html) with UML shapes, and automatic hierarchic layout (alt-shift-h).
Pro

Get More Out of Instructables

Already have an Account?

close

PDF Downloads
As a Pro member, you will gain access to download any Instructable in the PDF format. You also have the ability to customize your PDF download.

Upgrade to Pro today!