本文整理汇总了C++中Input::OnPress方法的典型用法代码示例。如果您正苦于以下问题:C++ Input::OnPress方法的具体用法?C++ Input::OnPress怎么用?C++ Input::OnPress使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Input
的用法示例。
在下文中一共展示了Input::OnPress方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: MouseButtonCallback
void MouseButtonCallback(int aIndex, int aState)
{
if (aState == GLFW_PRESS)
input.OnPress(Input::TYPE_MOUSE_BUTTON, 0, aIndex);
else
input.OnRelease(Input::TYPE_MOUSE_BUTTON, 0, aIndex);
}
示例2: KeyCallback
void KeyCallback(int aIndex, int aState)
{
if (aState == GLFW_PRESS)
{
input.OnPress(Input::TYPE_KEYBOARD, 0, aIndex);
switch (aIndex)
{
case GLFW_KEY_F4:
if (glfwGetKey(GLFW_KEY_LALT) || glfwGetKey(GLFW_KEY_RALT))
setgamestate = STATE_QUIT;
break;
case GLFW_KEY_ENTER:
if (glfwGetKey(GLFW_KEY_LALT) || glfwGetKey(GLFW_KEY_RALT))
{
CloseWindow();
SCREEN_FULLSCREEN = !SCREEN_FULLSCREEN;
OpenWindow();
}
break;
case GLFW_KEY_ESC:
if (curgamestate == STATE_PLAY)
{
if (escape)
EscapeMenuExit();
else
EscapeMenuEnter();
}
break;
case 'P':
if (glfwGetKey(GLFW_KEY_LSHIFT) || glfwGetKey(GLFW_KEY_RSHIFT))
{
paused = true;
singlestep = true;
}
else
{
paused = !paused;
}
if (paused)
Pause();
else
Resume();
break;
}
}
else
{
input.OnRelease(Input::TYPE_KEYBOARD, 0, aIndex);
}
}
示例3: RunState
// common run state
void RunState()
{
#if defined(USE_SDL)
// last ticks
unsigned int ticks = SDL_GetTicks();
#elif defined(USE_SFML)
// timer
sf::Clock timer;
// start timer
timer.Reset();
#elif defined(USE_GLFW)
double prevtime = glfwGetTime();
#endif
// input logging
TiXmlDocument inputlog(RECORD_CONFIG.c_str());
TiXmlElement *inputlogroot;
TiXmlElement *inputlognext;
if (playback)
{
if (!inputlog.LoadFile())
DebugPrint("error loading recording file \"%s\": %s\n", RECORD_CONFIG.c_str(), inputlog.ErrorDesc());
inputlogroot = inputlog.RootElement();
inputlognext = inputlogroot->FirstChildElement();
}
else if (record)
{
inputlogroot = inputlog.LinkEndChild(new TiXmlElement("journal"))->ToElement();
inputlognext = NULL;
}
else
{
inputlogroot = NULL;
inputlognext = NULL;
}
#ifdef GET_PERFORMANCE_DETAILS
PerfTimer::Init();
PerfTimer control_timer;
PerfTimer simulate_timer;
PerfTimer collide_timer;
PerfTimer update_timer;
PerfTimer render_timer;
PerfTimer overlay_timer;
PerfTimer display_timer;
PerfTimer total_timer;
total_timer.Stamp();
#endif
#ifdef COLLECT_DEBUG_DRAW
// create a new draw list
GLuint debugdraw = glGenLists(1);
#endif
// wait for user exit
do
{
#ifdef GET_PERFORMANCE_DETAILS
PerfTimer::Next();
control_timer.Clear();
simulate_timer.Clear();
collide_timer.Clear();
update_timer.Clear();
render_timer.Clear();
overlay_timer.Clear();
display_timer.Clear();
total_timer.Clear();
#endif
// INPUT PHASE
#if defined(USE_SDL)
// event handler
SDL_Event event;
// process events
while( SDL_PollEvent( &event ) )
{
/* Give the console first dibs on event processing */
if (OGLCONSOLE_SDLEvent(&event))
continue;
switch (event.type)
{
case SDL_KEYDOWN:
input.OnPress( Input::TYPE_KEYBOARD, event.key.which, event.key.keysym.sym );
switch (event.key.keysym.sym)
{
case SDLK_F4:
if (event.key.keysym.mod & KMOD_ALT)
setgamestate = STATE_QUIT;
break;
case SDLK_RETURN:
if (event.key.keysym.mod & KMOD_ALT)
//.........这里部分代码省略.........