Oberon Community Platform Forum
November 22, 2019, 07:26:10 PM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: 1 [2]
  Print  
Author Topic: A2 Cursor  (Read 16930 times)
BohdanT
Sr. Member
****
Posts: 271


Life is difficult, but fortunately is short!


WWW
« Reply #15 on: October 26, 2010, 11:56:35 PM »

I just watched the game, I realized that I needed. If I find a solution that'll let you know.
Logged
BohdanT
Sr. Member
****
Posts: 271


Life is difficult, but fortunately is short!


WWW
« Reply #16 on: October 27, 2010, 01:00:34 AM »

It seems to work, at least in the Native A2 should work.

* TestMouse.Mod (3.06 KB - downloaded 288 times.)
Logged
staubesv
Administrator
Sr. Member
*****
Posts: 387



« Reply #17 on: October 27, 2010, 09:13:54 AM »

Quote
because the windowing system stops giving mouse events to the window if it determines that the mouse is not over the window
Yes, but the message preview handler will send the mouse messages to anyone interested, so this mechanism could be used (although, as mentioned before, it is somewhat dangerous...).

I wouldn't be hard to add a Flag to the WMWindowManager.Window that, when set, says the window manager to not re-evaluate the pointer owner...
But the question is: Would this now be a good or bad thing?
Logged
BohdanT
Sr. Member
****
Posts: 271


Life is difficult, but fortunately is short!


WWW
« Reply #18 on: October 27, 2010, 10:35:22 AM »

Quote
I wouldn't be hard to add a Flag to the WMWindowManager.Window

Add flag is not necessary because it can be implemented without a flag.
I think: need to make a library such as DirectX for gaming application.
Logged
sage
Full Member
***
Posts: 170



WWW
« Reply #19 on: October 27, 2010, 10:58:21 AM »

I think: need to make a library such as DirectX for gaming application.
Or such as OpenGL Wink
Logged
staubesv
Administrator
Sr. Member
*****
Posts: 387



« Reply #20 on: October 27, 2010, 11:31:42 AM »

The idea of the flag would be to make the Window Manager aware of such situations. Even if you grab the user input directly from Inputs interface, you most likely don't want the Window Manager to handle the same events (showing & moving mouse cursor, in this example).
But if you prevent the Window Manager from doing so, there must be a reliable way of giving control back to the Window Manager.
If the Window Manager is aware of this mechanism (e.g. presence of windows that completely take over user input once they have it), the Window Manager could also provide a key combination that simply grabs control back without the window that has controls having a chance to prevent this.

BTW: Are you aware of the fact the native A2 can handle USB-joysticks quite well? Just because I've noticed the term "gaming application"  Cool
« Last Edit: October 27, 2010, 11:33:56 AM by staubesv » Logged
BohdanT
Sr. Member
****
Posts: 271


Life is difficult, but fortunately is short!


WWW
« Reply #21 on: October 27, 2010, 12:17:12 PM »

Quote
But if you prevent the Window Manager from doing so, there must be a reliable way of giving control back to the Window Manager.
with that in my example, and there is a problem.
I'm having problems with Inputs.mouse.Unregister (pointer);
thereon made Inputs.mouse: = Inputs.NewBroadcaster ();
After recovery, I see that the mouse works, but something goes wrong ...

By this, I think that there should be a library.
By the way, then we will implement an emergency exit (by hotkey) from the capture mode.

small cleanup
Code:
MODULE TestMouse;
IMPORT Inputs,  KernelLog;
TYPE

Pointer* = OBJECT (Inputs.Pointer)
VAR
grab*:BOOLEAN;
PROCEDURE Handle*(VAR m: Inputs.Message);
BEGIN {EXCLUSIVE}
IF ~grab THEN Handle^(m)
ELSE
IF m IS Inputs.MouseMsg THEN
WITH m: Inputs.MouseMsg DO
KernelLog.String("dx= "); KernelLog.Int(m.dx, 0);
KernelLog.String(" dy= "); KernelLog.Int(m.dy, 0); KernelLog.Ln;
END;
ELSIF m IS Inputs.AbsMouseMsg THEN
WITH m: Inputs.AbsMouseMsg DO
KernelLog.String("x= "); KernelLog.Int(m.x, 0);
KernelLog.String(" y= "); KernelLog.Int(m.y, 0); KernelLog.Ln;
END;
END
END;
END Handle;
PROCEDURE &Init*(t, s: LONGINT);
BEGIN
grab:=FALSE;
Init^(t,s);
END Init;
END Pointer;
VAR
pointer:Pointer;

PROCEDURE TestOn*;
BEGIN

Inputs.mouse := Inputs.NewBroadcaster();


NEW(pointer,5,15);
Inputs.main:=pointer;

KernelLog.String("Try grab mouse....ok  "); KernelLog.Ln;
pointer.grab:=TRUE;

END TestOn;
PROCEDURE TestOff*;
BEGIN
Inputs.mouse := Inputs.NewBroadcaster();
pointer:=NIL;
KernelLog.String("TODO:ungrab  mouse :)  "); KernelLog.Ln;
NEW(Inputs.main,5,15);
END TestOff;

END TestMouse.TestOn~

TestMouse.TestOff~
Logged
soren renner
Global Moderator
Full Member
*****
Posts: 216



« Reply #22 on: October 27, 2010, 03:52:01 PM »

Which you have already shown me how to do, assuming that I can find out the current screen position of the window from the WM.
Logged
BohdanT
Sr. Member
****
Posts: 271


Life is difficult, but fortunately is short!


WWW
« Reply #23 on: October 27, 2010, 04:30:14 PM »

You do not need the current screen position,
You need to detect mouse move: dx and dy

Logged
sage
Full Member
***
Posts: 170



WWW
« Reply #24 on: January 27, 2011, 02:39:27 PM »

With small improvement seems all works fine  Wink
Code:
VAR
pointer:Pointer;
oldPointer: Inputs.Pointer;
oldMouse: Inputs.Group;

PROCEDURE TestOn*;
BEGIN {EXCLUSIVE}
oldPointer := Inputs.main;
oldMouse := Inputs.mouse;
Inputs.mouse := Inputs.NewBroadcaster();
NEW(pointer,5,15);
Inputs.main:=pointer;
pointer.grab:=TRUE;
KernelLog.String("Try grab mouse....ok  "); KernelLog.Ln
END TestOn;

PROCEDURE TestOff*;
BEGIN {EXCLUSIVE}
pointer.grab:=FALSE;
pointer:=NIL;
Inputs.main := oldPointer;
Inputs.mouse := oldMouse;
KernelLog.String("Ungrab  mouse :)  "); KernelLog.Ln
END TestOff;
Logged
sage
Full Member
***
Posts: 170



WWW
« Reply #25 on: January 27, 2011, 03:29:07 PM »

You need to detect mouse move: dx and dy
I've tried another approach to get relative mouse movements. I've connected a handler directly to mouse driver. It possible and looks much safe then above code examples.
Code:
MODULE Test;
IMPORT
Modules, Inputs, KernelLog;
TYPE
MouseObj = OBJECT(Inputs.Sink)
VAR
threshold, speedup: LONGINT;
x, y, z: LONGINT;
bFirst: BOOLEAN;
PROCEDURE &Init*(t, s: LONGINT);
BEGIN
bFirst := TRUE;
Inputs.mouse.Register(SELF);
threshold := t; speedup := s
END Init;
PROCEDURE Handle(VAR msg: Inputs.Message);
VAR dx, dy, dz: LONGINT;
BEGIN {EXCLUSIVE}
IF (msg IS Inputs.MouseMsg) OR (msg IS Inputs.AbsMouseMsg) THEN
IF msg IS Inputs.MouseMsg THEN
WITH msg: Inputs.MouseMsg DO
dx := msg.dx; dy := msg.dy; dz := msg.dz
END
ELSIF msg IS Inputs.AbsMouseMsg THEN
WITH msg: Inputs.AbsMouseMsg DO
IF bFirst THEN
bFirst := FALSE;
x := msg.x;  y := msg.y;  z := msg.z;
dx := 0; dy := 0; dz := 0
ELSE
(*dx := x - msg.x; x := msg.x;
dy := y - msg.y; y := msg.y;
dz := z - msg.z; z := msg.z*)
IF msg.dx # 0 THEN dx := x - msg.dx; x := msg.dx ELSE dx := x - msg.x; x := msg.x END;
IF msg.dy # 0 THEN dy := y - msg.dy; y := msg.dy  ELSE dy := y - msg.y; y := msg.y END;
IF msg.dz # 0 THEN dz := msg.dz  ELSE dz := z - msg.z; z := msg.z END
END
END
END;
IF (ABS(dx) > threshold) OR (ABS(dy) > threshold) THEN
dx := dx * speedup DIV 10; dy := dy * speedup DIV 10
END;
IF (dx # 0) OR (dy # 0) OR (dz # 0) THEN
KernelLog.String("dx, dy, dz: ");
KernelLog.Int(dx, 10); KernelLog.Int(dy, 10); KernelLog.Int(dz, 10);
KernelLog.Ln
END
END
END Handle;
END MouseObj;
VAR
mouse: MouseObj;
PROCEDURE Test*;
BEGIN
END Test;
PROCEDURE Init;
BEGIN
NEW(mouse, 5, 15)
END Init;
PROCEDURE Cleanup;
BEGIN
Inputs.mouse.Unregister(mouse)
END Cleanup;
BEGIN
Modules.InstallTermHandler(Cleanup);
Init
END Test.
Test.Test ~
SystemTools.Free Test ~
Under WinAos (with "Boot1 = Display.Install FULLSCREEN") this code able to calculate dx and dy from absolute coordinate values (msg.x and msg.y) only when mouse coordinates are in range of display resolution. When cursor goes through display resolution ranges, driver gives msg.x and msg.y equal to 0, but then gives some absolute (!) values in msg.dx and msg.dy fields. I've tried to calculate relative dx and dy from that msg.dx and msg.dy and i've got some results looks as it should look, BUT when I've tried to move mouse deep to down side of screen driver gives msg.dx and msg.dy equal to 0. Is it a bug?

Not tested it yet under native.
« Last Edit: January 27, 2011, 03:32:45 PM by sage » Logged
sage
Full Member
***
Posts: 170



WWW
« Reply #26 on: January 31, 2011, 06:49:24 AM »

Under native A2 this approach with direct using mouse driver events works fust perfect, driver returns exact what I need - relative mouse coordinates. So, WinAos handles mouse differently.
Is it possible to get relative mouse coordinates with Windows API???
Logged
sage
Full Member
***
Posts: 170



WWW
« Reply #27 on: January 31, 2011, 09:54:35 AM »

I've found the description how to implement properly the mouse input under WinAos.
Handling of WM_INPUT messages should be used http://msdn.microsoft.com/en-us/library/ee418864(v=VS.85).aspx
« Last Edit: January 31, 2011, 01:27:17 PM by sage » Logged
Pages: 1 [2]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines Valid XHTML 1.0! Valid CSS!