Example #1
0
static void DIB_GenerateMouseMotionEvent(void)
{
	extern int mouse_relative;
	extern int posted;

	POINT mouse;
	GetCursorPos( &mouse );

	if ( mouse_relative ) {
		POINT center;
		center.x = (SDL_VideoSurface->w/2);
		center.y = (SDL_VideoSurface->h/2);
		ClientToScreen(SDL_Window, &center);

		mouse.x -= (Sint16)center.x;
		mouse.y -= (Sint16)center.y;
		if ( mouse.x || mouse.y ) {
			SetCursorPos(center.x, center.y);
			posted = SDL_PrivateMouseMotion(0, 1, mouse.x, mouse.y);
		}
	} else if ( SDL_GetAppState() & SDL_APPMOUSEFOCUS ) {
		ScreenToClient(SDL_Window, &mouse);
#ifdef _WIN32_WCE
		if (SDL_VideoSurface)
			GapiTransform(this->hidden->userOrientation, this->hidden->hiresFix, &mouse.x, &mouse.y);
#endif
		posted = SDL_PrivateMouseMotion(0, 0, mouse.x, mouse.y);
	}
}
Example #2
0
/**
 * Kludge a mouse event by taking advantage of unprotected global funcs 
 *
 * \param ev An analog joystick event
 */
void fakemouse_event(SDL_Event ev) {
	int x, y;

	SDL_GetMouseState (&x, &y);

	switch (ev.type) {
		case SDL_JOYAXISMOTION:
			if ((ev.jaxis.value > -JOY_DEADZONE) && (ev.jaxis.value < JOY_DEADZONE))
				return;
			switch (ev.jaxis.axis) {
				case 0:         
					SDL_PrivateMouseMotion(0, 1, ev.jaxis.value / 1024, 0);
					break;
				case 1:         
					SDL_PrivateMouseMotion(0, 1, 0, ev.jaxis.value / 1024);
					break;
			}
			break;

		case SDL_JOYBUTTONUP:
			SDL_PrivateMouseButton(SDL_RELEASED, 1, x, y);
			break;

		case SDL_JOYBUTTONDOWN:
			SDL_PrivateMouseButton(SDL_PRESSED, 1, x, y);
			break;
	}
}
static void DIB_GenerateMouseMotionEvent(_THIS)
{
	extern int mouse_relative;
	extern int posted;

	POINT mouse;
#ifdef _WIN32_WCE
	if ( !GetCursorPos(&mouse) && !GetLastStylusPos(&mouse) ) return;
#else
	if ( !GetCursorPos(&mouse) ) return;
#endif

	if ( mouse_relative ) {
		POINT center;
		center.x = (SDL_VideoSurface->w/2);
		center.y = (SDL_VideoSurface->h/2);
		ClientToScreen(SDL_Window, &center);

		mouse.x -= center.x;
		mouse.y -= center.y;
		if ( mouse.x || mouse.y ) {
			SetCursorPos(center.x, center.y);
			posted = SDL_PrivateMouseMotion(0, 1, (Sint16)mouse.x, (Sint16)mouse.y);
		}
	} else {
		ScreenToClient(SDL_Window, &mouse);
#ifdef SDL_VIDEO_DRIVER_GAPI
       if (SDL_VideoSurface && this->hidden->gapiInfo)
			GapiTransform(this->hidden->gapiInfo, &mouse.x, &mouse.y);
#endif
		posted = SDL_PrivateMouseMotion(0, 0, (Sint16)mouse.x, (Sint16)mouse.y);
	}
}
Example #4
0
static __inline__ int X11_WarpedMotion(_THIS, XEvent *xevent)
{
	int w, h, i;
	int deltax, deltay;
	int posted;

	w = SDL_VideoSurface->w;
	h = SDL_VideoSurface->h;
	deltax = xevent->xmotion.x - mouse_last.x;
	deltay = xevent->xmotion.y - mouse_last.y;
#ifdef DEBUG_MOTION
  printf("Warped mouse motion: %d,%d\n", deltax, deltay);
#endif
	mouse_last.x = xevent->xmotion.x;
	mouse_last.y = xevent->xmotion.y;
	posted = SDL_PrivateMouseMotion(0, 1, deltax, deltay);

	if ( (xevent->xmotion.x < MOUSE_FUDGE_FACTOR) ||
	     (xevent->xmotion.x > (w-MOUSE_FUDGE_FACTOR)) ||
	     (xevent->xmotion.y < MOUSE_FUDGE_FACTOR) ||
	     (xevent->xmotion.y > (h-MOUSE_FUDGE_FACTOR)) ) {
		/* Get the events that have accumulated */
		while ( XCheckTypedEvent(SDL_Display, MotionNotify, xevent) ) {
			deltax = xevent->xmotion.x - mouse_last.x;
			deltay = xevent->xmotion.y - mouse_last.y;
#ifdef DEBUG_MOTION
  printf("Extra mouse motion: %d,%d\n", deltax, deltay);
#endif
			mouse_last.x = xevent->xmotion.x;
			mouse_last.y = xevent->xmotion.y;
			posted += SDL_PrivateMouseMotion(0, 1, deltax, deltay);
		}
		mouse_last.x = w/2;
		mouse_last.y = h/2;
		XWarpPointer(SDL_Display, None, SDL_Window, 0, 0, 0, 0,
					mouse_last.x, mouse_last.y);
		for ( i=0; i<10; ++i ) {
        		XMaskEvent(SDL_Display, PointerMotionMask, xevent);
			if ( (xevent->xmotion.x >
			          (mouse_last.x-MOUSE_FUDGE_FACTOR)) &&
			     (xevent->xmotion.x <
			          (mouse_last.x+MOUSE_FUDGE_FACTOR)) &&
			     (xevent->xmotion.y >
			          (mouse_last.y-MOUSE_FUDGE_FACTOR)) &&
			     (xevent->xmotion.y <
			          (mouse_last.y+MOUSE_FUDGE_FACTOR)) ) {
				break;
			}
#ifdef DEBUG_XEVENTS
  printf("Lost mouse motion: %d,%d\n", xevent->xmotion.x, xevent->xmotion.y);
#endif
		}
#ifdef DEBUG_XEVENTS
		if ( i == 10 ) {
			printf("Warning: didn't detect mouse warp motion\n");
		}
#endif
	}
	return(posted);
}
Example #5
0
static void DIB_GenerateMouseMotionEvent(_THIS)
{
	extern int mouse_relative;
	extern int posted;

	POINT mouse;
	GetCursorPos( &mouse );

	if ( mouse_relative ) {
		POINT center;
		center.x = (SDL_VideoSurface->w/2);
		center.y = (SDL_VideoSurface->h/2);
		ClientToScreen(SDL_Window, &center);

		mouse.x -= (Sint16)center.x;
		mouse.y -= (Sint16)center.y;
		if ( mouse.x || mouse.y ) {
			SetCursorPos(center.x, center.y);
			posted = SDL_PrivateMouseMotion(0, 1, mouse.x, mouse.y);
		}
	} else if ( SDL_GetAppState() & SDL_APPMOUSEFOCUS ) {
		ScreenToClient(SDL_Window, &mouse);
#ifdef SDL_VIDEO_DRIVER_GAPI
       if (SDL_VideoSurface && this->hidden->gapiInfo)
			GapiTransform(this->hidden->gapiInfo->coordinateTransform, this->hidden->gapiInfo->hiresFix, &mouse.x, &mouse.y);
#endif
		posted = SDL_PrivateMouseMotion(0, 0, mouse.x, mouse.y);
	}
}
Example #6
0
void
PLAYBOOK_PumpEvents(_THIS)
{
	while (1)
	{
		int rc = screen_get_event(this->hidden->screenContext, this->hidden->screenEvent, 0 /*timeout*/);
		if (rc)
			break;

		int type;
		rc = screen_get_event_property_iv(this->hidden->screenEvent, SCREEN_PROPERTY_TYPE, &type);
		if (rc || type == SCREEN_EVENT_NONE)
			break;

		screen_window_t window;
		screen_get_event_property_pv(this->hidden->screenEvent, SCREEN_PROPERTY_WINDOW, (void **)&window);
		if (!window && type != SCREEN_EVENT_KEYBOARD)
			break;

		switch (type)
		{
		case SCREEN_EVENT_CLOSE:
			SDL_PrivateQuit(); // We can't stop it from closing anyway
			break;
		case SCREEN_EVENT_PROPERTY:
			{
				int val;
				screen_get_event_property_iv(this->hidden->screenEvent, SCREEN_PROPERTY_NAME, &val);

				//fprintf(stderr, "Property change (property val=%d)\n", val);
			}
			break;
		case SCREEN_EVENT_POINTER:
			handlePointerEvent(this->hidden->screenEvent, window);
			break;
		case SCREEN_EVENT_KEYBOARD:
			handleKeyboardEvent(this->hidden->screenEvent);
			break;
		case SCREEN_EVENT_MTOUCH_TOUCH:
		case SCREEN_EVENT_MTOUCH_MOVE:
		case SCREEN_EVENT_MTOUCH_RELEASE:
			handleMtouchEvent(this->hidden->screenEvent, window, type);
			break;
		}
	}

#ifdef TOUCHPAD_SIMULATE
	if (state.pending[0] || state.pending[1]) {
		SDL_PrivateMouseMotion(state.mask, 1, state.pending[0], state.pending[1]);
		state.pending[0] = 0;
		state.pending[1] = 0;
	}
#endif
	if (moveEvent.pending) {
		SDL_PrivateMouseMotion((moveEvent.touching?SDL_BUTTON_LEFT:0), 0, moveEvent.pos[0], moveEvent.pos[1]);
		moveEvent.pending = 0;
	}
}
void DirectFB_PumpEvents (_THIS)
{
  DFBInputEvent evt;

  while (HIDDEN->eventbuffer->GetEvent (HIDDEN->eventbuffer,
                                        DFB_EVENT (&evt)) == DFB_OK)
    {
      SDL_keysym keysym;

      switch (evt.type)
        {
        case DIET_BUTTONPRESS:
          posted += SDL_PrivateMouseButton(SDL_PRESSED,
                                           DirectFB_TranslateButton (&evt), 0, 0);
          break;
        case DIET_BUTTONRELEASE:
          posted += SDL_PrivateMouseButton(SDL_RELEASED,
                                           DirectFB_TranslateButton (&evt), 0, 0);
          break;
        case DIET_KEYPRESS:
          posted += SDL_PrivateKeyboard(SDL_PRESSED, DirectFB_TranslateKey(&evt, &keysym));
          break;
        case DIET_KEYRELEASE:
          posted += SDL_PrivateKeyboard(SDL_RELEASED, DirectFB_TranslateKey(&evt, &keysym));
          break;
        case DIET_AXISMOTION:
          if (evt.flags & DIEF_AXISREL)
            {
              if (evt.axis == DIAI_X)
                posted += SDL_PrivateMouseMotion(0, 1, evt.axisrel, 0);
              else if (evt.axis == DIAI_Y)
                posted += SDL_PrivateMouseMotion(0, 1, 0, evt.axisrel);
            }
          else if (evt.flags & DIEF_AXISABS)
            {
              static int last_x, last_y;
              if (evt.axis == DIAI_X)
                last_x = evt.axisabs;
              else if (evt.axis == DIAI_Y)
                last_y = evt.axisabs;
              posted += SDL_PrivateMouseMotion(0, 0, last_x, last_y);
            }
          break;
        default:
          ;
        }
    }
}
Example #8
0
void X11_WarpWMCursor(_THIS, Uint16 x, Uint16 y)
{
	if ( using_dga & DGA_MOUSE ) {
		SDL_PrivateMouseMotion(0, 0, x, y);
	} else if ( mouse_relative) {
		/*	RJR: March 28, 2000
			leave physical cursor at center of screen if
			mouse hidden and grabbed */
		SDL_PrivateMouseMotion(0, 0, x, y);
	} else {
		SDL_Lock_EventThread();
		XWarpPointer(SDL_Display, None, SDL_Window, 0, 0, 0, 0, x, y);
		XSync(SDL_Display, False);
		SDL_Unlock_EventThread();
	}
}
Example #9
0
// Update the current mouse state and position
static void NX_UpdateMouse (_THIS)
{
    int            x, y ;
    GR_WINDOW_INFO info ;
    GR_SCREEN_INFO si ;


    Dprintf ("enter NX_UpdateMouse\n") ;

    // Lock the event thread, in multi-threading environments
    SDL_Lock_EventThread () ;
    
    GrGetScreenInfo (& si) ;
    GrGetWindowInfo (SDL_Window, & info) ;
    x = si.xpos - info.x ;
    y = si.ypos - info.y ;
    if (x >= 0 && x <= info.width && y >= 0 && y <= info.height) {
        SDL_PrivateAppActive (1, SDL_APPMOUSEFOCUS) ;
        SDL_PrivateMouseMotion (0, 0, x, y);
    } else {
        SDL_PrivateAppActive (0, SDL_APPMOUSEFOCUS) ;
    }

    SDL_Unlock_EventThread () ;
    Dprintf ("leave NX_UpdateMouse\n") ;
}
Example #10
0
extern void JAVA_EXPORT_NAME(DemoGLSurfaceView_nativeMouse)(JNIEnv* env, jobject thiz, jint x, jint y, jint action) {
	//__android_log_print(ANDROID_LOG_INFO, "libSDL", "mouse event %i at (%03i, %03i)", action, x, y);
	if (action == MOUSE_DOWN || action == MOUSE_UP)
		SDL_PrivateMouseButton((action == MOUSE_DOWN) ? SDL_PRESSED : SDL_RELEASED, 1, x, y);
	if (action == MOUSE_MOVE)
		SDL_PrivateMouseMotion(0, 0, x, y);
}
Example #11
0
void SDL_WarpMouse (Uint16 x, Uint16 y)
{
 SDL_VideoDevice *video = current_video;
 SDL_VideoDevice *this  = current_video;

 if ( !video || !SDL_PublicSurface ) {
   SDL_SetError("A video mode must be set before warping mouse");
   return;
 }

 /* If we have an offset video mode, offset the mouse coordinates */
 if (this->screen->pitch == 0) {
   x += this->screen->offset / this->screen->format->BytesPerPixel;
   y += this->screen->offset;
 } else {
   x += (this->screen->offset % this->screen->pitch) /
         this->screen->format->BytesPerPixel;
   y += (this->screen->offset / this->screen->pitch);
 }

 /* This generates a mouse motion event */
 if ( video->WarpWMCursor ) {
   video->WarpWMCursor(this, x, y);
 } else {
   SDL_PrivateMouseMotion(0, 0, x, y);
 }
}
Example #12
0
void SDL_AtariXbios_PostMouseEvents(_THIS, SDL_bool buttonEvents)
{
	if (SDL_AtariXbios_enabled==0) {
		return;
	}

	/* Mouse motion ? */
	if (SDL_AtariXbios_mousex || SDL_AtariXbios_mousey) {
		SDL_PrivateMouseMotion(0, 1, SDL_AtariXbios_mousex, SDL_AtariXbios_mousey);
		SDL_AtariXbios_mousex = SDL_AtariXbios_mousey = 0;
	}
	
	/* Mouse button ? */
	if (buttonEvents && (SDL_AtariXbios_mouseb != atari_prevmouseb)) {
		int i;

		for (i=0;i<2;i++) {
			int curbutton, prevbutton;

			curbutton = SDL_AtariXbios_mouseb & (1<<i);
			prevbutton = atari_prevmouseb & (1<<i);

			if (curbutton && !prevbutton) {
				SDL_PrivateMouseButton(SDL_PRESSED, atari_GetButton(i), 0, 0);
			}
			if (!curbutton && prevbutton) {
				SDL_PrivateMouseButton(SDL_RELEASED, atari_GetButton(i), 0, 0);
			}
		}
		atari_prevmouseb = SDL_AtariXbios_mouseb;
	}
}
void ph_UpdateMouse(_THIS)
{
    PhCursorInfo_t phcursor;
    short abs_x;
    short abs_y;

    /* Lock the event thread, in multi-threading environments */
    SDL_Lock_EventThread();

    /* synchronizing photon mouse cursor position and SDL mouse position, if cursor appears over window. */
    PtGetAbsPosition(window, &abs_x, &abs_y);
    PhQueryCursor(PhInputGroup(NULL), &phcursor);
    if (((phcursor.pos.x >= abs_x) && (phcursor.pos.x <= abs_x + this->screen->w)) &&
        ((phcursor.pos.y >= abs_y) && (phcursor.pos.y <= abs_y + this->screen->h)))
    {
        SDL_PrivateAppActive(1, SDL_APPMOUSEFOCUS);
        SDL_PrivateMouseMotion(0, 0, phcursor.pos.x-abs_x, phcursor.pos.y-abs_y);
    }
    else
    {
        SDL_PrivateAppActive(0, SDL_APPMOUSEFOCUS);
    }

    /* Unlock the event thread, in multi-threading environments */
    SDL_Unlock_EventThread();
}
void HELENOS_PumpEvents(_THIS){
	kbd_event_t kbd_event;
	pos_event_t pos_event;
	SDL_keysym keysym;
	int posted=0;
	while(canvas_pop_keyboard_event(&kbd_event)){
		if(kbd_event.type == KEY_PRESS) {
			posted += SDL_PrivateKeyboard(SDL_PRESSED, HelenOS_TranslateKey(&kbd_event, &keysym));
		} else if(kbd_event.type == KEY_RELEASE){
			posted += SDL_PrivateKeyboard(SDL_RELEASED, HelenOS_TranslateKey(&kbd_event, &keysym));
		}
	}

	while(canvas_pop_position_event(&pos_event)){
		static int mouse_x = 0, mouse_y = 0;

		if(pos_event.type == POS_PRESS){
			posted += SDL_PrivateMouseButton(SDL_PRESSED, (uint8_t)pos_event.btn_num, 0, 0);
		} else if(pos_event.type == POS_RELEASE){
			posted += SDL_PrivateMouseButton(SDL_RELEASED, (uint8_t)pos_event.btn_num, 0, 0);
		} else if(pos_event.type == POS_UPDATE){
			if (mouse_x != pos_event.hpos || mouse_y != pos_event.vpos)
			{
				mouse_x = pos_event.hpos;
				mouse_y = pos_event.vpos;
//				int x = pos_event.hpos - mouse_x;
//				int y = pos_event.vpos - mouse_y;
				posted += SDL_PrivateMouseMotion(0, 0, pos_event.hpos,  pos_event.vpos);
			}
		}
	}
}
Example #15
0
void WIN_WarpWMCursor(_THIS, Uint16 x, Uint16 y)
{
	if ( DDRAW_FULLSCREEN() ) {
		SDL_PrivateMouseMotion(0, 0, x, y);
	} else if ( mouse_relative) {
		/*	RJR: March 28, 2000
			leave physical cursor at center of screen if
			mouse hidden and grabbed */
		SDL_PrivateMouseMotion(0, 0, x, y);
	} else {
		POINT pt;
		pt.x = x;
		pt.y = y;
		ClientToScreen(SDL_Window, &pt);
		SetCursorPos(pt.x, pt.y);
	}
}
extern void SDL_ANDROID_PumpEvents()
{
    static int oldMouseButtons = 0;
    SDL_Event ev;

    SDL_mutexP(BufferedEventsMutex);
    while( BufferedEventsStart != BufferedEventsEnd )
    {
        ev = BufferedEvents[BufferedEventsStart];
        BufferedEvents[BufferedEventsStart].type = 0;
        BufferedEventsStart++;
        if( BufferedEventsStart >= MAX_BUFFERED_EVENTS )
            BufferedEventsStart = 0;
        SDL_mutexV(BufferedEventsMutex);

        switch( ev.type )
        {
        case SDL_MOUSEMOTION:
            //__android_log_print(ANDROID_LOG_INFO, "libSDL", "SDL_MOUSEMOTION REAL: x=%i y=%i", ev.motion.x, ev.motion.y);
            if( SDL_ANDROID_sWindowWidth > 0 && SDL_ANDROID_sWindowHeight > 0 ) {
                int x = ev.motion.x * SDL_ANDROID_sFakeWindowWidth  / SDL_ANDROID_sWindowWidth;
                int y = ev.motion.y * SDL_ANDROID_sFakeWindowHeight / SDL_ANDROID_sWindowHeight;
                //__android_log_print(ANDROID_LOG_INFO, "libSDL", "SDL_MOUSEMOTION: x=%i y=%i", x, y);
                SDL_PrivateMouseMotion(0, 0, x, y);
            }
            break;
        case SDL_MOUSEBUTTONDOWN:
            //__android_log_print(ANDROID_LOG_INFO, "libSDL", "SDL_MOUSEBUTTONDOWN: %i %i", ev.button.button, ev.button.state);
            if( ((oldMouseButtons & SDL_BUTTON(ev.button.button)) != 0) != ev.button.state )
            {
                oldMouseButtons = (oldMouseButtons & ~SDL_BUTTON(ev.button.button)) | (ev.button.state ? SDL_BUTTON(ev.button.button) : 0);
                SDL_PrivateMouseButton( ev.button.state, ev.button.button, 0, 0 );
            }
            break;
        case SDL_KEYDOWN:
            //__android_log_print(ANDROID_LOG_INFO, "libSDL", "SDL_KEYDOWN: %i %i", ev.key.keysym.sym, ev.key.state);
            SDL_PrivateKeyboard( ev.key.state, &ev.key.keysym );
            break;

        //
        case SDL_VIDEOEXPOSE:
        {
            SDL_Surface* screen = SDL_GetVideoSurface();
            if(screen) {
                SDL_Flip(screen);
            }
        }
        break;
        default:
            break;
        }

        SDL_mutexP(BufferedEventsMutex);
    }
    SDL_mutexV(BufferedEventsMutex);
};
Example #17
0
static int fakemouse_update(void *data)
{
	while (running) {
		SDL_SemWait(sem);
		/* Delay 1/60th of a second */
		SDL_Delay(1000 / 60);  
		if (dx ||  dy)
			SDL_PrivateMouseMotion(0, 1, dx, dy);
		SDL_SemPost(sem);
	}
	return 0;
}
Example #18
0
LOCAL_C TInt PointerBufferReadyEvent(_THIS/*, const TTime& aEventTime*/)
    {
    // Own threaded is not supported - it is fair easy to do, but needs some work so I would implemented
    // it only upon request :-) 
    
    /*
    TTime time;
    time.UniversalTime();
    TTimeIntervalMicroSeconds d = time.MicroSecondsFrom(aEventTime);
    
    TInt skipcount  = 1;
    
    if(d < TTimeIntervalMicroSeconds(5000))
        skipcount = -1;
    else if (d < TTimeIntervalMicroSeconds(50000))
        {
        skipcount = (50000 - d.Int64()) / 5000;
        }
    
    RDebug::Print(_L("skipCount %d"), skipcount);
    
    TInt skip = skipcount;
    */
    RWindow* win = EnvUtils::IsOwnThreaded() ? NULL : EpocSdlEnv::Window();
    TInt posted = 0;
    if(win != NULL)
        {
        TPoint points[KPointerBufferSize];
        TPckg<TPoint[KPointerBufferSize]> buf(points);
        User::LeaveIfError(win->RetrievePointerMoveBuffer(buf));
        const TInt count = buf.Length() / sizeof(TPoint);
        
        
        for(TInt i = 0; i < count; i++)
            {
      /*      --skip;
            if(!skip)
                {
                skip = skipcount;
                }
            else
                {*/
                const TPoint point = points[i] - Private->iScreenPos; 
                const TPoint mousePos = EpocSdlEnv::WindowCoordinates(point);
                if(mousePos.iX >= 0 && mousePos.iY >= 0 && mousePos.iX < _this->screen->w && mousePos.iY < _this->screen->h)
                    {
                    posted += SDL_PrivateMouseMotion(0, 0, mousePos.iX, mousePos.iY); /* Absolute position on screen */
                    }
                //}
            }
        }
    return posted;
    }
Example #19
0
/* Update the current mouse state and position */
void WIN_UpdateMouse(_THIS)
{
	POINT pt;

	/* Always unset SDL_APPMOUSEFOCUS to give the WM_MOUSEMOVE event
	 * handler a chance to install a TRACKMOUSEEVENT */
	SDL_PrivateAppActive(0, SDL_APPMOUSEFOCUS);

	GetCursorPos(&pt);
	ScreenToClient(SDL_Window, &pt);
	SDL_PrivateMouseMotion(0,0, (Sint16)pt.x, (Sint16)pt.y);
}
Example #20
0
int handleTouchScreen(int x, int y, int tap, int hold)
{
    if (tap) {
        SDL_PrivateMouseButton(SDL_PRESSED, SDL_BUTTON_LEFT, x, y);
        SDL_PrivateMouseButton(SDL_RELEASED, SDL_BUTTON_LEFT, x, y);
    } else if (hold) {
        SDL_PrivateMouseButton(SDL_PRESSED, SDL_BUTTON_RIGHT, x, y);
        SDL_PrivateMouseButton(SDL_RELEASED, SDL_BUTTON_RIGHT, x, y);
    } else {
        SDL_PrivateMouseMotion(SDL_GetMouseState(0, 0), 0, x, y);
    }
    return TCO_SUCCESS;
}
Example #21
0
void WIN_WarpWMCursor(_THIS, Uint16 x, Uint16 y)
{
	if ( mouse_relative) {
		/*	RJR: March 28, 2000
			leave physical cursor at center of screen if
			mouse hidden and grabbed */
		SDL_PrivateMouseMotion(0, 0, x, y);
	} else {
		POINT pt;

		/* With DirectInput the position doesn't follow
		 * the cursor, so it is set manually */
		if ( DINPUT() ) {
			SDL_PrivateMouseMotion(0, 0, x, y);
		}

		pt.x = x;
		pt.y = y;
		ClientToScreen(SDL_Window, &pt);
		SetCursorPos(pt.x, pt.y);
	}
}
static int DGA_DispatchEvent(_THIS)
{
	int posted;
	SDL_NAME(XDGAEvent) xevent;

	XNextEvent(DGA_Display, (XEvent *)&xevent);

	posted = 0;
	xevent.type -= DGA_event_base;
	switch (xevent.type) {

	    /* Mouse motion? */
	    case MotionNotify: {
		if ( SDL_VideoSurface ) {
			posted = SDL_PrivateMouseMotion(0, 1,
					xevent.xmotion.dx, xevent.xmotion.dy);
		}
	    }
	    break;

	    /* Mouse button press? */
	    case ButtonPress: {
		posted = SDL_PrivateMouseButton(SDL_PRESSED, 
					xevent.xbutton.button, 0, 0);
	    }
	    break;

	    /* Mouse button release? */
	    case ButtonRelease: {
		posted = SDL_PrivateMouseButton(SDL_RELEASED, 
					xevent.xbutton.button, 0, 0);
	    }
	    break;

	    /* Key press or release? */
	    case KeyPress:
	    case KeyRelease: {
		SDL_keysym keysym;
		XKeyEvent xkey;

		SDL_NAME(XDGAKeyEventToXKeyEvent)(&xevent.xkey, &xkey);
		posted = SDL_PrivateKeyboard((xevent.type == KeyPress), 
					X11_TranslateKey(DGA_Display,
							 &xkey, xkey.keycode,
							 &keysym));
	    }
	    break;

	}
	return(posted);
}
static void post_mouse_motion(int relative, Sint16 x, Sint16 y)
{
	extern int mouse_relative;

	if ( SDL_GetAppState() & SDL_APPMOUSEFOCUS ) {
		posted = SDL_PrivateMouseMotion(
			0, relative, x, y);

		if ( !mouse_relative ) {
			int current_x, current_y;
			POINT cursor;
			RECT trap;
			RECT window;
			int at_edge;

			
			SDL_GetMouseState(&current_x, &current_y);
			cursor.x = current_x;
			cursor.y = current_y;
			ClientToScreen(SDL_Window, &cursor);

			trap.left = cursor.x;
			trap.top = cursor.y;
			trap.right = cursor.x + 1;
			trap.bottom = cursor.y + 1;

			GetClientRect(SDL_Window, &window);
			window.right -= window.left; window.left = 0;
			window.bottom -= window.top; window.top = 0;

			at_edge = (current_x == window.left) ||
				(current_x == (window.right - 1)) ||
				(current_y == window.top) ||
				(current_y == (window.bottom - 1));

			if ( at_edge ) {
				ClipCursor(NULL);
			} else {
				ClipCursor(&trap);
			}
		} else {
			POINT center;
			center.x = (SDL_VideoSurface->w/2);
			center.y = (SDL_VideoSurface->h/2);
			ClientToScreen(SDL_Window, &center);
			SetCursorPos(center.x, center.y);
		}
	}
}
Example #24
0
void AtariIkbd_PumpEvents(_THIS)
{
	int i, specialkeys;
	SDL_keysym keysym;

	/*--- Send keyboard events ---*/

	for (i=0; i<ATARIBIOS_MAXKEYS; i++) {
		/* Key pressed ? */
		if (SDL_AtariIkbd_keyboard[i]==KEY_PRESSED) {
			SDL_PrivateKeyboard(SDL_PRESSED,
				SDL_Atari_TranslateKey(i, &keysym, SDL_TRUE));
			SDL_AtariIkbd_keyboard[i]=KEY_UNDEFINED;
		}
			
		/* Key released ? */
		if (SDL_AtariIkbd_keyboard[i]==KEY_RELEASED) {
			SDL_PrivateKeyboard(SDL_RELEASED,
				SDL_Atari_TranslateKey(i, &keysym, SDL_FALSE));
			SDL_AtariIkbd_keyboard[i]=KEY_UNDEFINED;
		}
	}

	/*--- Send mouse events ---*/

	/* Mouse motion ? */
	if (SDL_AtariIkbd_mousex || SDL_AtariIkbd_mousey) {
		SDL_PrivateMouseMotion(0, 1, SDL_AtariIkbd_mousex, SDL_AtariIkbd_mousey);
		SDL_AtariIkbd_mousex = SDL_AtariIkbd_mousey = 0;
	}

	/* Mouse button ? */
	if (SDL_AtariIkbd_mouseb != atari_prevmouseb) {
		for (i=0;i<2;i++) {
			int curbutton, prevbutton;

			curbutton = SDL_AtariIkbd_mouseb & (1<<i);
			prevbutton = atari_prevmouseb & (1<<i);

			if (curbutton && !prevbutton) {
				SDL_PrivateMouseButton(SDL_PRESSED, atari_GetButton(i), 0, 0);
			}
			if (!curbutton && prevbutton) {
				SDL_PrivateMouseButton(SDL_RELEASED, atari_GetButton(i), 0, 0);
			}
		}
		atari_prevmouseb = SDL_AtariIkbd_mouseb;
	}
}
Example #25
0
/* Update the current mouse state and position */
void WIN_UpdateMouse(_THIS)
{
	RECT rect;
	POINT pt;

	if ( ! DDRAW_FULLSCREEN() ) {
		GetClientRect(SDL_Window, &rect);
		GetCursorPos(&pt);
		MapWindowPoints(NULL, SDL_Window, &pt, 1);
		if (PtInRect(&rect, pt) && (WindowFromPoint(pt) == SDL_Window)){
			SDL_PrivateAppActive(1, SDL_APPMOUSEFOCUS);
			SDL_PrivateMouseMotion(0,0, (Sint16)pt.x, (Sint16)pt.y);
		} else {
			SDL_PrivateAppActive(0, SDL_APPMOUSEFOCUS);
		}
	}
}
Example #26
0
static void mouse_update(void)
{
	int mouseX, mouseY;
	unsigned char changed;
	XMOUSE_INPUT mouseinput = XInputGetMouseData();

	if(lastMouseX == mouseinput.cX && lastMouseY == mouseinput.cY)
	{
		mouseX = 0;
		mouseY = 0;
	}
	else
	{
		mouseX = mouseinput.cX;
		mouseY = mouseinput.cY;
	}

	if (mouseX||mouseY)
		SDL_PrivateMouseMotion(0,1, mouseX, mouseY);

	changed = mouseinput.ucButtons ^ prevMouseButtons;

	if(changed & XMOUSE_BUTTON_1)
		SDL_PrivateMouseButton( (mouseinput.ucButtons & XMOUSE_BUTTON_1) ? SDL_PRESSED : SDL_RELEASED, 1, 0, 0);

	if(changed & XMOUSE_BUTTON_2)
		SDL_PrivateMouseButton( (mouseinput.ucButtons & XMOUSE_BUTTON_2) ? SDL_PRESSED : SDL_RELEASED, 2, 0, 0);

	if(changed & XMOUSE_BUTTON_3)
		SDL_PrivateMouseButton( (mouseinput.ucButtons & XMOUSE_BUTTON_3) ? SDL_PRESSED : SDL_RELEASED, 3, 0, 0);

	if(changed & XMOUSE_BUTTON_4)
		SDL_PrivateMouseButton( (mouseinput.ucButtons & XMOUSE_BUTTON_4) ? SDL_PRESSED : SDL_RELEASED, 4, 0, 0);

	if(changed & XMOUSE_BUTTON_5)
		SDL_PrivateMouseButton( (mouseinput.ucButtons & XMOUSE_BUTTON_5) ? SDL_PRESSED : SDL_RELEASED, 5, 0, 0);


	prevMouseButtons = mouseinput.ucButtons;
	lastMouseX = mouseinput.cX;
	lastMouseY = mouseinput.cY;

}
Example #27
0
void ORBITAL_PumpEvents(_THIS)
{
    struct Event event;
    while(read(this->hidden->fd, &event, sizeof(event)) > 0){
        if ( event.code == EVENT_KEY ){
            SDL_keysym keysym;
        	keysym.unicode = event.a;
        	keysym.scancode = event.b;
        	keysym.sym = keymap[event.b];
        	keysym.mod = KMOD_NONE;
            if ( event.c > 0 ) {
                SDL_PrivateKeyboard(SDL_PRESSED, &keysym);
            } else {
                SDL_PrivateKeyboard(SDL_RELEASED, &keysym);
            }
        }else if( event.code == EVENT_MOUSE ){
            SDL_PrivateMouseMotion(event.c, 0, event.a, event.b);
            //SDL_PrivateMouseButton(Uint8 state, Uint8 button, Sint16 x, Sint16 y);
        }
    }
}
Example #28
0
/* Warp the window manager cursor to (x,y)
   If NULL, a mouse motion event is posted internally.
 */
void sdl_netbas_gi_WarpWMCursor (_THIS, Uint16 x, Uint16 y)
{
   gi_window_info_t info ;

    SDL_Lock_EventThread () ;

	if ( mouse_relative) {
		/*	RJR: March 28, 2000
			leave physical cursor at center of screen if
			mouse hidden and grabbed */
		SDL_PrivateMouseMotion(0, 0, x, y);
	} else{
    
    gi_get_window_info (SDL_Window, & info) ;
    gi_move_cursor (info.x + x, info.y + y) ;
	}

    SDL_Unlock_EventThread () ;

	//DEBUG_OUT("sdl_netbas_gi_WarpWMCursor\n");
}
static int ph_WarpedMotion(_THIS, PhEvent_t *winEvent)
{
    PhRect_t *rect = PhGetRects( winEvent );

    int centre_x, centre_y;
    int dx, dy;
    short abs_x, abs_y;
    int posted;

    centre_x = SDL_VideoSurface->w / 2;
    centre_y = SDL_VideoSurface->h / 2;

    dx = rect->ul.x - centre_x;
    dy = rect->ul.y - centre_y;

    posted = SDL_PrivateMouseMotion( 0, 1, dx, dy );

    /* Move mouse cursor to middle of the window */
    PtGetAbsPosition( window, &abs_x, &abs_y );
    PhMoveCursorAbs(PhInputGroup(NULL), abs_x + centre_x, abs_y + centre_y);

    return (posted);
}
Example #30
0
LOCAL_C TInt PointerEvent(_THIS, const TWsEvent& aWsEvent)
    {
    
    const TPointerEvent* pointerEvent = aWsEvent.Pointer();
    const TPoint mousePos = EpocSdlEnv::WindowCoordinates(pointerEvent->iPosition - Private->iScreenPos);

    TInt posted = 0;
    
    if(mousePos.iX >= 0 && mousePos.iY >= 0 && mousePos.iX < _this->screen->w && mousePos.iY < _this->screen->h)
        {
        posted = SDL_PrivateMouseMotion(0, 0, mousePos.iX, mousePos.iY); /* Absolute position on screen */
        }
    
    switch (pointerEvent->iType)
        {
        case TPointerEvent::EButton1Down:
            posted += SDL_PrivateMouseButton(SDL_PRESSED, SDL_BUTTON_LEFT, 0, 0);
            break;
        case TPointerEvent::EButton1Up:
            posted += SDL_PrivateMouseButton(SDL_RELEASED, SDL_BUTTON_LEFT, 0, 0);
            break;
        case TPointerEvent::EButton2Down:
            posted += SDL_PrivateMouseButton(SDL_PRESSED, SDL_BUTTON_RIGHT, 0, 0);
            break;
        case TPointerEvent::EButton2Up:
            posted += SDL_PrivateMouseButton(SDL_RELEASED, SDL_BUTTON_RIGHT, 0, 0);
            break;
        case TPointerEvent::EButton3Down:
            posted += SDL_PrivateMouseButton(SDL_PRESSED, SDL_BUTTON_MIDDLE, 0, 0);
            break;
        case TPointerEvent::EButton3Up:
            posted += SDL_PrivateMouseButton(SDL_RELEASED, SDL_BUTTON_MIDDLE, 0, 0);
            break;
        default:;
        } // switch
    return posted;
    }