Okay, let's see how to hook up the buttons to an input port:

I don't know what code to use, so I thought IPT_OUTPUT would work, and that allows me to click on the buttons.

Code
PORT_START("tablet_menu_buttons")
PORT_BIT( 0x1, IP_ACTIVE_HIGH, IPT_OUTPUT)
PORT_BIT( 0x2, IP_ACTIVE_HIGH, IPT_OUTPUT)
PORT_BIT( 0x4, IP_ACTIVE_HIGH, IPT_OUTPUT)
PORT_BIT( 0x8, IP_ACTIVE_HIGH, IPT_OUTPUT)
PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_OUTPUT)
PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_OUTPUT)
PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_OUTPUT)
PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_OUTPUT)
PORT_BIT( 0x100, IP_ACTIVE_HIGH, IPT_OUTPUT)
PORT_BIT( 0x200, IP_ACTIVE_HIGH, IPT_OUTPUT)
PORT_BIT( 0x400, IP_ACTIVE_HIGH, IPT_OUTPUT)
PORT_BIT( 0x800, IP_ACTIVE_HIGH, IPT_OUTPUT)
PORT_BIT( 0x1000, IP_ACTIVE_HIGH, IPT_OUTPUT)


I define an element for each menu button, from menu0 to menu21:

If I don't define a state option, it gets a state="0" by default and when I click on it it disappears.

Code
         <element name="menu0">
	  <rect>
	         <bounds x="0" y="0" width="1" height="1"/><color red="1.0" green="0.88" blue="0.42" alpha="1.0"/>
	    </rect>
	    <text string="RESET">
	         <bounds x="0" y=".37" width="1.0" height=".25"/><color red="0.0" green="0.0" blue="0.0" alpha="1.0"/>
	    </text>
	 </element>

	<element name="menu1">
	   <rect state="0"><bounds x="0" y="0" width="1" height="1"/><color red="1.0" green="0.88" blue="0.42" alpha="1.0"/></rect>
	   <rect state="1"><bounds x="0" y="0" width="1" height="1"/><color red="1.0" green="0.88" blue="0.42" alpha="0.5"/></rect>
	  <text string="CLEAR"><bounds x="0" y=".37" width="1.0" height=".25"/><color red="0.0" green="0.0" blue="0.0" alpha="1.0"/></text>
	  <text state="1" string="CLEAR"><bounds x="0" y=".37" width="1.0" height=".25"/><color red="1.0" green="1.0" blue="1.0" alpha="1.0"/></text>
	 </element>

So I've got 22 buttons, and I use one bit of the port for each button.

Code
                       <repeat count="22">
			<param name="menunum" start="0" increment="1"/>
			<param name="xpos" start="0" increment="255"/>
			<param name="maskbits" start="1" lshift="1"/>
			<cpanel element="menu~menunum~" inputtag="sl2:agraphtablet:tablet_menu_buttons" inputmask="~maskbits~"><bounds y="0" x="~xpos~" width="245" height="245"/></cpanel>
			</repeat>
			

and then I check the button status and if nonzero, find out which button and use that to set the values returned to the x and y axis so the software thinks the pen is over the button.

Code
	    if (m_tablet_menu_buttons->read())
		{
		int buttonstate=m_tablet_menu_buttons->read();
		for(int i=0;i<22;i++)
		    if (buttonstate & (1<<i))
			m_timervalue = (m_tabletmax-m_tabletmin)/255.0*(i*250.0/22+(250.0/22/2))+m_tabletmin;   // multiply by 250/22  and then offset by half of 250/22 so it's in the middle.
		}

and I can draw like it's 1980! (The graphics tablet software isn't quite DeluxePaint. 8-)

Anybody know where to find the Utopia Graphics System (mentioned at http://www.edibleapple.com/2009/11/23/the-first-apple-tablet-from-1979/ )

[Linked Image from i.imgur.com]