Skip to content

Commit

Permalink
Start of plugin-target docs
Browse files Browse the repository at this point in the history
  • Loading branch information
ollydev committed Oct 11, 2023
1 parent b675687 commit ccaa8b6
Show file tree
Hide file tree
Showing 3 changed files with 77 additions and 3 deletions.
3 changes: 2 additions & 1 deletion DocGen/source/tutorials/plugins/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ Plugins
:maxdepth: 2

writing-plugins.rst
plugin-cpp.rst
plugin-cpp.rst
plugin-target.rst
7 changes: 5 additions & 2 deletions DocGen/source/tutorials/plugins/plugin-cpp.rst
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,11 @@ main.h
void (*ExternalImage_Lock)(void* img);
void (*ExternalImage_UnLock)(void* img);

void (*ExternalImage_AddCallbackOnUnlock)(void* img, void(*callback)(void*));
void (*ExternalImage_RemoveCallbackOnUnlock)(void* img, void(*callback)(void*));
void (*ExternalImage_AddCallbackOnUnlock)(void* img, void(*callback)(void*)(void*));
void (*ExternalImage_RemoveCallbackOnUnlock)(void* img, void(*callback)(void*)(void*));

void (*ExternalImage_SetUserData)(void* img, void* USerData);
void* (*ExternalImage_GetUserData)(void* img);
};

TSimbaInfo* SIMBA_INFO = {0};
Expand Down
70 changes: 70 additions & 0 deletions DocGen/source/tutorials/plugins/plugin-target.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
#############
Plugin Target
#############

A plugin can also provide a target for a script.

.. code-block::
Target.SetPlugin('myplugin.dll', 'someargs')
Will load :code:`myplugin.dll` expecting these exports:

.. code-block::
SimbaPluginTarget_Request: function(Args: PChar): Pointer; cdecl;
SimbaPluginTarget_RequestWithDebugImage: function(Args: PChar; out DebugImage: TSimbaExternalImage): Pointer; cdecl;
SimbaPluginTarget_Release: procedure(Target: Pointer); cdecl;
SimbaPluginTarget_GetDimensions: procedure(Target: Pointer; out W, H: Int32); cdecl;
SimbaPluginTarget_GetImageData: function(Target: Pointer; X, Y, Width, Height: Int32; var Data: PColorBGRA; var DataWidth: Int32): Boolean; cdecl;
SimbaPluginTarget_MousePressed: function(Target: Pointer; Button: Int32): Boolean; cdecl;
SimbaPluginTarget_MousePosition: function(Target: Pointer): TPoint; cdecl;
SimbaPluginTarget_MouseTeleport: procedure(Target: Pointer; P: TPoint); cdecl;
SimbaPluginTarget_MouseUp: procedure(Target: Pointer; Button: Int32); cdecl;
SimbaPluginTarget_MouseDown: procedure(Target: Pointer; Button: Int32); cdecl;
SimbaPluginTarget_MouseScroll: procedure(Target: Pointer; Scrolls: Int32); cdecl;
SimbaPluginTarget_KeyDown: procedure(Target: Pointer; Key: Int32); cdecl;
SimbaPluginTarget_KeyUp: procedure(Target: Pointer; Key: Int32); cdecl;
SimbaPluginTarget_KeySend: procedure(Target: Pointer; Text: PChar; TextLen: Int32; SleepTimes: PInt32); cdecl;
SimbaPluginTarget_KeyPressed: function(Target: Pointer; Key: Int32): Boolean; cdecl;
-----

KeySend
-------

The plugins KeySend is responsible for holding down modifiers (such as shift).

:code:`SleepTimes` is a Int32 array which is graciously overallocated :code:`(TextLen*5)` of sleep times which should be performed after every keydown/keyrelease which is used to control the speed of typing.

Something like:

.. code-block::
procedure SimbaPluginTarget_KeySend(Text: PChar; TextLen: Integer; SleepTimes: PInt32);
procedure DoSleep;
begin
PreciseSleep(SleepTimes^);
Inc(SleepTimes);
end;
var
I: Integer;
begin
for I := 0 to TextLen - 1 do
begin
PressTheKey();
DoSleep();
ReleaseTheKey();
DoSleep();
end;
end;
.. note::

A high resolution :code:`Sleep` is preferred if possible.

0 comments on commit ccaa8b6

Please sign in to comment.