void ctkEAScenario2EventPublisher::runTest() { /* Claims the reference of the EventAdmin Service */ serviceReference = context->getServiceReference<ctkEventAdmin>(); /* assert that a reference is aquired */ QVERIFY2(serviceReference, "Should be able to get reference to ctkEventAdmin service"); eventAdmin = context->getService<ctkEventAdmin>(serviceReference); QVERIFY2(eventAdmin, "Should be able to get instance to ctkEventAdmin object"); connect(&thread, SIGNAL(started()), SLOT(sendEvents())); thread.start(); /* wait until thread is dead */ thread.wait(); disconnect(&thread, SIGNAL(started()), this, SLOT(sendEvents())); connect(&thread, SIGNAL(started()), SLOT(postEvents())); thread.start(); /* wait until thread is dead */ thread.wait(); context->ungetService(serviceReference); QTest::qWait(1000); // allow for delivery }
void StreamlineSetup::handleRequest(char* xml) { mxml_node_t *tree, *node; const char * attr = NULL; tree = mxmlLoadString(NULL, xml, MXML_NO_CALLBACK); node = mxmlFindElement(tree, tree, TAG_REQUEST, ATTR_TYPE, NULL, MXML_DESCEND_FIRST); if (node) { attr = mxmlElementGetAttr(node, ATTR_TYPE); } if (attr && strcmp(attr, VALUE_EVENTS) == 0) { sendEvents(); logg.logMessage("Sent events xml response"); } else if (attr && strcmp(attr, VALUE_CONFIGURATION) == 0) { sendConfiguration(); logg.logMessage("Sent configuration xml response"); } else if (attr && strcmp(attr, VALUE_COUNTERS) == 0) { sendCounters(); logg.logMessage("Sent counters xml response"); } else if (attr && strcmp(attr, VALUE_CAPTURED) == 0) { CapturedXML capturedXML; char* capturedText = capturedXML.getXML(false); sendData(capturedText, strlen(capturedText), RESPONSE_XML); free(capturedText); logg.logMessage("Sent captured xml response"); } else if (attr && strcmp(attr, VALUE_DEFAULTS) == 0) { sendDefaults(); logg.logMessage("Sent default configuration xml response"); } else { char error[] = "Unknown request"; sendData(error, strlen(error), RESPONSE_NAK); logg.logMessage("Received unknown request:\n%s", xml); } mxmlDelete(tree); }
bool Entity::addComponent( const ComponentPtr& component ) { if( !component ) return false; Class* type = component->getType(); if( componentsMap.Find(type) != componentsMap.End() ) { LogWarn( "Component '%s' already exists in '%s'", type->name, name.CString() ); return false; } componentsMap[type] = component; component->setEntity(this); onComponentAdded(component); sendEvents(); if( IsGroup(parent) ) { Group* group = (Group*) parent; group->onEntityComponentAdded(component); } components.Push(component); return true; }
bool Entity::removeComponent(const ComponentPtr& component) { if (!component) return false; Class* type = component->getType(); ComponentMap::Iterator it = componentsMap.Find(type); if( it == componentsMap.End() ) return false; componentsMap.Erase(it); onComponentRemoved(component); sendEvents(); if (IsGroup(parent)) { Group* group = (Group*) parent; group->onEntityComponentRemoved(component); } if (type->inherits(GeometryGetType())) getTransform()->markBoundingVolumeDirty(); return true; }
void ServerBase::clientEvent(ClientBase* client, GameEvent* event) { unique_lock<mutex> lock(_lock); auto playerIDItr = _assignedIDs.reverseFind(client); if(playerIDItr == _assignedIDs.reverseEnd()) { if(event->type == AssignName) { Info("Attempting to assign name to client"); AssignNameEvent* e = (AssignNameEvent*)event; lock.unlock(); if(!assignClient(client, e->name)) { Error("Failed to assign client to name " << e->name); } else { Info("Accepted client " << e->name); } return; } else { Error("Unassigned client attempting to send data to the server"); return; } } PlayerID playerID = playerIDItr->second; auto clientNameItr = _assignedClients.reverseFind(client); if(clientNameItr == _assignedClients.reverseEnd()) { return; } string clientName = clientNameItr->second; Debug("Received client event from " << clientName << " (ID " << playerID << ")"); EventMap<PlayerID> results; _core->processPlayerEvent(playerID, event, results); sendEvents(results); }
void ServerBase::removeClient(ClientBase* client) { auto clientIDItr = _assignedIDs.reverseFind(client); EventMap<PlayerID> results; _core->unloadCharacter(clientIDItr->second, results); sendEvents(results); _assignedClients.reverseErase(client); _assignedIDs.reverseErase(client); }
void MenuView::loop() { while (running) { sendEvents(); sfgDesktop.Update(1.f); clear(); draw(); display(); } }
void ServerBase::innerLoop() { clock_t last = clock(); while(!_shouldDie) { // This will get removed once the game is in full swing sleep(1); Debug("...Server is thinking..."); EventMap<PlayerID> updateEvents; unique_lock<mutex> lock(_lock); clock_t next = clock(); _core->update(next - last, updateEvents); last = next; sendEvents(updateEvents); } }
//----------------------------------------------------------------------------- // Main Routine // after initialization, the program simply polls the !req input and when // !req goes low, !ack on is lowered to acknowledge, // the address is captured in P1 (AE0-7) and P2 (AE8-15) and is copied to XRAM. // Then !ack is raised, we wait for !req to go high and start over. // We initiate BlockWrite in main after disabling interrupts. This is not advised because // device is not supposed to intiate transfers, but it works fine, at least in USBXPress v2.1 // Commands are handled in the USB ISR. //----------------------------------------------------------------------------- void main(void) { PCA0MD &= ~0x40; // Disable Watchdog timer /** SPI info 18.1.4. Slave Select (NSS) The function of the slave-select (NSS) signal is dependent on the setting of the NSSMD1 and NSSMD0 bits in the SPI0CN register. There are three possible modes that can be selected with these bits: 1.NSSMD[1:0] = 00: 3-Wire Master or 3-Wire Slave Mode: SPI0 operates in 3-wire mode, and NSS is disabled. When operating as a slave device, SPI0 is always selected in 3-wire mode. Since no select signal is present, SPI0 must be the only slave on the bus in 3-wire mode. This is intended for point-to-point communication between a master and one slave. http://www.cygnal.org/ubb/Forum1/HTML/000157.html "The SPI0 is set in 3-wire single master mode." To configure the SPI to 3-wire mode, set it to 3-wire mode before attaching it to the crossbar. If this order is reversed, NSS signal is assigned overlapping on other peripheral pins. SPI0CN = 0x00; // 3-wire master mode XBR0 = 0x02; // attach SPI to crossbar */ config(); /* 3.1. USB_Init Description: Enables the USB interface and the use of Device Interface Functions. On return, the USB interface is configured, including the USB clock and memory. Neither the system or USB clock configurations should be modified by user software after calling the USB_Init function. See Appendix A for a complete list of SFRs that should not be modified after USB_Init is called. In addition, C8051F32x interrupts are globally enabled on the return of this function. User software should not globally disable interrupts (set EA = 0) but should enable/disable user configured interrupts individually using the interrupt's source interrupt enable flag. This function allows the user to specify the Vendor and Product IDs as well as a Manufacturer, Product Description and Serial Number string returned as part of the device's USB descriptor during the USB enumeration (connection). note that ProductID is important that windows hardware installation wizard can find the USBXPress driver this driver must be preinstalled before plugging in device see the Preinstaller but note that path in .ini file may need to be changed for preinstaller to locate driver files so that they can be copied to standard windows driver search folder for drivers. this initVariables is for 60mA device, bus powered, serial number 1.00 */ //void USB_Init (int VendorID, int ProductID, uchar *ManufacturerStr,uchar *ProductStr, uchar *SerialNumberStr, byte MaxPower, byte PwAttributes, uint bcdDevice) USB_Init (0, 0xEA61, ManufacturerStr, ProductStr, SerialNumberStr,30,0x80,0x0100); // very important, USB_Init should be called AFTER config() so that USB clock is setup correctly. //Config doesn't deal with USB at all. CLKSEL |= 0x02; // system clock 24MHz (48MHz USB/2) RSTSRC |= 0x02; // power on reset IP=0x01; // ext int 0 high priority ?? LedOrangeOn(); //SPIEN=1; // enable SPI interface -- leave it enabled so that output port SCK and MOSI don't float initVariables(); isActive=0; USB_Int_Enable(); // Enable USB_API Interrupts // send the bias values from flash memory out the SPI port sendFlashedBiases(); while (1){ if(isActive){ while(NOTREQ==1) { // wait for !req low if( TH1==0xFF){ // while polling req, check if we have wrapped timer1 since last transfer if(AECounter>0){ sendEvents(); // if so just send available events } } } LedOrangeOn(); // got req NOTACK=0; // lower acknowledge //USB_Int_Disable(); // using these functions increases cycle time to >8us EA=0; // disable interrupts during snapshot of AE to avoid USB interrupt during snapshot //note according to C51 compiler specs, shorts are stored big-endian, MSB comes first *AEPtr++=P2; // AE8-15 *AEPtr++=P1; // AE07 *AEPtr++=PCA0CPH0; // captured PCA counter/timer MSB. This was captured by req low. *AEPtr++=PCA0CPL0; // timer LSB. AECounter++; // increment counter for events EA=1; // reenable interrupts // USB_Int_Enable(); // using these functions increases cycle time to >8us // very important!!!! // check HERE if buffer is full so that last request is acknowledged and retina can take away its // request before the pause to transmit events over USB. during this transfer, the usb chip // has acknowledged and the retina takes away its request, but it cannot generate a new request // until the USB chip takes away its ack, below. // if this is not done in this order, you get vertical streaks of events, because (hyppothesis) // the retina is not rapidly acknowledged and therefore it is still pulling down on the column req // line and pulling it to ground. this makes it easier for other pixels in the same column to generate // new events, compared with normally-timed handshake cyles. with the present timing scheme, the retina // is acknowledged with normal timing, and therefore the pixel takes away its request with normal timing. // this is the working hypothesis. if(AECounter==AE_BUFFER_SIZE){ // when we have collected buffer, initiate transfer // during this 860us no handshaking is occurring sendEvents(); } // if the retina is powered off, then its req will be low (no power). so this code will come here and // will have lowered ack and stored a bogus address. now it will wait for req to go high. // but req will be low from the retina and won't go high // because ack is low. therefore we can get stuck here if the retina is powered on after reset. while(NOTREQ==0){ // wait for req to go high if( TH1==0xFF) { // while polling req, check if we have wrapped timer1 since last transfer TH1=0; AECounter--; // throw away that event break; // break from possibly infinite loop. this will raise ack } } NOTACK=1; // raise acknowledge, completing handshake LedOrangeOff(); // got req // }else if(state==ST_WAITING){ }else{ // isActive is false, USB not open, just handshake // plain handshake cycle is about 1+/-0.2us while(NOTREQ==1) { // wait for !req low if( TH1==0xFF) { // while polling req, check if we have wrapped timer1 since last transfer TH1=0; NOTACK=0; NOTACK=1; // toggle ack an extra time in case we are stuck } } LedOrangeOn(); // !req received NOTACK=0; // lower acknowledge while(NOTREQ==0){ // wait for req to go high if( TH1==0xFF) { // while polling req, check if we have wrapped timer1 since last transfer TH1=0; break; // break from possibly infinite loop } } NOTACK=1; // raise acknowledge, completing handshake LedOrangeOff(); } } }
bool MWindow::onEvents(void) { while(XPending(display)) { MWinEvent mevent; XEvent event; XNextEvent(display, &event); switch(event.type) { case Expose: { if(event.xexpose.count != 0) break; // refresh break; } case ButtonPress: { // A mouse button was pressed or a scrolling event occurred if(event.xbutton.button == Button1) { mevent.type = MWIN_EVENT_MOUSE_BUTTON_DOWN; mevent.data[0] = MMOUSE_BUTTON_LEFT; sendEvents(&mevent); } else if(event.xbutton.button == Button2) { mevent.type = MWIN_EVENT_MOUSE_BUTTON_DOWN; mevent.data[0] = MMOUSE_BUTTON_MIDDLE; sendEvents(&mevent); } else if(event.xbutton.button == Button3) { mevent.type = MWIN_EVENT_MOUSE_BUTTON_DOWN; mevent.data[0] = MMOUSE_BUTTON_RIGHT; sendEvents(&mevent); } // XFree86 3.3.2 and later translates mouse wheel up/down into // mouse button 4 & 5 presses else if(event.xbutton.button == Button4) { mevent.type = MWIN_EVENT_MOUSE_WHEEL_MOVE; mevent.data[0] = 1; sendEvents(&mevent); } else if( event.xbutton.button == Button5 ) { mevent.type = MWIN_EVENT_MOUSE_WHEEL_MOVE; mevent.data[0] = -1; sendEvents(&mevent); } break; } case ButtonRelease: { if(event.xbutton.button == Button1) { mevent.type = MWIN_EVENT_MOUSE_BUTTON_UP; mevent.data[0] = MMOUSE_BUTTON_LEFT; sendEvents(&mevent); } else if(event.xbutton.button == Button2) { mevent.type = MWIN_EVENT_MOUSE_BUTTON_UP; mevent.data[0] = MMOUSE_BUTTON_MIDDLE; sendEvents(&mevent); } else if(event.xbutton.button == Button3) { mevent.type = MWIN_EVENT_MOUSE_BUTTON_UP; mevent.data[0] = MMOUSE_BUTTON_RIGHT; sendEvents(&mevent); } break; } case KeyPress: { int key = translateKey(event.xkey.keycode); if(key > 0 && key < 256) { mevent.type = MWIN_EVENT_KEY_DOWN; mevent.data[0] = key; sendEvents(&mevent); } int car = translateChar(&event.xkey); //if(car == 127 || car == 32 || car == 13 || car == 9) // not return, space, delete etc.. // break; if(car == -1) break; mevent.type = MWIN_EVENT_CHAR; mevent.data[0] = car; sendEvents(&mevent); break; } case KeyRelease: { int key = translateKey(event.xkey.keycode); if(key > 0 && key < 256) { mevent.type = MWIN_EVENT_KEY_UP; mevent.data[0] = key; sendEvents(&mevent); } break; } case MotionNotify: { mevent.type = MWIN_EVENT_MOUSE_MOVE; mevent.data[0] = event.xmotion.x; mevent.data[1] = event.xmotion.y; sendEvents(&mevent); break; } case ConfigureNotify: { if(event.xconfigure.width != m_width || event.xconfigure.height != m_height) { mevent.type = MWIN_EVENT_WINDOW_RESIZE; mevent.data[0] = event.xconfigure.width; mevent.data[1] = event.xconfigure.height; sendEvents(&mevent); } break; } case FocusIn: { m_focus = true; break; } case FocusOut: { m_focus = false; break; } case DestroyNotify: { mevent.type = MWIN_EVENT_WINDOW_CLOSE; sendEvents(&mevent); break; } case ClientMessage: { if((Atom)event.xclient.data.l[0] == wmDelete) { mevent.type = MWIN_EVENT_WINDOW_CLOSE; sendEvents(&mevent); } break; } default: break; } } return true; }
int beatboxmain() { int vol=0; numberOfSamples=44100/10; synthbuf(); rb->pcm_play_data(&get_more, NULL, 0); rb->lcd_set_background(0x000000); rb->lcd_clear_display(); resetPosition(); int i, j; /* Start at 16 cells/loop for now. User can un-loop if more are needed */ for(i=0; i<V_NUMCELLS; i++) trackData[16][i] = VAL_LOOP; /* Very very rough beat to 'Goodbye Horses' trackData[16][3] = VAL_LOOP; trackData[16][2] = VAL_LOOP; trackData[0][3] = 1; trackData[4][3] = 1; trackData[8][3] = 1; trackData[9][3] = 1; trackData[12][3] = 1; trackData[13][3] = 1; trackData[2][2] = 1; trackData[6][2] = 1; trackData[10][2] = 1; trackData[14][2] = 1; */ drawGrid(); showDrumName(yCursor); updateDisplay(); redrawScreen(1); while(!quit) { #ifndef SYNC synthbuf(); #endif rb->yield(); if(stepFlag) { advancePosition(); sendEvents(); updateDisplay(); redrawScreen(0); stepFlag=0; } /* Prevent idle poweroff */ rb->reset_poweroff_timer(); /* Code taken from Oscilloscope plugin */ switch(rb->button_get(false)) { /* case BTN_UP: case BTN_UP | BUTTON_REPEAT: vol = rb->global_settings->volume; if (vol < rb->sound_max(SOUND_VOLUME)) { vol++; rb->sound_set(SOUND_VOLUME, vol); rb->global_settings->volume = vol; } break; case BTN_DOWN: case BTN_DOWN | BUTTON_REPEAT: vol = rb->global_settings->volume; if (vol > rb->sound_min(SOUND_VOLUME)) { vol--; rb->sound_set(SOUND_VOLUME, vol); rb->global_settings->volume = vol; } break; case BTN_RIGHT: { //pressNote(9, 40, 127); // resetPosition(); advancePosition(); sendEvents(); updateDisplay(); redrawScreen(0); break; } case BUTTON_LEFT: { // isPlaying=1; resetPosition(); updateDisplay(); redrawScreen(0); //pressNote(9, 39, 127); break; } */ case BEATBOX_UP: case BEATBOX_UP | BUTTON_REPEAT: { if(editState == EDITSTATE_PATTERN) { if(yCursor > 0) { yCursor--; showDrumName(yCursor); updateDisplay(); redrawScreen(0); } } break; } case BEATBOX_DOWN: case BEATBOX_DOWN | BUTTON_REPEAT: { if(editState == EDITSTATE_PATTERN) { if(yCursor < V_NUMCELLS-1) { yCursor++; showDrumName(yCursor); updateDisplay(); redrawScreen(0); } } break; } case BEATBOX_LEFT: case BEATBOX_LEFT | BUTTON_REPEAT: { if(editState == EDITSTATE_PATTERN) { if(xCursor > 0) { xCursor--; updateDisplay(); redrawScreen(0); } } break; } case BEATBOX_RIGHT: case BEATBOX_RIGHT | BUTTON_REPEAT: { if(editState == EDITSTATE_PATTERN) { if(xCursor < H_NUMCELLS-1) { xCursor++; updateDisplay(); redrawScreen(0); } } break; } case BEATBOX_SELECT: { if(editState == EDITSTATE_PATTERN) { int cv = trackData[xCursor][yCursor]; cv++; if(cv > VAL_LOOP) cv = VAL_NONE; trackData[xCursor][yCursor] = cv; updateDisplay(); redrawScreen(0); } break; } case BEATBOX_PLAY: { if(playState == STATE_PLAYING) playState = STATE_PAUSED; else { updateDisplay(); redrawScreen(0); sendEvents(); playState = STATE_PLAYING; } break; } case BEATBOX_STOP: { if(playState == STATE_STOPPED) { quit=1; } else { playState =STATE_STOPPED; resetPosition(); updateDisplay(); redrawScreen(0); } break; } } } return 0; }
QThreadPostEventPrivate::QThreadPostEventPrivate() { events.setAutoDelete( TRUE ); connect( qApp, SIGNAL( guiThreadAwake() ), this, SLOT( sendEvents() ) ); }
int GameEngineMain(int argc, _TCHAR* argv[]) // int _main (int argc, const char * const* argv) #endif { bool bStdModuleExist = EngineStdReference(); klb_assert(bStdModuleExist, "The links of a system are insufficient."); glutInit(&argc, argv); glutInitDisplayMode(GLUT_RGB | GLUT_DEPTH); glutCreateWindow("GLEW Test"); GLenum err = glewInit(); if (GLEW_OK != err) { /* Problem: glewInit failed, something is seriously wrong. */ fprintf(stderr, "Error: %s\n", glewGetErrorString(err)); } fprintf(stdout, "Status: Using GLEW %s\n", glewGetString(GLEW_VERSION)); #define HEIGHT (768) #define WIDTH (1024) #define POS_X (10) #define POS_Y (10) //#define HEIGHT (800) //#define WIDTH (400) int scrW = WIDTH; int scrH = HEIGHT; int fixedDelta = 0; *g_basePath = 0; *g_fileName = 0; g_pathExtern = PATH_EXTERN; g_pathInstall = PATH_INSTALL; g_fileName[0] = 0; bool hasDefaultFont = true; bool hasDefaultDB = false; if (argc > 1) { int parse = 1; int max = argc; while (parse < max) { if(*argv[parse] == '-') { if (strcmp("-w",argv[parse]) == 0) { sscanf_s(argv[parse+1],"%i",&scrW); } if (strcmp("-h",argv[parse]) == 0) { sscanf_s(argv[parse+1],"%i",&scrH); } if (strcmp("-i",argv[parse]) == 0) { g_pathInstall = convertPath(argv[parse+1]); } if (strcmp("-e",argv[parse]) == 0) { g_pathExtern = convertPath(argv[parse+1]); } if (strcmp("-t",argv[parse]) == 0) { fixedDelta = atoi(argv[parse+1]); } if (strcmp("-enc", argv[parse]) == 0) { bool encrypt = false; if (stricmp(argv[parse+1],"true") == 0) { encrypt = true; } if (stricmp(argv[parse+1],"1") == 0) { encrypt = true; } CWin32Platform::setEncrypt(encrypt); } if (strcmp("-no", argv[parse]) == 0) { if (strcmp("defaultfont", argv[parse+1]) == 0) { hasDefaultFont = false; } } parse += 2; } else { // Specify the boot file const char* file = argv[parse]; int lenf = strlen(file); memcpy(g_fileName, file, lenf); g_fileName[lenf] = 0; // ファイル名そのものは start.lua に相当する起動ファイルとする。 // File name of the file used as a start.lua parse++; } } } CWin32PathConv& pathconv = CWin32PathConv::getInstance(); pathconv.setPath(g_pathInstall, g_pathExtern); WNDCLASS wc; HWND hwnd; HDC hDC; HGLRC hRC; HINSTANCE hInstance = GetModuleHandle(NULL); // register window class wc.style = CS_OWNDC; wc.lpfnWndProc = WndProc; wc.cbClsExtra = 0; wc.cbWndExtra = 0; wc.hInstance = hInstance; wc.hIcon = LoadIcon( NULL, IDI_APPLICATION ); wc.hCursor = LoadCursor( NULL, IDC_ARROW ); wc.hbrBackground = (HBRUSH)GetStockObject( BLACK_BRUSH ); wc.lpszMenuName = NULL; wc.lpszClassName = "GameEngineGL"; RegisterClass( &wc ); // create main window hwnd = CreateWindow( "GameEngineGL", "Playground", WS_CAPTION | WS_POPUPWINDOW | WS_VISIBLE, 0, 0, 256, 256, NULL, NULL, hInstance, NULL ); /* "EngineGL", NULL, WS_THICKFRAME|WS_DISABLED, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL, hInstance, NULL );*/ if (!hwnd) return -1; // enable OpenGL for the window EnableOpenGL( hwnd, &hDC, &hRC ); // COM Initialization CoInitialize(NULL); EnableWindow(hwnd, TRUE); DragAcceptFiles(hwnd, true); RECT area; area.left = 0; area.top = 0; #ifdef _WIN32_WCE area.right = GetSystemMetrics(SM_CXSCREEN); area.bottom = GetSystemMetrics(SM_CYSCREEN); SetWindowLong(hwnd, GWL_STYLE, WS_POPUP); SetWindowPos(hwnd, HWND_TOPMOST, area.left, area.top, area.right, area.bottom, SWP_FRAMECHANGED); #else // Window border hard coded //area.right = scrW + 8; //area.bottom = scrH + 27; ////area.right = GetSystemMetrics(SM_CXSCREEN); ////area.bottom = GetSystemMetrics(SM_CYSCREEN); int addW = GetSystemMetrics(SM_CXSIZEFRAME) * 2; int addH = GetSystemMetrics(SM_CYSIZEFRAME) * 2 + GetSystemMetrics(SM_CYCAPTION); area.right = scrW + addW; area.bottom = scrH + addH; /* AdjustWindowRect( &area, WS_SYSMENU|WS_THICKFRAME|WS_DISABLED, false );*/ SetWindowPos(hwnd, HWND_TOP, area.left, area.top, area.right, area.bottom, SWP_NOMOVE); #endif /* set as foreground window to give this app focus in case it doesn't have it */ SetForegroundWindow(hwnd); ShowWindow(hwnd, SW_SHOWNORMAL); glClearColor(1.0f, 0.7f, 0.2039f, 0.0f); glDisable( GL_CULL_FACE ); // // testCodeInit(); CPFInterface& pfif = CPFInterface::getInstance(); CWin32Platform * pPlatform = new CWin32Platform(hwnd); if (!hasDefaultFont) { pPlatform->setNoDefaultFont(); } pfif.setPlatformRequest(pPlatform); GameSetup(); // client side setup // Can only access client AFTER GameSetup. pfif.client().setInitParam((hasDefaultDB ? IClientRequest::ENGINE_USE_DEFAULTDB : 0) | (hasDefaultFont ? IClientRequest::ENGINE_USE_DEFAULTFONT : 0), NULL); // sound initialize SoundSystemInitFor_Win32(); CWin32AudioMgr::getInstance().init(hwnd); // set screen size pfif.client().setScreenInfo(false, scrW, scrH); // boot path if (strlen(g_fileName)) { pfif.client().setFilePath(g_fileName); } else { pfif.client().setFilePath(NULL); } if (!pfif.client().initGame()) { klb_assertAlways("Could not initialize game, most likely memory error"); } else { static DWORD lastTime = GetTickCount(); // Main message loop: bool quit = false; s32 frameTime = pfif.client().getFrameTime(); IClientRequest& pClient = pfif.client(); while (!quit) { /* relay message queue messages to windowproc's */ MSG msg; while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) { TranslateMessage(&msg); if (msg.message == WM_QUIT) { quit = true; break; } DispatchMessage(&msg); } if (!quit) { // This is not the safest or best way to handle timing, but this code // is only added to make the triangle rotate at a basically constant // rate, independent of the target (Win32) platform DWORD newTime = GetTickCount(); DWORD delta = newTime - lastTime; // Handle rollover if (newTime < lastTime) { delta = 0; } else { if (delta > (DWORD)frameTime) { sendEvents(); lastTime = newTime; //dglClear(GL_COLOR_BUFFER_BIT); // // Rendering complete. // //testCodeLoop(delta); pClient.frameFlip(fixedDelta ? fixedDelta : delta); // pfIF.platform().flipFrame(); SwapBuffers( hDC ); } // コントロール(ex. TextBox)が作られている場合、その再描画を行う // If a Control (ex TextBox) is done, redraw them. CWin32Widget::ReDrawControls(); } } Sleep(1); } } pfif.client().finishGame(); SoundSystemExitFor_Win32(); delete pPlatform; // shutdown OpenGL DisableOpenGL( hwnd, hDC, hRC ); CWin32AudioMgr::getInstance().release(); // End of COM CoUninitialize(); if(DestroyWindow (hwnd)) { printf("DestroyWindow SUCCESS\n"); } return 0; }
void Button::updateView(float mouseData[2], int clickType, wchar_t keyChar, vector<string> eventCompList) { if (getVisible() == true) { sentClickEvent = false; float posX = getPosX(); float posY = getPosY(); float height = getHeight(); float width = getWidth(); float transparency = getTransparency(); if ((getFocusEffect() == true) && (getMouseOverContainer() == true)) transparency = 1.0f; if (getEnabled() == false) setActualTex(getDisabledTex()); else { if ((isMouseOver(mouseData) == true) && (getMouseOverContainer())) { if (getFocusEffect() == true) transparency = 1.0f; if (clickType == 0) { if (hintCounter < 1.0f) hintCounter += 1/GameEngine::FPS(); if (getActualTex() != getPressedTex()) { setActualTex(getHighlightTex()); if (wasLeft) sendOnce = false; if ((sendOnce == false) && (wasLeft == true)) { sendOnce = true; wasOver = true; wasLeft = false; GUIEventData::sendToGUI(new GUIEventData(O_COMP_MOUSEOVER,this->getName())); sendEvents(O_COMP_MOUSEOVER, eventCompList); } if (hintCounter >= 1.0f) { if (!hint->getVisible() ) { //needed for aspect ratio (maximum width) int m_camID = GameEngine::entityWorldID("camera"); int x,y, width, height; H3DNode camID = GameEngine::entitySceneGraphID( m_camID ); x = h3dGetNodeParamI( camID, H3DCamera::ViewportXI); y = h3dGetNodeParamI( camID, H3DCamera::ViewportYI); width = h3dGetNodeParamI( camID, H3DCamera::ViewportWidthI); height = h3dGetNodeParamI( camID, H3DCamera::ViewportHeightI); float aspect = (float)width/(float)height; hint->setText(getHintText()); float posX = mouseData[0]+0.03f; if (posX+ hint->getWidth() > aspect) posX = aspect - hint->getWidth() - 0.01f; hint->setPosX(posX); float posY = mouseData[1]+0.06f; if (posY+ hint->getHeight() > 1.0f) posY = mouseData[1] - hint->getHeight() - 0.06f; hint->setPosY(posY); hint->setVisible(true); } } } } if (clickType == 1) { setActualTex(getPressedTex()); clickWasOver = true; } if ((clickType == -1) && (clickWasOver)) { setActualTex(getHighlightTex()); if (wasLeft) sendOnce = false; if ((sendOnce == false) && (wasLeft == true)) { sendOnce = true; wasOver = true; wasLeft = false; GUIEventData::sendToGUI(new GUIEventData(O_COMP_MOUSEOVER,this->getName())); sendEvents(O_COMP_MOUSEOVER, eventCompList); } //prevent sending the same event multiple times if (oldClickType != clickType) { //send event to all listed components sendEvents(O_BUTTON_CLICKED, eventCompList); //send to GUI for sound GUIEventData::sendToGUI(new GUIEventData(O_BUTTON_CLICKED,this->getName())); sentClickEvent = true; } } } else { clickWasOver = false; setActualTex(getNormalTex()); if (wasOver) sendOnce = false; if ((sendOnce == false) && (wasOver == true)) { sendOnce = true; wasOver = false; wasLeft = true; GUIEventData::sendToGUI(new GUIEventData(O_COMP_MOUSELEFT,this->getName())); sendEvents(O_COMP_MOUSELEFT, eventCompList); hint->setVisible(false); hintCounter = 0.0f; } } } oldClickType = clickType; float vals[] = { posX, posY, 0, 1, posX, posY+height, 0, 0, posX+width, posY+height, 1, 0, posX+width, posY, 1, 1 }; h3dShowOverlays(vals, 4,1, 1, 1, transparency,getActualTex(), 0 ); } else if (!wasLeft) { //if a mouseleft event wasn't sent it's done here GUIEventData::sendToGUI(new GUIEventData(O_COMP_MOUSELEFT,this->getName())); wasLeft = true; } }
void Entity::setName( const String& name ) { this->name = name; sendEvents(); }
void IMS_Storable::PreStep(IMS_Location *location) { sendEvents(); }
//----------------------------------------------------------------------------- // Main Routine // after initialization, the program simply polls the !req input and when // !req goes low, !ack on P0.1 is lowered to acknowledge, // the address is captured in P1 (AE0-7) and P2 (AE8-15) and is copied to XRAM. // Then !ack is raised, we wait for !req to go high and start over. // When we get an interrupt from USB, we transmit the existing buffer of data. //----------------------------------------------------------------------------- void main(void) { PCA0MD &= ~0x40; // Disable Watchdog timer //void USB_Init (int VendorID, int ProductID, uchar *ManufacturerStr,uchar *ProductStr, uchar *SerialNumberStr, byte MaxPower, byte PwAttributes, uint bcdDevice) // note that ProductID is important that windows hardware installation wizard can find the USBXPress driver // this driver must be preinstalled before plugging in device // see the Preinstaller but note that path in .ini file may need to be changed for preinstaller to locate driver files // so that they can be copied to standard windows driver search folder for drivers. // this initVariables is for 60mA device, bus powered, serial number 1.00 USB_Init (0, 0xEA61, ManufacturerStr, ProductStr, SerialNumberStr,250,0x80,0x0100); CLKSEL |= 0x02; // system clock 24MHz (48MHz USB/2) RSTSRC |= 0x02; // power on reset Timer_Init(); // Init Timer and Capture for event timing. Init PCA peripheral before port init. Port_Init(); // Initialize crossbar and GPIO initVariables(); LedGreenOff(); LedBlueOff(); /* LedRedOn(); delay(); LedRedOff(); LedGreenOn(); delay(); LedGreenOff(); LedBlueOn(); delay(); LedBlueOff(); */ //flushEvents(); // flush some events in case the sender has been powered up //state=ST_WAITING; isActive=0; USB_Int_Enable(); // Enable USB_API Interrupts while (1){ // if(state==ST_ACTIVE){ if(isActive){ while(NOTREQ==1) { // wait for !req low if( TH1==0xFF){ // while polling req, check if we have wrapped timer1 since last transfer if(AECounter>0){ sendEvents(); // if so just send available events } } } LedGreenOn(); // got req NOTACK=0; // lower acknowledge //USB_Int_Disable(); // using these functions increases cycle time to >8us EA=0; // disable interrupts during snapshot of AE to avoid USB interrupt during snapshot //note according to C51 compiler specs, shorts are stored big-endian, MSB comes first *AEPtr++=P2; // AE8-15 *AEPtr++=P1; // AE07 *AEPtr++=PCA0CPH0; // captured PCA counter/timer MSB. This was captured by req low. *AEPtr++=PCA0CPL0; // timer LSB. AECounter++; // increment counter for events EA=1; // reenable interrupts // USB_Int_Enable(); // using these functions increases cycle time to >8us // if the retina is powered off, then its req will be low (no power). so this code will come here and // will have lowered ack and stored a bogus address. now it will wait for req to go high. // but req will be low from the retina and won't go high // because ack is low. therefore we can get stuck here if the retina is powered on after reset. while(NOTREQ==0){ // wait for req to go high if( TH1==0xFF) { // while polling req, check if we have wrapped timer1 since last transfer TH1=0; AECounter--; // throw away that event break; // break from possibly infinite loop. this will raise ack } } NOTACK=1; // raise acknowledge, completing handshake LedGreenOff(); // got req if(AECounter==AE_BUFFER_SIZE){ // when we have collected buffer, initiate transfer // during this 860us no handshaking is occurring sendEvents(); } // }else if(state==ST_WAITING){ }else{ // isActive is false, USB not open, just handshake // plain handshake cycle is about 1+/-0.2us while(NOTREQ==1) { // wait for !req low if( TH1==0xFF) { // while polling req, check if we have wrapped timer1 since last transfer TH1=0; NOTACK=0; NOTACK=1; // toggle ack an extra time in case we are stuck } } LedGreenOn(); // !req received NOTACK=0; // lower acknowledge while(NOTREQ==0){ // wait for req to go high if( TH1==0xFF) { // while polling req, check if we have wrapped timer1 since last transfer TH1=0; break; // break from possibly infinite loop } } NOTACK=1; // raise acknowledge, completing handshake LedGreenOff(); } } }