1
0
mirror of https://github.com/moparisthebest/Simba synced 2024-11-25 10:42:20 -05:00

Added mouse test + some changes

git-svn-id: http://www.villavu.com/repositories/merlijn/mufasa@224 3f818213-9676-44b0-a9b4-5e4c4e03d09d
This commit is contained in:
Wizzup? 2009-11-10 20:39:20 +00:00
parent bfa8b3eb39
commit f8fc7069d3
5 changed files with 282 additions and 93 deletions

View File

@ -33,7 +33,7 @@
<PackageName Value="LCL"/> <PackageName Value="LCL"/>
</Item2> </Item2>
</RequiredPackages> </RequiredPackages>
<Units Count="235"> <Units Count="251">
<Unit0> <Unit0>
<Filename Value="project1.lpr"/> <Filename Value="project1.lpr"/>
<IsPartOfProject Value="True"/> <IsPartOfProject Value="True"/>
@ -229,8 +229,8 @@
<Filename Value="../../Units/MMLCore/mufasatypes.pas"/> <Filename Value="../../Units/MMLCore/mufasatypes.pas"/>
<IsPartOfProject Value="True"/> <IsPartOfProject Value="True"/>
<UnitName Value="MufasaTypes"/> <UnitName Value="MufasaTypes"/>
<CursorPos X="3" Y="51"/> <CursorPos X="1" Y="1"/>
<TopLine Value="36"/> <TopLine Value="1"/>
<EditorIndex Value="1"/> <EditorIndex Value="1"/>
<UsageCount Value="201"/> <UsageCount Value="201"/>
<Loaded Value="True"/> <Loaded Value="True"/>
@ -275,10 +275,10 @@
<Unit32> <Unit32>
<Filename Value="../../Units/MMLCore/input.pas"/> <Filename Value="../../Units/MMLCore/input.pas"/>
<UnitName Value="Input"/> <UnitName Value="Input"/>
<CursorPos X="44" Y="21"/> <CursorPos X="5" Y="188"/>
<TopLine Value="1"/> <TopLine Value="169"/>
<EditorIndex Value="4"/> <EditorIndex Value="4"/>
<UsageCount Value="79"/> <UsageCount Value="81"/>
<Loaded Value="True"/> <Loaded Value="True"/>
</Unit32> </Unit32>
<Unit33> <Unit33>
@ -307,9 +307,9 @@
<Filename Value="../../Units/MMLAddon/mmlpsthread.pas"/> <Filename Value="../../Units/MMLAddon/mmlpsthread.pas"/>
<IsPartOfProject Value="True"/> <IsPartOfProject Value="True"/>
<UnitName Value="mmlpsthread"/> <UnitName Value="mmlpsthread"/>
<CursorPos X="30" Y="198"/> <CursorPos X="1" Y="1"/>
<TopLine Value="183"/> <TopLine Value="1"/>
<EditorIndex Value="7"/> <EditorIndex Value="12"/>
<UsageCount Value="202"/> <UsageCount Value="202"/>
<Loaded Value="True"/> <Loaded Value="True"/>
</Unit36> </Unit36>
@ -376,10 +376,10 @@
</Unit45> </Unit45>
<Unit46> <Unit46>
<Filename Value="../../Units/MMLAddon/PSInc/pscompile.inc"/> <Filename Value="../../Units/MMLAddon/PSInc/pscompile.inc"/>
<CursorPos X="60" Y="105"/> <CursorPos X="68" Y="104"/>
<TopLine Value="91"/> <TopLine Value="99"/>
<EditorIndex Value="10"/> <EditorIndex Value="16"/>
<UsageCount Value="94"/> <UsageCount Value="96"/>
<Loaded Value="True"/> <Loaded Value="True"/>
</Unit46> </Unit46>
<Unit47> <Unit47>
@ -413,8 +413,8 @@
<Filename Value="../../Units/MMLAddon/PSInc/Wrappers/colour.inc"/> <Filename Value="../../Units/MMLAddon/PSInc/Wrappers/colour.inc"/>
<CursorPos X="1" Y="1"/> <CursorPos X="1" Y="1"/>
<TopLine Value="1"/> <TopLine Value="1"/>
<EditorIndex Value="11"/> <EditorIndex Value="17"/>
<UsageCount Value="38"/> <UsageCount Value="40"/>
<Loaded Value="True"/> <Loaded Value="True"/>
</Unit51> </Unit51>
<Unit52> <Unit52>
@ -566,9 +566,9 @@
<Unit74> <Unit74>
<Filename Value="../../Units/MMLAddon/PSInc/Wrappers/mouse.inc"/> <Filename Value="../../Units/MMLAddon/PSInc/Wrappers/mouse.inc"/>
<CursorPos X="33" Y="31"/> <CursorPos X="33" Y="31"/>
<TopLine Value="20"/> <TopLine Value="1"/>
<EditorIndex Value="9"/> <EditorIndex Value="15"/>
<UsageCount Value="15"/> <UsageCount Value="17"/>
<Loaded Value="True"/> <Loaded Value="True"/>
</Unit74> </Unit74>
<Unit75> <Unit75>
@ -648,9 +648,9 @@
<Unit86> <Unit86>
<Filename Value="../../Units/MMLAddon/PSInc/psdefines.inc"/> <Filename Value="../../Units/MMLAddon/PSInc/psdefines.inc"/>
<CursorPos X="1" Y="1"/> <CursorPos X="1" Y="1"/>
<TopLine Value="8"/> <TopLine Value="1"/>
<EditorIndex Value="8"/> <EditorIndex Value="14"/>
<UsageCount Value="10"/> <UsageCount Value="12"/>
<Loaded Value="True"/> <Loaded Value="True"/>
</Unit86> </Unit86>
<Unit87> <Unit87>
@ -863,7 +863,7 @@
<UnitName Value="ocr"/> <UnitName Value="ocr"/>
<CursorPos X="19" Y="91"/> <CursorPos X="19" Y="91"/>
<TopLine Value="75"/> <TopLine Value="75"/>
<UsageCount Value="189"/> <UsageCount Value="193"/>
</Unit116> </Unit116>
<Unit117> <Unit117>
<Filename Value="../../Units/PascalScript/uPSR_extctrls.pas"/> <Filename Value="../../Units/PascalScript/uPSR_extctrls.pas"/>
@ -991,7 +991,7 @@
<UnitName Value="web"/> <UnitName Value="web"/>
<CursorPos X="1" Y="1"/> <CursorPos X="1" Y="1"/>
<TopLine Value="1"/> <TopLine Value="1"/>
<UsageCount Value="114"/> <UsageCount Value="118"/>
</Unit136> </Unit136>
<Unit137> <Unit137>
<Filename Value="../../../lazarus/lcl/lazhelphtml.pas"/> <Filename Value="../../../lazarus/lcl/lazhelphtml.pas"/>
@ -1190,8 +1190,8 @@
<UnitName Value="framescript"/> <UnitName Value="framescript"/>
<CursorPos X="15" Y="195"/> <CursorPos X="15" Y="195"/>
<TopLine Value="180"/> <TopLine Value="180"/>
<EditorIndex Value="12"/> <EditorIndex Value="18"/>
<UsageCount Value="107"/> <UsageCount Value="111"/>
<Loaded Value="True"/> <Loaded Value="True"/>
</Unit161> </Unit161>
<Unit162> <Unit162>
@ -1505,9 +1505,9 @@
<ResourceBaseClass Value="Form"/> <ResourceBaseClass Value="Form"/>
<UnitName Value="colourhistory"/> <UnitName Value="colourhistory"/>
<CursorPos X="37" Y="126"/> <CursorPos X="37" Y="126"/>
<TopLine Value="41"/> <TopLine Value="95"/>
<EditorIndex Value="6"/> <EditorIndex Value="11"/>
<UsageCount Value="44"/> <UsageCount Value="48"/>
<Loaded Value="True"/> <Loaded Value="True"/>
</Unit208> </Unit208>
<Unit209> <Unit209>
@ -1621,10 +1621,10 @@
<Unit225> <Unit225>
<Filename Value="../../Units/MMLCore/mmlkeyinput.pas"/> <Filename Value="../../Units/MMLCore/mmlkeyinput.pas"/>
<UnitName Value="MMLKeyInput"/> <UnitName Value="MMLKeyInput"/>
<CursorPos X="83" Y="46"/> <CursorPos X="62" Y="31"/>
<TopLine Value="21"/> <TopLine Value="21"/>
<EditorIndex Value="5"/> <EditorIndex Value="8"/>
<UsageCount Value="20"/> <UsageCount Value="22"/>
<Loaded Value="True"/> <Loaded Value="True"/>
</Unit225> </Unit225>
<Unit226> <Unit226>
@ -1672,9 +1672,9 @@
<Unit232> <Unit232>
<Filename Value="../../../../Documents/lazarus/lcl/lcltype.pp"/> <Filename Value="../../../../Documents/lazarus/lcl/lcltype.pp"/>
<UnitName Value="LCLType"/> <UnitName Value="LCLType"/>
<CursorPos X="1" Y="1"/> <CursorPos X="67" Y="522"/>
<TopLine Value="481"/> <TopLine Value="507"/>
<UsageCount Value="10"/> <UsageCount Value="11"/>
</Unit232> </Unit232>
<Unit233> <Unit233>
<Filename Value="../../../../Documents/lazarus/lcl/include/listitem.inc"/> <Filename Value="../../../../Documents/lazarus/lcl/include/listitem.inc"/>
@ -1688,127 +1688,242 @@
<TopLine Value="311"/> <TopLine Value="311"/>
<UsageCount Value="10"/> <UsageCount Value="10"/>
</Unit234> </Unit234>
<Unit235>
<Filename Value="../../Units/MMLAddon/PSInc/Wrappers/keyboard.inc"/>
<CursorPos X="13" Y="46"/>
<TopLine Value="16"/>
<EditorIndex Value="13"/>
<UsageCount Value="12"/>
<Loaded Value="True"/>
</Unit235>
<Unit236>
<Filename Value="../../../../Documents/fpc/packages/x11/src/xlib.pp"/>
<UnitName Value="xlib"/>
<CursorPos X="10" Y="1535"/>
<TopLine Value="1520"/>
<UsageCount Value="10"/>
</Unit236>
<Unit237>
<Filename Value="../../../../Documents/lazarus/lcl/include/winapih.inc"/>
<CursorPos X="1" Y="312"/>
<TopLine Value="100"/>
<UsageCount Value="11"/>
</Unit237>
<Unit238>
<Filename Value="../../../../Documents/lazarus/components/mouseandkeyinput/xkeyinput.pas"/>
<UnitName Value="XKeyInput"/>
<CursorPos X="60" Y="51"/>
<TopLine Value="31"/>
<EditorIndex Value="9"/>
<UsageCount Value="11"/>
<Loaded Value="True"/>
</Unit238>
<Unit239>
<Filename Value="../../../../Documents/lazarus/lcl/interfaces/gtk2/gtk2winapi.inc"/>
<CursorPos X="34" Y="10"/>
<TopLine Value="1"/>
<UsageCount Value="10"/>
</Unit239>
<Unit240>
<Filename Value="../../../../Documents/lazarus/lcl/interfaces/gtk/gtkwinapi.inc"/>
<CursorPos X="32" Y="5220"/>
<TopLine Value="5199"/>
<UsageCount Value="10"/>
</Unit240>
<Unit241>
<Filename Value="../../../../Documents/lazarus/lcl/interfaces/gtk/gtkint.pp"/>
<UnitName Value="GtkInt"/>
<CursorPos X="26" Y="87"/>
<TopLine Value="82"/>
<UsageCount Value="10"/>
</Unit241>
<Unit242>
<Filename Value="../../../../Documents/fpc/rtl/objpas/classes/classesh.inc"/>
<CursorPos X="3" Y="170"/>
<TopLine Value="165"/>
<UsageCount Value="10"/>
</Unit242>
<Unit243>
<Filename Value="../../../../Documents/fpc/packages/x11/src/x.pp"/>
<UnitName Value="x"/>
<CursorPos X="4" Y="82"/>
<TopLine Value="67"/>
<UsageCount Value="10"/>
</Unit243>
<Unit244>
<Filename Value="../../../../Documents/fpc/rtl/unix/aliasctp.inc"/>
<CursorPos X="7" Y="49"/>
<TopLine Value="31"/>
<UsageCount Value="10"/>
</Unit244>
<Unit245>
<Filename Value="../../../../Documents/fpc/rtl/unix/ctypes.inc"/>
<CursorPos X="3" Y="59"/>
<TopLine Value="40"/>
<UsageCount Value="10"/>
</Unit245>
<Unit246>
<Filename Value="../../../../Documents/fpc/packages/x11/src/keysym.pp"/>
<UnitName Value="keysym"/>
<CursorPos X="3" Y="501"/>
<TopLine Value="486"/>
<EditorIndex Value="10"/>
<UsageCount Value="11"/>
<Loaded Value="True"/>
</Unit246>
<Unit247>
<Filename Value="../../../../Documents/fpc/rtl/objpas/math.pp"/>
<UnitName Value="math"/>
<CursorPos X="10" Y="326"/>
<TopLine Value="311"/>
<UsageCount Value="10"/>
</Unit247>
<Unit248>
<Filename Value="../../../../Documents/lazarus/lcl/interfaces/gtk/gtkproc.inc"/>
<CursorPos X="14" Y="3074"/>
<TopLine Value="3064"/>
<EditorIndex Value="5"/>
<UsageCount Value="10"/>
<Loaded Value="True"/>
</Unit248>
<Unit249>
<Filename Value="../../Units/Linux/xdo_util.inc"/>
<CursorPos X="24" Y="12"/>
<TopLine Value="1"/>
<EditorIndex Value="6"/>
<UsageCount Value="10"/>
<Loaded Value="True"/>
</Unit249>
<Unit250>
<Filename Value="../../Units/Linux/xkeyboard.pas"/>
<UnitName Value="xkeyboard"/>
<CursorPos X="26" Y="9"/>
<TopLine Value="9"/>
<EditorIndex Value="7"/>
<UsageCount Value="10"/>
<Loaded Value="True"/>
</Unit250>
</Units> </Units>
<JumpHistory Count="30" HistoryIndex="29"> <JumpHistory Count="30" HistoryIndex="29">
<Position1> <Position1>
<Filename Value="testunit.pas"/> <Filename Value="../../Units/MMLCore/input.pas"/>
<Caret Line="486" Column="20" TopLine="460"/> <Caret Line="199" Column="53" TopLine="185"/>
</Position1> </Position1>
<Position2> <Position2>
<Filename Value="testunit.pas"/> <Filename Value="../../Units/MMLCore/input.pas"/>
<Caret Line="508" Column="13" TopLine="493"/> <Caret Line="193" Column="21" TopLine="178"/>
</Position2> </Position2>
<Position3> <Position3>
<Filename Value="testunit.pas"/> <Filename Value="../../Units/MMLCore/input.pas"/>
<Caret Line="249" Column="9" TopLine="241"/> <Caret Line="198" Column="43" TopLine="178"/>
</Position3> </Position3>
<Position4> <Position4>
<Filename Value="testunit.pas"/> <Filename Value="../../Units/MMLCore/input.pas"/>
<Caret Line="266" Column="24" TopLine="241"/> <Caret Line="203" Column="91" TopLine="188"/>
</Position4> </Position4>
<Position5> <Position5>
<Filename Value="testunit.pas"/> <Filename Value="../../Units/MMLAddon/mmlpsthread.pas"/>
<Caret Line="267" Column="24" TopLine="241"/> <Caret Line="244" Column="17" TopLine="235"/>
</Position5> </Position5>
<Position6> <Position6>
<Filename Value="testunit.pas"/> <Filename Value="../../Units/MMLAddon/PSInc/pscompile.inc"/>
<Caret Line="322" Column="21" TopLine="307"/> <Caret Line="114" Column="73" TopLine="99"/>
</Position6> </Position6>
<Position7> <Position7>
<Filename Value="testunit.pas"/> <Filename Value="../../Units/MMLCore/input.pas"/>
<Caret Line="461" Column="7" TopLine="446"/> <Caret Line="169" Column="11" TopLine="148"/>
</Position7> </Position7>
<Position8> <Position8>
<Filename Value="testunit.pas"/> <Filename Value="../../Units/MMLCore/input.pas"/>
<Caret Line="462" Column="11" TopLine="446"/> <Caret Line="200" Column="3" TopLine="178"/>
</Position8> </Position8>
<Position9> <Position9>
<Filename Value="testunit.pas"/> <Filename Value="../../Units/MMLCore/mmlkeyinput.pas"/>
<Caret Line="324" Column="45" TopLine="306"/> <Caret Line="31" Column="61" TopLine="21"/>
</Position9> </Position9>
<Position10> <Position10>
<Filename Value="framescript.pas"/> <Filename Value="../../Units/MMLCore/mmlkeyinput.pas"/>
<Caret Line="64" Column="17" TopLine="49"/> <Caret Line="31" Column="62" TopLine="21"/>
</Position10> </Position10>
<Position11> <Position11>
<Filename Value="framescript.pas"/> <Filename Value="../../../../Documents/lazarus/components/mouseandkeyinput/xkeyinput.pas"/>
<Caret Line="180" Column="15" TopLine="165"/> <Caret Line="53" Column="47" TopLine="31"/>
</Position11> </Position11>
<Position12> <Position12>
<Filename Value="testunit.pas"/> <Filename Value="../../../../Documents/lazarus/components/mouseandkeyinput/xkeyinput.pas"/>
<Caret Line="327" Column="12" TopLine="306"/> <Caret Line="117" Column="23" TopLine="101"/>
</Position12> </Position12>
<Position13> <Position13>
<Filename Value="testunit.pas"/> <Filename Value="../../Units/MMLCore/input.pas"/>
<Caret Line="330" Column="19" TopLine="309"/> <Caret Line="196" Column="12" TopLine="188"/>
</Position13> </Position13>
<Position14> <Position14>
<Filename Value="testunit.pas"/> <Filename Value="../../Units/MMLCore/input.pas"/>
<Caret Line="331" Column="22" TopLine="309"/> <Caret Line="320" Column="67" TopLine="303"/>
</Position14> </Position14>
<Position15> <Position15>
<Filename Value="../../Units/MMLAddon/plugins.pas"/> <Filename Value="../../../../Documents/lazarus/components/mouseandkeyinput/xkeyinput.pas"/>
<Caret Line="68" Column="23" TopLine="50"/> <Caret Line="105" Column="23" TopLine="91"/>
</Position15> </Position15>
<Position16> <Position16>
<Filename Value="../../Units/MMLAddon/plugins.pas"/> <Filename Value="../../Units/MMLCore/input.pas"/>
<Caret Line="206" Column="8" TopLine="183"/> <Caret Line="35" Column="31" TopLine="21"/>
</Position16> </Position16>
<Position17> <Position17>
<Filename Value="../../Units/MMLAddon/plugins.pas"/> <Filename Value="../../Units/MMLCore/input.pas"/>
<Caret Line="59" Column="26" TopLine="44"/> <Caret Line="39" Column="29" TopLine="21"/>
</Position17> </Position17>
<Position18> <Position18>
<Filename Value="../../Units/MMLAddon/mmlpsthread.pas"/> <Filename Value="../../Units/MMLCore/input.pas"/>
<Caret Line="198" Column="24" TopLine="181"/> <Caret Line="324" Column="27" TopLine="309"/>
</Position18> </Position18>
<Position19> <Position19>
<Filename Value="testunit.pas"/> <Filename Value="../../Units/MMLCore/input.pas"/>
<Caret Line="35" Column="10" TopLine="21"/> <Caret Line="325" Column="43" TopLine="310"/>
</Position19> </Position19>
<Position20> <Position20>
<Filename Value="../../Units/MMLAddon/mmlpsthread.pas"/> <Filename Value="../../Units/MMLCore/input.pas"/>
<Caret Line="171" Column="18" TopLine="151"/> <Caret Line="324" Column="71" TopLine="309"/>
</Position20> </Position20>
<Position21> <Position21>
<Filename Value="../../Units/MMLAddon/mmlpsthread.pas"/> <Filename Value="../../Units/MMLCore/input.pas"/>
<Caret Line="243" Column="19" TopLine="231"/> <Caret Line="325" Column="68" TopLine="309"/>
</Position21> </Position21>
<Position22> <Position22>
<Filename Value="../../Units/MMLAddon/PSInc/Wrappers/mouse.inc"/> <Filename Value="../../Units/MMLCore/input.pas"/>
<Caret Line="34" Column="54" TopLine="8"/> <Caret Line="321" Column="3" TopLine="307"/>
</Position22> </Position22>
<Position23> <Position23>
<Filename Value="../../Units/MMLAddon/PSInc/Wrappers/mouse.inc"/> <Filename Value="../../Units/MMLCore/input.pas"/>
<Caret Line="36" Column="38" TopLine="13"/> <Caret Line="326" Column="92" TopLine="310"/>
</Position23> </Position23>
<Position24> <Position24>
<Filename Value="../../Units/MMLCore/input.pas"/> <Filename Value="../../../../Documents/lazarus/lcl/interfaces/gtk/gtkproc.inc"/>
<Caret Line="48" Column="40" TopLine="33"/> <Caret Line="24" Column="55" TopLine="1"/>
</Position24> </Position24>
<Position25> <Position25>
<Filename Value="../../Units/MMLCore/input.pas"/> <Filename Value="../../Units/MMLCore/input.pas"/>
<Caret Line="49" Column="40" TopLine="33"/> <Caret Line="325" Column="90" TopLine="311"/>
</Position25> </Position25>
<Position26> <Position26>
<Filename Value="../../Units/MMLCore/input.pas"/> <Filename Value="../../Units/MMLCore/input.pas"/>
<Caret Line="50" Column="33" TopLine="26"/> <Caret Line="324" Column="12" TopLine="309"/>
</Position26> </Position26>
<Position27> <Position27>
<Filename Value="../../Units/MMLAddon/mmlpsthread.pas"/> <Filename Value="../../Units/MMLCore/input.pas"/>
<Caret Line="244" Column="19" TopLine="231"/> <Caret Line="328" Column="9" TopLine="309"/>
</Position27> </Position27>
<Position28> <Position28>
<Filename Value="../../Units/MMLAddon/PSInc/pscompile.inc"/> <Filename Value="../../Units/MMLCore/input.pas"/>
<Caret Line="106" Column="95" TopLine="81"/> <Caret Line="312" Column="17" TopLine="299"/>
</Position28> </Position28>
<Position29> <Position29>
<Filename Value="../../Units/MMLAddon/PSInc/Wrappers/mouse.inc"/> <Filename Value="../../Units/MMLCore/input.pas"/>
<Caret Line="31" Column="33" TopLine="20"/> <Caret Line="326" Column="47" TopLine="311"/>
</Position29> </Position29>
<Position30> <Position30>
<Filename Value="../../Units/MMLCore/input.pas"/> <Filename Value="../../Units/MMLCore/input.pas"/>
<Caret Line="46" Column="34" TopLine="31"/> <Caret Line="321" Column="26" TopLine="305"/>
</Position30> </Position30>
</JumpHistory> </JumpHistory>
</ProjectOptions> </ProjectOptions>

32
Tests/PS/mouse.mufa Normal file
View File

@ -0,0 +1,32 @@
program Mouse;
{
This program illustrates the Mufasa Mouse Functions
}
var
w, h, x, y: integer;
begin
getclientdimensions(w,h);
writeln(inttostr(w) + ', ' + inttostr(h));
MoveMouse(0, 0);
getmousepos(x, y);
writeln(inttostr(x) + ', ' + inttostr(y));
wait(1000);
MoveMouse(w, 0);
getmousepos(x, y);
writeln(inttostr(x) + ', ' + inttostr(y));
wait(1000);
MoveMouse(0, h);
getmousepos(x, y);
writeln(inttostr(x) + ', ' + inttostr(y));
wait(1000);
MoveMouse(w, h);
getmousepos(x, y);
writeln(inttostr(x) + ', ' + inttostr(y));
wait(1000);
ClickMouse(0, 0, mouse_Right);
for x := 0 to 400 do
MoveMouse(x, x);
end.

View File

@ -40,3 +40,8 @@ procedure PressKey(key: Word);
begin begin
CurrThread.Client.MInput.PressKey(key); CurrThread.Client.MInput.PressKey(key);
end; end;
function isKeyDown(key: Word): boolean;
begin
Result := CurrThread.Client.MInput.isKeyDown(key);
end;

View File

@ -111,6 +111,7 @@ Sender.AddFunction(@KeyDown, 'procedure KeyDown(key: Word);');
Sender.AddFunction(@KeyUp, 'procedure KeyUp(key: Word);'); Sender.AddFunction(@KeyUp, 'procedure KeyUp(key: Word);');
Sender.AddFunction(@PressKey, 'procedure PressKey(key: Word);'); Sender.AddFunction(@PressKey, 'procedure PressKey(key: Word);');
Sender.AddFunction(@SendKeys, 'procedure SendKeys(s: string);'); Sender.AddFunction(@SendKeys, 'procedure SendKeys(s: string);');
Sender.AddFunction(@isKeyDown, 'function isKeyDown(key: Word): Boolean;');
{ OCR} { OCR}

View File

@ -32,11 +32,11 @@ uses
mufasatypes, // for common mufasa types mufasatypes, // for common mufasa types
windowutil, // for mufasa window utils windowutil, // for mufasa window utils
{$IFDEF LINUX} {$IFDEF LINUX}
ctypes,x, xlib,xtest,// for X* stuff ctypes,x, xlib,xtest,keysym,// for X* stuff
// do non silent keys/mouse with XTest / TKeyInput. // do non silent keys/mouse with XTest / TKeyInput.
{Later on we should use xdotool, as it allows silent input} {Later on we should use xdotool, as it allows silent input}
{$ENDIF} {$ENDIF}
MMLKeyInput, lclintf; MMLKeyInput, lclintf,math;
type type
TMInput = class(TObject) TMInput = class(TObject)
@ -53,6 +53,7 @@ type
procedure KeyDown(key: Word); procedure KeyDown(key: Word);
procedure PressKey(key: Word); procedure PressKey(key: Word);
procedure SendText(text: string); procedure SendText(text: string);
function isKeyDown(key: Word): Boolean;
// Not used yet. // Not used yet.
procedure SetSilent(_Silent: Boolean); procedure SetSilent(_Silent: Boolean);
@ -186,6 +187,41 @@ begin
end; end;
end; end;
function TMInput.isKeyDown(key: Word): Boolean;
{$IFDEF LINUX}
{var
key_states: chararr32;
i, j: integer;
_key: TKeySym;
_code: TKeyCode;
wat: integer; }
{$ENDIF}
begin
{$IFDEF MSWINDOWS}
{$ELSE}
raise Exception.CreateFmt('IsKeyDown isn''t implemented yet on Linux', []);
{XQueryKeymap(TClient(Client).MWindow.XDisplay, key_states);
_key := VirtualKeyToXKeySym(key);
_code := XKeysymToKeycode(TClient(Client).MWindow.XDisplay, _key);
for i := 0 to 31 do
for j := 7 to 0 do
begin
wat := Byte(key_states[i]) and (1 shl (j));
if wat > 0 then
begin
writeln(inttostr((i * 8) + j) + ': ' + inttostr(Byte(key_states[i]) and (1 shl j)));
writeln(inttostr((i * 8) + j) + ': ' + inttostr(Byte(key_states[i]) and (1 shl (8-j))));
end;
end;
writeln(Format('key: %d, _key: %d, _code: %d', [key, _key, _code]));
writeln('Wat: ' + inttostr((Byte(key_states[floor(_code / 8)]) and 1 shl (_code mod 8))));
result := (Byte(key_states[floor(_code / 8)]) and 1 shl (_code mod 8)) > 0; }
{XQueryKeymap -> Print all values ! }
{$ENDIF}
end;
procedure TMInput.GetMousePos(var X, Y: Integer); procedure TMInput.GetMousePos(var X, Y: Integer);
{$IFDEF LINUX} {$IFDEF LINUX}
var var