I wanted to see if I could control the ioports for the joystick and after much fiddling and adding some code to luaengine and ioports.h and ioports.cpp I think I've got it.

Yes, it's a bit of a hack, but it's pretty useful to be able to precisely control an anlog input.

So now I can draw spirals with the graphics tablet:

Code
function spiral()
for i=16384,16384+8192-1 do manager:machine().devices[":maincpu"].spaces["program"]:write_u8(i,0) end
for i=0,256*16,1 do 
x=math.cos(i/256.0*math.pi*2.0)*i/256.0*8.0*1024
y=math.sin(i/256.0*math.pi*2.0)*i/256.0*8.0*1024
ioports=manager:machine():ioport().ports ioports[":sl2:agraphtablet:joystick_3_x"].fields["P3 Joystick X"].live:set_analog_value(math.floor(x),math.floor(x),0)
ioports=manager:machine():ioport().ports ioports[":sl2:agraphtablet:joystick_3_y"].fields["P3 Joystick Y"].live:set_analog_value(math.floor(y),math.floor(y),0)
print (i,x,y,ioports[":sl2:agraphtablet:joystick_3_x"]:read(),ioports[":sl2:agraphtablet:joystick_3_y"]:read())
emu.wait(1/60+.001) 
print (i,x,y,ioports[":sl2:agraphtablet:joystick_3_x"]:read(),ioports[":sl2:agraphtablet:joystick_3_y"]:read())
end 
end
co1=coroutine.create(spiral) ok,err=coroutine.resume(co1) print(ok,err)


I wrote a function set_analog_value that just stuffs values into m_accum and m_previousvalue for the live ioport analog member. m_previousanalog doesn't seem to have any effect.

Code
       // live analog value tracking
        s32                 m_accum;                // accumulated value (including relative adjustments)
        s32                 m_previous;             // previous adjusted value
        s32                 m_previousanalog;       // previous analog value

In ioport.h

Code
struct ioport_field_live
{
        // construction/destruction
        ioport_field_live(ioport_field &field, analog_field *analog);

        void set_value(ioport_value newvalue) {value = newvalue;};
        void set_analog_value(s32 newaccumvalue, s32 newpreviousvalue, s32 newpreviousanalogvalue);



In ioport.cpp

Code
void ioport_field_live::set_analog_value(s32 newaccumvalue, s32 newpreviousvalue, s32 newpreviousanalogvalue)
   {analog->set_accum(newaccumvalue); analog->set_previous(newpreviousvalue); analog->set_previousanalog(newpreviousanalogvalue);}

Just added set_accum, set_previous and set_previousanalog to class analog field:

Code
// ======================> analog_field

// live analog field information
class analog_field
{
        friend class simple_list<analog_field>;
        friend class ioport_manager;
        friend void ioport_field::set_user_settings(const ioport_field::user_settings &settings);

public:
        // construction/destruction
        analog_field(ioport_field &field);

        // getters
        analog_field *next() const { return m_next; }
        ioport_manager &manager() const { return m_field.manager(); }
        ioport_field &field() const { return m_field; }
        s32 sensitivity() const { return m_sensitivity; }
        bool reverse() const { return m_reverse; }
        s32 delta() const { return m_delta; }
        s32 centerdelta() const { return m_centerdelta; }

        // readers
        void read(ioport_value &value);
        float crosshair_read();
        void frame_update(running_machine &machine);

        void set_accum(s32 newvalue){m_accum=newvalue;};
        void set_previous(s32 newvalue){m_previous=newvalue;};
        void set_previousanalog(s32 newvalue){m_previousanalog=newvalue;};


In luaengine.cpp

Code
/* field.live
 */

	sol().registry().new_usertype<ioport_field_live>("ioport_field_live", "new", sol::no_constructor,
                        "set_value", &ioport_field_live::set_value,
                        "set_analog_value", &ioport_field_live::set_analog_value,		
			"name", &ioport_field_live::name,
                        "value", &ioport_field_live::value);

It kinda looks like a fingerprint.


[Linked Image from i.imgur.com]