本文整理汇总了C++中MouseInput::setReal方法的典型用法代码示例。如果您正苦于以下问题:C++ MouseInput::setReal方法的具体用法?C++ MouseInput::setReal怎么用?C++ MouseInput::setReal使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MouseInput
的用法示例。
在下文中一共展示了MouseInput::setReal方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: simulateMouseClick
void SDLInput::simulateMouseClick(const int x, const int y,
const MouseButton::Type button)
{
MouseInput mouseInput;
mouseInput.setX(x);
mouseInput.setY(y);
mouseInput.setReal(x, y);
mouseInput.setButton(button);
mouseInput.setType(MouseEventType::PRESSED);
mouseInput.setTimeStamp(SDL_GetTicks());
mMouseInputQueue.push(mouseInput);
mouseInput.setType(MouseEventType::RELEASED);
mouseInput.setTimeStamp(SDL_GetTicks());
mMouseInputQueue.push(mouseInput);
}
示例2: pushInput
void SDLInput::pushInput(const SDL_Event &event)
{
BLOCK_START("SDLInput::pushInput")
KeyInput keyInput;
MouseInput mouseInput;
switch (event.type)
{
case SDL_KEYDOWN:
{
keyInput.setType(KeyEventType::PRESSED);
convertKeyEventToKey(event, keyInput);
mKeyInputQueue.push(keyInput);
break;
}
case SDL_KEYUP:
{
keyInput.setType(KeyEventType::RELEASED);
convertKeyEventToKey(event, keyInput);
mKeyInputQueue.push(keyInput);
break;
}
#ifdef USE_SDL2
case SDL_TEXTINPUT:
keyInput.setType(KeyEventType::PRESSED);
keyInput.setKey(Key(Key::TEXTINPUT));
keyInput.setText(event.text.text);
mKeyInputQueue.push(keyInput);
break;
case SDL_MOUSEWHEEL:
{
const int y = event.wheel.y;
if (y)
{
mouseInput.setX(gui->getLastMouseX());
mouseInput.setY(gui->getLastMouseY());
#ifdef ANDROID
mouseInput.setReal(0, 0);
#endif
mouseInput.setButton(MouseButton::WHEEL);
if (y > 0)
mouseInput.setType(MouseEventType::WHEEL_MOVED_UP);
else
mouseInput.setType(MouseEventType::WHEEL_MOVED_DOWN);
mouseInput.setTimeStamp(SDL_GetTicks());
mMouseInputQueue.push(mouseInput);
}
break;
}
#endif
#ifdef ANDROID
#ifndef USE_SDL2
case SDL_ACCELEROMETER:
break;
#endif
#endif
case SDL_MOUSEBUTTONDOWN:
{
mMouseDown = true;
const int scale = mainGraphics->getScale();
const int x = event.button.x / scale;
const int y = event.button.y / scale;
mouseInput.setX(x);
mouseInput.setY(y);
#ifdef ANDROID
#ifdef USE_SDL2
mouseInput.setReal(x, y);
#else
mouseInput.setReal(event.button.realx / scale,
event.button.realy / scale);
#endif
#endif
mouseInput.setButton(convertMouseButton(event.button.button));
#ifndef USE_SDL2
if (event.button.button == SDL_BUTTON_WHEELDOWN)
mouseInput.setType(MouseEventType::WHEEL_MOVED_DOWN);
else if (event.button.button == SDL_BUTTON_WHEELUP)
mouseInput.setType(MouseEventType::WHEEL_MOVED_UP);
else
#endif
mouseInput.setType(MouseEventType::PRESSED);
mouseInput.setTimeStamp(SDL_GetTicks());
mMouseInputQueue.push(mouseInput);
break;
}
case SDL_MOUSEBUTTONUP:
{
mMouseDown = false;
const int scale = mainGraphics->getScale();
const int x = event.button.x / scale;
const int y = event.button.y / scale;
mouseInput.setX(x);
mouseInput.setY(y);
//.........这里部分代码省略.........