CORTES12 / wjoy

Automatically exported from code.google.com/p/wjoy
0 stars 0 forks source link

non-relative pointer is losing resolution somewhere between setPosition and the pointer position #60

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
I've implemented the uDraw extension (which I'll submit a patch for as soon as 
I'm happy with it).

When creating a virtual mouse with a non-relative pointer, I seem to be getting 
jumpiness in the mouse, as if the position I'm setting is getting 
truncated/rounded.

Do you happen to have any idea what might be truncating the positional values?  
I've run logging and the values in the NSPoint seem fine.

-Michael

Original issue reported on code.google.com by mikep...@gmail.com on 5 Oct 2014 at 6:46

GoogleCodeExporter commented 8 years ago
Hmm... Sorry, i don't know, why it's happens. May be you post code here or to 
my e-mail? Maybe i'll find something.

Original comment by alexandr.serkov on 5 Oct 2014 at 11:00

GoogleCodeExporter commented 8 years ago
I've distilled the problem down away from my hardware into the following:

See below or attached.

@implementation AppDelegate

- (void)updatePosition {
    NSPoint newPosition = NSZeroPoint;

    //Divide just to keep the mouse near the center of the screen.
    newPosition.x = sin(progress)/4.0f;
    newPosition.y = cos(progress)/4.0f;

    NSLog(@"%0.4f, %0.4f", newPosition.x, newPosition.y);

    [m_MouseState setPointer:0
     position:newPosition];

     progress += .01;
}

- (void)VHIDDevice:(VHIDDevice*)device stateChanged:(NSData*)state {
    [m_VirtualMouse updateHIDState:state];
}

- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
    // Insert code here to initialize your application

    m_MouseState = [[VHIDDevice alloc] initWithType:VHIDDeviceTypeMouse pointerCount:1 buttonCount:2 isRelative:false];

    m_VirtualMouse  = [[WJoyDevice alloc] initWithHIDDescriptor:[m_MouseState descriptor]
                                                  productString:@"Virtual Alxn1 Mouse"];

    [m_MouseState setDelegate:self];

    progress = 0.0f;

    updateTimer = [NSTimer scheduledTimerWithTimeInterval:.1 target:self selector:@selector(updatePosition) userInfo:nil repeats:true];
}

Original comment by mikep...@gmail.com on 5 Oct 2014 at 3:03

Attachments:

GoogleCodeExporter commented 8 years ago
I think, problem in that: real mouse doesn't send direct coordinates, only 
relative. And this coordinates is are not in pixels, but in some 
mouse-dependent units. Mouse driver receiving this relative offsets from one 
mouse position to other, and translate this units to pixels on screen. This 
translation based on time, in that this coordinates changed, and on mouse and 
screen dpi. My VHIDDevice doesn't send any information about dpi, and apple 
mouse driver use standart value (i think, 400, but may be it's wrong).

If you want use VHID framework for mouse emulation, you need to be consider 
time and emulated dpi, i think.

And you can look on new VHID2 framework (experimental/VHID2). I refactor it 
today to framework and test application, and new version of WJoy will use it. 
New API is simpler, and it can't create mouse device with non-relative pointer 
coordinates. In current VHID version this is mistake in architecture. :)

Original comment by alexandr.serkov on 6 Oct 2014 at 8:56

GoogleCodeExporter commented 8 years ago
That's sad to hear that this is being decommissioned.  If that's the direction 
you are going, I'll look into alternative options for non-relative pointers for 
tablets such as the uDraw, as they are absolute coordinate devices.

Thank you for all of your help so far; this week I'll take a look at the 
internals of your VHID before looking elsewhere to see if I can rectify the 
current version.

Original comment by mikep...@gmail.com on 6 Oct 2014 at 3:44

GoogleCodeExporter commented 8 years ago
I think, you can use this method for set mouse cursor position: 
http://stackoverflow.com/questions/10255995/how-can-i-set-the-mouse-position

I didn't test it, but it's looks like something appropriate.

Original comment by alexandr.serkov on 6 Oct 2014 at 3:57

GoogleCodeExporter commented 8 years ago
Sorry; I meant to respond with the uDraw extension.

Its not complete, but works for my purposes.  Feel free to incorporate it if 
you see fit.

Original comment by mikep...@gmail.com on 7 Oct 2014 at 8:23

Attachments:

GoogleCodeExporter commented 8 years ago
Big thanks for code!

Can i reformat/rewrite your code to support all uDraw abilities? And, if i do 
it, can you test it? If you can it, i'll be happy :)

I can't do it immediately, but i will try do it as quick as possible. :)  And 
may be i will find way to publish uDraw as pointing device in system.

Original comment by alexandr.serkov on 8 Oct 2014 at 6:28

GoogleCodeExporter commented 8 years ago
 TODO: uDraw protocol: http://www.brandonw.net/udraw/

Original comment by alexandr.serkov on 8 Oct 2014 at 6:28

GoogleCodeExporter commented 8 years ago
Of course, let me know how I can help.

Original comment by mikep...@gmail.com on 8 Oct 2014 at 8:14

GoogleCodeExporter commented 8 years ago
Hello, Mike!

I done integration of uDraw support in Wiimote framework, but i haven't this 
device. Can you update code from cvs and test Wiimote.framework? Works it with 
uDraw or not?

PS: Code for setting mouse cursor position:

- (void)setMousePosition:(NSPoint)position
{
    CGEventRef event = NULL;

    position.y = [[NSScreen mainScreen] frame].size.height - position.y - 1.0f; // may be -1 needed here, may be not :)
    event      = CGEventCreateMouseEvent(NULL, kCGEventMouseMoved, position, 0);

    CGEventPost(kCGSessionEventTap, event);
    CFRelease(event);
}

It's really work.

Original comment by alexandr.serkov on 11 Oct 2014 at 6:10

GoogleCodeExporter commented 8 years ago
Ops... from svn :)

Original comment by alexandr.serkov on 11 Oct 2014 at 6:11

GoogleCodeExporter commented 8 years ago
Cool, I'm out of town for a few days but I'll check it out in a few days when I 
get back,  I hope my changes were helpful.

Original comment by mikep...@gmail.com on 11 Oct 2014 at 9:12