Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » Developing U++ » U++ Developers corner » Using Pen with U++
Re: Using Pen with U++ [message #56670 is a reply to message #56666] Fri, 02 April 2021 10:05 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Tom1 wrote on Fri, 02 April 2021 08:26
mirek wrote on Thu, 01 April 2021 23:49
Are you 100% sure this does not work with Wacom:

https://stackoverflow.com/questions/29857587/detect-if-wm-mo usemove-is-caused-by-touch-pen

?


Last time I tried it did not work. It was zero all the time. Since then, I have reinstalled the Wacom drivers.

Now I get: "GetMessageExtraInfo() = 4283520772" for pen and "GetMessageExtraInfo() = 0" for mouse. These are present for e.g. WM_MOUSEMOVE and WM_LBUTTONDOWN.

So, I may have made some stupid mistake last time or the driver re-installation may have had an effect.

Best regards,

Tom


OK, backup your changes, I am going to try yet another approach... Smile

Mirek
Re: Using Pen with U++ [message #56671 is a reply to message #56670] Fri, 02 April 2021 11:43 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Please try trunk reference/Pen now...

Notes: This is just a first rough attempt, if this works, it needs a cleanup and handling of history.
Re: Using Pen with U++ [message #56672 is a reply to message #56671] Fri, 02 April 2021 12:30 Go to previous messageGo to next message
Tom1
Messages: 1212
Registered: March 2007
Senior Contributor
Hi,

I'm currently out of town, but will be back home in the evening. I'll test it then ASAP.

Thanks and best regards,

Tom
Re: Using Pen with U++ [message #56682 is a reply to message #56671] Fri, 02 April 2021 21:27 Go to previous messageGo to next message
Tom1
Messages: 1212
Registered: March 2007
Senior Contributor
mirek wrote on Fri, 02 April 2021 12:43
Please try trunk reference/Pen now...

Notes: This is just a first rough attempt, if this works, it needs a cleanup and handling of history.


Hi Mirek,

I just updated to latest SVN. All drags start 2 cm late. (Let's call this issue 'DragLag' for short from now on.) This is no wonder as WM_POINTERUPDATE does not send MouseMove() events to the app through any channel. Giving WM_POINTER* messages to the DefWindowProc*() to handle, causes DragLag before WM_LBUTTONDOWN and respective WM_MOUSEMOVE messages are generated. I have spent last two weeks on the issue and have not found any clean and easy way out with Wacom.

I understand that you don't have this DragLag -nightmare with XP-PEN and everything you do works with it. And that my attempts here are complex and ugly.

However, in order for Wacom to work with immediate response, we have to process everything from WM_POINTER* messages to application events (such as MouseMove(), LeftDown(), etc. or Pen() with proper PenInfo to decode the operations in the app.) If we also decide to break into DefWindowProc*() processing at the end of processing WM_POINTER* messages, we will need to block its resulting output to the Pen -enabled controls.

Best regards,

Tom
Re: Using Pen with U++ [message #56687 is a reply to message #56682] Sat, 03 April 2021 08:44 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Tom1 wrote on Fri, 02 April 2021 21:27
mirek wrote on Fri, 02 April 2021 12:43
Please try trunk reference/Pen now...

Notes: This is just a first rough attempt, if this works, it needs a cleanup and handling of history.


Hi Mirek,

I just updated to latest SVN. All drags start 2 cm late. (Let's call this issue 'DragLag' for short from now on.) This is no wonder as WM_POINTERUPDATE does not send MouseMove() events to the app through any channel. Giving WM_POINTER* messages to the DefWindowProc*() to handle, causes DragLag before WM_LBUTTONDOWN and respective WM_MOUSEMOVE messages are generated. I have spent last two weeks on the issue and have not found any clean and easy way out with Wacom.


What about other issues? I mean, does it work as mouse elsewhere?

Quote:

I understand that you don't have this DragLag -nightmare with XP-PEN and everything you do works with it. And that my attempts here are complex and ugly.


I think there is some small draglag.

Mirek
Re: Using Pen with U++ [message #56688 is a reply to message #56687] Sat, 03 April 2021 08:52 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
https://docs.microsoft.com/cs-cz/windows/win32/tablet/timeli ne-of-mouse-messages-and-system-events
Re: Using Pen with U++ [message #56689 is a reply to message #56688] Sat, 03 April 2021 08:57 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
In general: I strongly believe that whatever model we choose in the end, it must not require changes in CtrlLib.

WRT to draglag, after reading MSDN docs, I have the impression that this is exactly what M$ wants to happen.

Anyway, a draglag related question - it is not quite clear to me whether the draglag which you experience is

a) drag starts late, after moving pen a bit, not immediately
b) drag has offset

(With XPPEN, with current model, drag just starts a little late, but position is correct)

Mirek
Re: Using Pen with U++ [message #56690 is a reply to message #56689] Sat, 03 April 2021 10:37 Go to previous messageGo to next message
Tom1
Messages: 1212
Registered: March 2007
Senior Contributor
mirek wrote on Sat, 03 April 2021 09:57
In general: I strongly believe that whatever model we choose in the end, it must not require changes in CtrlLib.

WRT to draglag, after reading MSDN docs, I have the impression that this is exactly what M$ wants to happen.

Anyway, a draglag related question - it is not quite clear to me whether the draglag which you experience is

a) drag starts late, after moving pen a bit, not immediately
b) drag has offset

(With XPPEN, with current model, drag just starts a little late, but position is correct)

Mirek


What I decided to call draglag is a), it starts 2 cm late on screen, but does not introduce any offset.

Now that I read your MSDN finding, I understand draglag is the decision lag for Windows Ink to figure out 'pen gestures'.

Quote:
What about other issues? I mean, does it work as mouse elsewhere?

In principle almost everything works. Draglag is the only serious problem.

Other related peculiarities (Windows pen gestures?):
- LeftHold translates to RightDown+RightUp
- While tap with barrel pressed tranlates to RightDown+RightUp, a drag with barrel becomes a left drag (=LeftDown+LeftDrag+MouseMoves+LeftUp).

Also, my Sketcher no longer works, but that should be fixable here as RectTracker works.

So, in my opinion, we should get rid of DragLag and hopefully Windows pen gestures too, and receive just the same event behavior as is available with a mouse. This way CtrlLib (and apps) would not require any changes to support pen, but with GetPenInfo() we could benefit from the pen. I would suggest that a pressed barrel would change pen down to RightDown and so on.

That would be the most natural experience for a user. If we want to emulate Right click with pen hold, we would map LeftHold to RightUp in our app.

Best regards,

Tom
Re: Using Pen with U++ [message #56691 is a reply to message #56690] Sat, 03 April 2021 11:14 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
What about

https://docs.microsoft.com/cs-cz/windows/win32/tablet/wm-tab let-querysystemgesturestatus-message

?

Especially the "press and hold" comment might be useful.
Re: Using Pen with U++ [message #56692 is a reply to message #56691] Sat, 03 April 2021 11:37 Go to previous messageGo to next message
Tom1
Messages: 1212
Registered: March 2007
Senior Contributor
Adding:
	case WM_TABLET_QUERYSYSTEMGESTURESTATUS:
			return TABLET_DISABLE_PRESSANDHOLD;


Removes the pen down/hold/up mapping to RightDown/RightUp and instead gives LeftDown/LeftUp. No LeftHold is generated during the prolonged pen-down though.

Unfortunately, this does not help at all with draglag.

Best regards,

Tom
Re: Using Pen with U++ [message #56693 is a reply to message #56692] Sat, 03 April 2021 15:52 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Tom1 wrote on Sat, 03 April 2021 11:37
Adding:
	case WM_TABLET_QUERYSYSTEMGESTURESTATUS:
			return TABLET_DISABLE_PRESSANDHOLD;


Removes the pen down/hold/up mapping to RightDown/RightUp and instead gives LeftDown/LeftUp. No LeftHold is generated during the prolonged pen-down though.

Unfortunately, this does not help at all with draglag.

Best regards,

Tom


Another thing we can try is to retain Pen method, but discard bool return value, always process with DefWindowProc. Create new RectTracker just for Pen...
Re: Using Pen with U++ [message #56694 is a reply to message #56693] Sat, 03 April 2021 16:02 Go to previous messageGo to next message
Tom1
Messages: 1212
Registered: March 2007
Senior Contributor
mirek wrote on Sat, 03 April 2021 16:52
Tom1 wrote on Sat, 03 April 2021 11:37
Adding:
	case WM_TABLET_QUERYSYSTEMGESTURESTATUS:
			return TABLET_DISABLE_PRESSANDHOLD;


Removes the pen down/hold/up mapping to RightDown/RightUp and instead gives LeftDown/LeftUp. No LeftHold is generated during the prolonged pen-down though.

Unfortunately, this does not help at all with draglag.

Best regards,

Tom


Another thing we can try is to retain Pen method, but discard bool return value, always process with DefWindowProc. Create new RectTracker just for Pen...


OK, let's see how it turns out. GetMessageExtraInfo() may be useful to classify events to application so that we can filter out already processed pen events and not do it again as if they are coming from the mouse.

Best regards,

Tom
Re: Using Pen with U++ [message #56695 is a reply to message #56694] Sat, 03 April 2021 16:05 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Tom1 wrote on Sat, 03 April 2021 16:02
mirek wrote on Sat, 03 April 2021 16:52
Tom1 wrote on Sat, 03 April 2021 11:37
Adding:
	case WM_TABLET_QUERYSYSTEMGESTURESTATUS:
			return TABLET_DISABLE_PRESSANDHOLD;


Removes the pen down/hold/up mapping to RightDown/RightUp and instead gives LeftDown/LeftUp. No LeftHold is generated during the prolonged pen-down though.

Unfortunately, this does not help at all with draglag.

Best regards,

Tom


Another thing we can try is to retain Pen method, but discard bool return value, always process with DefWindowProc. Create new RectTracker just for Pen...


OK, let's see how it turns out. GetMessageExtraInfo() may be useful to classify events to application so that we can filter out already processed pen events and not do it again as if they are coming from the mouse.


Exactly. Will you try that approach or should I do it? (I would prefer doing something else... Smile

Mirek
Re: Using Pen with U++ [message #56696 is a reply to message #56695] Sat, 03 April 2021 16:17 Go to previous messageGo to next message
Tom1
Messages: 1212
Registered: March 2007
Senior Contributor
OK, I'll try, but I'm afraid it may fall back to you eventually...

As for the RectTracker, I would prefer it is a single RectTracker capable of reacting to both pen and mouse, so that I do not need to create separate Sketchers for each.

Best regards,

Tom
Re: Using Pen with U++ [message #56698 is a reply to message #56696] Sat, 03 April 2021 17:28 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Tom1 wrote on Sat, 03 April 2021 16:17
OK, I'll try, but I'm afraid it may fall back to you eventually...

As for the RectTracker, I would prefer it is a single RectTracker capable of reacting to both pen and mouse, so that I do not need to create separate Sketchers for each.

Best regards,

Tom


I can live with that.
Re: Using Pen with U++ [message #56701 is a reply to message #56698] Sat, 03 April 2021 22:57 Go to previous messageGo to next message
Tom1
Messages: 1212
Registered: March 2007
Senior Contributor
Hi Mirek,

Please find attached the changed CtrlCore files. Everything works now.

The widget specific pen support works on Pen() interface now. Returning true from Pen() avoids duplicates on mouse interface, (such as MouseMove(), LeftDown(), etc...) for pen events.

RectTracker works now with both mouse and pen.

There is also duplicate coordinate skipping optimization on pen history events.

Please test and merge.

Best regards,

Tom
  • Attachment: CtrlCore.7z
    (Size: 24.74KB, Downloaded 83 times)
Re: Using Pen with U++ [message #56709 is a reply to message #56701] Sun, 04 April 2021 18:55 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Looks good (and applied), except "supports_pen". The problem I see is that we are not quite sure IMO that the current mouse message is translated pen message that has set it to true. Plus the only thing it seems to do is to prevent the final dispatch of event to Ctrl - you can do that as well in the client code IMO.

Plus, it seems to fix the pointer image to Arrow (no CursorImage), which can be a problem too...

IMO I would try to get rid of it. If not possible, lets us be upfront and just make it Ctrl flag (not Pen return value).

Mirek
Re: Using Pen with U++ [message #56711 is a reply to message #56709] Sun, 04 April 2021 20:35 Go to previous messageGo to next message
Tom1
Messages: 1212
Registered: March 2007
Senior Contributor
Hi Mirek,

Thanks for accepting the changes.

It was a stupid mistake of me to use Image::Arrow() instead of CursorImage(). It should be in CtrlMouse.cpp(145) like:
	if(supports_pen && is_pen_event) return CursorImage(p, keyflags); // Avoid duplicated pen events

Although, after returning from every other event except 'case CURSORIMAGE:' in 'Image Ctrl::MouseEvent()' causes returning Image::Arrow()...

Without 'supports_pen' it would become a tedious battle in client code to avoid various pen originated duplicate mouse events, so I rather block them just before. Anyway, making 'bool supports_pen;' a configurable flag in Ctrl:: in CtrlCore.h is fine with me:
	Ctrl&   EnablePenSupport(bool b = true)                   { supports_pen = b; return *this; }

Then, to avoid Pen() return value assignment in Win32Proc.cpp(147), we should remove 'supports_pen =' and have just:
				q->Pen(p, pen, GetMouseFlags());


This works here. (I will of course add 'EnablePenSupport();' to constructors of Pen() enabled widgets.)

This includes RectTracker::RectTracker() in LocalLoop.cpp:
RectTracker::RectTracker(Ctrl& master)
{
	EnablePenSupport();


Best regards,

Tom

[Updated on: Sun, 04 April 2021 20:40]

Report message to a moderator

Re: Using Pen with U++ [message #56712 is a reply to message #56711] Sun, 04 April 2021 20:42 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Tom1 wrote on Sun, 04 April 2021 20:35
Hi Mirek,

Thanks for accepting the changes.

It was a stupid mistake of me to use Image::Arrow() instead of CursorImage(). It should be in CtrlMouse.cpp(145) like:
	if(supports_pen && is_pen_event) return CursorImage(p, keyflags); // Avoid duplicated pen events

Without 'supports_pen' it would become a tedious battle in client code to avoid various pen originated duplicate mouse events, so I rather block them just before. Anyway, making 'bool supports_pen;' a configurable flag in Ctrl:: in CtrlCore.h is fine with me:



I understand that, but would that be really that hard? Esp. now that we have K_PEN?

Quote:

	Ctrl&   EnablePenSupport(bool b = true)                   { supports_pen = b; return *this; }

Then, to avoid Pen() return value assignment in Win32Proc.cpp(147), we should remove 'supports_pen =' and have just:
				q->Pen(p, pen, GetMouseFlags());


This works here. (I will of course add 'EnablePenSupport();' to constructors of Pen() enabled widgets.)

This includes RectTracker::RectTracker() in LocalLoop.cpp:
RectTracker::RectTracker(Ctrl& master)
{
	EnablePenSupport();


Best regards,

Tom


Actually, maybe you could rather not call EnablePenSupport in RectTracker contructor and leave that to client code?

But then, should not that prevent call of Pen virtual method too?

BTW, given what it does, should not that rather be called "DiasbleMouse"? Smile

Mirek
Re: Using Pen with U++ [message #56713 is a reply to message #56712] Sun, 04 April 2021 22:02 Go to previous messageGo to previous message
Tom1
Messages: 1212
Registered: March 2007
Senior Contributor
I agree that 'EnablePenSupport' is a bad name for it. 'DisableMouse' is not any better. In fact it should be something like 'DisableEmulatedMouseEventsForPen'.

But, as practically always, you are right: I can do everything related to 'supports_pen' flag at client side. I just add this to my Pen enabled widget:
	virtual Image MouseEvent(int event, Point p, int zdelta, dword keyflags) override {
		if(keyflags&K_PEN) return CursorImage(p, keyflags);
		return Ctrl::MouseEvent(event, p, zdelta, keyflags);
	}

In this case, I would drop everything in CtrlCore having something to do with 'supports_pen'.

So the last question is: Do you really want to get rid of 'supports_pen' flag? Both ways are fine with me.

Best regards,

Tom
Previous Topic: WString vs Grapheme Cluster idea (with possible flaw)
Next Topic: .gitignore
Goto Forum:
  


Current Time: Tue Apr 23 23:23:44 CEST 2024

Total time taken to generate the page: 0.02998 seconds