本文整理汇总了C++中Event函数的典型用法代码示例。如果您正苦于以下问题:C++ Event函数的具体用法?C++ Event怎么用?C++ Event使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Event函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: AllocConsole
ATTRIBUTES_DECLARE_ALL
MainWindow::MainWindow()
{
QWidget::installEventFilter(this);
menu = NULL;
gameWidget = NULL;
// Create console
//#ifdef XKILL_DEBUG
AllocConsole();
SetConsoleTitle(L"Debug console");
int hConHandle;
long lStdHandle;
FILE *fp; // redirect unbuffered STDOUT to the console
lStdHandle = (long)GetStdHandle(STD_OUTPUT_HANDLE);
hConHandle = _open_osfhandle(lStdHandle, _O_TEXT);
fp = _fdopen( hConHandle, "w" );
*stdout = *fp;
setvbuf( stdout, NULL, _IONBF, 0 );
//#endif
// Init iterators
ATTRIBUTES_INIT_ALL;
// subscribe to events
SUBSCRIBE_TO_EVENT(this, EVENT_SHOW_FULLSCREEN);
SUBSCRIBE_TO_EVENT(this, EVENT_SHOW_MESSAGEBOX);
SUBSCRIBE_TO_EVENT(this, EVENT_QUIT_TO_DESKTOP);
// create UI generated from XML file
ui.setupUi(this);
ui.mainToolBar->hide();
MainWindow::setWindowTitle("XKILL");
resize(1000, 600);
QWidget::setAttribute(Qt::WA_PaintOnScreen);
// init game
gameWidget = new GameWidget(this);
this->setCentralWidget(gameWidget);
// init tools
new Menu_Editor(ui, this);
menu = new Menu_Main(this);
// setup signals and slots
connect(ui.actionFullscreen, SIGNAL(triggered()), this, SLOT(slot_toggleFullScreen()));
connect(ui.actionCap_FPS, SIGNAL(toggled(bool)), gameWidget, SLOT(slot_toggleCapFPS(bool)));
ui.actionCap_FPS->setChecked(true);
connect(ui.actionQuit, SIGNAL(triggered()), this, SLOT(close()));
connect(gameWidget, SIGNAL(signal_fpsChanged(QString)), this, SLOT(slot_setTitle(QString)));
connect(gameWidget, SIGNAL(signal_fpsChanged(QString)), this, SLOT(slot_setTitle(QString)));
// Listen to incomming event
this->installEventFilter(this);
slot_toggleFullScreen(); //Fullscreen
// DEBUG build specific settings (setAlwaysOnTopAndShow(false) is set in Menu_Main2::Menu_Main2() if DEBUG)
#if defined(DEBUG) || defined(_DEBUG)
slot_toggleFullScreen(); //Windowed
SEND_EVENT(&Event(EVENT_STARTGAME));//Skips menu in DEBUG
#endif
}
开发者ID:CaterHatterPillar,项目名称:xkill-source,代码行数:63,代码来源:MainWindow.cpp
示例2: Java_org_xcsoar_EventBridge_onKeyUp
void
Java_org_xcsoar_EventBridge_onKeyUp(JNIEnv *env, jclass cls, jint key_code)
{
event_queue->push(Event(Event::KEY_UP, TranslateKeyCode(key_code)));
}
开发者ID:joachimwieland,项目名称:xcsoar-jwieland,代码行数:5,代码来源:EventBridge.cpp
示例3:
int DefaultEventManager<Platform::POLL>::isRegistered(
const SocketHandle::Handle& handle,
const EventType::Type event) const
{
return d_callbacks.end() != d_callbacks.find(Event(handle, event));
}
开发者ID:AlisdairM,项目名称:bde,代码行数:6,代码来源:btlso_defaulteventmanager_poll.cpp
示例4: EventProcess
bool CButton::EventProcess(const Event &event)
{
if ( (m_state & STATE_VISIBLE) == 0 ) return true;
if ( m_state & STATE_DEAD ) return true;
CControl::EventProcess(event);
if ( event.type == EVENT_FRAME )
{
if ( m_bRepeat && m_repeat != 0.0f )
{
m_repeat -= event.rTime;
if ( m_repeat <= 0.0f )
{
m_repeat = DELAY2;
m_event->AddEvent(Event(m_eventType));
return false;
}
}
}
if ( event.type == EVENT_MOUSE_BUTTON_DOWN &&
event.GetData<MouseButtonEventData>()->button == MOUSE_BUTTON_LEFT &&
(m_state & STATE_VISIBLE) &&
(m_state & STATE_ENABLE) )
{
if ( CControl::Detect(event.mousePos) )
{
m_bCapture = true;
m_repeat = DELAY1;
if ( m_bImmediat || m_bRepeat )
{
m_event->AddEvent(Event(m_eventType));
}
return false;
}
}
if ( event.type == EVENT_MOUSE_MOVE && m_bCapture )
{
}
if ( event.type == EVENT_MOUSE_BUTTON_UP && //left
event.GetData<MouseButtonEventData>()->button == MOUSE_BUTTON_LEFT &&
m_bCapture )
{
if ( CControl::Detect(event.mousePos) )
{
if ( !m_bImmediat && !m_bRepeat )
{
m_event->AddEvent(Event(m_eventType));
}
}
m_bCapture = false;
m_repeat = 0.0f;
}
return true;
}
开发者ID:BTML,项目名称:colobot,代码行数:62,代码来源:button.cpp
示例5: processText
int Edit::processEvent (const Event& event)
{
if (event.key > 0 && event.key < 256 && isprint (event.key)) {
processText (event);
return 1;
}
switch (event.key) {
case KB_UP:
case KB_KP_UP:
up ();
break;
case KB_DOWN:
case KB_KP_DOWN:
down ();
break;
case KB_LEFT:
case KB_KP_LEFT:
left ();
break;
case KB_RIGHT:
case KB_KP_RIGHT:
right ();
break;
case KB_BKSPACE:
backSpace ();
break;
case KB_TAB:
tab ();
break;
case KB_HOME:
case KB_KP_HOME:
home ();
break;
case KB_END:
case KB_KP_END:
end ();
break;
case KB_INS:
case KB_KP_INS:
ins ();
break;
case KB_DEL:
case KB_KP_DEL:
del ();
break;
case KB_ESC:
mExitKey = KB_ESC;
postEvent (Event (EV_QUIT));
break;
case KB_ENTER:
strncpy (mpRealText, mpText, mLength);
mpRealText[mLength] = '\0';
if (mpHist != 0)
mpHist->add (mpText);
mExitKey = KB_ENTER;
postEvent (Event (EV_QUIT));
break;
case EV_COLOR_CHANGE:
draw ();
return Popup::processEvent (event);
default:
return Popup::processEvent (event);
}
return 1;
}
开发者ID:ancientlore,项目名称:hermit,代码行数:81,代码来源:edit.cpp
示例6: Event
Event DiscreteTimeLayer::getNextEvent()
{
return Event(this,time + event_frequency);
}
开发者ID:BeepBoopBop,项目名称:BeepHive,代码行数:4,代码来源:DiscreteTimeLayer.cpp
示例7: UpdateInterface
bool CAutoResearch::EventProcess(const Event &event)
{
CPowerContainerObject* power;
Math::Vector pos, speed;
Error message;
Math::Point dim;
float angle;
CAuto::EventProcess(event);
if ( m_engine->GetPause() ) return true;
if ( event.type == EVENT_UPDINTERFACE )
{
if ( m_object->GetSelect() ) CreateInterface(true);
}
if ( m_object->GetSelect() ) // center selected?
{
Error err = ERR_UNKNOWN;
if ( event.type == EVENT_OBJECT_RTANK ) err = StartAction(RESEARCH_TANK);
if ( event.type == EVENT_OBJECT_RFLY ) err = StartAction(RESEARCH_FLY);
if ( event.type == EVENT_OBJECT_RTHUMP ) err = StartAction(RESEARCH_THUMP);
if ( event.type == EVENT_OBJECT_RCANON ) err = StartAction(RESEARCH_CANON);
if ( event.type == EVENT_OBJECT_RTOWER ) err = StartAction(RESEARCH_TOWER);
if ( event.type == EVENT_OBJECT_RPHAZER ) err = StartAction(RESEARCH_PHAZER);
if ( event.type == EVENT_OBJECT_RSHIELD ) err = StartAction(RESEARCH_SHIELD);
if ( event.type == EVENT_OBJECT_RATOMIC ) err = StartAction(RESEARCH_ATOMIC);
if( err != ERR_OK && err != ERR_UNKNOWN )
m_main->DisplayError(err, m_object);
if( err != ERR_UNKNOWN )
return false;
}
if ( event.type != EVENT_FRAME ) return true;
m_progress += event.rTime*m_speed;
m_timeVirus -= event.rTime;
if ( m_object->GetVirusMode() ) // contaminated by a virus?
{
if ( m_timeVirus <= 0.0f )
{
m_timeVirus = 0.1f+Math::Rand()*0.3f;
}
return true;
}
UpdateInterface(event.rTime);
EventProgress(event.rTime);
angle = m_time*0.1f;
m_object->SetPartRotationY(1, angle); // rotates the antenna
angle = (30.0f+sinf(m_time*0.3f)*20.0f)*Math::PI/180.0f;
m_object->SetPartRotationZ(2, angle); // directs the antenna
if ( m_phase == ALP_WAIT )
{
FireStopUpdate(m_progress, false); // extinguished
return true;
}
if ( m_phase == ALP_SEARCH )
{
FireStopUpdate(m_progress, true); // flashes
if ( m_progress < 1.0f )
{
if ( m_object->GetPower() == nullptr || !m_object->GetPower()->Implements(ObjectInterfaceType::PowerContainer) ) // more battery?
{
SetBusy(false);
UpdateInterface();
m_phase = ALP_WAIT;
m_progress = 0.0f;
m_speed = 1.0f/1.0f;
return true;
}
power = dynamic_cast<CPowerContainerObject*>(m_object->GetPower());
power->SetEnergyLevel(1.0f-m_progress);
if ( m_lastParticle+m_engine->ParticleAdapt(0.05f) <= m_time )
{
m_lastParticle = m_time;
pos = m_object->GetPosition();
pos.x += (Math::Rand()-0.5f)*6.0f;
pos.z += (Math::Rand()-0.5f)*6.0f;
pos.y += 11.0f;
speed.x = (Math::Rand()-0.5f)*2.0f;
speed.z = (Math::Rand()-0.5f)*2.0f;
speed.y = Math::Rand()*20.0f;
dim.x = Math::Rand()*1.0f+1.0f;
dim.y = dim.x;
m_particle->CreateParticle(pos, speed, dim, Gfx::PARTIVAPOR);
}
}
else
//.........这里部分代码省略.........
开发者ID:2asoft,项目名称:colobot,代码行数:101,代码来源:autoresearch.cpp
示例8: sendEvent
void Agent::sendEvent(std::string name, folly::dynamic params) {
if (!channel_) {
return;
}
channel_->sendMessage(Event(getDomain(), std::move(name), std::move(params)));
}
开发者ID:EmingK,项目名称:react-native,代码行数:6,代码来源:Agent.cpp
示例9: ThrowDShowException
//----------------------------------------------------------------------------
//! @brief フィルタグラフの構築
//! @param callbackwin : メッセージを送信するウィンドウ
//! @param stream : 読み込み元ストリーム
//! @param streamname : ストリームの名前
//! @param type : メディアタイプ(拡張子)
//! @param size : メディアサイズ
//----------------------------------------------------------------------------
void __stdcall tTVPDSVideoOverlay::BuildGraph( HWND callbackwin, IStream *stream,
const wchar_t * streamname, const wchar_t *type, unsigned __int64 size )
{
HRESULT hr;
// CoInitialize(NULL);
// detect CMediaType from stream's extension ('type')
try {
if( FAILED(hr = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED)) )
ThrowDShowException(L"Failed to call CoInitializeEx.", hr);
// create IFilterGraph instance
if( FAILED(hr = m_GraphBuilder.CoCreateInstance(CLSID_FilterGraph, NULL, CLSCTX_INPROC)) )
ThrowDShowException(L"Failed to create FilterGraph.", hr);
// Register to ROT
if(GetShouldRegisterToROT())
{
AddToROT(m_dwROTReg);
}
if( IsWindowsMediaFile(type) )
{
CComPtr<IBaseFilter> pVRender; // for video renderer filter
if( FAILED(hr = pVRender.CoCreateInstance(CLSID_VideoRenderer, NULL, CLSCTX_INPROC_SERVER)) )
ThrowDShowException(L"Failed to create video renderer filter object.", hr);
if( FAILED(hr = GraphBuilder()->AddFilter(pVRender, L"Video Renderer")) )
ThrowDShowException(L"Failed to call IFilterGraph::AddFilter.", hr);
BuildWMVGraph( pVRender, stream );
}
else
{
CMediaType mt;
mt.majortype = MEDIATYPE_Stream;
ParseVideoType( mt, type ); // may throw an exception
// create proxy filter
m_Proxy = new CIStreamProxy( stream, size );
hr = S_OK;
m_Reader = new CIStreamReader( m_Proxy, &mt, &hr );
if( FAILED(hr) || m_Reader == NULL )
ThrowDShowException(L"Failed to create proxy filter object.", hr);
m_Reader->AddRef();
// add fliter
if( FAILED(hr = GraphBuilder()->AddFilter( m_Reader, NULL)) )
ThrowDShowException(L"Failed to call IFilterGraph::AddFilter.", hr);
// AddFilterしたのでRelease
m_Reader->Release();
if( mt.subtype == MEDIASUBTYPE_Avi || mt.subtype == MEDIASUBTYPE_QTMovie )
{
// render output pin
if( FAILED(hr = GraphBuilder()->Render(m_Reader->GetPin(0))) )
ThrowDShowException(L"Failed to call IGraphBuilder::Render.", hr);
}
else
{
CComPtr<IBaseFilter> pVRender; // for video renderer filter
if( FAILED(hr = pVRender.CoCreateInstance(CLSID_VideoRenderer, NULL, CLSCTX_INPROC_SERVER)) )
ThrowDShowException(L"Failed to create video renderer filter object.", hr);
if( FAILED(hr = GraphBuilder()->AddFilter(pVRender, L"Video Renderer")) )
ThrowDShowException(L"Failed to call IFilterGraph::AddFilter.", hr);
BuildMPEGGraph( pVRender, m_Reader); // may throw an exception
}
}
// query each interfaces
if( FAILED(hr = m_GraphBuilder.QueryInterface( &m_MediaControl )) )
ThrowDShowException(L"Failed to query IMediaControl", hr);
if( FAILED(hr = m_GraphBuilder.QueryInterface( &m_MediaPosition )) )
ThrowDShowException(L"Failed to query IMediaPosition", hr);
if( FAILED(hr = m_GraphBuilder.QueryInterface( &m_MediaSeeking )) )
ThrowDShowException(L"Failed to query IMediaSeeking", hr);
if( FAILED(hr = m_GraphBuilder.QueryInterface( &m_MediaEventEx )) )
ThrowDShowException(L"Failed to query IMediaEventEx", hr);
if( FAILED(hr = m_GraphBuilder.QueryInterface( &m_BasicVideo )) )
ThrowDShowException(L"Failed to query IBasicVideo", hr);
if( FAILED(hr = m_GraphBuilder.QueryInterface( &m_VideoWindow )) )
ThrowDShowException(L"Failed to query IVideoWindow", hr);
if( FAILED(hr = m_GraphBuilder.QueryInterface( &m_BasicAudio )) )
ThrowDShowException(L"Failed to query IBasicAudio", hr);
// check whether the stream has video
if(!m_VideoWindow || !m_BasicVideo )
//.........这里部分代码省略.........
开发者ID:harada3,项目名称:krkrz,代码行数:101,代码来源:dsoverlay.cpp
示例10: SDL_GetTicks
MainState
Game::run()
{
SDL_Event event;
running = true;
Uint32 fpsTicks = SDL_GetTicks();
Uint32 lastticks = fpsTicks;
Desktop* desktop = dynamic_cast<Desktop*> (gui.get());
if(!desktop)
{ throw std::runtime_error("Toplevel component is not a Desktop");}
gui->resize(getConfig()->videoX, getConfig()->videoY);
int frame = 0;
while(running) {
getGameView()->scroll();
while(SDL_PollEvent(&event)) {
switch(event.type) {
case SDL_VIDEORESIZE:
initVideo(event.resize.w, event.resize.h);
gui->resize(event.resize.w, event.resize.h);
getConfig()->videoX = event.resize.w;
getConfig()->videoY = event.resize.h;
break;
case SDL_KEYUP: {
Event gui_event(event);
if( gui_event.keysym.sym == SDLK_ESCAPE ){
getButtonPanel()->selectQueryTool();
break;
}
if( gui_event.keysym.sym == SDLK_b ){
getButtonPanel()->toggleBulldozeTool();
break;
}
/* //FIXME hack for monitoring constructionCount
if( gui_event.keysym.sym == SDLK_c ){
std::cout << "ConstructionCount.size() = " << constructionCount.size() << std::endl;
int i, j;
for (i = 0, j = 0; i < constructionCount.size(); i++) {constructionCount[i]?j++:j;}
std::cout << "for a total of " << j << " active constructions" << std::endl;
break;
}
*/
if( gui_event.keysym.sym == SDLK_p ){
static int i = 0;
while(i < constructionCount.size() && !constructionCount[i]) {i++;}
if (i < constructionCount.size())
{
main_screen_originx = constructionCount[i]->x;
main_screen_originy = constructionCount[i]->y;
getGameView()->readOrigin(true);
mps_set( main_screen_originx, main_screen_originy, MPS_MAP);
mps_update();
mps_refresh();
i++;
}
else
{
i = 0;
}
break;
}
if( gui_event.keysym.sym == SDLK_F1 ){
helpWindow->showTopic("help");
break;
}
if( gui_event.keysym.sym == SDLK_F12 ){
quickSave();
break;
}
if( gui_event.keysym.sym == SDLK_F9 ){
quickLoad();
break;
}
#ifdef DEBUG
if( gui_event.keysym.sym == SDLK_F5 ){
testAllHelpFiles();
break;
}
#endif
int need_break=true;
switch(gui_event.keysym.sym) {
case SDLK_BACKQUOTE: getMiniMap()->mapViewChangeDisplayMode(MiniMap::NORMAL); break;
case SDLK_1: getMiniMap()->mapViewChangeDisplayMode(MiniMap::STARVE); break;
case SDLK_2: getMiniMap()->mapViewChangeDisplayMode(MiniMap::UB40); break;
case SDLK_3: getMiniMap()->mapViewChangeDisplayMode(MiniMap::POWER); break;
case SDLK_4: getMiniMap()->mapViewChangeDisplayMode(MiniMap::FIRE); break;
case SDLK_5: getMiniMap()->mapViewChangeDisplayMode(MiniMap::CRICKET); break;
case SDLK_6: getMiniMap()->mapViewChangeDisplayMode(MiniMap::HEALTH); break;
case SDLK_7: getMiniMap()->mapViewChangeDisplayMode(MiniMap::TRAFFIC); break;
case SDLK_8: getMiniMap()->mapViewChangeDisplayMode(MiniMap::POLLUTION); break;
case SDLK_9: getMiniMap()->mapViewChangeDisplayMode(MiniMap::COAL); break;
case SDLK_0: getMiniMap()->mapViewChangeDisplayMode(MiniMap::COMMODITIES); break;
default: need_break=false;
}
if (need_break) break;
gui->event(gui_event);
break;
}
case SDL_MOUSEMOTION:
//.........这里部分代码省略.........
开发者ID:SirIvanMoReau,项目名称:lincity-ng,代码行数:101,代码来源:Game.cpp
示例11: sizeof
void
LinuxInputDevice::Read()
{
struct input_event buffer[64];
const ssize_t nbytes = fd.Read(buffer, sizeof(buffer));
if (nbytes < 0) {
/* device has failed or was unplugged - bail out */
if (errno != EAGAIN && errno != EINTR)
Close();
return;
}
unsigned n = size_t(nbytes) / sizeof(buffer[0]);
for (unsigned i = 0; i < n; ++i) {
const struct input_event &e = buffer[i];
switch (e.type) {
case EV_SYN:
if (e.code == SYN_REPORT) {
/* commit the finger movement */
const bool pressed = pressing;
const bool released = releasing;
pressing = releasing = false;
if (pressed)
merge.SetDown(true);
if (released)
merge.SetDown(false);
if (IsKobo() && released) {
/* workaround: on the Kobo Touch N905B, releasing the touch
screen reliably produces a finger position that is way
off; in that case, ignore finger movement */
moving = false;
edit_position = public_position;
}
if (moving) {
moving = false;
public_position = edit_position;
merge.MoveAbsolute(public_position.x, public_position.y);
} else if (rel_x != 0 || rel_y != 0) {
merge.MoveRelative(rel_x, rel_y);
rel_x = rel_y = 0;
}
}
break;
case EV_KEY:
if (e.code == BTN_TOUCH || e.code == BTN_MOUSE) {
bool new_down = e.value;
if (new_down != down) {
down = new_down;
if (new_down)
pressing = true;
else
releasing = true;
}
} else
queue.Push(Event(e.value ? Event::KEY_DOWN : Event::KEY_UP,
TranslateKeyCode(e.code)));
break;
case EV_ABS:
moving = true;
switch (e.code) {
case ABS_X:
edit_position.x = e.value;
break;
case ABS_Y:
edit_position.y = e.value;
break;
}
break;
case EV_REL:
switch (e.code) {
case REL_X:
rel_x += e.value;
break;
case ABS_Y:
rel_y += e.value;
break;
}
break;
}
}
}
开发者ID:DRIZO,项目名称:xcsoar,代码行数:98,代码来源:Input.cpp
示例12: LOG
void
ServerApp::handleScreenError(const Event&, void*)
{
LOG((CLOG_CRIT "error on screen"));
m_events->addEvent(Event(Event::kQuit));
}
开发者ID:neilmayhew,项目名称:synergy,代码行数:6,代码来源:ServerApp.cpp
示例13:
void
ServerApp::handleClientsDisconnected(const Event&, void*)
{
m_events->addEvent(Event(Event::kQuit));
}
开发者ID:neilmayhew,项目名称:synergy,代码行数:5,代码来源:ServerApp.cpp
示例14: SDL_GetTicks
MainState
MainMenu::run()
{
SDL_Event event;
running = true;
quitState = QUIT;
Uint32 fpsTicks = SDL_GetTicks();
Uint32 lastticks = fpsTicks;
int frame = 0;
while(running)
{
while(SDL_PollEvent(&event))
{
switch(event.type) {
case SDL_VIDEORESIZE:
initVideo(event.resize.w, event.resize.h);
currentMenu->resize(event.resize.w, event.resize.h);
getConfig()->videoX = event.resize.w;
getConfig()->videoY = event.resize.h;
if(currentMenu == optionsMenu.get())//update resolution display
{
std::stringstream mode;
mode.str("");
mode << event.resize.w << "x" << event.resize.h;
getParagraph( *optionsMenu, "resolutionParagraph")->setText(mode.str());
}
break;
case SDL_MOUSEMOTION:
case SDL_MOUSEBUTTONUP:
case SDL_MOUSEBUTTONDOWN:
case SDL_KEYDOWN:{
Event gui_event(event);
currentMenu->event(gui_event);
break;
}
case SDL_KEYUP: {
Event gui_event(event);
//In menu ESC as well as ^c exits the game.
//might come in handy if video-mode is not working as expected.
if( ( gui_event.keysym.sym == SDLK_ESCAPE ) ||
( gui_event.keysym.sym == SDLK_c && ( gui_event.keysym.mod & KMOD_CTRL) ) ){
running = false;
quitState = QUIT;
break;
}
currentMenu->event(gui_event);
break;
}
case SDL_VIDEOEXPOSE:
currentMenu->resize( currentMenu->getWidth(), currentMenu->getHeight() );
break;
case SDL_ACTIVEEVENT:
if( event.active.gain == 1 ){
currentMenu->resize( currentMenu->getWidth(), currentMenu->getHeight() );
}
break;
case SDL_QUIT:
running = false;
quitState = QUIT;
break;
default:
break;
}
}
SDL_Delay(100); // give the CPU time to relax... (we are in main menu)
// create update Event
Uint32 ticks = SDL_GetTicks();
float elapsedTime = ((float) (ticks - lastticks)) / 1000.0;
currentMenu->event(Event(elapsedTime));
lastticks = ticks;
if(currentMenu->needsRedraw()) {
currentMenu->draw(*painter);
flipScreenBuffer();
}
frame++;
if(ticks - fpsTicks > 1000) {
#ifdef DEBUG_FPS
printf("MainMenu FPS: %d.\n", (frame*1000) / (ticks - fpsTicks));
#endif
frame = 0;
fpsTicks = ticks;
}
}
return quitState;
}
开发者ID:okosan,项目名称:lincity-xg,代码行数:91,代码来源:MainMenu.cpp
示例15: popIO
Event Device::popIO(int id) {
if (ioDevices[id].empty()) { return Event(Event::NO_OP, 0.0, 0.0, -1, id); }
auto item = ioDevices[id].front();
ioDevices[id].pop();
return item;
}
开发者ID:Candlemancer,项目名称:Junior-Year,代码行数:6,代码来源:Device.cpp
示例16: Push
void Push(Event::Callback callback, void *ctx) {
Push(Event(callback, ctx));
}
开发者ID:Exadios,项目名称:xcsoar-exp,代码行数:3,代码来源:Queue.hpp
示例17: MouseEnter
virtual inline void MouseEnter() { Dispatch(Event(UIElement::EvtMouseEnter)); }
开发者ID:WhoBrokeTheBuild,项目名称:Dusk2D,代码行数:1,代码来源:UIElement.hpp
示例18: scale_key_velocity
// Calculate and return features about the percussiveness of the key press
KeyPositionTracker::PercussivenessFeatures KeyPositionTracker::pressPercussiveness() {
PercussivenessFeatures features;
key_buffer_index index;
key_velocity maximumVelocity, largestVelocityDifference;
key_buffer_index maximumVelocityIndex, largestVelocityDifferenceIndex;
// Check that we have a valid start point from which to calculate
if(missing_value<timestamp_type>::isMissing(startTimestamp_) || keyBuffer_.beginIndex() > startIndex_ - 1) {
std::cout << "*** no start time\n";
features.percussiveness = missing_value<float>::missing();
return features;
}
// From the start of the key press, look for an initial maximum in velocity
index = startIndex_;
maximumVelocity = scale_key_velocity(0);
maximumVelocityIndex = startIndex_;
largestVelocityDifference = scale_key_velocity(0);
largestVelocityDifferenceIndex = startIndex_;
std::cout << "*** start index " << index << std::endl;
while(index < keyBuffer_.endIndex()) {
if(pressIndex_ != 0 && index >= pressIndex_)
break;
key_position diffPosition = keyBuffer_[index] - keyBuffer_[index - 1];
timestamp_diff_type diffTimestamp = keyBuffer_.timestampAt(index) - keyBuffer_.timestampAt(index - 1);
key_velocity velocity = calculate_key_velocity(diffPosition, diffTimestamp);
// Look for maximum of velocity
if(velocity > maximumVelocity) {
maximumVelocity = velocity;
maximumVelocityIndex = index;
std::cout << "*** found new max velocity " << maximumVelocity << " at index " << index << std::endl;
}
// And given the difference between the max and the current sample,
// look for the largest rebound (velocity hitting a peak and falling)
if(maximumVelocity - velocity > largestVelocityDifference) {
largestVelocityDifference = maximumVelocity - velocity;
largestVelocityDifferenceIndex = index;
std::cout << "*** found new diff velocity " << largestVelocityDifference << " at index " << index << std::endl;
}
// Only look at the early part of the key press: if the key position
// makes it more than a certain amount down, assume the initial spike
// has passed and finish up. But always allow at least 5 points for the
// fastest key presses to be considered.
if(index - startIndex_ >= 4 && keyBuffer_[index] > kPositionTrackerPositionThresholdForPercussivenessCalculation) {
break;
}
index++;
}
// Now transfer what we've found to the data structure
features.velocitySpikeMaximum = Event(maximumVelocityIndex, maximumVelocity, keyBuffer_.timestampAt(maximumVelocityIndex));
features.velocitySpikeMinimum = Event(largestVelocityDifferenceIndex, maximumVelocity - largestVelocityDifference,
keyBuffer_.timestampAt(largestVelocityDifferenceIndex));
features.timeFromStartToSpike = keyBuffer_.timestampAt(maximumVelocityIndex) - keyBuffer_.timestampAt(startIndex_);
// Check if we found a meaningful difference. If not, percussiveness is set to 0
if(largestVelocityDifference == scale_key_velocity(0)) {
features.percussiveness = 0.0;
features.areaPrecedingSpike = scale_key_velocity(0);
features.areaFollowingSpike = scale_key_velocity(0);
return features;
}
// Calculate the area under the velocity curve before and after the maximum
features.areaPrecedingSpike = scale_key_velocity(0);
for(index = startIndex_; index < maximumVelocityIndex; index++) {
key_position diffPosition = keyBuffer_[index] - keyBuffer_[index - 1];
timestamp_diff_type diffTimestamp = keyBuffer_.timestampAt(index) - keyBuffer_.timestampAt(index - 1);
features.areaPrecedingSpike += calculate_key_velocity(diffPosition, diffTimestamp);
}
features.areaFollowingSpike = scale_key_velocity(0);
for(index = maximumVelocityIndex; index < largestVelocityDifferenceIndex; index++) {
key_position diffPosition = keyBuffer_[index] - keyBuffer_[index - 1];
timestamp_diff_type diffTimestamp = keyBuffer_.timestampAt(index) - keyBuffer_.timestampAt(index - 1);
features.areaFollowingSpike += calculate_key_velocity(diffPosition, diffTimestamp);
}
std::cout << "area before = " << features.areaPrecedingSpike << " after = " << features.areaFollowingSpike << std::endl;
features.percussiveness = features.velocitySpikeMaximum.position;
return features;
}
开发者ID:EQ4,项目名称:MRP,代码行数:92,代码来源:KeyPositionTracker.cpp
示例19: MouseLeave
virtual inline void MouseLeave() { Dispatch(Event(UIElement::EvtMouseLeave)); }
开发者ID:WhoBrokeTheBuild,项目名称:Dusk2D,代码行数:1,代码来源:UIElement.hpp
示例20: Event
/*-----------------------------------------------*/
void VillagerC::onTrigger()
{
Event ev = Event(Event::ET_COLLISION_START, "dialog", "villager_grumble");
eventQueue->queueEvent(ev);
}
开发者ID:D4rkFr4g,项目名称:zRPG,代码行数:6,代码来源:VillagerC.cpp
注:本文中的Event函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论