mirror of
https://github.com/moparisthebest/Simba
synced 2024-11-26 03:02:15 -05:00
Ben, either get rid of those run parameters in your compiler options or stop commiting project1.lpi please ^_^.
Added a copydata parameter to TRawTarget.create. (This now fixes a memory leak in Unfreeze). Also please get rid of those two extra spaces in front of everything, so anti-pascal-syntax ^^. Also fixed the bug in IsTargetValid. git-svn-id: http://www.villavu.com/repositories/merlijn/mufasa@452 3f818213-9676-44b0-a9b4-5e4c4e03d09d
This commit is contained in:
parent
3d4131af95
commit
2b8721e6b0
@ -65,7 +65,7 @@ interface
|
|||||||
| Currently this uses the pointer as-is, but it might be needed to make a local copy... }
|
| Currently this uses the pointer as-is, but it might be needed to make a local copy... }
|
||||||
TRawTarget = class(TTarget)
|
TRawTarget = class(TTarget)
|
||||||
public
|
public
|
||||||
constructor Create(rgb: prgb32; w,h: integer);
|
constructor Create(rgb: prgb32; w,h: integer; CopyData : boolean);
|
||||||
destructor Destroy; override;
|
destructor Destroy; override;
|
||||||
|
|
||||||
procedure GetTargetDimensions(var w, h: integer); override;
|
procedure GetTargetDimensions(var w, h: integer); override;
|
||||||
@ -73,6 +73,7 @@ interface
|
|||||||
|
|
||||||
private
|
private
|
||||||
rgb: prgb32;
|
rgb: prgb32;
|
||||||
|
freedata : boolean;
|
||||||
w,h: integer;
|
w,h: integer;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -246,387 +247,394 @@ implementation
|
|||||||
|
|
||||||
//***implementation*** TIOManager
|
//***implementation*** TIOManager
|
||||||
|
|
||||||
constructor TIOManager_Abstract.Create(plugin_dir: string);
|
constructor TIOManager_Abstract.Create(plugin_dir: string);
|
||||||
|
begin
|
||||||
|
inherited Create;
|
||||||
|
eios_controller.AddAndLoadPath(plugin_dir);
|
||||||
|
keymouse:= nil;
|
||||||
|
image:= nil;
|
||||||
|
frozen:= nil;
|
||||||
|
NativeInit;
|
||||||
|
SetDesktop;
|
||||||
|
{
|
||||||
|
self.create;
|
||||||
|
eios_controller.AddAndLoadPath(plugin_dir);
|
||||||
|
}
|
||||||
|
end;
|
||||||
|
|
||||||
|
constructor TIOManager_Abstract.Create;
|
||||||
|
begin
|
||||||
|
inherited Create;
|
||||||
|
keymouse:= nil;
|
||||||
|
image:= nil;
|
||||||
|
frozen:= nil;
|
||||||
|
NativeInit;
|
||||||
|
SetDesktop;
|
||||||
|
end;
|
||||||
|
|
||||||
|
destructor TIOManager_Abstract.Destroy;
|
||||||
|
begin
|
||||||
|
if bothsame then keymouse.Destroy() else
|
||||||
begin
|
begin
|
||||||
inherited Create;
|
keymouse.Free();
|
||||||
eios_controller.AddAndLoadPath(plugin_dir);
|
image.Free();
|
||||||
keymouse:= nil;
|
end;
|
||||||
image:= nil;
|
if IsFrozen then frozen.Destroy();
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TIOManager_Abstract.SetImageTarget(target: TTarget);
|
||||||
|
begin
|
||||||
|
if IsFrozen then
|
||||||
|
raise Exception.Create('You cannot set a target when Frozen');
|
||||||
|
if not(bothsame) then image.Free();
|
||||||
|
image:= target;
|
||||||
|
bothsame:= false;
|
||||||
|
end;
|
||||||
|
procedure TIOManager_Abstract.SetKeyMouseTarget(target: TTarget);
|
||||||
|
begin
|
||||||
|
if not(bothsame) then keymouse.Free();
|
||||||
|
keymouse:= target;
|
||||||
|
bothsame:= false;
|
||||||
|
end;
|
||||||
|
procedure TIOManager_Abstract.SetBothTargets(target: TTarget);
|
||||||
|
begin
|
||||||
|
if IsFrozen then
|
||||||
|
raise Exception.Create('You cannot set a target when Frozen');
|
||||||
|
if bothsame then image.Destroy() else
|
||||||
|
begin
|
||||||
|
image.Free();
|
||||||
|
keymouse.Free();
|
||||||
|
end;
|
||||||
|
image:= target;
|
||||||
|
keymouse:= target;
|
||||||
|
bothsame:= true;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TIOManager_Abstract.SetFrozen(makefrozen: boolean);
|
||||||
|
var
|
||||||
|
w,h: integer;
|
||||||
|
buffer: TRetData;
|
||||||
|
begin
|
||||||
|
if (makefrozen) and (IsFrozen) then
|
||||||
|
raise Exception.Create('The window is already frozen.');
|
||||||
|
//BenLand100 edit: I say we leave this exception out. POLS
|
||||||
|
//if not(isfrozen) and (frozen = nil) then
|
||||||
|
// raise Exception.Create('The window is not frozen.');
|
||||||
|
if makefrozen then //No need for the Frozen = nil check, already done above with the exception.
|
||||||
|
begin
|
||||||
|
frozen:= image;
|
||||||
|
frozen.GetTargetDimensions(w,h);
|
||||||
|
buffer:= frozen.ReturnData(0,0,w,h);
|
||||||
|
image:= TRawTarget.Create(buffer.Ptr,w,h,true);
|
||||||
|
frozen.FreeReturnData;
|
||||||
|
end else
|
||||||
|
begin
|
||||||
|
image.Free();
|
||||||
|
image:= frozen;
|
||||||
frozen:= nil;
|
frozen:= nil;
|
||||||
NativeInit;
|
|
||||||
SetDesktop;
|
|
||||||
end;
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
constructor TIOManager_Abstract.Create;
|
function TIOManager_Abstract.IsFrozen: boolean;
|
||||||
begin
|
begin
|
||||||
inherited Create;
|
result:= frozen <> nil;
|
||||||
keymouse:= nil;
|
end;
|
||||||
image:= nil;
|
|
||||||
frozen:= nil;
|
|
||||||
NativeInit;
|
|
||||||
SetDesktop;
|
|
||||||
end;
|
|
||||||
|
|
||||||
destructor TIOManager_Abstract.Destroy;
|
function TIOManager_Abstract.GetColor(x,y : integer) : TColor; begin result:= image.GetColor(x,y); end;
|
||||||
begin
|
function TIOManager_Abstract.ReturnData(xs,ys,width,height: integer): TRetData; begin result:= image.ReturnData(xs,ys,width,height); end;
|
||||||
if bothsame then keymouse.Destroy() else
|
procedure TIOManager_Abstract.FreeReturnData; begin image.freeReturnData(); end;
|
||||||
begin
|
|
||||||
keymouse.Free();
|
|
||||||
image.Free();
|
|
||||||
end;
|
|
||||||
if frozen <> nil then frozen.Destroy();
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure TIOManager_Abstract.SetImageTarget(target: TTarget);
|
function TIOManager_Abstract.SetTarget(ArrPtr: PRGB32; Size: TPoint): integer; begin SetImageTarget(TRawTarget.Create(ArrPtr,Size.X,Size.Y,false)); end;
|
||||||
begin
|
function TIOManager_Abstract.SetTarget(bmp : TMufasaBitmap) : integer; begin SetImageTarget(TRawTarget.Create(bmp.FData,bmp.width,bmp.height,false)); end;
|
||||||
if frozen <> nil then
|
function TIOManager_Abstract.SetTarget(name: string; initargs: pointer): integer;
|
||||||
raise Exception.Create('You cannot set a target when Frozen');
|
var
|
||||||
if not(bothsame) then image.Free();
|
client: TEIOS_Client;
|
||||||
image:= target;
|
begin
|
||||||
bothsame:= false;
|
if not eios_controller.ClientExists(name) then raise Exception.Create('EIOS Client by specified name does not exist');
|
||||||
end;
|
client:= eios_controller.GetClient(name);
|
||||||
procedure TIOManager_Abstract.SetKeyMouseTarget(target: TTarget);
|
SetBothTargets(TEIOS_Target.Create(client, initargs));
|
||||||
begin
|
end;
|
||||||
if not(bothsame) then keymouse.Free();
|
|
||||||
keymouse:= target;
|
|
||||||
bothsame:= false;
|
|
||||||
end;
|
|
||||||
procedure TIOManager_Abstract.SetBothTargets(target: TTarget);
|
|
||||||
begin
|
|
||||||
if frozen <> nil then
|
|
||||||
raise Exception.Create('You cannot set a target when Frozen');
|
|
||||||
if bothsame then image.Destroy() else
|
|
||||||
begin
|
|
||||||
image.Free();
|
|
||||||
keymouse.Free();
|
|
||||||
end;
|
|
||||||
image:= target;
|
|
||||||
keymouse:= target;
|
|
||||||
bothsame:= true;
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure TIOManager_Abstract.SetFrozen(makefrozen: boolean);
|
function TIOManager_Abstract.TargetValid: Boolean;
|
||||||
var
|
begin
|
||||||
w,h: integer;
|
result:= false;
|
||||||
buffer: TRetData;
|
if (keymouse <> nil) and (image <> nil) then
|
||||||
begin
|
result := (keymouse.TargetValid and image.TargetValid);
|
||||||
if (makefrozen) and (frozen <> nil) then
|
end;
|
||||||
raise Exception.Create('The window is already frozen.');
|
|
||||||
//BenLand100 edit: I say we leave this exception out. POLS
|
|
||||||
//if not(isfrozen) and (frozen = nil) then
|
|
||||||
// raise Exception.Create('The window is not frozen.');
|
|
||||||
if not(makefrozen) then
|
|
||||||
begin
|
|
||||||
image.Free();
|
|
||||||
image:= frozen;
|
|
||||||
frozen:= nil;
|
|
||||||
end else if frozen = nil then
|
|
||||||
begin
|
|
||||||
frozen:= image;
|
|
||||||
frozen.GetTargetDimensions(w,h);
|
|
||||||
buffer:= frozen.ReturnData(0,0,w,h);
|
|
||||||
GetMem(freezebuffer, w * h * sizeof(TRGB32));
|
|
||||||
Move(buffer.Ptr[0], freezebuffer[0], w*h*sizeof(TRGB32));
|
|
||||||
frozen.FreeReturnData;
|
|
||||||
image:= TRawTarget.Create(freezebuffer,w,h);
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
|
|
||||||
function TIOManager_Abstract.IsFrozen: boolean;
|
procedure TIOManager_Abstract.GetDimensions(var W, H: Integer); begin image.GetTargetDimensions(w,h) end;
|
||||||
begin
|
procedure TIOManager_Abstract.ActivateClient; begin {lolwat} end;
|
||||||
result:= frozen <> nil;
|
|
||||||
end;
|
|
||||||
|
|
||||||
function TIOManager_Abstract.GetColor(x,y : integer) : TColor; begin result:= image.GetColor(x,y); end;
|
procedure TIOManager_Abstract.GetMousePos(var X, Y: Integer); begin keymouse.GetMousePosition(x,y) end;
|
||||||
function TIOManager_Abstract.ReturnData(xs,ys,width,height: integer): TRetData; begin result:= image.ReturnData(xs,ys,width,height); end;
|
procedure TIOManager_Abstract.SetMousePos(X, Y: Integer); begin keymouse.MoveMouse(x,y); end;
|
||||||
procedure TIOManager_Abstract.FreeReturnData; begin image.freeReturnData(); end;
|
procedure TIOManager_Abstract.HoldMouse(x,y : integer; button: TClickType); begin keymouse.ReleaseMouse(x,y,button); end;
|
||||||
|
procedure TIOManager_Abstract.ReleaseMouse(x,y : integer; button: TClickType); begin keymouse.ReleaseMouse(x,y,button); end;
|
||||||
|
procedure TIOManager_Abstract.ClickMouse(X, Y: Integer; button: TClickType);
|
||||||
|
begin
|
||||||
|
HoldMouse(x,y,button);
|
||||||
|
//BenLand100 note: probably should wait here
|
||||||
|
ReleaseMouse(x,y,button);
|
||||||
|
end;
|
||||||
|
|
||||||
function TIOManager_Abstract.SetTarget(ArrPtr: PRGB32; Size: TPoint): integer; begin SetImageTarget(TRawTarget.Create(ArrPtr,Size.X,Size.Y)); end;
|
procedure TIOManager_Abstract.KeyUp(key: Word); begin keymouse.ReleaseKey(key) end;
|
||||||
function TIOManager_Abstract.SetTarget(bmp : TMufasaBitmap) : integer; begin SetImageTarget(TRawTarget.Create(bmp.FData,bmp.width,bmp.height)); end;
|
procedure TIOManager_Abstract.KeyDown(key: Word); begin keymouse.HoldKey(key) end;
|
||||||
function TIOManager_Abstract.SetTarget(name: string; initargs: pointer): integer;
|
procedure TIOManager_Abstract.PressKey(key: Word); begin keyup(key); keydown(key); end;
|
||||||
var
|
procedure TIOManager_Abstract.SendText(text: string); begin keymouse.SendString(text); end;
|
||||||
client: TEIOS_Client;
|
function TIOManager_Abstract.isKeyDown(key: Word): Boolean; begin result:= keymouse.IsKeyHeld(key); end;
|
||||||
begin
|
|
||||||
if not eios_controller.ClientExists(name) then raise Exception.Create('EIOS Client by specified name does not exist');
|
|
||||||
client:= eios_controller.GetClient(name);
|
|
||||||
SetBothTargets(TEIOS_Target.Create(client, initargs));
|
|
||||||
end;
|
|
||||||
|
|
||||||
function TIOManager_Abstract.TargetValid: Boolean;
|
|
||||||
begin
|
|
||||||
result:= false;
|
|
||||||
if (keymouse <> nil) and (image <> nil) then
|
|
||||||
begin
|
|
||||||
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure TIOManager_Abstract.GetDimensions(var W, H: Integer); begin image.GetTargetDimensions(w,h) end;
|
|
||||||
procedure TIOManager_Abstract.ActivateClient; begin {lolwat} end;
|
|
||||||
|
|
||||||
procedure TIOManager_Abstract.GetMousePos(var X, Y: Integer); begin keymouse.GetMousePosition(x,y) end;
|
|
||||||
procedure TIOManager_Abstract.SetMousePos(X, Y: Integer); begin keymouse.MoveMouse(x,y); end;
|
|
||||||
procedure TIOManager_Abstract.HoldMouse(x,y : integer; button: TClickType); begin keymouse.ReleaseMouse(x,y,button); end;
|
|
||||||
procedure TIOManager_Abstract.ReleaseMouse(x,y : integer; button: TClickType); begin keymouse.ReleaseMouse(x,y,button); end;
|
|
||||||
procedure TIOManager_Abstract.ClickMouse(X, Y: Integer; button: TClickType);
|
|
||||||
begin
|
|
||||||
HoldMouse(x,y,button);
|
|
||||||
//BenLand100 note: probably should wait here
|
|
||||||
ReleaseMouse(x,y,button);
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure TIOManager_Abstract.KeyUp(key: Word); begin keymouse.ReleaseKey(key) end;
|
|
||||||
procedure TIOManager_Abstract.KeyDown(key: Word); begin keymouse.HoldKey(key) end;
|
|
||||||
procedure TIOManager_Abstract.PressKey(key: Word); begin keyup(key); keydown(key); end;
|
|
||||||
procedure TIOManager_Abstract.SendText(text: string); begin keymouse.SendString(text); end;
|
|
||||||
function TIOManager_Abstract.isKeyDown(key: Word): Boolean; begin result:= keymouse.IsKeyHeld(key); end;
|
|
||||||
|
|
||||||
//***implementation*** TTarget
|
//***implementation*** TTarget
|
||||||
|
|
||||||
procedure TTarget.GetTargetDimensions(var w, h: integer); begin raise Exception.Create('GetTargetDimensions not avaliable for this target'); end;
|
procedure TTarget.GetTargetDimensions(var w, h: integer); begin raise Exception.Create('GetTargetDimensions not avaliable for this target'); end;
|
||||||
function TTarget.GetColor(x,y : integer) : TColor;
|
function TTarget.GetColor(x,y : integer) : TColor;
|
||||||
begin
|
begin
|
||||||
with ReturnData(x,y,1,1) do
|
with ReturnData(x,y,1,1) do
|
||||||
Result := RGBToColor(Ptr[0].r,Ptr[0].g,Ptr[0].b);
|
Result := RGBToColor(Ptr[0].r,Ptr[0].g,Ptr[0].b);
|
||||||
FreeReturnData;
|
FreeReturnData;
|
||||||
end;
|
end;
|
||||||
function TTarget.ReturnData(xs, ys, width, height: Integer): TRetData; begin raise Exception.Create('ReturnData not avaliable for this target'); end;
|
function TTarget.ReturnData(xs, ys, width, height: Integer): TRetData; begin raise Exception.Create('ReturnData not avaliable for this target'); end;
|
||||||
procedure TTarget.FreeReturnData; begin {do nothing by default} end;
|
procedure TTarget.FreeReturnData; begin {do nothing by default} end;
|
||||||
procedure TTarget.ActivateClient; begin raise Exception.Create('ActivateClient not avaliable for this target'); end;
|
procedure TTarget.ActivateClient; begin raise Exception.Create('ActivateClient not avaliable for this target'); end;
|
||||||
function TTarget.TargetValid: boolean; begin result:= true; end;
|
function TTarget.TargetValid: boolean; begin result:= true; end;
|
||||||
|
|
||||||
procedure TTarget.GetMousePosition(var x,y: integer); begin raise Exception.Create('GetMousePosition not avaliable for this target'); end;
|
procedure TTarget.GetMousePosition(var x,y: integer); begin raise Exception.Create('GetMousePosition not avaliable for this target'); end;
|
||||||
procedure TTarget.MoveMouse(x,y: integer); begin raise Exception.Create('MoveMouse not avaliable for this target'); end;
|
procedure TTarget.MoveMouse(x,y: integer); begin raise Exception.Create('MoveMouse not avaliable for this target'); end;
|
||||||
procedure TTarget.HoldMouse(x,y: integer; button: TClickType); begin raise Exception.Create('HoldMouse not avaliable for this target'); end;
|
procedure TTarget.HoldMouse(x,y: integer; button: TClickType); begin raise Exception.Create('HoldMouse not avaliable for this target'); end;
|
||||||
procedure TTarget.ReleaseMouse(x,y: integer; button: TClickType); begin raise Exception.Create('ReleaseMouse not avaliable for this target'); end;
|
procedure TTarget.ReleaseMouse(x,y: integer; button: TClickType); begin raise Exception.Create('ReleaseMouse not avaliable for this target'); end;
|
||||||
|
|
||||||
procedure TTarget.SendString(str: string); begin raise Exception.Create('SendString not avaliable for this target'); end;
|
procedure TTarget.SendString(str: string); begin raise Exception.Create('SendString not avaliable for this target'); end;
|
||||||
procedure TTarget.HoldKey(key: integer); begin raise Exception.Create('HoldKey not avaliable for this target'); end;
|
procedure TTarget.HoldKey(key: integer); begin raise Exception.Create('HoldKey not avaliable for this target'); end;
|
||||||
procedure TTarget.ReleaseKey(key: integer); begin raise Exception.Create('ReleaseKey not avaliable for this target'); end;
|
procedure TTarget.ReleaseKey(key: integer); begin raise Exception.Create('ReleaseKey not avaliable for this target'); end;
|
||||||
function TTarget.IsKeyHeld(key: integer): boolean; begin raise Exception.Create('IsKeyHeld not avaliable for this target'); end;
|
function TTarget.IsKeyHeld(key: integer): boolean; begin raise Exception.Create('IsKeyHeld not avaliable for this target'); end;
|
||||||
|
|
||||||
//***implementation*** TEIOS_Target
|
//***implementation*** TEIOS_Target
|
||||||
|
|
||||||
constructor TEIOS_Target.Create(client: TEIOS_Client; initval: pointer); begin
|
constructor TEIOS_Target.Create(client: TEIOS_Client; initval: pointer); begin
|
||||||
inherited Create;
|
inherited Create;
|
||||||
self.client:= client;
|
self.client:= client;
|
||||||
if Pointer(client.RequestTarget) <> nil then
|
if Pointer(client.RequestTarget) <> nil then
|
||||||
self.target:= client.RequestTarget(initval);
|
self.target:= client.RequestTarget(initval);
|
||||||
if Pointer(client.GetImageBuffer) <> nil then
|
if Pointer(client.GetImageBuffer) <> nil then
|
||||||
self.buffer:= client.GetImageBuffer(target)
|
self.buffer:= client.GetImageBuffer(target)
|
||||||
else
|
else
|
||||||
self.buffer:= nil;
|
self.buffer:= nil;
|
||||||
GetTargetDimensions(self.width,self.height);
|
GetTargetDimensions(self.width,self.height);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
destructor TEIOS_Target.Destroy; begin
|
destructor TEIOS_Target.Destroy; begin
|
||||||
client.ReleaseTarget(self.target);
|
client.ReleaseTarget(self.target);
|
||||||
inherited Destroy;
|
inherited Destroy;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TEIOS_Target.GetTargetDimensions(var w, h: integer);
|
procedure TEIOS_Target.GetTargetDimensions(var w, h: integer);
|
||||||
begin
|
begin
|
||||||
if Pointer(client.GetTargetDimensions) <> nil then
|
if Pointer(client.GetTargetDimensions) <> nil then
|
||||||
client.GetTargetDimensions(target,w,h)
|
client.GetTargetDimensions(target,w,h)
|
||||||
else
|
else
|
||||||
inherited GetTargetDimensions(w,h);
|
inherited GetTargetDimensions(w,h);
|
||||||
|
end;
|
||||||
|
function TEIOS_Target.ReturnData(xs, ys, width, height: Integer): TRetData;
|
||||||
|
begin
|
||||||
|
if Pointer(client.UpdateImageBufferBounds) <> nil then
|
||||||
|
client.UpdateImageBufferBounds(target,xs,ys,xs+width,ys+height)
|
||||||
|
else if Pointer(client.UpdateImageBuffer) <> nil then
|
||||||
|
client.UpdateImageBuffer(target)
|
||||||
|
else begin
|
||||||
|
{no update command exported}
|
||||||
end;
|
end;
|
||||||
function TEIOS_Target.ReturnData(xs, ys, width, height: Integer): TRetData;
|
result.Ptr := buffer;
|
||||||
|
result.RowLen:= self.width;
|
||||||
|
result.IncPtrWith:= result.RowLen - width;
|
||||||
|
Inc(result.Ptr, ys * result.RowLen + xs);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TEIOS_Target.GetMousePosition(var x,y: integer);
|
||||||
|
begin
|
||||||
|
if Pointer(client.GetMousePosition) <> nil then
|
||||||
|
client.GetMousePosition(target,x,y)
|
||||||
|
else
|
||||||
|
inherited GetMousePosition(x,y);
|
||||||
|
end;
|
||||||
|
procedure TEIOS_Target.MoveMouse(x,y: integer);
|
||||||
|
begin
|
||||||
|
if Pointer(client.MoveMouse) <> nil then
|
||||||
|
client.MoveMouse(target,x,y)
|
||||||
|
else
|
||||||
|
inherited MoveMouse(x,y);
|
||||||
|
end;
|
||||||
|
procedure TEIOS_Target.HoldMouse(x,y: integer; button: TClickType);
|
||||||
|
begin
|
||||||
|
if Pointer(client.HoldMouse) <> nil then
|
||||||
begin
|
begin
|
||||||
if Pointer(client.UpdateImageBufferBounds) <> nil then
|
case button of
|
||||||
client.UpdateImageBufferBounds(target,xs,ys,xs+width,ys+height)
|
mouse_Left: client.HoldMouse(target,x,y,true);
|
||||||
else if Pointer(client.UpdateImageBuffer) <> nil then
|
mouse_Middle: raise Exception.Create('EIOS does not implement the middle mouse button.');
|
||||||
client.UpdateImageBuffer(target)
|
mouse_Right: client.HoldMouse(target,x,y,false);
|
||||||
else begin
|
|
||||||
{no update command exported}
|
|
||||||
end;
|
end;
|
||||||
result.Ptr := buffer;
|
end else
|
||||||
result.RowLen:= self.width;
|
inherited HoldMouse(x,y,button);
|
||||||
result.IncPtrWith:= result.RowLen - width;
|
end;
|
||||||
Inc(result.Ptr, ys * result.RowLen + xs);
|
procedure TEIOS_Target.ReleaseMouse(x,y: integer; button: TClickType);
|
||||||
end;
|
begin
|
||||||
|
if Pointer(client.ReleaseMouse) <> nil then
|
||||||
|
begin
|
||||||
|
case button of
|
||||||
|
mouse_Left: client.ReleaseMouse(target,x,y,true);
|
||||||
|
mouse_Middle: raise Exception.Create('EIOS does not implement the middle mouse button.');
|
||||||
|
mouse_Right: client.ReleaseMouse(target,x,y,false);
|
||||||
|
end;
|
||||||
|
end else
|
||||||
|
inherited ReleaseMouse(x,y,button);
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TEIOS_Target.GetMousePosition(var x,y: integer);
|
procedure TEIOS_Target.SendString(str: string);
|
||||||
begin
|
begin
|
||||||
if Pointer(client.GetMousePosition) <> nil then
|
if Pointer(client.SendString) <> nil then
|
||||||
client.GetMousePosition(target,x,y)
|
client.SendString(target,PChar(str))
|
||||||
else
|
else
|
||||||
inherited GetMousePosition(x,y);
|
inherited SendString(str);
|
||||||
end;
|
end;
|
||||||
procedure TEIOS_Target.MoveMouse(x,y: integer);
|
procedure TEIOS_Target.HoldKey(key: integer);
|
||||||
begin
|
begin
|
||||||
if Pointer(client.MoveMouse) <> nil then
|
if Pointer(client.HoldKey) <> nil then
|
||||||
client.MoveMouse(target,x,y)
|
client.HoldKey(target,key)
|
||||||
else
|
else
|
||||||
inherited MoveMouse(x,y);
|
inherited HoldKey(key);
|
||||||
end;
|
end;
|
||||||
procedure TEIOS_Target.HoldMouse(x,y: integer; button: TClickType);
|
procedure TEIOS_Target.ReleaseKey(key: integer);
|
||||||
begin
|
begin
|
||||||
if Pointer(client.HoldMouse) <> nil then
|
if Pointer(client.ReleaseKey) <> nil then
|
||||||
begin
|
client.ReleaseKey(target,key)
|
||||||
case button of
|
else
|
||||||
mouse_Left: client.HoldMouse(target,x,y,true);
|
inherited ReleaseKey(key);
|
||||||
mouse_Middle: raise Exception.Create('EIOS does not implement the middle mouse button.');
|
end;
|
||||||
mouse_Right: client.HoldMouse(target,x,y,false);
|
function TEIOS_Target.IsKeyHeld(key: integer): boolean;
|
||||||
end;
|
begin
|
||||||
end else
|
if Pointer(client.IsKeyHeld) <> nil then
|
||||||
inherited HoldMouse(x,y,button);
|
result:= client.IsKeyHeld(target,key)
|
||||||
end;
|
else
|
||||||
procedure TEIOS_Target.ReleaseMouse(x,y: integer; button: TClickType);
|
result:= inherited IsKeyHeld(key);
|
||||||
begin
|
end;
|
||||||
if Pointer(client.ReleaseMouse) <> nil then
|
|
||||||
begin
|
|
||||||
case button of
|
|
||||||
mouse_Left: client.ReleaseMouse(target,x,y,true);
|
|
||||||
mouse_Middle: raise Exception.Create('EIOS does not implement the middle mouse button.');
|
|
||||||
mouse_Right: client.ReleaseMouse(target,x,y,false);
|
|
||||||
end;
|
|
||||||
end else
|
|
||||||
inherited ReleaseMouse(x,y,button);
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure TEIOS_Target.SendString(str: string);
|
|
||||||
begin
|
|
||||||
if Pointer(client.SendString) <> nil then
|
|
||||||
client.SendString(target,PChar(str))
|
|
||||||
else
|
|
||||||
inherited SendString(str);
|
|
||||||
end;
|
|
||||||
procedure TEIOS_Target.HoldKey(key: integer);
|
|
||||||
begin
|
|
||||||
if Pointer(client.HoldKey) <> nil then
|
|
||||||
client.HoldKey(target,key)
|
|
||||||
else
|
|
||||||
inherited HoldKey(key);
|
|
||||||
end;
|
|
||||||
procedure TEIOS_Target.ReleaseKey(key: integer);
|
|
||||||
begin
|
|
||||||
if Pointer(client.ReleaseKey) <> nil then
|
|
||||||
client.ReleaseKey(target,key)
|
|
||||||
else
|
|
||||||
inherited ReleaseKey(key);
|
|
||||||
end;
|
|
||||||
function TEIOS_Target.IsKeyHeld(key: integer): boolean;
|
|
||||||
begin
|
|
||||||
if Pointer(client.IsKeyHeld) <> nil then
|
|
||||||
result:= client.IsKeyHeld(target,key)
|
|
||||||
else
|
|
||||||
result:= inherited IsKeyHeld(key);
|
|
||||||
end;
|
|
||||||
|
|
||||||
//***implementation*** TRawTarget
|
//***implementation*** TRawTarget
|
||||||
|
|
||||||
constructor TRawTarget.Create(rgb: prgb32; w,h: integer);
|
constructor TRawTarget.Create(rgb: prgb32; w,h: integer; CopyData : boolean);
|
||||||
|
begin
|
||||||
|
inherited Create;
|
||||||
|
self.w:= w;
|
||||||
|
self.h:= h;
|
||||||
|
self.freedata:= copydata;
|
||||||
|
if CopyData then
|
||||||
begin
|
begin
|
||||||
inherited Create;
|
GetMem(self.rgb,w*h*sizeof(TRGB32));
|
||||||
|
Move(rgb[0],self.rgb[0],w*h*sizeof(TRGB32));
|
||||||
|
end else
|
||||||
self.rgb:= rgb;
|
self.rgb:= rgb;
|
||||||
self.w:= w;
|
end;
|
||||||
self.h:= h;
|
|
||||||
end;
|
|
||||||
|
|
||||||
destructor TRawTarget.Destroy;
|
destructor TRawTarget.Destroy;
|
||||||
begin
|
begin
|
||||||
{do nothing}
|
if freedata then
|
||||||
inherited Destroy;
|
Freemem(self.rgb,w*h*sizeof(TRGB32));
|
||||||
end;
|
inherited Destroy;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TRawTarget.GetTargetDimensions(var w, h: integer);
|
procedure TRawTarget.GetTargetDimensions(var w, h: integer);
|
||||||
begin
|
begin
|
||||||
w:= self.w;
|
w:= self.w;
|
||||||
h:= self.h;
|
h:= self.h;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TRawTarget.ReturnData(xs, ys, width, height: Integer): TRetData;
|
function TRawTarget.ReturnData(xs, ys, width, height: Integer): TRetData;
|
||||||
begin
|
begin
|
||||||
result.Ptr := rgb;
|
result.Ptr := rgb;
|
||||||
result.RowLen:= self.w;
|
result.RowLen:= self.w;
|
||||||
result.IncPtrWith:= result.RowLen - width;
|
result.IncPtrWith:= result.RowLen - width;
|
||||||
Inc(result.Ptr, ys * result.RowLen + xs);
|
Inc(result.Ptr, ys * result.RowLen + xs);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
//***implementation*** TEIOS_Controller
|
//***implementation*** TEIOS_Controller
|
||||||
|
|
||||||
constructor TEIOS_Controller.Create();
|
constructor TEIOS_Controller.Create();
|
||||||
begin
|
begin
|
||||||
inherited Create;
|
inherited Create;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
destructor TEIOS_Controller.Destroy;
|
destructor TEIOS_Controller.Destroy;
|
||||||
var
|
var
|
||||||
i: integer;
|
i: integer;
|
||||||
begin
|
begin
|
||||||
SetLength(plugs,0);
|
SetLength(plugs,0);
|
||||||
inherited Destroy;
|
inherited Destroy;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TEIOS_Controller.InitPlugin(plugin: TLibHandle): boolean;
|
function TEIOS_Controller.InitPlugin(plugin: TLibHandle): boolean;
|
||||||
var
|
var
|
||||||
GetName: procedure(name: pchar); stdcall;
|
GetName: procedure(name: pchar); stdcall;
|
||||||
buffer: pchar;
|
buffer: pchar;
|
||||||
idx: integer;
|
idx: integer;
|
||||||
|
begin
|
||||||
|
Pointer(GetName) := GetProcAddress(plugin, PChar('EIOS_GetName'));
|
||||||
|
if Pointer(GetName) = nil then begin result:= false; exit; end;
|
||||||
|
idx:= Length(plugs);
|
||||||
|
SetLength(plugs,idx+1);
|
||||||
|
buffer:= stralloc(255);
|
||||||
|
GetName(buffer);
|
||||||
|
plugs[idx].name:= buffer;
|
||||||
|
strdispose(buffer);
|
||||||
|
{link in all eios methods that *might* exist}
|
||||||
|
with plugs[idx].client do
|
||||||
begin
|
begin
|
||||||
Pointer(GetName) := GetProcAddress(plugin, PChar('EIOS_GetName'));
|
Pointer(RequestTarget):= GetProcAddress(plugin, PChar('EIOS_RequestTarget'));
|
||||||
if Pointer(GetName) = nil then begin result:= false; exit; end;
|
Pointer(ReleaseTarget):= GetProcAddress(plugin, PChar('EIOS_ReleaseTarget'));
|
||||||
idx:= Length(plugs);
|
|
||||||
SetLength(plugs,idx+1);
|
Pointer(GetTargetDimensions):= GetProcAddress(plugin, PChar('EIOS_GetTargetDimensions'));
|
||||||
buffer:= stralloc(255);
|
Pointer(GetImageBuffer):= GetProcAddress(plugin, PChar('EIOS_GetImageBuffer'));
|
||||||
GetName(buffer);
|
Pointer(UpdateImageBuffer):= GetProcAddress(plugin, PChar('EIOS_UpdateImageBuffer'));
|
||||||
plugs[idx].name:= buffer;
|
Pointer(UpdateImageBufferBounds):= GetProcAddress(plugin, PChar('EIOS_UpdateImageBufferBounds'));
|
||||||
strdispose(buffer);
|
|
||||||
{link in all eios methods that *might* exist}
|
Pointer(GetMousePosition):= GetProcAddress(plugin, PChar('EIOS_GetMousePosition'));
|
||||||
with plugs[idx].client do
|
Pointer(MoveMouse):= GetProcAddress(plugin, PChar('EIOS_MoveMouse'));
|
||||||
|
Pointer(HoldMouse):= GetProcAddress(plugin, PChar('EIOS_HoldMouse'));
|
||||||
|
Pointer(ReleaseMouse):= GetProcAddress(plugin, PChar('EIOS_ReleaseMouse'));
|
||||||
|
|
||||||
|
Pointer(SendString):= GetProcAddress(plugin, PChar('EIOS_SendString'));
|
||||||
|
Pointer(HoldKey):= GetProcAddress(plugin, PChar('EIOS_HoldKey'));
|
||||||
|
Pointer(ReleaseKey):= GetProcAddress(plugin, PChar('EIOS_ReleaseKey'));
|
||||||
|
Pointer(IsKeyHeld):= GetProcAddress(plugin, PChar('EIOS_IsKeyHeld'));
|
||||||
|
end;
|
||||||
|
{done linking in methods}
|
||||||
|
result:= true;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TEIOS_Controller.FindClient(name: string): integer;
|
||||||
|
var
|
||||||
|
i: integer;
|
||||||
|
begin
|
||||||
|
for i:= 0 to length(plugs) - 1 do
|
||||||
|
if plugs[i].name = name then
|
||||||
begin
|
begin
|
||||||
Pointer(RequestTarget):= GetProcAddress(plugin, PChar('EIOS_RequestTarget'));
|
result:= i;
|
||||||
Pointer(ReleaseTarget):= GetProcAddress(plugin, PChar('EIOS_ReleaseTarget'));
|
exit;
|
||||||
|
|
||||||
Pointer(GetTargetDimensions):= GetProcAddress(plugin, PChar('EIOS_GetTargetDimensions'));
|
|
||||||
Pointer(GetImageBuffer):= GetProcAddress(plugin, PChar('EIOS_GetImageBuffer'));
|
|
||||||
Pointer(UpdateImageBuffer):= GetProcAddress(plugin, PChar('EIOS_UpdateImageBuffer'));
|
|
||||||
Pointer(UpdateImageBufferBounds):= GetProcAddress(plugin, PChar('EIOS_UpdateImageBufferBounds'));
|
|
||||||
|
|
||||||
Pointer(GetMousePosition):= GetProcAddress(plugin, PChar('EIOS_GetMousePosition'));
|
|
||||||
Pointer(MoveMouse):= GetProcAddress(plugin, PChar('EIOS_MoveMouse'));
|
|
||||||
Pointer(HoldMouse):= GetProcAddress(plugin, PChar('EIOS_HoldMouse'));
|
|
||||||
Pointer(ReleaseMouse):= GetProcAddress(plugin, PChar('EIOS_ReleaseMouse'));
|
|
||||||
|
|
||||||
Pointer(SendString):= GetProcAddress(plugin, PChar('EIOS_SendString'));
|
|
||||||
Pointer(HoldKey):= GetProcAddress(plugin, PChar('EIOS_HoldKey'));
|
|
||||||
Pointer(ReleaseKey):= GetProcAddress(plugin, PChar('EIOS_ReleaseKey'));
|
|
||||||
Pointer(IsKeyHeld):= GetProcAddress(plugin, PChar('EIOS_IsKeyHeld'));
|
|
||||||
end;
|
end;
|
||||||
{done linking in methods}
|
result:= -1;
|
||||||
result:= true;
|
end;
|
||||||
end;
|
|
||||||
|
|
||||||
function TEIOS_Controller.FindClient(name: string): integer;
|
function TEIOS_Controller.ClientExists(name: string): boolean;
|
||||||
var
|
begin
|
||||||
i: integer;
|
result:= FindClient(name) >= 0;
|
||||||
begin
|
end;
|
||||||
for i:= 0 to length(plugs) - 1 do
|
|
||||||
if plugs[i].name = name then
|
|
||||||
begin
|
|
||||||
result:= i;
|
|
||||||
exit;
|
|
||||||
end;
|
|
||||||
result:= -1;
|
|
||||||
end;
|
|
||||||
|
|
||||||
function TEIOS_Controller.ClientExists(name: string): boolean;
|
function TEIOS_Controller.GetClient(name: string): TEIOS_Client;
|
||||||
begin
|
var
|
||||||
result:= FindClient(name) >= 0;
|
i: integer;
|
||||||
end;
|
begin
|
||||||
|
i:= FindClient(name);
|
||||||
|
if i >= 0 then
|
||||||
|
result:= plugs[i].client
|
||||||
|
end;
|
||||||
|
|
||||||
function TEIOS_Controller.GetClient(name: string): TEIOS_Client;
|
initialization
|
||||||
var
|
eios_controller:= TEIOS_Controller.Create;
|
||||||
i: integer;
|
finalization
|
||||||
begin
|
eios_controller.Free;
|
||||||
i:= FindClient(name);
|
|
||||||
if i >= 0 then
|
|
||||||
result:= plugs[i].client
|
|
||||||
end;
|
|
||||||
|
|
||||||
initialization
|
|
||||||
eios_controller:= TEIOS_Controller.Create;
|
|
||||||
finalization
|
|
||||||
eios_controller.Free;
|
|
||||||
end.
|
end.
|
||||||
|
Loading…
Reference in New Issue
Block a user