コード例 #1
0
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();
}
コード例 #2
0
ファイル: SDL_nxvideo.c プロジェクト: Goettsch/game-editor
SDL_Surface * NX_SetVideoMode (_THIS, SDL_Surface * current,
                int width, int height, int bpp, Uint32 flags)
{
    Dprintf ("enter NX_SetVideoMode\n") ;

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

    bpp = SDL_Visual.bpp ;
    if (NX_CreateWindow (this, current, width, height, bpp, flags) < 0) {
        current = NULL;
        goto done;
    }

    if (current -> w != width || current -> h != height) {
        current -> w = width ;
        current -> h = height ;
        current -> pitch = SDL_CalculatePitch (current) ;
        NX_ResizeImage (this, current, flags) ;
    }
    current -> flags |= (flags & (SDL_RESIZABLE | SDL_NOFRAME)) ;

  done:
    SDL_Unlock_EventThread () ;

    Dprintf ("leave NX_SetVideoMode\n") ;

    // We're done!
    return current ;
}
コード例 #3
0
static void unlock_display(void)
{
	/* Make sure any X11 transactions are completed */
	SDL_VideoDevice *this = current_video;
	XSync(SDL_Display, False);
	SDL_Unlock_EventThread();
}
コード例 #4
0
ファイル: SDL_nxvideo.c プロジェクト: Goettsch/game-editor
// 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") ;
}
コード例 #5
0
void SDL_JoystickQuit(void)
{
	const int numsticks = SDL_numjoysticks;
	int i;

	
	SDL_Lock_EventThread();
	SDL_numjoysticks = 0;
	SDL_Unlock_EventThread();

	if (SDL_joysticks != NULL) {
		for (i = 0; i < numsticks; i++) {
			SDL_Joystick *stick = SDL_joysticks[i];
			if (stick && (stick->ref_count >= 1)) {
				stick->ref_count = 1;
				SDL_JoystickClose(stick);
			}
		}
	}

	
	SDL_SYS_JoystickQuit();
	if ( SDL_joysticks ) {
		SDL_free(SDL_joysticks);
		SDL_joysticks = NULL;
		SDL_allocatedjoysticks = 0;
	}
}
コード例 #6
0
SDL_GrabMode ph_GrabInput(_THIS, SDL_GrabMode mode)
{
    SDL_Lock_EventThread();
    mode = ph_GrabInputNoLock(this, mode);
    SDL_Unlock_EventThread();

    return(mode);
}
コード例 #7
0
ファイル: SDL_gicursor.c プロジェクト: grimtraveller/netbas
/* If not NULL, create a black/white window manager cursor */
WMcursor * sdl_netbas_gi_CreateWMCursor (_THIS, Uint8 *data, Uint8 *mask, int w, int h, int hot_x, int hot_y)
{
	SDL_Lock_EventThread();
	WMcursor *cursor = (WMcursor *) malloc(sizeof(WMcursor));
	SDL_Unlock_EventThread();
	DEBUG_OUT("sdl_netbas_gi_CreateWMCursor\n");
	return cursor;
}
コード例 #8
0
ファイル: SDL_gicursor.c プロジェクト: grimtraveller/netbas
/* Free a window manager cursor
   This function can be NULL if CreateWMCursor is also NULL.
 */
void sdl_netbas_gi_FreeWMCursor (_THIS, WMcursor *cursor)
{
	SDL_Lock_EventThread();
	if(cursor)
	free(cursor);
	SDL_Unlock_EventThread();
	DEBUG_OUT("sdl_netbas_gi_FreeWMCursor\n");
}
コード例 #9
0
void ph_WarpWMCursor(_THIS, Uint16 x, Uint16 y)
{
    short abs_x, abs_y;

    SDL_Lock_EventThread();
    PtGetAbsPosition( window, &abs_x, &abs_y );
    PhMoveCursorAbs( PhInputGroup(NULL), x + abs_x, y + abs_y );
    SDL_Unlock_EventThread();
}
コード例 #10
0
ファイル: SDL_x11gamma.c プロジェクト: cmb33595/ozex
int X11_SetVidModeGamma(_THIS, float red, float green, float blue)
{
    int result;

    SDL_Lock_EventThread();
    result = X11_SetGammaNoLock(this, red, green, blue);
    SDL_Unlock_EventThread();

    return(result);
}
コード例 #11
0
ファイル: SDL_x11mouse.c プロジェクト: BITINT/DEFCON2
void X11_FreeWMCursor(_THIS, WMcursor *cursor)
{
	if ( SDL_Display != NULL ) {
		SDL_Lock_EventThread();
		XFreeCursor(SDL_Display, cursor->x_cursor);
		XSync(SDL_Display, False);
		SDL_Unlock_EventThread();
	}
	SDL_free(cursor);
}
コード例 #12
0
/* Set window caption */
void ph_SetCaption(_THIS, const char *title, const char *icon)
{
    SDL_Lock_EventThread();

    /* sanity check for set caption call before window init */
    if (window!=NULL)
    {
        PtSetResource(window, Pt_ARG_WINDOW_TITLE, title, 0);
    }

    SDL_Unlock_EventThread();
}
コード例 #13
0
void ph_SetCaption(_THIS, const char *title, const char *icon)
{
    SDL_Lock_EventThread();

    
    if (window!=NULL)
    {
        PtSetResource(window, Pt_ARG_WINDOW_TITLE, title, 0);
    }

    SDL_Unlock_EventThread();
}
コード例 #14
0
void NX_SetCaption (_THIS, const char * title, const char * icon)
{
    Dprintf ("enter NX_SetCaption\n") ;

    // Lock the event thread, in multi-threading environments
    SDL_Lock_EventThread () ;
    
    if (SDL_Window) 
        GrSetWindowTitle (SDL_Window, title) ;
    
    SDL_Unlock_EventThread () ;
    Dprintf ("leave NX_SetCaption\n") ;
}
コード例 #15
0
void NX_WarpWMCursor(_THIS, Uint16 x, Uint16 y)
{
    GR_WINDOW_INFO info ;

    Dprintf ("enter NX_WarpWMCursor\n") ;
    SDL_Lock_EventThread () ;
    
    GrGetWindowInfo (SDL_Window, & info) ;
    GrMoveCursor (info.x + x, info.y + y) ;

    SDL_Unlock_EventThread () ;
    Dprintf ("leave NX_WarpWMCursor\n") ;
}
コード例 #16
0
int ph_ShowWMCursor(_THIS, WMcursor* cursor)
{
    PtArg_t args[3];
    int nargs = 0;

    /* Don't do anything if the display is gone */
    if (window == NULL)
    {
        return (0);
    }

    /* looks like photon can't draw mouse cursor in direct mode */
    if ((this->screen->flags & SDL_FULLSCREEN) == SDL_FULLSCREEN)
    {
         /* disable the fake mouse in the fullscreen OpenGL mode */
         if ((this->screen->flags & SDL_OPENGL) == SDL_OPENGL)
         {
             cursor=NULL;
         }
         else
         {
             return (0);
         }
    }

    /* Set the photon cursor, or blank if cursor is NULL */
    if (cursor!=NULL)
    {
        PtSetArg(&args[0], Pt_ARG_CURSOR_TYPE, Ph_CURSOR_BITMAP, 0);
        /* Could set next to any PgColor_t value */
        PtSetArg(&args[1], Pt_ARG_CURSOR_COLOR, Ph_CURSOR_DEFAULT_COLOR , 0);
        PtSetArg(&args[2], Pt_ARG_BITMAP_CURSOR, cursor->ph_cursor, (cursor->ph_cursor->hdr.len + sizeof(PhRegionDataHdr_t)));
        nargs = 3;
    }
    else /* Ph_CURSOR_NONE */
    {
        PtSetArg(&args[0], Pt_ARG_CURSOR_TYPE, Ph_CURSOR_NONE, 0);
        nargs = 1;
    }

    SDL_Lock_EventThread();

    if (PtSetResources(window, nargs, args) < 0 )
    {
        return (0);
    }	

    SDL_Unlock_EventThread();

    return (1);
}
コード例 #17
0
ファイル: SDL_joystick.c プロジェクト: Goettsch/game-editor
void SDL_JoystickQuit(void)
{
	/* Stop the event polling */
	SDL_Lock_EventThread();
	SDL_numjoysticks = 0;
	SDL_Unlock_EventThread();

	/* Quit the joystick setup */
	SDL_SYS_JoystickQuit();
	if ( SDL_joysticks ) {
		free(SDL_joysticks);
		SDL_joysticks = NULL;
	}
}
コード例 #18
0
/* Iconify the window */
int CGX_IconifyWindow(_THIS)
{
#if 0
	int result;

	SDL_Lock_EventThread();
	result = XIconifyWindow(SDL_Display, WMwindow, SDL_Screen);
	XSync(SDL_Display, False);
	SDL_Unlock_EventThread();
	return(result);
#else
	return 0;
#endif
}
コード例 #19
0
ファイル: SDL_gicursor.c プロジェクト: grimtraveller/netbas
/* Show the specified cursor, or hide if cursor is NULL */
int sdl_netbas_gi_ShowWMCursor (_THIS, WMcursor *cursor)
{
	SDL_Lock_EventThread();
	if (cursor)
	{
		gi_load_cursor(SDL_Window,GI_CURSOR_ARROW);
	}
	else{
		gi_load_cursor(SDL_Window,GI_CURSOR_NO);
	}
	SDL_Unlock_EventThread();
	DEBUG_OUT("sdl_netbas_gi_ShowWMCursor\n");
	return 1;
}
コード例 #20
0
ファイル: SDL_gicursor.c プロジェクト: grimtraveller/netbas
/* Determine whether the mouse should be in relative mode or not.
   This function is called when the input grab state or cursor
   visibility state changes.
   If the cursor is not visible, and the input is grabbed, the
   driver can place the mouse in relative mode, which may result
   in higher accuracy sampling of the pointer motion.
*/
void sdl_netbas_gi_CheckMouseMode (_THIS)
{
	SDL_Lock_EventThread();

	DEBUG_OUT("sdl_netbas_gi_CheckMouseMode\n");
	 /* If the mouse is hidden and input is grabbed, we use relative mode */
        if ( !(SDL_cursorstate & CURSOR_VISIBLE) &&
             (this->input_grab != SDL_GRAB_OFF) ) {
                mouse_relative = 1;
        } else {
                mouse_relative = 0;
        }
	SDL_Unlock_EventThread();
}
コード例 #21
0
ファイル: SDL_joystick.c プロジェクト: AlexOteiza/n64ios
/*
 * Close a joystick previously opened with SDL_JoystickOpen()
 */
void
SDL_JoystickClose(SDL_Joystick * joystick)
{
    int i;

    if (!SDL_PrivateJoystickValid(&joystick)) {
        return;
    }

    /* First decrement ref count */
    if (--joystick->ref_count > 0) {
        return;
    }

    /* Lock the event queue - prevent joystick polling */
    SDL_Lock_EventThread();

    if (joystick == default_joystick) {
        default_joystick = NULL;
    }
    SDL_SYS_JoystickClose(joystick);

    /* Remove joystick from list */
    for (i = 0; SDL_joysticks[i]; ++i) {
        if (joystick == SDL_joysticks[i]) {
            SDL_memmove(&SDL_joysticks[i], &SDL_joysticks[i + 1],
                        (SDL_numjoysticks - i) * sizeof(joystick));
            break;
        }
    }

    /* Let the event thread keep running */
    SDL_Unlock_EventThread();

    /* Free the data associated with this joystick */
    if (joystick->axes) {
        SDL_free(joystick->axes);
    }
    if (joystick->hats) {
        SDL_free(joystick->hats);
    }
    if (joystick->balls) {
        SDL_free(joystick->balls);
    }
    if (joystick->buttons) {
        SDL_free(joystick->buttons);
    }
    SDL_free(joystick);
}
コード例 #22
0
ファイル: SDL_x11mouse.c プロジェクト: BITINT/DEFCON2
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();
	}
}
コード例 #23
0
/* Iconify current window */
int ph_IconifyWindow(_THIS)
{
    PhWindowEvent_t windowevent;

    SDL_Lock_EventThread();

    SDL_memset(&windowevent, 0, sizeof(windowevent));
    windowevent.event_f = Ph_WM_HIDE;
    windowevent.event_state = Ph_WM_EVSTATE_HIDE;
    windowevent.rid = PtWidgetRid(window);
    PtForwardWindowEvent(&windowevent);

    SDL_Unlock_EventThread();

    return 0;
}
コード例 #24
0
void ph_FreeWMCursor(_THIS, WMcursor *cursor)
{
    if (window != NULL)
    {
        SDL_Lock_EventThread();

        if (PtSetResource(window, Pt_ARG_CURSOR_TYPE, Ph_CURSOR_INHERIT, 0) < 0)
        {
            /* TODO: output error msg */
        }

        SDL_Unlock_EventThread();
    }	

    free(cursor);
}
コード例 #25
0
void SDL_JoystickClose(SDL_Joystick *joystick)
{
	int i;

	if ( ! ValidJoystick(&joystick) ) {
		return;
	}

	
	if ( --joystick->ref_count > 0 ) {
		return;
	}

	
	SDL_Lock_EventThread();

	SDL_SYS_JoystickClose(joystick);

	
	for ( i=0; SDL_joysticks[i]; ++i ) {
		if ( joystick == SDL_joysticks[i] ) {
			SDL_memmove(&SDL_joysticks[i], &SDL_joysticks[i+1],
			       (SDL_allocatedjoysticks-i)*sizeof(joystick));
			break;
		}
	}

	
	SDL_Unlock_EventThread();

	
	if ( joystick->axes ) {
		SDL_free(joystick->axes);
	}
	if ( joystick->hats ) {
		SDL_free(joystick->hats);
	}
	if ( joystick->balls ) {
		SDL_free(joystick->balls);
	}
	if ( joystick->buttons ) {
		SDL_free(joystick->buttons);
	}
	SDL_free(joystick);
}
コード例 #26
0
ファイル: SDL_x11gl.c プロジェクト: cuttl/wii2600
/* Make the current context active */
int X11_GL_MakeCurrent(_THIS)
{
	int retval;
	
	retval = 0;
	if ( ! this->gl_data->glXMakeCurrent(GFX_Display,
	                                     SDL_Window, glx_context) ) {
		SDL_SetError("Unable to make GL context current");
		retval = -1;
	}
	XSync( GFX_Display, False );

	/* More Voodoo X server workarounds... Grr... */
	SDL_Lock_EventThread();
	X11_CheckDGAMouse(this);
	SDL_Unlock_EventThread();

	return(retval);
}
コード例 #27
0
/* Make the current context active */
int X11_GL_MakeCurrent(_THIS)
{
	int retval;
	
	retval = 0;
	if ( ! this->gl_data->glXMakeCurrent(GFX_Display,
	                                     SDL_Window, glx_context) ) {
		SDL_SetError("Unable to make GL context current");
		retval = -1;
	}
	XSync( GFX_Display, False );

	/* 
	 * The context is now current, check for glXReleaseBuffersMESA() 
	 * extension. If extension is _not_ supported, destroy the pointer 
	 * (to make sure it will not be called in X11_GL_Shutdown() ).
	 * 
	 * DRI/Mesa drivers include glXReleaseBuffersMESA() in the libGL.so, 
	 * but there's no need to call it (is is only needed for some old 
	 * non-DRI drivers).
	 * 
	 * When using for example glew (http://glew.sf.net), dlsym() for
	 * glXReleaseBuffersMESA() returns the pointer from the glew library
	 * (namespace conflict).
	 *
	 * The glXReleaseBuffersMESA() pointer in the glew is NULL, if the 
	 * driver doesn't support this extension. So blindly calling it will
	 * cause segfault with DRI/Mesa drivers!
	 * 
	 */
	
	if ( ! ExtensionSupported("glXReleaseBuffersMESA") ) {
		this->gl_data->glXReleaseBuffersMESA = NULL;
	}

	/* More Voodoo X server workarounds... Grr... */
	SDL_Lock_EventThread();
	X11_CheckDGAMouse(this);
	SDL_Unlock_EventThread();

	return(retval);
}
コード例 #28
0
SDL_GrabMode ph_GrabInputNoLock(_THIS, SDL_GrabMode mode)
{
    short abs_x, abs_y;

    if( mode == SDL_GRAB_OFF )
    {
        PtSetResource(window, Pt_ARG_WINDOW_STATE, Pt_FALSE, Ph_WM_STATE_ISALTKEY);
    }
    else
    {
        PtSetResource(window, Pt_ARG_WINDOW_STATE, Pt_TRUE, Ph_WM_STATE_ISALTKEY);

        PtGetAbsPosition(window, &abs_x, &abs_y);
        PhMoveCursorAbs(PhInputGroup(NULL), abs_x + SDL_VideoSurface->w/2, abs_y + SDL_VideoSurface->h/2);
    }

    SDL_Unlock_EventThread();

    return(mode);
}
コード例 #29
0
ファイル: SDL_gicursor.c プロジェクト: grimtraveller/netbas
/* 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");
}
コード例 #30
0
ファイル: SDL_x11mouse.c プロジェクト: BITINT/DEFCON2
int X11_ShowWMCursor(_THIS, WMcursor *cursor)
{
	/* Don't do anything if the display is gone */
	if ( SDL_Display == NULL ) {
		return(0);
	}

	/* Set the X11 cursor cursor, or blank if cursor is NULL */
	if ( SDL_Window ) {
		SDL_Lock_EventThread();
		if ( cursor == NULL ) {
			if ( SDL_BlankCursor != NULL ) {
				XDefineCursor(SDL_Display, SDL_Window,
					SDL_BlankCursor->x_cursor);
			}
		} else {
			XDefineCursor(SDL_Display, SDL_Window, cursor->x_cursor);
		}
		XSync(SDL_Display, False);
		SDL_Unlock_EventThread();
	}
	return(1);
}