本文整理汇总了C++中SDL_ShowCursor函数的典型用法代码示例。如果您正苦于以下问题:C++ SDL_ShowCursor函数的具体用法?C++ SDL_ShowCursor怎么用?C++ SDL_ShowCursor使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了SDL_ShowCursor函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char *argv[])
{
Uint32 flags;
SDL_Surface *screen, *image;
int i, depth, done;
SDL_Event event;
SDL_RWops* rw_ops;
/* Check command line usage */
if ( ! argv[1] ) {
fprintf(stderr, "Usage: %s <image_file>\n", argv[0]);
return(1);
}
/* Initialize the SDL library */
if ( SDL_Init(SDL_INIT_VIDEO) < 0 ) {
fprintf(stderr, "Couldn't initialize SDL: %s\n",SDL_GetError());
return(255);
}
flags = SDL_SWSURFACE;
for ( i=1; argv[i]; ++i ) {
if ( strcmp(argv[i], "-fullscreen") == 0 ) {
SDL_ShowCursor(0);
flags |= SDL_FULLSCREEN;
continue;
}
#if 0
rw_ops = SDL_RWFromFile(argv[1], "r");
fprintf(stderr, "BMP:\t%d\n", IMG_isBMP(rw_ops));
fprintf(stderr, "GIF:\t%d\n", IMG_isGIF(rw_ops));
fprintf(stderr, "JPG:\t%d\n", IMG_isJPG(rw_ops));
fprintf(stderr, "PNG:\t%d\n", IMG_isPNG(rw_ops));
fprintf(stderr, "TIF:\t%d\n", IMG_isTIF(rw_ops));
/* fprintf(stderr, "TGA:\t%d\n", IMG_isTGA(rw_ops)); */
fprintf(stderr, "PCX:\t%d\n", IMG_isPCX(rw_ops));
#endif
/* Open the image file */
#ifdef XPM_INCLUDED
image = IMG_ReadXPMFromArray(picture_xpm);
#else
image = IMG_Load(argv[i]);
#endif
if ( image == NULL ) {
fprintf(stderr, "Couldn't load %s: %s\n",
argv[i], SDL_GetError());
continue;
}
SDL_WM_SetCaption(argv[i], "showimage");
/* Create a display for the image */
depth = SDL_VideoModeOK(image->w, image->h, 32, flags);
/* Use the deepest native mode, except that we emulate 32bpp
for viewing non-indexed images on 8bpp screens */
if ( depth == 0 ) {
if ( image->format->BytesPerPixel > 1 ) {
depth = 32;
} else {
depth = 8;
}
} else
if ( (image->format->BytesPerPixel > 1) && (depth == 8) ) {
depth = 32;
}
if(depth == 8)
flags |= SDL_HWPALETTE;
screen = SDL_SetVideoMode(image->w, image->h, depth, flags);
if ( screen == NULL ) {
fprintf(stderr,"Couldn't set %dx%dx%d video mode: %s\n",
image->w, image->h, depth, SDL_GetError());
continue;
}
/* Set the palette, if one exists */
if ( image->format->palette ) {
SDL_SetColors(screen, image->format->palette->colors,
0, image->format->palette->ncolors);
}
/* Draw a background pattern if the surface has transparency */
if(image->flags & (SDL_SRCALPHA | SDL_SRCCOLORKEY))
draw_background(screen);
/* Display the image */
SDL_BlitSurface(image, NULL, screen, NULL);
SDL_UpdateRect(screen, 0, 0, 0, 0);
done = 0;
while ( ! done ) {
if ( SDL_PollEvent(&event) ) {
switch (event.type) {
case SDL_KEYUP:
switch (event.key.keysym.sym) {
case SDLK_LEFT:
if ( i > 1 ) {
i -= 2;
done = 1;
}
//.........这里部分代码省略.........
示例2: GLimp_SetMode
//.........这里部分代码省略.........
sdlcolorbits = 0; /* Use minimum size for 16-bit color */
/* Need alpha or else SGIs choose 36+ bit RGB mode */
SDL_GL_SetAttribute( SDL_GL_ALPHA_SIZE, 1);
#endif
SDL_GL_SetAttribute( SDL_GL_RED_SIZE, sdlcolorbits );
SDL_GL_SetAttribute( SDL_GL_GREEN_SIZE, sdlcolorbits );
SDL_GL_SetAttribute( SDL_GL_BLUE_SIZE, sdlcolorbits );
SDL_GL_SetAttribute( SDL_GL_DEPTH_SIZE, tdepthbits );
SDL_GL_SetAttribute( SDL_GL_STENCIL_SIZE, tstencilbits );
if( haveMultiSample )
{
SDL_GL_SetAttribute( SDL_GL_MULTISAMPLEBUFFERS, samples ? 1 : 0 );
SDL_GL_SetAttribute( SDL_GL_MULTISAMPLESAMPLES, samples );
}
if(r_stereoEnabled->integer)
{
glConfig.stereoEnabled = ( SDL_GL_SetAttribute(SDL_GL_STEREO, 1) == 0 );
}
else
{
glConfig.stereoEnabled = qfalse;
SDL_GL_SetAttribute(SDL_GL_STEREO, 0);
}
SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 );
#if 0 // See http://bugzilla.icculus.org/show_bug.cgi?id=3526
// If not allowing software GL, demand accelerated
if( !r_allowSoftwareGL->integer )
{
if( SDL_GL_SetAttribute( SDL_GL_ACCELERATED_VISUAL, 1 ) < 0 )
{
ri.Printf( PRINT_ALL, "Unable to guarantee accelerated "
"visual with libSDL < 1.2.10\n" );
}
}
#endif
if( SDL_GL_SetAttribute( SDL_GL_SWAP_CONTROL, r_swapInterval->integer ) < 0 )
ri.Printf( PRINT_ALL, "r_swapInterval requires libSDL >= 1.2.10\n" );
#ifdef USE_ICON
{
SDL_Surface *icon = SDL_CreateRGBSurfaceFrom(
(void *)CLIENT_WINDOW_ICON.pixel_data,
CLIENT_WINDOW_ICON.width,
CLIENT_WINDOW_ICON.height,
CLIENT_WINDOW_ICON.bytes_per_pixel * 8,
CLIENT_WINDOW_ICON.bytes_per_pixel * CLIENT_WINDOW_ICON.width,
#ifdef Q3_LITTLE_ENDIAN
0x000000FF, 0x0000FF00, 0x00FF0000, 0xFF000000
#else
0xFF000000, 0x00FF0000, 0x0000FF00, 0x000000FF
#endif
);
SDL_WM_SetIcon( icon, NULL );
SDL_FreeSurface( icon );
}
#endif
SDL_WM_SetCaption(CLIENT_WINDOW_TITLE, CLIENT_WINDOW_MIN_TITLE);
SDL_ShowCursor(0);
if (!(vidscreen = SDL_SetVideoMode(glConfig.vidWidth, glConfig.vidHeight, colorbits, flags)))
{
ri.Printf( PRINT_DEVELOPER, "SDL_SetVideoMode failed: %s\n", SDL_GetError( ) );
continue;
}
opengl_context = GLimp_GetCurrentContext();
ri.Printf( PRINT_ALL, "Using %d/%d/%d Color bits, %d depth, %d stencil display.\n",
sdlcolorbits, sdlcolorbits, sdlcolorbits, tdepthbits, tstencilbits);
glConfig.colorBits = tcolorbits;
glConfig.depthBits = tdepthbits;
glConfig.stencilBits = tstencilbits;
break;
}
GLimp_DetectAvailableModes();
if (!vidscreen)
{
ri.Printf( PRINT_ALL, "Couldn't get a visual\n" );
return RSERR_INVALID_MODE;
}
screen = vidscreen;
glstring = (char *) qglGetString (GL_RENDERER);
ri.Printf( PRINT_ALL, "GL_RENDERER: %s\n", glstring );
return RSERR_OK;
}
示例3: InitVideo
/**
* Attempts to initialize the graphical video display. Returns 0 on
* success, -1 on failure.
*/
int
InitVideo(FCEUGI *gi)
{
// XXX soules - const? is this necessary?
const SDL_VideoInfo *vinf;
int error, flags = 0;
int doublebuf, xstretch, ystretch, xres, yres;
FCEUI_printf("Initializing video...");
// load the relevant configuration variables
g_config->getOption("SDL.Fullscreen", &s_fullscreen);
g_config->getOption("SDL.DoubleBuffering", &doublebuf);
#ifdef OPENGL
g_config->getOption("SDL.OpenGL", &s_useOpenGL);
#endif
g_config->getOption("SDL.SpecialFilter", &s_sponge);
g_config->getOption("SDL.XStretch", &xstretch);
g_config->getOption("SDL.YStretch", &ystretch);
g_config->getOption("SDL.XResolution", &xres);
g_config->getOption("SDL.YResolution", &yres);
g_config->getOption("SDL.ClipSides", &s_clipSides);
g_config->getOption("SDL.NoFrame", &noframe);
// check the starting, ending, and total scan lines
FCEUI_GetCurrentVidSystem(&s_srendline, &s_erendline);
s_tlines = s_erendline - s_srendline + 1;
// check for OpenGL and set the global flags
#if OPENGL
if(s_useOpenGL && !s_sponge) {
flags = SDL_OPENGL;
}
#endif
// initialize the SDL video subsystem if it is not already active
if(!SDL_WasInit(SDL_INIT_VIDEO)) {
error = SDL_InitSubSystem(SDL_INIT_VIDEO);
if(error) {
FCEUD_PrintError(SDL_GetError());
return -1;
}
}
s_inited = 1;
// shows the cursor within the display window
SDL_ShowCursor(1);
// determine if we can allocate the display on the video card
vinf = SDL_GetVideoInfo();
if(vinf->hw_available) {
flags |= SDL_HWSURFACE;
}
// check if we are rendering fullscreen
if(s_fullscreen) {
flags |= SDL_FULLSCREEN;
SDL_ShowCursor(0);
}
else {
SDL_ShowCursor(1);
}
if(noframe) {
flags |= SDL_NOFRAME;
}
// gives the SDL exclusive palette control... ensures the requested colors
flags |= SDL_HWPALETTE;
// enable double buffering if requested and we have hardware support
#ifdef OPENGL
if(s_useOpenGL) {
FCEU_printf("Initializing with OpenGL (Disable with '-opengl 0').\n");
if(doublebuf) {
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
}
} else
#endif
if(doublebuf && (flags & SDL_HWSURFACE)) {
flags |= SDL_DOUBLEBUF;
}
if(s_fullscreen) {
int desbpp, autoscale;
g_config->getOption("SDL.BitsPerPixel", &desbpp);
g_config->getOption("SDL.AutoScale", &autoscale);
if (autoscale)
{
double auto_xscale = GetXScale(xres);
double auto_yscale = GetYScale(yres);
double native_ratio = ((double)NWIDTH) / s_tlines;
//.........这里部分代码省略.........
示例4: SDL_ShowCursor
Gource::Gource(FrameExporter* exporter) {
this->logfile = gGourceSettings.path;
commitlog = 0;
fontlarge = fontmanager.grab("FreeSans.ttf", 42);
fontlarge.dropShadow(true);
fontlarge.roundCoordinates(true);
fontmedium = fontmanager.grab("FreeSans.ttf", gGourceSettings.font_size);
fontmedium.dropShadow(true);
fontmedium.roundCoordinates(false);
font = fontmanager.grab("FreeSans.ttf", 14);
font.dropShadow(true);
font.roundCoordinates(true);
bloomtex = texturemanager.grab("bloom.tga");
beamtex = texturemanager.grab("beam.png");
logotex = 0;
backgroundtex = 0;
//load logo
if(gGourceSettings.logo.size() > 0) {
logotex = texturemanager.grabFile(gGourceSettings.logo);
}
//load background image
if(gGourceSettings.background_image.size() > 0) {
backgroundtex = texturemanager.grabFile(gGourceSettings.background_image);
}
stop_position_reached=false;
paused = false;
first_read = true;
draw_loading = true;
mousemoved = false;
mousedragged = false;
mouseclicked = false;
if(gGourceSettings.hide_mouse) {
SDL_ShowCursor(false);
}
splash = -1.0;
debug = false;
trace_debug = false;
frameExporter = 0;
dirNodeTree = 0;
userTree = 0;
selectedFile = 0;
hoverFile = 0;
selectedUser = 0;
hoverUser = 0;
date_x_offset = 0;
camera = ZoomCamera(vec3f(0,0, -300), vec3f(0.0, 0.0, 0.0), 250.0, 5000.0);
setCameraMode(gGourceSettings.camera_mode);
root = 0;
//min phsyics rate 60fps (ie maximum allowed delta 1.0/60)
max_tick_rate = 1.0 / 60.0;
runtime = 0.0f;
frameskip = 0;
framecount = 0;
reset();
if(exporter!=0) setFrameExporter(exporter, gGourceSettings.output_framerate);
//if recording a video or in demo mode, or multiple repos, the slider is initially hidden
if(exporter==0 && gGourceSettings.repo_count==1) slider.show();
}
示例5: screenshot
void Gource::keyPress(SDL_KeyboardEvent *e) {
if (e->type == SDL_KEYUP) return;
if (e->type == SDL_KEYDOWN) {
if (e->keysym.unicode == SDLK_ESCAPE) {
appFinished=true;
}
if(commitlog==0) return;
if(e->keysym.sym == SDLK_F12) {
screenshot();
}
if (e->keysym.sym == SDLK_q) {
debug = !debug;
}
if (e->keysym.sym == SDLK_w) {
trace_debug = !trace_debug;
}
if (e->keysym.sym == SDLK_m) {
Uint8 ms = SDL_GetMouseState(0,0);
//toggle mouse visiblity unless mouse clicked/pressed/dragged
if(!(mousedragged || mouseclicked || ms & SDL_BUTTON(SDL_BUTTON_LEFT))) {
if(SDL_ShowCursor(SDL_QUERY) == SDL_ENABLE) {
SDL_ShowCursor(false);
gGourceSettings.hide_mouse = true;
} else {
SDL_ShowCursor(true);
gGourceSettings.hide_mouse = false;
}
}
}
if (e->keysym.sym == SDLK_n) {
idle_time = gGourceSettings.auto_skip_seconds;
}
if (e->keysym.sym == SDLK_t) {
gGourceQuadTreeDebug = !gGourceQuadTreeDebug;
}
if (e->keysym.sym == SDLK_g) {
gGourceSettings.hide_users = !gGourceSettings.hide_users;
}
if (e->keysym.sym == SDLK_u) {
gGourceSettings.hide_usernames = !gGourceSettings.hide_usernames;
}
if (e->keysym.sym == SDLK_d) {
gGourceSettings.hide_dirnames = ! gGourceSettings.hide_dirnames;
}
if (e->keysym.sym == SDLK_f) {
gGourceSettings.hide_filenames = !gGourceSettings.hide_filenames;
}
if(e->keysym.sym == SDLK_c) {
splash = 15.0f;
}
if (e->keysym.sym == SDLK_v) {
toggleCameraMode();
}
if (e->keysym.sym == SDLK_z) {
gGourceGravity = !gGourceGravity;
}
if(e->keysym.unicode == SDLK_TAB) {
selectNextUser();
}
if (e->keysym.unicode == SDLK_SPACE) {
paused = !paused;
}
if (e->keysym.unicode == SDLK_EQUALS || e->keysym.unicode == SDLK_PLUS) {
if(gGourceSettings.days_per_second>=1.0) {
gGourceSettings.days_per_second = std::min(30.0f, floorf(gGourceSettings.days_per_second) + 1.0f);
} else {
gGourceSettings.days_per_second = std::min(1.0f, gGourceSettings.days_per_second * 2.0f);
}
}
if (e->keysym.unicode == SDLK_MINUS) {
if(gGourceSettings.days_per_second>1.0) {
gGourceSettings.days_per_second = std::max(0.0f, floorf(gGourceSettings.days_per_second) - 1.0f);
} else {
gGourceSettings.days_per_second = std::max(0.0f, gGourceSettings.days_per_second * 0.5f);
}
}
if(e->keysym.sym == SDLK_UP) {
zoom(true);
//.........这里部分代码省略.........
示例6: SDL_ShowCursor
//Enable / Disable cursor image
void M_Input::EnableCursorImage()
{
SDL_ShowCursor(SDL_ENABLE);
}
示例7: main
//.........这里部分代码省略.........
#else
NativeInit(remain_argc, (const char **)remain_argv, path, "/tmp", nullptr);
#endif
// Use the setting from the config when initing the window.
if (g_Config.bFullScreen)
mode |= SDL_WINDOW_FULLSCREEN_DESKTOP;
g_Screen = SDL_CreateWindow(app_name_nice.c_str(), SDL_WINDOWPOS_UNDEFINED_DISPLAY(getDisplayNumber()),\
SDL_WINDOWPOS_UNDEFINED, pixel_xres, pixel_yres, mode);
if (g_Screen == NULL) {
NativeShutdown();
fprintf(stderr, "SDL_CreateWindow failed: %s\n", SDL_GetError());
SDL_Quit();
return 2;
}
SDL_GLContext glContext = SDL_GL_CreateContext(g_Screen);
if (glContext == NULL) {
NativeShutdown();
fprintf(stderr, "SDL_GL_CreateContext failed: %s\n", SDL_GetError());
SDL_Quit();
return 2;
}
#ifdef USING_EGL
EGL_Init();
#endif
SDL_SetWindowTitle(g_Screen, (app_name_nice + " " + PPSSPP_GIT_VERSION).c_str());
#ifdef MOBILE_DEVICE
SDL_ShowCursor(SDL_DISABLE);
#endif
#ifndef USING_GLES2
// Some core profile drivers elide certain extensions from GL_EXTENSIONS/etc.
// glewExperimental allows us to force GLEW to search for the pointers anyway.
if (gl_extensions.IsCoreContext)
glewExperimental = true;
if (GLEW_OK != glewInit()) {
printf("Failed to initialize glew!\n");
return 1;
}
// Unfortunately, glew will generate an invalid enum error, ignore.
if (gl_extensions.IsCoreContext)
glGetError();
if (GLEW_VERSION_2_0) {
printf("OpenGL 2.0 or higher.\n");
} else {
printf("Sorry, this program requires OpenGL 2.0.\n");
return 1;
}
#endif
pixel_in_dps_x = (float)pixel_xres / dp_xres;
pixel_in_dps_y = (float)pixel_yres / dp_yres;
g_dpi_scale_x = dp_xres / (float)pixel_xres;
g_dpi_scale_y = dp_yres / (float)pixel_yres;
g_dpi_scale_real_x = g_dpi_scale_x;
g_dpi_scale_real_y = g_dpi_scale_y;
示例8: stat
void Graphics::close()
{
stat("Graphics::Close()");
SDL_ShowCursor(true);
SDL_DestroyWindow(window); window = NULL;
}
示例9: main
int main(int argc, char **argv)
{
// initialize everything
if( SDL_Init( SDL_INIT_VIDEO | SDL_INIT_EVENTS ) < 0 )
{
return 1;
}
if (!g_oculusVR.InitVR())
{
SDL_Quit();
return 1;
}
ovrSizei hmdResolution = g_oculusVR.GetResolution();
ovrSizei windowSize = { hmdResolution.w / 2, hmdResolution.h / 2 };
g_renderContext.Init("Oculus Rift OpenGL Debug Info Renderer", 100, 100, windowSize.w, windowSize.h);
SDL_ShowCursor(SDL_DISABLE);
if (glewInit() != GLEW_OK)
{
g_oculusVR.DestroyVR();
g_renderContext.Destroy();
SDL_Quit();
return 1;
}
if (!g_oculusVR.InitVRBuffers(windowSize.w, windowSize.h))
{
g_oculusVR.DestroyVR();
g_renderContext.Destroy();
SDL_Quit();
return 1;
}
ShaderManager::GetInstance()->LoadShaders();
g_oculusVR.CreateDebug();
g_application.OnStart();
while (g_application.Running())
{
// handle key presses
processEvents();
glClearColor(0.2f, 0.2f, 0.6f, 0.0f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
g_oculusVR.OnRenderStart();
g_oculusVR.UpdateDebug();
for (int eyeIndex = 0; eyeIndex < ovrEye_Count; eyeIndex++)
{
OVR::Matrix4f MVPMatrix = g_oculusVR.OnEyeRender(eyeIndex);
// update MVP in quad shader
const ShaderProgram &shader = ShaderManager::GetInstance()->UseShaderProgram(ShaderManager::BasicShader);
glUniformMatrix4fv(shader.uniforms[ModelViewProjectionMatrix], 1, GL_FALSE, &MVPMatrix.Transposed().M[0][0]);
g_application.OnRender();
g_oculusVR.RenderDebug();
g_oculusVR.OnEyeRenderFinish(eyeIndex);
}
g_oculusVR.SubmitFrame();
g_oculusVR.BlitMirror();
SDL_GL_SwapWindow(g_renderContext.window);
}
g_oculusVR.DestroyVR();
g_renderContext.Destroy();
SDL_Quit();
return 0;
}
示例10: SDL_ShowCursor
Mouse::~Mouse()
{
// Show cursor
SDL_ShowCursor(1);
}
示例11: ImGui_ImplSdlGL2_NewFrame
void ImGui_ImplSdlGL2_NewFrame(SDL_Window *window)
{
if (!g_FontTexture)
ImGui_ImplSdlGL2_CreateDeviceObjects();
ImGuiIO& io = ImGui::GetIO();
// Setup display size (every frame to accommodate for window resizing)
int w, h;
int display_w, display_h;
SDL_GetWindowSize(window, &w, &h);
SDL_GL_GetDrawableSize(window, &display_w, &display_h);
io.DisplaySize = ImVec2((float)w, (float)h);
io.DisplayFramebufferScale = ImVec2(w > 0 ? ((float)display_w / w) : 0, h > 0 ? ((float)display_h / h) : 0);
// Setup time step (we don't use SDL_GetTicks() because it is using millisecond resolution)
static Uint64 frequency = SDL_GetPerformanceFrequency();
Uint64 current_time = SDL_GetPerformanceCounter();
io.DeltaTime = g_Time > 0 ? (float)((double)(current_time - g_Time) / frequency) : (float)(1.0f / 60.0f);
g_Time = current_time;
// Setup mouse inputs (we already got mouse wheel, keyboard keys & characters from our event handler)
int mx, my;
Uint32 mouse_buttons = SDL_GetMouseState(&mx, &my);
io.MousePos = ImVec2(-FLT_MAX, -FLT_MAX);
io.MouseDown[0] = g_MousePressed[0] || (mouse_buttons & SDL_BUTTON(SDL_BUTTON_LEFT)) != 0; // If a mouse press event came, always pass it as "mouse held this frame", so we don't miss click-release events that are shorter than 1 frame.
io.MouseDown[1] = g_MousePressed[1] || (mouse_buttons & SDL_BUTTON(SDL_BUTTON_RIGHT)) != 0;
io.MouseDown[2] = g_MousePressed[2] || (mouse_buttons & SDL_BUTTON(SDL_BUTTON_MIDDLE)) != 0;
g_MousePressed[0] = g_MousePressed[1] = g_MousePressed[2] = false;
// We need to use SDL_CaptureMouse() to easily retrieve mouse coordinates outside of the client area. This is only supported from SDL 2.0.4 (released Jan 2016)
#if (SDL_MAJOR_VERSION >= 2) && (SDL_MINOR_VERSION >= 0) && (SDL_PATCHLEVEL >= 4)
if ((SDL_GetWindowFlags(window) & (SDL_WINDOW_MOUSE_FOCUS | SDL_WINDOW_MOUSE_CAPTURE)) != 0)
io.MousePos = ImVec2((float)mx, (float)my);
bool any_mouse_button_down = false;
for (int n = 0; n < IM_ARRAYSIZE(io.MouseDown); n++)
any_mouse_button_down |= io.MouseDown[n];
if (any_mouse_button_down && (SDL_GetWindowFlags(window) & SDL_WINDOW_MOUSE_CAPTURE) == 0)
SDL_CaptureMouse(SDL_TRUE);
if (!any_mouse_button_down && (SDL_GetWindowFlags(window) & SDL_WINDOW_MOUSE_CAPTURE) != 0)
SDL_CaptureMouse(SDL_FALSE);
#else
if ((SDL_GetWindowFlags(window) & SDL_WINDOW_INPUT_FOCUS) != 0)
io.MousePos = ImVec2((float)mx, (float)my);
#endif
// Update OS/hardware mouse cursor if imgui isn't drawing a software cursor
ImGuiMouseCursor cursor = ImGui::GetMouseCursor();
if (io.MouseDrawCursor || cursor == ImGuiMouseCursor_None)
{
SDL_ShowCursor(0);
}
else
{
SDL_SetCursor(g_MouseCursors[cursor] ? g_MouseCursors[cursor] : g_MouseCursors[ImGuiMouseCursor_Arrow]);
SDL_ShowCursor(1);
}
// Start the frame. This call will update the io.WantCaptureMouse, io.WantCaptureKeyboard flag that you can use to dispatch inputs (or not) to your application.
ImGui::NewFrame();
}
示例12: Control
/**
* Control for vout display
*/
static int Control(vout_display_t *vd, int query, va_list args)
{
vout_display_sys_t *sys = vd->sys;
switch (query)
{
case VOUT_DISPLAY_HIDE_MOUSE:
SDL_ShowCursor(0);
return VLC_SUCCESS;
case VOUT_DISPLAY_CHANGE_DISPLAY_SIZE: {
const vout_display_cfg_t *cfg = va_arg(args, const vout_display_cfg_t *);
/* */
sys->display = SDL_SetVideoMode(cfg->display.width,
cfg->display.height,
sys->display_bpp, sys->display_flags);
if (!sys->display) {
sys->display = SDL_SetVideoMode(vd->cfg->display.width,
vd->cfg->display.height,
sys->display_bpp, sys->display_flags);
return VLC_EGENERIC;
}
if (sys->overlay)
vout_display_PlacePicture(&sys->place, &vd->source, cfg, !sys->overlay);
else
vout_display_SendEventPicturesInvalid(vd);
return VLC_SUCCESS;
}
case VOUT_DISPLAY_CHANGE_FULLSCREEN: {
vout_display_cfg_t cfg = *va_arg(args, const vout_display_cfg_t *);
/* Fix flags */
sys->display_flags &= ~(SDL_FULLSCREEN | SDL_RESIZABLE);
sys->display_flags |= cfg.is_fullscreen ? SDL_FULLSCREEN : SDL_RESIZABLE;
if (cfg.is_fullscreen) {
cfg.display.width = sys->desktop_width;
cfg.display.height = sys->desktop_height;
}
if (sys->overlay) {
sys->display = SDL_SetVideoMode(cfg.display.width, cfg.display.height,
sys->display_bpp, sys->display_flags);
vout_display_PlacePicture(&sys->place, &vd->source, &cfg, !sys->overlay);
}
vout_display_SendEventDisplaySize(vd, cfg.display.width, cfg.display.height, cfg.is_fullscreen);
return VLC_SUCCESS;
}
case VOUT_DISPLAY_CHANGE_ZOOM:
case VOUT_DISPLAY_CHANGE_DISPLAY_FILLED:
case VOUT_DISPLAY_CHANGE_SOURCE_ASPECT: {
const vout_display_cfg_t *cfg;
const video_format_t *source;
if (query == VOUT_DISPLAY_CHANGE_SOURCE_ASPECT) {
source = va_arg(args, const video_format_t *);
cfg = vd->cfg;
} else {
source = &vd->source;
cfg = va_arg(args, const vout_display_cfg_t *);
}
if (sys->overlay) {
sys->display = SDL_SetVideoMode(cfg->display.width, cfg->display.height,
sys->display_bpp, sys->display_flags);
vout_display_PlacePicture(&sys->place, source, cfg, !sys->overlay);
} else {
vout_display_SendEventPicturesInvalid(vd);
}
return VLC_SUCCESS;
}
示例13: os_poll
void os_poll(void)
{
#ifdef USE_SDL
SDL_Event event;
/* The event queue works only with the video initialized */
if (!SDL_WasInit(SDL_INIT_VIDEO))
return;
log_debug(("os: SDL_PollEvent()\n"));
while (SDL_PollEvent(&event)) {
log_debug(("os: SDL_PollEvent() -> event.type:%d\n", (int)event.type));
switch (event.type) {
case SDL_KEYDOWN :
#ifdef USE_KEYBOARD_SDL
keyb_sdl_event_press(event.key.keysym.sym);
#endif
#ifdef USE_INPUT_SDL
inputb_sdl_event_press(event.key.keysym.sym);
#endif
/* toggle fullscreen check */
if (event.key.keysym.sym == SDLK_RETURN
&& (event.key.keysym.mod & KMOD_ALT) != 0) {
if (SDL_WasInit(SDL_INIT_VIDEO) && SDL_GetVideoSurface()) {
SDL_WM_ToggleFullScreen(SDL_GetVideoSurface());
if ((SDL_GetVideoSurface()->flags & SDL_FULLSCREEN) != 0) {
SDL_ShowCursor(SDL_DISABLE);
} else {
SDL_ShowCursor(SDL_ENABLE);
}
}
}
break;
case SDL_KEYUP :
#ifdef USE_KEYBOARD_SDL
keyb_sdl_event_release(event.key.keysym.sym);
#endif
#ifdef USE_INPUT_SDL
inputb_sdl_event_release(event.key.keysym.sym);
#endif
break;
case SDL_MOUSEMOTION :
#ifdef USE_MOUSE_SDL
mouseb_sdl_event_move(event.motion.xrel, event.motion.yrel);
#endif
break;
case SDL_MOUSEBUTTONDOWN :
#ifdef USE_MOUSE_SDL
if (event.button.button > 0)
mouseb_sdl_event_press(event.button.button-1);
#endif
break;
case SDL_MOUSEBUTTONUP :
#ifdef USE_MOUSE_SDL
if (event.button.button > 0)
mouseb_sdl_event_release(event.button.button-1);
#endif
break;
case SDL_QUIT :
OS.is_quit = 1;
break;
}
}
#endif
}
示例14: input_handle
/**
* @brief Handles global input.
*
* Basically separates the event types
*
* @param event Incoming SDL_Event.
*/
void input_handle( SDL_Event* event )
{
/* Special case mouse stuff. */
if ((event->type == SDL_MOUSEMOTION) ||
(event->type == SDL_MOUSEBUTTONDOWN) ||
(event->type == SDL_MOUSEBUTTONUP)) {
input_mouseTimer = MOUSE_HIDE;
SDL_ShowCursor( SDL_ENABLE );
}
if (toolkit_isOpen()) /* toolkit handled completely separately */
if (toolkit_input(event))
return; /* we don't process it if toolkit grabs it */
if (ovr_isOpen())
if (ovr_input(event))
return; /* Don't process if the map overlay wants it. */
/* GUI gets event. */
if (gui_handleEvent(event))
return;
switch (event->type) {
/*
* game itself
*/
case SDL_JOYAXISMOTION:
input_joyaxis(event->jaxis.axis, event->jaxis.value);
break;
case SDL_JOYBUTTONDOWN:
input_joyevent(KEY_PRESS, event->jbutton.button);
break;
case SDL_JOYBUTTONUP:
input_joyevent(KEY_RELEASE, event->jbutton.button);
break;
case SDL_KEYDOWN:
input_keyevent(KEY_PRESS, event->key.keysym.sym, event->key.keysym.mod, 0);
break;
case SDL_KEYUP:
input_keyevent(KEY_RELEASE, event->key.keysym.sym, event->key.keysym.mod, 0);
break;
/* Mouse stuff. */
case SDL_MOUSEBUTTONDOWN:
input_clickevent( event );
break;
case SDL_MOUSEMOTION:
input_mouseMove( event );
break;
default:
break;
}
}
示例15: SDL_GetMouseState
void Application::on_loop()
{
SDL_GetMouseState(&m_mouse_x,&m_mouse_y);
for(unsigned int i = 0; i < m_input_keys.size(); ++i)
{
if(m_input_keys.at(i))
{
m_renderer->get_rig()->update_position(i,1.0f);
}
}
if(m_joystick != NULL)
{
int epsilon = 3000;
//~ //Forward / Backward
if(SDL_JoystickGetAxis(m_joystick, 1) > epsilon) m_renderer->get_rig()->update_position(0,abs(SDL_JoystickGetAxis(m_joystick, 1)/10000.0));
if(SDL_JoystickGetAxis(m_joystick, 1) < -epsilon) m_renderer->get_rig()->update_position(1,abs(SDL_JoystickGetAxis(m_joystick, 1)/10000.0));
//~ //Left / Right
if(SDL_JoystickGetAxis(m_joystick, 0) < -epsilon) m_renderer->get_rig()->update_position(2,abs(SDL_JoystickGetAxis(m_joystick, 0)/10000.0));
if(SDL_JoystickGetAxis(m_joystick, 0) > epsilon) m_renderer->get_rig()->update_position(3,abs(SDL_JoystickGetAxis(m_joystick, 0)/10000.0));
#ifdef _WIN32
epsilon = 10000;
//~ //Eyes to the ground / sky
if(SDL_JoystickGetAxis(m_joystick, 4) < -epsilon) m_mouse_x -= (abs(SDL_JoystickGetAxis(m_joystick, 4)/2500.0));
if(SDL_JoystickGetAxis(m_joystick, 4) > epsilon) m_mouse_x += (abs(SDL_JoystickGetAxis(m_joystick, 4)/2500.0));
if(SDL_JoystickGetAxis(m_joystick, 3) < -epsilon) m_mouse_y -= (abs(SDL_JoystickGetAxis(m_joystick, 3)/2500.0));
if(SDL_JoystickGetAxis(m_joystick, 3) > epsilon) m_mouse_y += (abs(SDL_JoystickGetAxis(m_joystick, 3)/2500.0));
#elif __linux
if(SDL_JoystickGetAxis(m_joystick, 2) < -epsilon) m_mouse_x -= (abs(SDL_JoystickGetAxis(m_joystick, 2)/1000.0));
if(SDL_JoystickGetAxis(m_joystick, 2) > epsilon) m_mouse_x += (abs(SDL_JoystickGetAxis(m_joystick, 2)/1000.0));
if(SDL_JoystickGetAxis(m_joystick, 3) < -epsilon) m_mouse_y -= (abs(SDL_JoystickGetAxis(m_joystick, 3)/1000.0));
if(SDL_JoystickGetAxis(m_joystick, 3) > epsilon) m_mouse_y += (abs(SDL_JoystickGetAxis(m_joystick, 3)/1000.0));
#endif
}
if(m_display_gui)
{
m_renderer->get_rig()->update_horizontal_angle(m_display->w/2);
m_renderer->get_rig()->update_vertical_angle(m_display->h/2);
m_renderer->set_display_gui(true);
SDL_ShowCursor(SDL_ENABLE);
}
else
{
SDL_WarpMouse(m_display->w/2, m_display->h/2);
if(m_has_focus_changed)
{
#ifdef _WIN32
m_mouse_x = m_display->w/2;
m_mouse_y = m_display->h/2;
#elif __linux
m_mouse_x = 0.0f;
m_mouse_y = 0.0f;
#endif
m_has_focus_changed = !m_has_focus_changed;
}
m_renderer->get_rig()->update_horizontal_angle(m_mouse_x);
m_renderer->get_rig()->update_vertical_angle(m_mouse_y);
m_renderer->set_display_gui(false);
SDL_ShowCursor(SDL_DISABLE);
}
m_renderer->get_rig()->update_target();
m_renderer->get_rig()->update_up();
m_renderer->get_rig()->get_camera_one()->compute_view_matrix();
m_renderer->get_rig()->get_camera_two()->compute_view_matrix();
}