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"/>
</Item2>
</RequiredPackages>
<Units Count="235">
<Units Count="251">
<Unit0>
<Filename Value="project1.lpr"/>
<IsPartOfProject Value="True"/>
@ -229,8 +229,8 @@
<Filename Value="../../Units/MMLCore/mufasatypes.pas"/>
<IsPartOfProject Value="True"/>
<UnitName Value="MufasaTypes"/>
<CursorPos X="3" Y="51"/>
<TopLine Value="36"/>
<CursorPos X="1" Y="1"/>
<TopLine Value="1"/>
<EditorIndex Value="1"/>
<UsageCount Value="201"/>
<Loaded Value="True"/>
@ -275,10 +275,10 @@
<Unit32>
<Filename Value="../../Units/MMLCore/input.pas"/>
<UnitName Value="Input"/>
<CursorPos X="44" Y="21"/>
<TopLine Value="1"/>
<CursorPos X="5" Y="188"/>
<TopLine Value="169"/>
<EditorIndex Value="4"/>
<UsageCount Value="79"/>
<UsageCount Value="81"/>
<Loaded Value="True"/>
</Unit32>
<Unit33>
@ -307,9 +307,9 @@
<Filename Value="../../Units/MMLAddon/mmlpsthread.pas"/>
<IsPartOfProject Value="True"/>
<UnitName Value="mmlpsthread"/>
<CursorPos X="30" Y="198"/>
<TopLine Value="183"/>
<EditorIndex Value="7"/>
<CursorPos X="1" Y="1"/>
<TopLine Value="1"/>
<EditorIndex Value="12"/>
<UsageCount Value="202"/>
<Loaded Value="True"/>
</Unit36>
@ -376,10 +376,10 @@
</Unit45>
<Unit46>
<Filename Value="../../Units/MMLAddon/PSInc/pscompile.inc"/>
<CursorPos X="60" Y="105"/>
<TopLine Value="91"/>
<EditorIndex Value="10"/>
<UsageCount Value="94"/>
<CursorPos X="68" Y="104"/>
<TopLine Value="99"/>
<EditorIndex Value="16"/>
<UsageCount Value="96"/>
<Loaded Value="True"/>
</Unit46>
<Unit47>
@ -413,8 +413,8 @@
<Filename Value="../../Units/MMLAddon/PSInc/Wrappers/colour.inc"/>
<CursorPos X="1" Y="1"/>
<TopLine Value="1"/>
<EditorIndex Value="11"/>
<UsageCount Value="38"/>
<EditorIndex Value="17"/>
<UsageCount Value="40"/>
<Loaded Value="True"/>
</Unit51>
<Unit52>
@ -566,9 +566,9 @@
<Unit74>
<Filename Value="../../Units/MMLAddon/PSInc/Wrappers/mouse.inc"/>
<CursorPos X="33" Y="31"/>
<TopLine Value="20"/>
<EditorIndex Value="9"/>
<UsageCount Value="15"/>
<TopLine Value="1"/>
<EditorIndex Value="15"/>
<UsageCount Value="17"/>
<Loaded Value="True"/>
</Unit74>
<Unit75>
@ -648,9 +648,9 @@
<Unit86>
<Filename Value="../../Units/MMLAddon/PSInc/psdefines.inc"/>
<CursorPos X="1" Y="1"/>
<TopLine Value="8"/>
<EditorIndex Value="8"/>
<UsageCount Value="10"/>
<TopLine Value="1"/>
<EditorIndex Value="14"/>
<UsageCount Value="12"/>
<Loaded Value="True"/>
</Unit86>
<Unit87>
@ -863,7 +863,7 @@
<UnitName Value="ocr"/>
<CursorPos X="19" Y="91"/>
<TopLine Value="75"/>
<UsageCount Value="189"/>
<UsageCount Value="193"/>
</Unit116>
<Unit117>
<Filename Value="../../Units/PascalScript/uPSR_extctrls.pas"/>
@ -991,7 +991,7 @@
<UnitName Value="web"/>
<CursorPos X="1" Y="1"/>
<TopLine Value="1"/>
<UsageCount Value="114"/>
<UsageCount Value="118"/>
</Unit136>
<Unit137>
<Filename Value="../../../lazarus/lcl/lazhelphtml.pas"/>
@ -1190,8 +1190,8 @@
<UnitName Value="framescript"/>
<CursorPos X="15" Y="195"/>
<TopLine Value="180"/>
<EditorIndex Value="12"/>
<UsageCount Value="107"/>
<EditorIndex Value="18"/>
<UsageCount Value="111"/>
<Loaded Value="True"/>
</Unit161>
<Unit162>
@ -1505,9 +1505,9 @@
<ResourceBaseClass Value="Form"/>
<UnitName Value="colourhistory"/>
<CursorPos X="37" Y="126"/>
<TopLine Value="41"/>
<EditorIndex Value="6"/>
<UsageCount Value="44"/>
<TopLine Value="95"/>
<EditorIndex Value="11"/>
<UsageCount Value="48"/>
<Loaded Value="True"/>
</Unit208>
<Unit209>
@ -1621,10 +1621,10 @@
<Unit225>
<Filename Value="../../Units/MMLCore/mmlkeyinput.pas"/>
<UnitName Value="MMLKeyInput"/>
<CursorPos X="83" Y="46"/>
<CursorPos X="62" Y="31"/>
<TopLine Value="21"/>
<EditorIndex Value="5"/>
<UsageCount Value="20"/>
<EditorIndex Value="8"/>
<UsageCount Value="22"/>
<Loaded Value="True"/>
</Unit225>
<Unit226>
@ -1672,9 +1672,9 @@
<Unit232>
<Filename Value="../../../../Documents/lazarus/lcl/lcltype.pp"/>
<UnitName Value="LCLType"/>
<CursorPos X="1" Y="1"/>
<TopLine Value="481"/>
<UsageCount Value="10"/>
<CursorPos X="67" Y="522"/>
<TopLine Value="507"/>
<UsageCount Value="11"/>
</Unit232>
<Unit233>
<Filename Value="../../../../Documents/lazarus/lcl/include/listitem.inc"/>
@ -1688,127 +1688,242 @@
<TopLine Value="311"/>
<UsageCount Value="10"/>
</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>
<JumpHistory Count="30" HistoryIndex="29">
<Position1>
<Filename Value="testunit.pas"/>
<Caret Line="486" Column="20" TopLine="460"/>
<Filename Value="../../Units/MMLCore/input.pas"/>
<Caret Line="199" Column="53" TopLine="185"/>
</Position1>
<Position2>
<Filename Value="testunit.pas"/>
<Caret Line="508" Column="13" TopLine="493"/>
<Filename Value="../../Units/MMLCore/input.pas"/>
<Caret Line="193" Column="21" TopLine="178"/>
</Position2>
<Position3>
<Filename Value="testunit.pas"/>
<Caret Line="249" Column="9" TopLine="241"/>
<Filename Value="../../Units/MMLCore/input.pas"/>
<Caret Line="198" Column="43" TopLine="178"/>
</Position3>
<Position4>
<Filename Value="testunit.pas"/>
<Caret Line="266" Column="24" TopLine="241"/>
<Filename Value="../../Units/MMLCore/input.pas"/>
<Caret Line="203" Column="91" TopLine="188"/>
</Position4>
<Position5>
<Filename Value="testunit.pas"/>
<Caret Line="267" Column="24" TopLine="241"/>
<Filename Value="../../Units/MMLAddon/mmlpsthread.pas"/>
<Caret Line="244" Column="17" TopLine="235"/>
</Position5>
<Position6>
<Filename Value="testunit.pas"/>
<Caret Line="322" Column="21" TopLine="307"/>
<Filename Value="../../Units/MMLAddon/PSInc/pscompile.inc"/>
<Caret Line="114" Column="73" TopLine="99"/>
</Position6>
<Position7>
<Filename Value="testunit.pas"/>
<Caret Line="461" Column="7" TopLine="446"/>
<Filename Value="../../Units/MMLCore/input.pas"/>
<Caret Line="169" Column="11" TopLine="148"/>
</Position7>
<Position8>
<Filename Value="testunit.pas"/>
<Caret Line="462" Column="11" TopLine="446"/>
<Filename Value="../../Units/MMLCore/input.pas"/>
<Caret Line="200" Column="3" TopLine="178"/>
</Position8>
<Position9>
<Filename Value="testunit.pas"/>
<Caret Line="324" Column="45" TopLine="306"/>
<Filename Value="../../Units/MMLCore/mmlkeyinput.pas"/>
<Caret Line="31" Column="61" TopLine="21"/>
</Position9>
<Position10>
<Filename Value="framescript.pas"/>
<Caret Line="64" Column="17" TopLine="49"/>
<Filename Value="../../Units/MMLCore/mmlkeyinput.pas"/>
<Caret Line="31" Column="62" TopLine="21"/>
</Position10>
<Position11>
<Filename Value="framescript.pas"/>
<Caret Line="180" Column="15" TopLine="165"/>
<Filename Value="../../../../Documents/lazarus/components/mouseandkeyinput/xkeyinput.pas"/>
<Caret Line="53" Column="47" TopLine="31"/>
</Position11>
<Position12>
<Filename Value="testunit.pas"/>
<Caret Line="327" Column="12" TopLine="306"/>
<Filename Value="../../../../Documents/lazarus/components/mouseandkeyinput/xkeyinput.pas"/>
<Caret Line="117" Column="23" TopLine="101"/>
</Position12>
<Position13>
<Filename Value="testunit.pas"/>
<Caret Line="330" Column="19" TopLine="309"/>
<Filename Value="../../Units/MMLCore/input.pas"/>
<Caret Line="196" Column="12" TopLine="188"/>
</Position13>
<Position14>
<Filename Value="testunit.pas"/>
<Caret Line="331" Column="22" TopLine="309"/>
<Filename Value="../../Units/MMLCore/input.pas"/>
<Caret Line="320" Column="67" TopLine="303"/>
</Position14>
<Position15>
<Filename Value="../../Units/MMLAddon/plugins.pas"/>
<Caret Line="68" Column="23" TopLine="50"/>
<Filename Value="../../../../Documents/lazarus/components/mouseandkeyinput/xkeyinput.pas"/>
<Caret Line="105" Column="23" TopLine="91"/>
</Position15>
<Position16>
<Filename Value="../../Units/MMLAddon/plugins.pas"/>
<Caret Line="206" Column="8" TopLine="183"/>
<Filename Value="../../Units/MMLCore/input.pas"/>
<Caret Line="35" Column="31" TopLine="21"/>
</Position16>
<Position17>
<Filename Value="../../Units/MMLAddon/plugins.pas"/>
<Caret Line="59" Column="26" TopLine="44"/>
<Filename Value="../../Units/MMLCore/input.pas"/>
<Caret Line="39" Column="29" TopLine="21"/>
</Position17>
<Position18>
<Filename Value="../../Units/MMLAddon/mmlpsthread.pas"/>
<Caret Line="198" Column="24" TopLine="181"/>
<Filename Value="../../Units/MMLCore/input.pas"/>
<Caret Line="324" Column="27" TopLine="309"/>
</Position18>
<Position19>
<Filename Value="testunit.pas"/>
<Caret Line="35" Column="10" TopLine="21"/>
<Filename Value="../../Units/MMLCore/input.pas"/>
<Caret Line="325" Column="43" TopLine="310"/>
</Position19>
<Position20>
<Filename Value="../../Units/MMLAddon/mmlpsthread.pas"/>
<Caret Line="171" Column="18" TopLine="151"/>
<Filename Value="../../Units/MMLCore/input.pas"/>
<Caret Line="324" Column="71" TopLine="309"/>
</Position20>
<Position21>
<Filename Value="../../Units/MMLAddon/mmlpsthread.pas"/>
<Caret Line="243" Column="19" TopLine="231"/>
<Filename Value="../../Units/MMLCore/input.pas"/>
<Caret Line="325" Column="68" TopLine="309"/>
</Position21>
<Position22>
<Filename Value="../../Units/MMLAddon/PSInc/Wrappers/mouse.inc"/>
<Caret Line="34" Column="54" TopLine="8"/>
<Filename Value="../../Units/MMLCore/input.pas"/>
<Caret Line="321" Column="3" TopLine="307"/>
</Position22>
<Position23>
<Filename Value="../../Units/MMLAddon/PSInc/Wrappers/mouse.inc"/>
<Caret Line="36" Column="38" TopLine="13"/>
<Filename Value="../../Units/MMLCore/input.pas"/>
<Caret Line="326" Column="92" TopLine="310"/>
</Position23>
<Position24>
<Filename Value="../../Units/MMLCore/input.pas"/>
<Caret Line="48" Column="40" TopLine="33"/>
<Filename Value="../../../../Documents/lazarus/lcl/interfaces/gtk/gtkproc.inc"/>
<Caret Line="24" Column="55" TopLine="1"/>
</Position24>
<Position25>
<Filename Value="../../Units/MMLCore/input.pas"/>
<Caret Line="49" Column="40" TopLine="33"/>
<Caret Line="325" Column="90" TopLine="311"/>
</Position25>
<Position26>
<Filename Value="../../Units/MMLCore/input.pas"/>
<Caret Line="50" Column="33" TopLine="26"/>
<Caret Line="324" Column="12" TopLine="309"/>
</Position26>
<Position27>
<Filename Value="../../Units/MMLAddon/mmlpsthread.pas"/>
<Caret Line="244" Column="19" TopLine="231"/>
<Filename Value="../../Units/MMLCore/input.pas"/>
<Caret Line="328" Column="9" TopLine="309"/>
</Position27>
<Position28>
<Filename Value="../../Units/MMLAddon/PSInc/pscompile.inc"/>
<Caret Line="106" Column="95" TopLine="81"/>
<Filename Value="../../Units/MMLCore/input.pas"/>
<Caret Line="312" Column="17" TopLine="299"/>
</Position28>
<Position29>
<Filename Value="../../Units/MMLAddon/PSInc/Wrappers/mouse.inc"/>
<Caret Line="31" Column="33" TopLine="20"/>
<Filename Value="../../Units/MMLCore/input.pas"/>
<Caret Line="326" Column="47" TopLine="311"/>
</Position29>
<Position30>
<Filename Value="../../Units/MMLCore/input.pas"/>
<Caret Line="46" Column="34" TopLine="31"/>
<Caret Line="321" Column="26" TopLine="305"/>
</Position30>
</JumpHistory>
</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
CurrThread.Client.MInput.PressKey(key);
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(@PressKey, 'procedure PressKey(key: Word);');
Sender.AddFunction(@SendKeys, 'procedure SendKeys(s: string);');
Sender.AddFunction(@isKeyDown, 'function isKeyDown(key: Word): Boolean;');
{ OCR}

View File

@ -32,11 +32,11 @@ uses
mufasatypes, // for common mufasa types
windowutil, // for mufasa window utils
{$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.
{Later on we should use xdotool, as it allows silent input}
{$ENDIF}
MMLKeyInput, lclintf;
MMLKeyInput, lclintf,math;
type
TMInput = class(TObject)
@ -53,6 +53,7 @@ type
procedure KeyDown(key: Word);
procedure PressKey(key: Word);
procedure SendText(text: string);
function isKeyDown(key: Word): Boolean;
// Not used yet.
procedure SetSilent(_Silent: Boolean);
@ -186,6 +187,41 @@ begin
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);
{$IFDEF LINUX}
var