コード例 #1
0
ファイル: quartzWindow.cpp プロジェクト: ardeujho/self
void QuartzWindow::warp_pointer(int x, int y) {
  // lprintf("warping to: %d, %d\n", x, y);
# if TARGET_OS_VERSION == MACOSX_VERSION
    CGPoint pt;
    pt.x = x;
    pt.y = y;
    const int n = 16;
    CGDisplayCount count = 0;
    CGDirectDisplayID dspys[n];
    CGDisplayErr err = CGGetDisplaysWithPoint( pt, n, dspys, &count);
    if (err != noErr) {
      lprintf("CGGetDisplaysWithPoint failed: %d\n", err);
      return;
    }
    // lprintf("CGGetDisplaysWithPoint count = %d\n", count);
    for (int i = 0;  i < count;  ++i) {
      // MUST adj pt to be relative to TL of display -- dmu 5/03
      CGRect bounds = CGDisplayBounds(dspys[i]);
      CGPoint adjusted_pt;
      adjusted_pt.x = pt.x - bounds.origin.x;
      adjusted_pt.y = pt.y - bounds.origin.y;
      err = CGDisplayMoveCursorToPoint( dspys[i], adjusted_pt);
      // lprintf("CGDisplayMoveCursorToPoint %d returned %d\n", i, err);
    }
# else
  Unused(x); Unused(y);
# endif
}
コード例 #2
0
ファイル: macosx_window.c プロジェクト: mikanradojevic/sdkpub
void _glfwMacFSSetMouseCursorPos( int x, int y )
{
    // TO DO: play with event suppression interval.  Ugh.
    // TO DO: what if we fail here?
    (void)CGDisplayMoveCursorToPoint( kCGDirectMainDisplay,
                                      CGPointMake( x, y ) );
}
コード例 #3
0
ファイル: main.cpp プロジェクト: revmischa/leapmouse
void MouseController::onFrame(const Leap::Controller &controller) {
    // get list of detected screens
    const Leap::ScreenList screens = controller.calibratedScreens();
    
    // make sure we have a detected screen
    if (screens.empty()) return;
    const Leap::Screen screen = screens[0];
    
    // find the first finger or tool
    const Leap::Frame frame = controller.frame();
    const Leap::HandList hands = frame.hands();
    if (hands.empty()) return;
    const Leap::PointableList pointables = hands[0].pointables();
    if (pointables.empty()) return;
    const Leap::Pointable firstPointable = pointables[0];
    
    // get x, y coordinates on the first screen
    const Leap::Vector intersection = screen.intersect(
                                                       firstPointable,
                                                       true,  // normalize
                                                       1.0f   // clampRatio
                                                       );
    
    // if the user is not pointing at the screen all components of
    // the returned vector will be Not A Number (NaN)
    // isValid() returns true only if all components are finite
    if (! intersection.isValid()) return;
    
    unsigned int x = screen.widthPixels() * intersection.x;
    // flip y coordinate to standard top-left origin
    unsigned int y = screen.heightPixels() * (1.0f - intersection.y);
    
    CGPoint destPoint = CGPointMake(x, y);
    CGDisplayMoveCursorToPoint(kCGDirectMainDisplay, destPoint);
}
コード例 #4
0
ファイル: input.cpp プロジェクト: ElementalSpork/Moviesandbox
void Input::confineMouse(){

    if (!bWarpMouse)
        return;

#ifdef TARGET_WIN32
    glutWarpPointer(renderer->windowX/2,renderer->windowY/2);
#endif

#ifdef TARGET_LINUX
    glutWarpPointer(renderer->windowX/2,renderer->windowY/2);
#endif

#ifdef TARGET_MACOSX
	CGPoint myPoint;
	    int centerX=renderer->windowX/2;
	    int centerY=renderer->windowY/2;
	myPoint.x=centerX+renderer->windowPosX;
	myPoint.y=centerY+renderer->windowPosY;
	CGDisplayMoveCursorToPoint( CGMainDisplayID (),myPoint);
#endif

	mouseX=renderer->windowX/2;
	mouseY=renderer->windowY/2;

}
コード例 #5
0
ファイル: macosx_window.c プロジェクト: x-y-z/SteerSuite-CUDA
void _glfwMacDWSetMouseCursorPos( int x, int y )
{
    Rect content;
    GetWindowBounds(_glfwWin.MacWindow, kWindowContentRgn, &content);

    _glfwInput.MousePosX = x + content.left;
    _glfwInput.MousePosY = y + content.top;

    CGDisplayMoveCursorToPoint( kCGDirectMainDisplay,
			        CGPointMake( _glfwInput.MousePosX,
					     _glfwInput.MousePosY ) );
}
コード例 #6
0
ファイル: carbon_window.c プロジェクト: chrisinajar/node-ogl
void _glfwPlatformSetMouseCursorPos( int x, int y )
{
    Rect content;

    if( _glfwWin.fullscreen )
    {
        CGDisplayMoveCursorToPoint( kCGDirectMainDisplay,
                                    CGPointMake( x, y ) );
    }
    else
    {
        GetWindowBounds(_glfwWin.window, kWindowContentRgn, &content);

        _glfwInput.MousePosX = x + content.left;
        _glfwInput.MousePosY = y + content.top;

        CGDisplayMoveCursorToPoint( kCGDirectMainDisplay,
                                    CGPointMake( _glfwInput.MousePosX,
                                                _glfwInput.MousePosY ) );
    }
}
コード例 #7
0
ファイル: macdriver_console.c プロジェクト: digarok/gsplus
void mac_warp_mouse()      {
#ifndef ACTIVEGS
  Rect port_rect;
  Point win_origin_pt;
  CGPoint cgpoint;
  CGDisplayErr cg_err;

  GetPortBounds(GetWindowPort(g_main_window), &port_rect);
  SetPt(&win_origin_pt, port_rect.left, port_rect.top);
  LocalToGlobal(&win_origin_pt);

  cgpoint = CGPointMake( (float)(win_origin_pt.h + X_A2_WINDOW_WIDTH/2),
                         (float)(win_origin_pt.v + X_A2_WINDOW_HEIGHT/2));
  cg_err = CGDisplayMoveCursorToPoint(kCGDirectMainDisplay, cgpoint);
#endif
}
コード例 #8
0
FREObject setCursorPos(FREContext ctx, void* funcData, uint32_t argc, FREObject argv[])
{
    int tx = 0;
    int ty = 0;
    FREGetObjectAsInt32(argv[0], &tx);
    FREGetObjectAsInt32(argv[1], &ty);

    //as3Print("Set cursor pos \n");//,tx,ty);

    CGPoint point;
    point.x = tx;
    point.y = ty;

    CGAssociateMouseAndMouseCursorPosition(true);
    
    //CGWarpMouseCursorPosition(point);
   // printf("Error : %i\n",error);
    CGDisplayMoveCursorToPoint(CGMainDisplayID(),point);

    CGAssociateMouseAndMouseCursorPosition(true);
    CGEventRef mouse = CGEventCreateMouseEvent (NULL, kCGEventMouseMoved, CGPointMake(tx, ty),0);
    CGEventPost(kCGHIDEventTap, mouse);
    CFRelease(mouse);
    
    
    CGEventRef event = CGEventCreate(NULL);
    CGPoint cursorGet = CGEventGetLocation(event);
    CFRelease(event);
    
    
    
    char msg[256];
    sprintf(msg,"After set, check pos %f %f\n",cursorGet.x, cursorGet.y);
    //as3Print(msg);
    
    FREObject result;
    FRENewObjectFromBool(1, &result);
    //FRENewObjectFromBool(true,&result);
    return result;
}
コード例 #9
0
ファイル: macosx_window.c プロジェクト: x-y-z/SteerSuite-CUDA
void _glfwMacFSSetMouseCursorPos( int x, int y )
{
    // TO DO: what if we fail here?
    CGDisplayMoveCursorToPoint( kCGDirectMainDisplay,
                                CGPointMake( x, y ) );
}
コード例 #10
0
ファイル: quartzPrims.cpp プロジェクト: AaronNGray/self
CGDisplayErr CGDisplayMoveCursorToPoint_wrap(CGDirectDisplayID d, float x, float y) {
  return CGDisplayMoveCursorToPoint(d, CGPointMake(x, y));
}