Пример #1
0
int SDL_ShowCursor (int toggle)
{
 int showing;

 showing = (SDL_cursorstate & CURSOR_VISIBLE);
 if ( toggle >= 0 ) {
   SDL_LockCursor();
   if ( toggle ) {
     SDL_cursorstate |= CURSOR_VISIBLE;
   } else {
     SDL_cursorstate &= ~CURSOR_VISIBLE;
   }
   SDL_UnlockCursor();
   if ( (SDL_cursorstate & CURSOR_VISIBLE) != showing ) {
     SDL_VideoDevice *video = current_video;
     SDL_VideoDevice *this  = current_video;

     SDL_SetCursor(NULL);
     if ( video && video->CheckMouseMode ) {
       video->CheckMouseMode(this);
     }
   }
 } else {
   /* Query current state */ ;
 }
 return(showing ? 1 : 0);
}
Пример #2
0
/* SDL_SetCursor(NULL) can be used to force the cursor redraw,
   if this is desired for any reason.  This is used when setting
   the video mode and when the SDL window gains the mouse focus.
 */
void SDL_SetCursor (SDL_Cursor *cursor)
{
	SDL_VideoDevice *video = current_video;
	SDL_VideoDevice *this  = current_video;

	/* Make sure that the video subsystem has been initialized */
	if ( ! video ) {
		return;
	}

	/* Prevent the event thread from moving the mouse */
	SDL_LockCursor();

	/* Set the new cursor */
	if ( cursor && (cursor != SDL_cursor) ) {
		/* Erase the current mouse position */
		if ( SHOULD_DRAWCURSOR(SDL_cursorstate) ) {
			SDL_EraseCursor(SDL_VideoSurface);
		} else if ( video->MoveWMCursor ) {
			/* If the video driver is moving the cursor directly,
			   it needs to hide the old cursor before (possibly)
			   showing the new one.  (But don't erase NULL cursor)
			 */
			if ( SDL_cursor ) {
				video->ShowWMCursor(this, NULL);
			}
		}
		SDL_cursor = cursor;
	}

	/* Draw the new mouse cursor */
	if ( SDL_cursor && (SDL_cursorstate&CURSOR_VISIBLE) ) {
		/* Use window manager cursor if possible */
		if ( SDL_cursor->wm_cursor && 
	             video->ShowWMCursor(this, SDL_cursor->wm_cursor) )
			SDL_cursorstate &= ~CURSOR_USINGSW;
		else {
			SDL_cursorstate |= CURSOR_USINGSW;
			if ( video->ShowWMCursor ) {
				video->ShowWMCursor(this, NULL);
			}
			{ int x, y;
				SDL_GetMouseState(&x, &y);
				SDL_cursor->area.x = (x - SDL_cursor->hot_x);
				SDL_cursor->area.y = (y - SDL_cursor->hot_y);
			}
			SDL_DrawCursor(SDL_VideoSurface);
		}
	} else {
		/* Erase window manager mouse (cursor not visible) */
		if ( SDL_cursor && (SDL_cursorstate & CURSOR_USINGSW) ) {
			SDL_EraseCursor(SDL_VideoSurface);
		} else {
			if ( video ) {
				video->ShowWMCursor(this, NULL);
			}
		}
	}
	SDL_UnlockCursor();
}
Пример #3
0
static SDL_Surface *OHQ_SetVideoMode(_THIS, SDL_Surface *current, int width, int height, int bpp, Uint32 flags) {
    if (flags & SDL_OPENGL) {
        OHQ_SwitchOff(this);
        return current_video->SetVideoMode(current_video,current,width,height,bpp,flags);
    }

    SDL_UnlockCursor();

    SendSyncCommand(this,OGL_NONE);
    filter_video = current_video;
    SAVE_VIDEO;
    if (!SendSyncCommand(this,OGL_DEINIT)) return NULL;
    if (this->hidden->surface == NULL) {
        this->hidden->surface = malloc(sizeof(*current));
        SDL_memcpy((SDL_Surface *)this->hidden->surface,current,sizeof(*current));
    }
	flags &= ~(SDL_HWPALETTE|SDL_HWSURFACE|SDL_ASYNCBLIT);

    // some video drivers can't handle odd widths properly
    width = (width+1)&~1;

    this->hidden->width = width;
    this->hidden->height = height;
    this->hidden->flags = flags;
    if (getenv("SDL_OPENGLHQ_DOUBLEBUF")) {
		if (getenv("SDL_OPENGLHQ_DOUBLEBUF")[0] == '1') this->hidden->flags |= SDL_DOUBLEBUF;
    	else this->hidden->flags &= ~(SDL_DOUBLEBUF);
	}
    this->hidden->bpp = bpp;
    this->hidden->postponed = 0;
    if (!SendSyncCommand(this,OGL_INIT)) return NULL;
    if (OHQ_NextMouseFilter == (void *)-1) {
        OHQ_NextMouseFilter = SDL_MouseFilter;
        SDL_MouseFilter = OHQ_MouseFilter;
    }
    bpp = this->hidden->bpp;

    if (!SDL_ReallocFormat(current, bpp, (bpp==32?0xff0000:bpp==16?0xf800:0x7c00), (bpp==32?0xff00:bpp==16?0x7e0:0x3e0), (bpp==32?0xff:0x1f), 0)) {
        return NULL;
    }

    current->w = this->hidden->width;
    current->h = this->hidden->height;
    current->pitch = this->hidden->pitch;
    current->flags = flags|SDL_PREALLOC;
    if (bpp == 8) current->flags |= SDL_HWPALETTE;
    current->pixels = this->hidden->framebuf;
    this->input_grab = this->hidden->real_video->input_grab;

    this->hidden->clip.x = 0;
    this->hidden->clip.y = 0;
    this->hidden->clip.w = current->w;
    this->hidden->clip.h = current->h;

    RESTORE_VIDEO;

    return current;
}
Пример #4
0
void SDL_MoveCursor(int x, int y)
{
 SDL_VideoDevice *video = current_video;

 /* Erase and update the current mouse position */
 if ( SHOULD_DRAWCURSOR(SDL_cursorstate) ) {
   /* Erase and redraw mouse cursor in new position */
   SDL_LockCursor();
   SDL_EraseCursor(SDL_VideoSurface);
   SDL_cursor->area.x = (x - SDL_cursor->hot_x);
   SDL_cursor->area.y = (y - SDL_cursor->hot_y);
   SDL_DrawCursor(SDL_VideoSurface);
   SDL_UnlockCursor();
 } else if ( video->MoveWMCursor ) {
   video->MoveWMCursor(video, x, y);
 }
}
Пример #5
0
static void GS_MoveCursor(_THIS, SDL_Cursor *cursor, int x, int y)
{
	SDL_Surface *screen;
	struct ps2_image image;
	SDL_Rect area;
	int mouse_y1, mouse_y2;
	void *saved_pixels;
	int screen_updated;

	/* Lock so we don't interrupt an update with mouse motion */
	SDL_LockCursor();

	/* Make sure any pending DMA has completed */
	if ( dma_pending ) {
		ioctl(console_fd, PS2IOC_SENDQCT, 1);
		dma_pending = 0;
	}

	/* Remove the cursor image from the DMA area */
	screen = this->screen;
	saved_pixels = screen->pixels;
	screen->pixels = mapped_mem + screen->offset;
	screen_updated = 0;
	if ( cursor_drawn ) {
		SDL_EraseCursorNoLock(screen);
		cursor_drawn = 0;
		screen_updated = 1;
	}

	/* Save the current mouse area */
	SDL_MouseRect(&area);
	mouse_y1 = area.y;
	mouse_y2 = area.y+area.h;

	/* Only draw the new cursor if there was one passed in */
	if ( cursor ) {
		/* Set the new location */
		cursor->area.x = (x - cursor->hot_x);
		cursor->area.y = (y - cursor->hot_y);

		/* Draw the cursor at the new location */
		if ( (SDL_cursorstate & CURSOR_VISIBLE) && screen->pixels ) {
			SDL_DrawCursorNoLock(screen);
			cursor_drawn = 1;
			screen_updated = 1;
		}
	}
	screen->pixels = saved_pixels;

	/* Update the affected area of the screen */
	if ( screen_updated ) {
		SDL_MouseRect(&area);
		if ( area.y < mouse_y1 ) {
			mouse_y1 = area.y;
		}
		if ( (area.y+area.h) > mouse_y2 ) {
			mouse_y2 = area.y+area.h;
		}
		image = screen_image;
		image.y += screen->offset / screen->pitch + mouse_y1;
		image.h = mouse_y2 - mouse_y1;
		image.ptr = mapped_mem +
		            (image.y - screen_image.y) * screen->pitch;
		ioctl(console_fd, PS2IOC_LOADIMAGE, &image);

		/* Need to scale offscreen image to TV output */
		if ( image.y > 0 ) {
			scaleimage_nonblock(console_fd,
			                    tex_tags_mem, scale_tags_mem);
		}
	}

	/* We're finished */
	SDL_UnlockCursor();
}