本文整理汇总了C++中SDL_SetCursor函数的典型用法代码示例。如果您正苦于以下问题:C++ SDL_SetCursor函数的具体用法?C++ SDL_SetCursor怎么用?C++ SDL_SetCursor使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了SDL_SetCursor函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SDL_SetCursor
void SDLMouse::setCursor( MouseCursor* mc )
{
pCursor = (SDLMouseCursor*)mc;
if ( pCursor != NULL ) {
if ( pCursor->isSystem() ) {
SDL_SetCursor( pCursor->getSDLCursorObject() );
} else {
}
}
}
示例2: sdl_hide_cursor
static void sdl_hide_cursor(void)
{
if (!cursor_hide)
return;
if (kbd_mouse_is_absolute()) {
SDL_ShowCursor(1);
SDL_SetCursor(sdl_cursor_hidden);
} else {
SDL_ShowCursor(0);
}
}
示例3: SDL_GetMouseState
bool Game::MouseDragReset(Entity *object)
{
//Cursor on Hover
if(dragOne == true && object->draggable == false)
return false;
int mouseX = 0;
int mouseY = 0;
SDL_GetMouseState(&mouseX, &mouseY);
if(object->Hover(mouseX, mouseY) == true)
{
SDL_SetCursor(Cursor);
if(LeftButtonPressed == true)
object->draggable = true;
}
if(LeftButtonPressed == false)
object->draggable = false;
if(object->draggable == true)
{
object->XPos = mouseX - object->Width / 2;
object->YPos = mouseY - object->Height / 2;
SDL_SetCursor(DragCursor);
dragOne = true;
return true;
}
else
{
dragOne = false;
object->XPos = object->defaultX;
object->YPos = object->defaultY;
return false;
}
}
示例4: SDL_FreeCursor
//------------------------------------------------------------------------------------------------------
//setter function that creates a system mouse cursor
//------------------------------------------------------------------------------------------------------
void InputManager::SetMouseCursorType(CursorType cursorType)
{
//first destroy old cursor object from memory
SDL_FreeCursor(m_cursor);
//based on type of cursor value passed, create mouse cursor using SDL ID flag value
m_cursor = SDL_CreateSystemCursor(SDL_SystemCursor(cursorType));
//use cursor pointer to assign cursor to SDL
SDL_SetCursor(m_cursor);
}
示例5: sdl_grab_start
static void sdl_grab_start(void)
{
if (guest_cursor) {
SDL_SetCursor(guest_sprite);
SDL_WarpMouse(guest_x, guest_y);
} else
sdl_hide_cursor();
SDL_WM_GrabInput(SDL_GRAB_ON);
/* dummy read to avoid moving the mouse */
SDL_GetRelativeMouseState(NULL, NULL);
gui_grab = 1;
sdl_update_caption();
}
示例6: SDL_CreateRGBSurfaceFrom
void InputDeviceSDL2::setMouseIcon(const std::string& name, const Point& hotSpot)
{
auto it = m_cursors.find(name);
if (it == m_cursors.end())
{
auto fullPath = oContentManager->findResourceFile(name);
if (!fullPath.empty())
{
Point size;
auto pngData = onut::loadPNG(fullPath, size);
if (!pngData.empty())
{
auto pSurface = SDL_CreateRGBSurfaceFrom(pngData.data(),
size.x,
size.y,
32,
size.x * 4,
0x000000ff,
0x0000ff00,
0x00ff0000,
0xff000000);
if (pSurface)
{
auto pCursor = SDL_CreateColorCursor(pSurface, hotSpot.x, hotSpot.y);
if (pCursor)
{
m_cursors[name] = pCursor;
SDL_SetCursor(pCursor);
}
SDL_FreeSurface(pSurface);
}
}
}
}
else
{
SDL_SetCursor(it->second);
}
}
示例7: break_computer_throw_cards_animation
void break_computer_throw_cards_animation(void) {
/** Computer throw cards animation end function. **/
game_control->GAME_STATUS = CARDS_THROW ;
game_control->SAVED_GAME_STATUS = CARDS_THROW ;
game_control->is_animation_running = false ;
game_control->cursor_type = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_ARROW) ;
SDL_SetCursor(game_control->cursor_type) ;
return ;
}
示例8: I_ShutdownGraphics
void I_ShutdownGraphics(void)
{
if (initialized)
{
SDL_SetCursor(cursors[1]);
SDL_ShowCursor(1);
SDL_WM_GrabInput(SDL_GRAB_OFF);
SDL_QuitSubSystem(SDL_INIT_VIDEO);
initialized = false;
}
}
示例9: sdl_hide_cursor
static void sdl_hide_cursor(void)
{
if (!cursor_hide) {
return;
}
if (qemu_input_is_absolute()) {
SDL_ShowCursor(1);
SDL_SetCursor(sdl_cursor_hidden);
} else {
SDL_SetRelativeMouseMode(SDL_TRUE);
}
}
示例10: timestamp
void Cursor::enable()
{
if (mAnimationFrames.size() > 1)
{
// Animated, set the begin and do everything else in setCurrentFrame()
mBeginTimeStamp = timestamp();
mLastFrame = static_cast<size_t>(-1);
}
else
{
// Not animated, just set the first frame
SDL_SetCursor(mAnimationFrames.front());
}
}
示例11: SDL_SetRelativeMouseMode
int
SDL_SetRelativeMouseMode(SDL_bool enabled)
{
SDL_Mouse *mouse = SDL_GetMouse();
SDL_Window *focusWindow = SDL_GetKeyboardFocus();
if (enabled == mouse->relative_mode) {
return 0;
}
if (enabled && focusWindow) {
/* Center it in the focused window to prevent clicks from going through
* to background windows.
*/
SDL_SetMouseFocus(focusWindow);
SDL_WarpMouseInWindow(focusWindow, focusWindow->w/2, focusWindow->h/2);
}
/* Set the relative mode */
if (!enabled && mouse->relative_mode_warp) {
mouse->relative_mode_warp = SDL_FALSE;
} else if (enabled && ShouldUseRelativeModeWarp(mouse)) {
mouse->relative_mode_warp = SDL_TRUE;
} else if (mouse->SetRelativeMouseMode(enabled) < 0) {
if (enabled) {
/* Fall back to warp mode if native relative mode failed */
mouse->relative_mode_warp = SDL_TRUE;
}
}
mouse->relative_mode = enabled;
mouse->scale_accum_x = 0.0f;
mouse->scale_accum_y = 0.0f;
if (mouse->focus) {
SDL_UpdateWindowGrab(mouse->focus);
/* Put the cursor back to where the application expects it */
if (!enabled) {
SDL_WarpMouseInWindow(mouse->focus, mouse->x, mouse->y);
}
}
/* Flush pending mouse motion - ideally we would pump events, but that's not always safe */
SDL_FlushEvent(SDL_MOUSEMOTION);
/* Update cursor visibility */
SDL_SetCursor(NULL);
return 0;
}
示例12: initmouse
void initmouse(void)
{
mouse = 1;
setmousesens(M_MEDIUM);
#ifdef PANDORA
Uint8 noData = 0;
fakeCursor = SDL_CreateCursor(&noData, &noData, 8, 1, 0, 0);
SDL_ShowCursor(SDL_ENABLE);
SDL_SetCursor(fakeCursor);
#else
//SDL_ShowCursor(SDL_DISABLE);
#endif
}
示例13: SDL_SetCursor
~sdl_cursor_handler()
{
m_inited = false;
if (m_system_cursor)
{
SDL_SetCursor(m_system_cursor);
m_system_cursor = NULL;
}
if (m_active_cursor)
{
SDL_FreeCursor(m_active_cursor);
m_active_cursor = NULL;
}
}
示例14: set_cursor
void set_cursor(gameswf::render_handler::cursor_type cursor) {
if (!m_inited)
{
init();
}
switch (cursor)
{
case gameswf::render_handler::SYSTEM_CURSOR:
if (m_system_cursor) {
SDL_SetCursor(m_system_cursor);
}
break;
case gameswf::render_handler::ACTIVE_CURSOR:
if (m_active_cursor) {
SDL_SetCursor(m_active_cursor);
}
break;
default:
assert(0);
}
}
示例15: SetSize
void Cursor::ApplyShape()
{
CursorShapeInfo& info = shapeInfos_[shape_];
texture_ = info.texture_;
imageRect_ = info.imageRect_;
SetSize(info.imageRect_.Size());
// If the OS cursor is being shown, define/set SDL cursor shape if necessary
// Only do this when we are the active UI cursor
if (GetSubsystem<Input>()->IsMouseVisible() && GetSubsystem<UI>()->GetCursor() == this)
{
// Remove existing SDL cursor if is not a system shape while we should be using those, or vice versa
if (info.osCursor_ && info.systemDefined_ != useSystemShapes_)
{
SDL_FreeCursor(info.osCursor_);
info.osCursor_ = 0;
}
// Create SDL cursor now if necessary
if (!info.osCursor_)
{
// Create a system default shape
if (useSystemShapes_)
{
info.osCursor_ = SDL_CreateSystemCursor((SDL_SystemCursor)osCursorLookup[shape_]);
info.systemDefined_ = true;
if (!info.osCursor_)
LOGERROR("Could not create system cursor");
}
// Create from image
else if (info.image_)
{
SDL_Surface* surface = info.image_->GetSDLSurface(info.imageRect_);
if (surface)
{
info.osCursor_ = SDL_CreateColorCursor(surface, info.hotSpot_.x_, info.hotSpot_.y_);
info.systemDefined_ = false;
if (!info.osCursor_)
LOGERROR("Could not create cursor from image " + info.image_->GetName());
SDL_FreeSurface(surface);
}
}
}
if (info.osCursor_)
SDL_SetCursor(info.osCursor_);
}
}