nicarran / jpen

Java library for accessing pen/digitizer tablets and pointing devices
43 stars 17 forks source link

PLevel X and Y are integer pixels ? #3

Closed Ant01n3 closed 7 years ago

Ant01n3 commented 7 years ago

Hello,

First, thank you for this really great job.

However I did not found an answer to the following question. I am using macOS X. PLevel coordinates X and Y are integer pixels (although the values are floats). Is it the normal behavior ? Is it possible to have fractional values ? I imagine the tablet should be far more precise ?

(By the way, to complicate things, I am using a custom PenOwner and PenClip as I am using Newt and Jogl, I found examples of this on the forum, could the problem come from this ?).

Thanks a lot

Ant01n3 commented 7 years ago

I think I have the start of an answer, trying JPen under windows, I effectively have fractional pixels.

Ant01n3 commented 7 years ago

Using this git repository, as it can now be built on macOS, all works as expected. Thanks :)

Ant01n3 commented 7 years ago

Too fast, still integer pixels on macOS...

nicarran commented 7 years ago

Hello Antoine,

I don't have macOS but I can try to help collecting some info. Do you get integer pixels (X,Y) when running the "JPen Demo" (java -Djava.library.path="." -jar jpen-2.jar) ? Please copy/paste here the "JPen Status Report" given by the "JPen Demo" ("Status Report..." button).

Cheers, Nicolas

Ant01n3 commented 7 years ago

Thanks for your response,

Yes the demo also displays integer pixels (sometimes X.004 or X.997 but globally no values in between). The windows version does provide fractional values, however I was not able to build it (maven fails when linking the native part) and I use the binary available on sourceforge. I have not yet tested it with Linux but I intend to do it as soon as I can.

Do not hesitate if you want me to do tests on the mac platform.

Cheers, Antoine

===== JPen - Status Report ===== JPen Version: 2-150301 Date: Tue Jan 10 19:33:07 CET 2017 Providers: Constructor: JPen Construction Exception: none Device: Emulation (Emulation@JPen) Enabled: true Kind: (type=IGNORE) Fractional Movements: true Constructor: Cocoa Construction Exception: none Native Version-Build(Expected): 3-201(201) Device: Cocoa Cursor (Cocoa Cursor@Cocoa) Enabled: true Kind: (type=CURSOR) Fractional Movements: true Device: Cocoa Stylus (Cocoa Stylus@Cocoa) Enabled: true Kind: (type=STYLUS) Fractional Movements: true Device: Cocoa Eraser (Cocoa Eraser@Cocoa) Enabled: true Kind: (type=ERASER) Fractional Movements: true Device: UNKNOWN (UNKNOWN@Cocoa) Enabled: true Kind: (type=IGNORE) Fractional Movements: true Constructor: System Construction Exception: none Device (System Mouse): Mouse (Mouse@System) Enabled: true Kind: (type=CURSOR) Fractional Movements: false Device: Keyboard (Keyboard@System) Enabled: true Kind: (type=IGNORE) Fractional Movements: false System Properties: awt.toolkit: sun.lwawt.macosx.LWCToolkit file.encoding: UTF-8 file.encoding.pkg: sun.io file.separator: / ftp.nonProxyHosts: local|.local|169.254/16|.169.254/16 gopherProxySet: false http.nonProxyHosts: local|.local|169.254/16|.169.254/16 java.awt.graphicsenv: sun.awt.CGraphicsEnvironment java.awt.printerjob: sun.lwawt.macosx.CPrinterJob java.class.path: jpen-2.jar java.class.version: 52.0 java.endorsed.dirs: /Library/Java/JavaVirtualMachines/jdk1.8.0_112.jdk/Contents/Home/jre/lib/endorsed java.ext.dirs: /Users/antoine/Library/Java/Extensions:/Library/Java/JavaVirtualMachines/jdk1.8.0_112.jdk/Contents/Home/jre/lib/ext:/Library/Java/Extensions:/Network/Library/Java/Extensions:/System/Library/Java/Extensions:/usr/lib/java java.home: /Library/Java/JavaVirtualMachines/jdk1.8.0_112.jdk/Contents/Home/jre java.library.path: . java.runtime.name: Java(TM) SE Runtime Environment java.runtime.version: 1.8.0_112-b16 java.specification.name: Java Platform API Specification java.specification.vendor: Oracle Corporation java.specification.version: 1.8 java.vendor: Oracle Corporation java.vendor.url: http://java.oracle.com/ java.vendor.url.bug: http://bugreport.sun.com/bugreport/ java.version: 1.8.0_112 java.vm.info: mixed mode java.vm.name: Java HotSpot(TM) 64-Bit Server VM java.vm.specification.name: Java Virtual Machine Specification java.vm.specification.vendor: Oracle Corporation java.vm.specification.version: 1.8 java.vm.vendor: Oracle Corporation java.vm.version: 25.112-b16 os.arch: x86_64 os.name: Mac OS X os.version: 10.12.1 path.separator: : socksNonProxyHosts: local|.local|169.254/16|.169.254/16 sun.arch.data.model: 64 sun.awt.enableExtraMouseButtons: true sun.boot.class.path: /Library/Java/JavaVirtualMachines/jdk1.8.0_112.jdk/Contents/Home/jre/lib/resources.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_112.jdk/Contents/Home/jre/lib/rt.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_112.jdk/Contents/Home/jre/lib/sunrsasign.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_112.jdk/Contents/Home/jre/lib/jsse.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_112.jdk/Contents/Home/jre/lib/jce.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_112.jdk/Contents/Home/jre/lib/charsets.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_112.jdk/Contents/Home/jre/lib/jfr.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_112.jdk/Contents/Home/jre/classes sun.boot.library.path: /Library/Java/JavaVirtualMachines/jdk1.8.0_112.jdk/Contents/Home/jre/lib sun.cpu.endian: little sun.cpu.isalist: sun.font.fontmanager: sun.font.CFontManager sun.io.unicode.encoding: UnicodeBig sun.java.command: jpen-2.jar sun.java.launcher: SUN_STANDARD sun.jnu.encoding: UTF-8 sun.management.compiler: HotSpot 64-Bit Tiered Compilers sun.os.patch.level: unknown user.country: FR user.language: fr user.timezone: Europe/Paris ===== ===== =====

nicarran commented 7 years ago

are you using the pen (stylus)? is it in pen mode where the position on the tablet maps directly to a position on the display (not mouse mode)? are you getting pressure fractional values?

Ant01n3 commented 7 years ago

Yes, using the stylus, in pen mode (absolute positionning ?). Pressure is correct going between 0 and 1, as well as tilt information. Rotation is always zero though.

nicarran commented 7 years ago

Let's see if the cocoa provider is receiving fractional values. Please insert:

System.out.println("screenX=" + screenX + " , pressure=" + pressure);

on line 313 of src/main/java/jpen/provider/osx/CocoaAccess.java then compile/package and see if you get fractional values for screenX and pressure on the standard output stream while playing with the "JPen Demo". Thank you!

edgar79 commented 7 years ago

Salut,

I tried to debug this on macOS 10.12 and the native code seems not to be doing any arithmetics which could result in this. I inserted

printf("locationInWindow :x=%1f y=%2f \n",[event locationInWindow].x, [event locationInWindow].y); printf("mouseLocation: x=%1f y=%2f \n",[NSEvent mouseLocation].x,[NSEvent mouseLocation].y);

in osx_push_provider.m, _sendEvent, case NSTabletPoint (don't find the line number in xcode ;) and locationInWindow as well as mouseLocation are giving the values at x.00000 nearly constantly - with a small fractional part added or subtracted depending on the direction from time to time, most often when I did not touch the tablet with the pen. So this data is coming with the NSEvent itself. (Just like the rotation bug, where the event always gives values of zero)

As I already contacted developer.wacom.com the solution for the rotation bug could eventually help to solve this too. I just tested this with the given sample code project I used to test rotation and it behaves the same - so I could ask about that too (when I got an answer).

edgar79 commented 7 years ago

Forgot to mention: Yesterday I tested this with Linux and there it is ok.

Ant01n3 commented 7 years ago

I just tried to insert the code of Nicolas and got lot of values "near" integers but also some fractional values ??? Here is an example :

screenX=709.34766 , pressure=0.9452659 screenX=709.6914 , pressure=0.9491722 screenX=709.8906 , pressure=0.95063704 screenX=709.97656 , pressure=0.9540551 screenX=709.97656 , pressure=0.95600826 screenX=709.97656 , pressure=0.95844966 screenX=709.97656 , pressure=0.9608911 screenX=709.97656 , pressure=0.9633326 screenX=709.83203 , pressure=0.96479744 screenX=709.60547 , pressure=0.9662623 screenX=709.40234 , pressure=0.96675056 screenX=709.1758 , pressure=0.96821547

Ant01n3 commented 7 years ago

Ok, I made my previous test on a retina screen. On my desktop screen I get integer pixels :

screenX=218.0039 , pressure=0.0 screenX=220.0039 , pressure=0.0 screenX=220.0039 , pressure=0.13725491 screenX=220.0039 , pressure=0.14459449 screenX=221.0039 , pressure=0.14901961 screenX=221.0 , pressure=0.23529412 screenX=221.0 , pressure=0.27058825

edgar79 commented 7 years ago

Ah, yes. The last looks like the results I had on an iMac (without retina screen), but during one test I had values that seem to contain correct (at least multiple) fractional values on that Mac too. I repeated the tests, but everything I tried looked according to your last post. So I will consider the difference between retina or not.

Cheers, Hannes

edgar79 commented 7 years ago

I didn't test this with a retina display yet, but I see there is a value repeated over several lines... Do you get repeatedly same values when you move the pen (or did you hold your hand still?) or does the fractional part seem to be ok when you move slowly on the machine with the retina display? (Looking on your first example I had the impression it could be ok on the retina machine?)

Ant01n3 commented 7 years ago

I tried to move slowly, but my hypothesis on retina screens was that the system presents half the pixels than the screen really has (logical vs. real pixels ?). Therefore fractional values would come from the real pixels ?? This would explain we have only very few values between integers ?? So I don't think it's ok on retina, since on windows I get far more precision (and I imagine on Linux also).

edgar79 commented 7 years ago

I just tested this on a macbook with retina display, macOS 10.12.1 with the Demo and I didn't got fractional values... just like on the other mac (most often x.000 ) But If I used the TouchPad I got fractional values... I found that there was a new driver version from 1/4/2017 but that didn't change it. So I wondered if there are any other differences (between the retina machines)... In the status report you posted os.version is 10.12.1. Is this the same on your retina machine? And which driver version are you using on the retina machine?

Ant01n3 commented 7 years ago

You are right. The two machines I have are both using macOS 10.12.1, however on the old non retina machine I have a 6.3.11-3 driver version. On the new retina machine I have the 6.3.17-5.

The non retina always produce integer values. The retina one indeed produce more values in between, even with the mouse or touchpad, and both when the demo is launched on the retina screen and to my great surprise on my desktop low-resolution screen (where each logical pixel = one real pixel).

On the retina mac but connected only to a non retina screen : screenX=290.26172 , pressure=0.86955065 screenX=285.82422 , pressure=0.88029295 screenX=279.59766 , pressure=0.88224614 screenX=271.57812 , pressure=0.88566417 screenX=262.1328 , pressure=0.8881056 screenX=252.17969 , pressure=0.8895705 screenX=242.30469 , pressure=0.89445335 screenX=232.9961 , pressure=0.8890822

Now I will try to upgrade the driver on the old machine... :)

Ant01n3 commented 7 years ago

I installed 6.3.20-4 on the non retina mac. Values are still integers indeed, with the tablet, with the mouse, but not with the touchpad which reports fractional values.

edgar79 commented 7 years ago

Just tested it successfully [on the non-retina mac] using driver version 6.3.17-5 found on http://support.wacom.asia/en/tablet-drivers

Tested it additionally in precision mode and the fractional part seems to be ok (but not triggering that much events so the steps seem to be larger...)

Rotation (with Art Pen) still stays at 0° with this driver.

Thanks!

Ant01n3 commented 7 years ago

I don't understand, you say you get fractional pixels on non retina mac ? I was unable to achieve this even with the new 6.3.20 driver.

What is precision mode ?

edgar79 commented 7 years ago

I was looking for a difference between the retina machines we where using and you wrote you are using driver version 6.3.17-5 on that machine while i was (at last) testing with 3.6.20-4 so I now just tested installing the driver 6.3.17-5 on the non retina mac (probably it doesn't depend on retina or not but on driver version / os version)

I'm using Intuos4 where "precision mode" is default on a button, but I guess it is a driver feature which you could set to a pen button or via menu (in the Tablet System Settings). It displays a small frame on the screen and the complete tablet is projected into this frame. This way you could use the tablet relatively with higher resolution on screen.

edgar79 commented 7 years ago

(while the change behind the API might have something to do with retina displays and logical / real pixels etc.)

Ant01n3 commented 7 years ago

Ok, but you seem to have fractional pixel, I dont have them, neither with 6.3.17 or 6.3.20 on my old non retina mac. So I am puzzled.

edgar79 commented 7 years ago

Hmmm... did you remove the driver completely (using the Wacom utility) before downgrading the driver? (I'm puzzled too now.)

Ant01n3 commented 7 years ago

Ah ah it's complicated, my new retina mac is still at 6.3.17. The old one was at 6.3.11, so I upgraded it, passing at 6.3.20 (ho, too many numbers !!! :)) But I will try now to downgrade to 6.3.17 and see !

Ant01n3 commented 7 years ago

Ok ! the 6.3.17 sends fractional pixels :) What is puzzling now is that the 6.3.20 did not ! But by the way, it seems it is not a JPen problem.

Thanks !

edgar79 commented 7 years ago

Thank you too!