library sample_plugin;

uses
  Windows,
  bspplg in '..\..\bspplg.pas',
  bsp in '..\..\..\bsp.pas';

var pInfo:PpluginInfo;


procedure Config(const winh:HWND);
begin
  Messagebox(winh,'Configuration','Info',0);
end;

function HandleKeyPress(const key:integer;const other:integer):integer;
begin
 Result:=0; 
 if Key=VK_SPACE then
 begin
  MessageBox(pInfo.hwndParent,'Space key was pressed','Info',0);
  Result:=1;//Cancel default key processing
 end else
 if (Key=VK_F1) and (other and keyShift=keyShift) and (other and keyControl=keyControl) then
 begin
  MessageBox(pInfo.hwndParent,'Shift+Control+F1 was pressed','Info',0);
 end else
 if (Key=VK_F1) and (other and keyShift=keyShift) then
 begin
  MessageBox(pInfo.hwndParent,'Shift+F1 was pressed','Info',0);
 end;
end;

function CallbackProc(const cmdID:DWORD;param1,param2:pointer):integer;stdcall;
begin
  Result:=0;//v2.11+, must return 0
  case cmdID of
    EV_UNLOAD:Messagebox(pInfo.hwndParent,'Plugin is unloading','Info',0);
    EV_PLAY:pInfo.ShowOSDText('Hello from plugin',4000,50000);
    EV_CONFIG:Config(HWND(param1));
    EV_ABOUT:Messagebox(HWND(param1),'Sample plugin v 0.2','About',0);
    EV_KEY_PRESS:Result:=HandleKeyPress(integer(param1),integer(param2));
  end;
end;

function pluginInit(plgInfo: PpluginInfo): BOOL; stdcall;
begin
  plgInfo.description:='Sample plugin';
  plgInfo.plgCallback:=CallbackProc;
  pInfo:=plgInfo;
  Messagebox(plgInfo.hwndParent,'Plugin init','Info',0);

  result:=true;
end;

//v2.11+
function pluginVersion():integer; stdcall;
begin
 Result:=BSP_PLUGIN_VER;
end;

exports pluginInit,
        pluginVersion;

begin
end.
 