Search titles only
By:
Home
Forums
New posts
Search forums
Articles
New articles
New comments
Search articles
Pinball DB
Pinball Tables
Pinball Games
What's new
New posts
New articles
New profile posts
New article comments
Latest activity
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Navigation
Install the app
Install
More options
Contact us
Close Menu
Welcome Back to Digital Pinball Fans -
please read this first
For latest updates, follow Digital Pinball Fans on
Facebook
and
Twitter
Home
Forums
Farsight Studios
The Pinball Arcade / Farsight Studios
Platform Specific
PC
Duo Pinball controller CAN be made to work on a Windows tablet
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="Alex Atkin UK" data-source="post: 170932" data-attributes="member: 1290"><p>DuoPinball just presents itself as a serial port, at which point it was fairly simple to figure out what each piece of data it sent represented.</p><p></p><p>The whole program is relatively short, simple and probably doing something fundamentally wrong as I am not at all familiar with coding for Windows. <img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite2" alt=";)" title="Wink ;)" loading="lazy" data-shortname=";)" /></p><p></p><p>[CODE]using System;</p><p>using System.Collections.Generic;</p><p>using System.ComponentModel;</p><p>using System.Data;</p><p>using System.Drawing;</p><p>using System.IO.Ports;</p><p>using System.Linq;</p><p>using System.Management;</p><p>using System.Text;</p><p>using System.Threading;</p><p>using System.Windows.Forms;</p><p>using WindowsInput;</p><p></p><p>namespace Duo_Pinball</p><p>{</p><p> public partial class Form1 : Form</p><p> {</p><p> string serialport = null;</p><p> int plungerval = 0;</p><p></p><p> public Form1()</p><p> {</p><p> InitializeComponent();</p><p> }</p><p></p><p> public void Form1_Load(object sender, EventArgs e)</p><p> { </p><p> }</p><p></p><p> public void ConnectSerial()</p><p> {</p><p> ResetLog();</p><p> if (String.IsNullOrEmpty(serialport))</p><p> {</p><p> UpdateStatus("Searching for Duo Pinball, please wait...");</p><p> serialport = null;</p><p> try</p><p> {</p><p> ManagementObjectSearcher searcher = new ManagementObjectSearcher("root\\CIMV2", "SELECT DeviceID,PNPDeviceID,Caption from Win32_SerialPort");</p><p> foreach (ManagementObject queryObj in searcher.Get())</p><p> {</p><p> UpdateLog(queryObj["DeviceID"].ToString() + "\t" + queryObj["Caption"].ToString());</p><p> //Search for the DuoPin VID/PID string </p><p> if (queryObj["PNPDeviceID"].ToString().Contains("VID&00010039_PID&5035"))</p><p> {</p><p> serialport = queryObj["DeviceID"].ToString();</p><p> UpdateStatus("Paired on " + queryObj["Caption"].ToString());</p><p> UpdateLog("Duo Pinball found paired to "+serialport);</p><p> break;</p><p> }</p><p> }</p><p> }</p><p> catch (ManagementException error)</p><p> {</p><p> UpdateLog("Unable to read list of COM ports from WMI: " + error.Message);</p><p> }</p><p> }</p><p></p><p> if (String.IsNullOrEmpty(serialport))</p><p> {</p><p> UpdateLog("Unable to find Duo Pinball COM port, please ensure it is paired with Bluetooth before launching this application.");</p><p> }</p><p> else</p><p> {</p><p> SerialPort mySerialPort = new SerialPort(serialport);</p><p> mySerialPort.BaudRate = 9600;</p><p> mySerialPort.Parity = Parity.None;</p><p> mySerialPort.StopBits = StopBits.One;</p><p> mySerialPort.DataBits = 8;</p><p> mySerialPort.Handshake = Handshake.None;</p><p> mySerialPort.DataReceived += new SerialDataReceivedEventHandler(DataReceivedHandler);</p><p> try</p><p> {</p><p> UpdateLog("Opening serial port "+serialport);</p><p> mySerialPort.Open();</p><p> ButtonText("Reconnect");</p><p> UpdateLog("Duo Pinball should now be working, you can see if the buttons are working or not above.\rIn games the flippers are mapped to left and right shift, the plunger button is mapped to Enter. Analog plunger is not (yet) supported.");</p><p> }</p><p> catch</p><p> {</p><p> UpdateLog("Unable to open serial port, please ensure Duo Pinball is awake and in range and try again.\rIf this happens and it took a long time to find the Duo Pinball COM port it often means the controller has locked up, try removing and re-inserting the batteries.");</p><p> ButtonText("Retry");</p><p> }</p><p> }</p><p> }</p><p></p><p> public void DataReceivedHandler(object sender, SerialDataReceivedEventArgs e)</p><p> {</p><p> SerialPort sp = (SerialPort)sender;</p><p> string indata = sp.ReadExisting();</p><p> char[] CharArray = indata.ToCharArray();</p><p> byte[] ByteArray = new byte[CharArray.Length];</p><p> // Convert ASCII string to HEX</p><p> for (int i = 0; i < CharArray.Length; i++)</p><p> {</p><p> ByteArray[i] = Convert.ToByte(CharArray[i]);</p><p> ByteArray[i] += 0x30;</p><p> }</p><p> string outdata = "";</p><p> for (int i = 0; i < CharArray.Length; i++)</p><p> {</p><p> outdata += ByteArray[i] + " ";</p><p> }</p><p></p><p> // If the first two digits are correct then interpret the command</p><p> if (ByteArray.Length > 3 && ByteArray[0] == 138 && ByteArray[1] == 111)</p><p> {</p><p> if (ByteArray[2] == 49)</p><p> {</p><p> // Flippers</p><p> if (ByteArray[3] == 48)</p><p> {</p><p> // Flippers Released</p><p> InputSimulator.SimulateKeyUp(VirtualKeyCode.LSHIFT);</p><p> InputSimulator.SimulateKeyUp(VirtualKeyCode.RSHIFT);</p><p> LeftFlipper(false);</p><p> RightFlipper(false);</p><p> }</p><p> else if (ByteArray[3] == 49)</p><p> {</p><p> // Left Flipper</p><p> InputSimulator.SimulateKeyDown(VirtualKeyCode.LSHIFT);</p><p> InputSimulator.SimulateKeyUp(VirtualKeyCode.RSHIFT);</p><p> LeftFlipper(true);</p><p> RightFlipper(false);</p><p> }</p><p> else if (ByteArray[3] == 50)</p><p> {</p><p> // Right Flipper</p><p> InputSimulator.SimulateKeyUp(VirtualKeyCode.LSHIFT);</p><p> InputSimulator.SimulateKeyDown(VirtualKeyCode.RSHIFT);</p><p> LeftFlipper(false);</p><p> RightFlipper(true);</p><p> }</p><p> else if (ByteArray[3] == 51)</p><p> {</p><p> // Both Flippers</p><p> InputSimulator.SimulateKeyDown(VirtualKeyCode.LSHIFT);</p><p> InputSimulator.SimulateKeyDown(VirtualKeyCode.RSHIFT);</p><p> LeftFlipper(true);</p><p> RightFlipper(true);</p><p> }</p><p> }</p><p> else if (ByteArray[2] == 50)</p><p> {</p><p> if (ByteArray[5] == 49)</p><p> {</p><p> // Ball Launcher Button</p><p> Plunger(0);</p><p> if (plungerval != 0)</p><p> {</p><p> plungerval = 0;</p><p> InputSimulator.SimulateKeyPress(VirtualKeyCode.RETURN);</p><p> }</p><p> }</p><p> else</p><p> {</p><p> plungerval = ByteArray[3] - 47;</p><p> Plunger(plungerval);</p><p> }</p><p> }</p><p> else</p><p> {</p><p> UpdateLog("Unknown Command: "+outdata+" ignored.");</p><p> }</p><p> }</p><p> else</p><p> {</p><p> UpdateLog("Garbage received: " + outdata + " ignored.");</p><p> }</p><p> }</p><p></p><p> private void button1_Click(object sender, EventArgs e)</p><p> {</p><p> ConnectSerial();</p><p> }</p><p> }</p><p>}</p><p>[/CODE]</p><p></p><p>Its so incredibly simple that its a shame Pinball Arcade doesn't support it natively so the plunger worked properly.</p></blockquote><p></p>
[QUOTE="Alex Atkin UK, post: 170932, member: 1290"] DuoPinball just presents itself as a serial port, at which point it was fairly simple to figure out what each piece of data it sent represented. The whole program is relatively short, simple and probably doing something fundamentally wrong as I am not at all familiar with coding for Windows. ;) [CODE]using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.IO.Ports; using System.Linq; using System.Management; using System.Text; using System.Threading; using System.Windows.Forms; using WindowsInput; namespace Duo_Pinball { public partial class Form1 : Form { string serialport = null; int plungerval = 0; public Form1() { InitializeComponent(); } public void Form1_Load(object sender, EventArgs e) { } public void ConnectSerial() { ResetLog(); if (String.IsNullOrEmpty(serialport)) { UpdateStatus("Searching for Duo Pinball, please wait..."); serialport = null; try { ManagementObjectSearcher searcher = new ManagementObjectSearcher("root\\CIMV2", "SELECT DeviceID,PNPDeviceID,Caption from Win32_SerialPort"); foreach (ManagementObject queryObj in searcher.Get()) { UpdateLog(queryObj["DeviceID"].ToString() + "\t" + queryObj["Caption"].ToString()); //Search for the DuoPin VID/PID string if (queryObj["PNPDeviceID"].ToString().Contains("VID&00010039_PID&5035")) { serialport = queryObj["DeviceID"].ToString(); UpdateStatus("Paired on " + queryObj["Caption"].ToString()); UpdateLog("Duo Pinball found paired to "+serialport); break; } } } catch (ManagementException error) { UpdateLog("Unable to read list of COM ports from WMI: " + error.Message); } } if (String.IsNullOrEmpty(serialport)) { UpdateLog("Unable to find Duo Pinball COM port, please ensure it is paired with Bluetooth before launching this application."); } else { SerialPort mySerialPort = new SerialPort(serialport); mySerialPort.BaudRate = 9600; mySerialPort.Parity = Parity.None; mySerialPort.StopBits = StopBits.One; mySerialPort.DataBits = 8; mySerialPort.Handshake = Handshake.None; mySerialPort.DataReceived += new SerialDataReceivedEventHandler(DataReceivedHandler); try { UpdateLog("Opening serial port "+serialport); mySerialPort.Open(); ButtonText("Reconnect"); UpdateLog("Duo Pinball should now be working, you can see if the buttons are working or not above.\rIn games the flippers are mapped to left and right shift, the plunger button is mapped to Enter. Analog plunger is not (yet) supported."); } catch { UpdateLog("Unable to open serial port, please ensure Duo Pinball is awake and in range and try again.\rIf this happens and it took a long time to find the Duo Pinball COM port it often means the controller has locked up, try removing and re-inserting the batteries."); ButtonText("Retry"); } } } public void DataReceivedHandler(object sender, SerialDataReceivedEventArgs e) { SerialPort sp = (SerialPort)sender; string indata = sp.ReadExisting(); char[] CharArray = indata.ToCharArray(); byte[] ByteArray = new byte[CharArray.Length]; // Convert ASCII string to HEX for (int i = 0; i < CharArray.Length; i++) { ByteArray[i] = Convert.ToByte(CharArray[i]); ByteArray[i] += 0x30; } string outdata = ""; for (int i = 0; i < CharArray.Length; i++) { outdata += ByteArray[i] + " "; } // If the first two digits are correct then interpret the command if (ByteArray.Length > 3 && ByteArray[0] == 138 && ByteArray[1] == 111) { if (ByteArray[2] == 49) { // Flippers if (ByteArray[3] == 48) { // Flippers Released InputSimulator.SimulateKeyUp(VirtualKeyCode.LSHIFT); InputSimulator.SimulateKeyUp(VirtualKeyCode.RSHIFT); LeftFlipper(false); RightFlipper(false); } else if (ByteArray[3] == 49) { // Left Flipper InputSimulator.SimulateKeyDown(VirtualKeyCode.LSHIFT); InputSimulator.SimulateKeyUp(VirtualKeyCode.RSHIFT); LeftFlipper(true); RightFlipper(false); } else if (ByteArray[3] == 50) { // Right Flipper InputSimulator.SimulateKeyUp(VirtualKeyCode.LSHIFT); InputSimulator.SimulateKeyDown(VirtualKeyCode.RSHIFT); LeftFlipper(false); RightFlipper(true); } else if (ByteArray[3] == 51) { // Both Flippers InputSimulator.SimulateKeyDown(VirtualKeyCode.LSHIFT); InputSimulator.SimulateKeyDown(VirtualKeyCode.RSHIFT); LeftFlipper(true); RightFlipper(true); } } else if (ByteArray[2] == 50) { if (ByteArray[5] == 49) { // Ball Launcher Button Plunger(0); if (plungerval != 0) { plungerval = 0; InputSimulator.SimulateKeyPress(VirtualKeyCode.RETURN); } } else { plungerval = ByteArray[3] - 47; Plunger(plungerval); } } else { UpdateLog("Unknown Command: "+outdata+" ignored."); } } else { UpdateLog("Garbage received: " + outdata + " ignored."); } } private void button1_Click(object sender, EventArgs e) { ConnectSerial(); } } } [/CODE] Its so incredibly simple that its a shame Pinball Arcade doesn't support it natively so the plunger worked properly. [/QUOTE]
Verification
Post reply
Members online
No members online now.
Latest posts
Z
Strategies.
Latest: Zaphod77
Apr 18, 2024
WHO dunnit (1995)
Y
AtGames Legends pinball
Latest: yespage
Apr 15, 2024
Digital Pinball Cabinets
Master List of Issues: Pinball FX
Latest: Pinballwiz45b
Apr 13, 2024
Pinball FX (4)
We are back with a new site
Latest: Ian Longstaff
Apr 8, 2024
Other Pinball Games
Z
5X Jackpot build strategy (POTO)
Latest: Zaphod77
Apr 5, 2024
Phantom of the Opera (1990)
Home
Forums
Farsight Studios
The Pinball Arcade / Farsight Studios
Platform Specific
PC
Duo Pinball controller CAN be made to work on a Windows tablet
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.
Accept
Learn more…
Top