コード例 #1
0
ファイル: bakacommands.cpp プロジェクト: wcy95/Baka-MPlayer
void BakaEngine::BakaScreenshot(QStringList &args)
{
    if(args.empty())
        Screenshot(false);
    else
    {
        QString arg = args.front();
        args.pop_front();
        if(args.empty() && arg == "subtitles")
            Screenshot(true);
        else
            InvalidParameter(arg);
    }
}
コード例 #2
0
ファイル: menu.c プロジェクト: alex34567/Decrypt9
u32 ScrollOutput()
{
    u32 log_start = LogWrite(NULL);
    
    // careful, these areas are used by other functions in Decrypt9
    char** logptr = (char**) 0x20316000;
    char* logtext = (char*)  0x20400000;
    u32 log_size = 0; // log size
    u32 l_total = 0; // total lines
    u32 l_curr = 0; // current line
    
    if (!FileOpen(LOG_FILE))
        return 0;
    log_size = FileGetSize();
    if ((log_size <= log_start) || (log_size - log_start >= 1024 * 1024)) {
        FileClose();
        return 0; // allow 1MB of text max
    }
    log_size -= log_start;
    if (!FileRead(logtext, log_size, log_start)) {
        FileClose();
        return 0;
    }
    FileClose();
    
    // read lines
    logtext[log_size - 1] = '\0';
    logptr[l_total++] = logtext;
    for (char* line = strchr(logtext, '\n'); line != NULL && l_total < 4000; line = strchr(line, '\n')) {
        *line = '\0';
        logptr[l_total++] = ++line; 
    }
    if (l_total >= 4000) // allow 4000 lines of text max
        return 0;
    for (; l_total < DBG_N_CHARS_Y; logptr[l_total++] = logtext + log_size - 1);
    
    // here, the actual output starts
    l_curr = l_total - DBG_N_CHARS_Y ;
    if (l_curr > 0) l_curr--; // start at the line before the last
    while (true) {
        DebugSet((const char**) logptr + l_curr);
        u32 pad_state = InputWait();
        if (pad_state & BUTTON_X) {
            Screenshot(NULL);
        } else if ((pad_state & BUTTON_UP) && (l_curr > 0)) {
            l_curr--;
        } else if ((pad_state & BUTTON_DOWN) && (l_curr < l_total - DBG_N_CHARS_Y)) {
            l_curr++;
        } else if (pad_state & (BUTTON_B | BUTTON_START)) {
            return pad_state;
        }
    }
    
    return 0;
}
コード例 #3
0
ファイル: MenuBar.cpp プロジェクト: Lionel07/dolphin
void MenuBar::AddEmulationMenu()
{
    QMenu* emu_menu = addMenu(tr("Emulation"));
    m_play_action = emu_menu->addAction(tr("Play"), this, SIGNAL(Play()));
    m_pause_action = emu_menu->addAction(tr("Pause"), this, SIGNAL(Pause()));
    m_stop_action = emu_menu->addAction(tr("Stop"), this, SIGNAL(Stop()));
    m_reset_action = emu_menu->addAction(tr("Reset"), this, SIGNAL(Reset()));
    m_fullscreen_action = emu_menu->addAction(tr("Fullscreen"), this, SIGNAL(Fullscreen()));
    m_frame_advance_action = emu_menu->addAction(tr("Frame Advance"), this, SIGNAL(FrameAdvance()));
    m_screenshot_action = emu_menu->addAction(tr("Take Screenshot"), this, SIGNAL(Screenshot()));
    AddStateLoadMenu(emu_menu);
    AddStateSaveMenu(emu_menu);
    AddStateSlotMenu(emu_menu);
    UpdateStateSlotMenu();
}
コード例 #4
0
ファイル: menu.c プロジェクト: alex34567/Decrypt9
void BatchScreenshot(MenuInfo* info, bool full_batch)
{
    for (u32 idx_m = 0; info[idx_m].name != NULL; idx_m++) {
        for (u32 idx_s = 0; idx_s < ((full_batch) ? info[idx_m].n_entries : 1); idx_s++) {
            char filename[16];
            snprintf(filename, 16, "menu%04lu.bmp", (idx_m * 100) + idx_s);
            #ifndef USE_THEME
            DrawMenu(info + idx_m, idx_s, true, true);
            #else
            LoadThemeGfxLogo();
            LoadThemeGfxMenu((idx_m * 100) + idx_s);
            #endif
            Screenshot(filename);
        }
    }
}
コード例 #5
0
ファイル: menu.c プロジェクト: PlayerAAA/Decrypt9WIP_ES
u32 ScrollOutput()
{
    u32 log_start = LogWrite(NULL);

    // careful, these areas are used by other functions in Decrypt9
    char** logptr = (char**) 0x21100000;
    char* logtext = (char*)  0x21200000;
    u32 log_size = FileGetData(LOG_FILE, logtext, 1024 * 1024, log_start); // log size
    u32 l_total = 0; // total lines
    u32 l_curr = 0; // current line

    // read log file (second time)
    log_size = FileGetData(LOG_FILE, logtext, 1024 * 1024, log_start);

    // allow 1MB of text max
    if ((log_size == 0) || (log_size >= 1024 * 1024))
        return 0;

    // organize lines
    logtext[log_size - 1] = '\0';
    logptr[l_total++] = logtext;
    for (char* line = strchr(logtext, '\n'); line != NULL && l_total < 4000; line = strchr(line, '\n')) {
        *line = '\0';
        logptr[l_total++] = ++line;
    }
    if (l_total >= 4000) // allow 4000 lines of text max
        return 0;
    for (; l_total < DBG_N_CHARS_Y; logptr[l_total++] = logtext + log_size - 1); // fill up with empty lines
    // here, the actual output starts
    l_curr = l_total - DBG_N_CHARS_Y;
    if (l_curr > 0) l_curr--; // start at the line before the last
    while (true) {
        DebugSet((const char**) logptr + l_curr);
        u32 pad_state = InputWait();
        if (pad_state & BUTTON_X) {
            Screenshot(NULL);
        } else if ((pad_state & BUTTON_UP) && (l_curr > 0)) {
            l_curr--;
        } else if ((pad_state & BUTTON_DOWN) && (l_curr < l_total - DBG_N_CHARS_Y)) {
            l_curr++;
        } else if (pad_state & (BUTTON_B | BUTTON_START)) {
            return pad_state;
        }
    }

    return 0;
}
コード例 #6
0
ファイル: main.cpp プロジェクト: aust/Bejeweled-Bot
// Averages each cell's color
void GetGems()
{
	int y, py;
	int x, px;

	COLORREF color;

	int r_avg = 0;
	int g_avg = 0;
	int b_avg = 0;

	Screenshot();

	for (y = 0; y < cell_count; y++)
	{
		for (x = 0; x < cell_count; x++)
		{
			// Reset averages for cell
			r_avg = 0;
			g_avg = 0;
			b_avg = 0;

			for (py = 0; py < box_size; py++)
			{
				for (px = 0; px < box_size; px++)
				{
					// Get pixel by calculating it relative to the game_origin
					// (game_origin) then the current cell_size (x * 40) then by the
					// current_center of the cell, finally by the position
					color = GetPixelRGB(game_origin.x + (x * 40) + current_center + px,
						(game_origin.y + (y * 40) + current_center + py));

					// Add up R, G, B separately
					r_avg += GetRValue(color);
					g_avg += GetGValue(color);
					b_avg += GetBValue(color);
				}
			}

			// Calculate averages, then construct RGB COLORREF
			grid[y][x] = RGB(r_avg / box_size * box_size,
				g_avg / box_size * box_size,
				b_avg / box_size * box_size);
		}
	}

}
コード例 #7
0
ファイル: stageros.cpp プロジェクト: iocchi/stage_ros
void StageNode::GUIRequest_cb(const boost::shared_ptr<std_msgs::String const>& msg)
{
#if NEW_GUI_ACCESS
    ROS_INFO_STREAM(msg->data);
    if (msg->data=="screenshot")
        Screenshot();
    else if (msg->data=="footprints")
        Footprints();
    else if (msg->data.substr(0,7)=="speedup") {
	std::vector<std::string> pp;
        boost::split(pp, msg->data, boost::is_any_of("_"));
	float s=1.0;
	if (pp.size()>1) {
	  s = atof(pp[1].c_str());
	  if (s<1e-6) s=1.0;
	}
        Speedup(s);
    }
#endif
}
コード例 #8
0
ファイル: Core.cpp プロジェクト: morukutsu/theabyss
	void Core::Display()
	{
		// Refresh
		lowRefresh();

		// Screenshot
		if(sf::Keyboard::isKeyPressed(sf::Keyboard::F1) )
		{
			Screenshot();
		}

		// Calcul du framerate
		mEllapsedTimeFPS += lowGetFrameTime();
		if(mEllapsedTimeFPS >= 1.0f)
		{
			mCurrentFPS = (int)((double)1.0/(double)lowGetFrameTime());
			mEllapsedTimeFPS = 0.0f;
		}
		lowResetFrameTimeClock();
	}
コード例 #9
0
int WINAPI WinMain(HINSTANCE,HINSTANCE,LPSTR,int)
{
    RegisterHotKey(
        NULL,
        1,
        MOD_ALT,
        0x42);
    //0x42 is 'b'

//when it receives a certain key ,it will modify the msg .then the msg will have valid value

    MSG msg = {0};

    while (GetMessage(&msg, NULL, 0, 0) != 0)
    {
        if (msg.message == WM_HOTKEY)
        {
            Screenshot();
        }
    }

    return 0;
}
コード例 #10
0
/**
**  Update KeyModifiers if a key is pressed.
**
**  @param key      Key scancode.
**  @param keychar  Character code.
**
**  @return         1 if modifier found, 0 otherwise
*/
int HandleKeyModifiersDown(unsigned key, unsigned)
{
	switch (key) {
		case SDLK_LSHIFT:
		case SDLK_RSHIFT:
			KeyModifiers |= ModifierShift;
			return 1;
		case SDLK_LCTRL:
		case SDLK_RCTRL:
			KeyModifiers |= ModifierControl;
			return 1;
		case SDLK_LALT:
		case SDLK_RALT:
		case SDLK_LMETA:
		case SDLK_RMETA:
			KeyModifiers |= ModifierAlt;
			// maxy: disabled
			if (InterfaceState == IfaceStateNormal) {
				SelectedUnitChanged(); // VLADI: to allow alt-buttons
			}
			return 1;
		case SDLK_LSUPER:
		case SDLK_RSUPER:
			KeyModifiers |= ModifierSuper;
			return 1;
		case SDLK_SYSREQ:
		case SDLK_PRINT:
			Screenshot();
			if (GameRunning) {
				SetMessage("%s", _("Screenshot made."));
			}
			return 1;
		default:
			break;
	}
	return 0;
}
コード例 #11
0
ファイル: RenderCommand.cpp プロジェクト: Razish/xsngine
	void RenderCommand::Execute( void ) const {
		switch ( type ) {

		case CommandType::DrawQuad: {
			DrawQuad( drawQuad );
		} break;

		case CommandType::DrawModel: {
			DrawModel( drawModel );
		} break;

		case CommandType::DrawParticles: {
			DrawParticles( drawParticles );
		} break;

		case CommandType::Screenshot: {
			Screenshot( screenshot );
		} break;

		default: {
		} break;

		}
	}
コード例 #12
0
ファイル: configure_intfc.cpp プロジェクト: bilenadam/aqtlow
void configure_intfc::on_pushButton_Print_clicked()
{
    emit Screenshot(QPixmap::grabWidget(this));
}
コード例 #13
0
ファイル: menu.c プロジェクト: soarqin/Decrypt9WIP
u32 ProcessEntry(MenuEntry* entry)
{
    bool emunand    = entry->param & N_EMUNAND;
    bool nand_force = entry->param & N_FORCEEMU;
    bool nand_write = entry->param & N_NANDWRITE;
    bool a9lh_write = (entry->param & N_A9LHWRITE) && ((*(u32*) 0x101401C0) == 0);
    
    u32 pad_state;
    u32 res = 0;
    
    // unlock sequence for dangerous features
    if (nand_write || a9lh_write) {
        const u32 unlockSequences[3][5] = {
            { BUTTON_LEFT , BUTTON_RIGHT, BUTTON_DOWN , BUTTON_UP   , BUTTON_A }, // EmuNAND
            { BUTTON_LEFT , BUTTON_UP   , BUTTON_RIGHT, BUTTON_UP   , BUTTON_A }, // SysNAND
            { BUTTON_RIGHT, BUTTON_DOWN , BUTTON_LEFT , BUTTON_DOWN , BUTTON_A }  // A9LH
        };
        const u32 unlockLvlMax = 5;
        u32* unlockSequence = (u32*) &(unlockSequences[(emunand) ? 0 : (a9lh_write) ? 2 : 1]);
        u32 warnColor = (emunand) ? COLOR_YELLOW : COLOR_RED;
        u32 unlockLvl = 0;
        #ifdef USE_THEME
        LoadThemeGfx((emunand) ? GFX_DANGER_E : GFX_DANGER_S, false);
        #endif
        DebugClear();
        Debug("You selected [%s].", entry->name);
        Debug("");
        if (!a9lh_write) {
            DebugColor(warnColor, "This feature writes to the %s.", (emunand) ? "EmuNAND" : "SysNAND");
            DebugColor(warnColor, "This may overwrite important data!");
        } else {
            DebugColor(warnColor, "!!! THIS WILL OVERWRITE THE A9LH !!!");
            DebugColor(warnColor, "!!! INSTALLATION IN YOUR SYSNAND !!!");
        }
        Debug("");
        Debug("If you wish to proceed, enter:");
        Debug((emunand) ? "<Left>, <Right>, <Down>, <Up>, <A>" : (a9lh_write) ? "<Right>, <Down>, <Left>, <Down>, <A>" : 
            "<Left>, <Up>, <Right>, <Up>, <A>");
        Debug("");
        Debug("(B to return, START to reboot)");
        while (true) {
            ShowProgress(unlockLvl, unlockLvlMax);
            if (unlockLvl == unlockLvlMax)
                break;
            pad_state = InputWait();
            if (!(pad_state & BUTTON_ANY))
                continue;
            else if (pad_state & unlockSequence[unlockLvl])
                unlockLvl++;
            else if (pad_state & (BUTTON_B | BUTTON_START))
                break;
            else if (unlockLvl == 0 || !(pad_state & unlockSequence[unlockLvl-1]))
                unlockLvl = 0;
        }
        ShowProgress(0, 0);
        if (unlockLvl < unlockLvlMax)
            return pad_state;
    }
    
    // execute this entries function
    #ifdef USE_THEME
    LoadThemeGfx(GFX_PROGRESS, false);
    #endif
    DebugClear();
    Debug("Selected: [%s]", entry->name);
    res = (SetNand(emunand, nand_force) == 0) ? (*(entry->function))(entry->param) : 1;
    DebugColor((res == 0) ? COLOR_GREEN : COLOR_RED, "%s: %s!", entry->name, (res == 0) ? "succeeded" : "failed");
    Debug("");
    Debug("Press B to return, START to reboot.");
    #ifdef USE_THEME
    LoadThemeGfx((res == 0) ? GFX_DONE : GFX_FAILED, false);
    #endif
    while(!((pad_state = InputWait()) & (BUTTON_B | BUTTON_START))) {
        if (pad_state & BUTTON_X) Screenshot(NULL);
        #ifdef LOG_FILE
        else if (pad_state & BUTTON_UP) {
            pad_state = ScrollOutput();
            break;
        }
        #endif
    }
    
    // returns the last known pad_state
    return pad_state;
}
コード例 #14
0
ファイル: Geo1spare.cpp プロジェクト: seagods/Geodesy
void HandleKeyPress(SDL_keysym *whatkey)
{ 
             int igetscreen;
             float myspeed=speed;

             switch(whatkey->sym)
             {
                 case SDLK_F1:
                   ToggleFullScreen();
                   break;
                 case SDLK_F2:
                   if(MouseOn==true)
                     {
                      MouseOn=false;
                     }
                     else
                    {
                      MouseOn=true;
                    }
                    break;
                 case SDLK_F9:
                   if(togglez==true)
                        togglez=false;
                   else
                        togglez=true;

                 case SDLK_F10:
                   igetscreen=Screenshot(MainWindow,"screenshot.bmp");
                   break;
                 case SDLK_ESCAPE:
                   SDL_Quit();
                   exit(0);
                   break;
                 case  SDLK_UP:
                   upPressed=true;
                   break;
		 case  SDLK_DOWN:
                   downPressed=true;
                   break;
                 case SDLK_LEFT:
                   leftPressed=true;
                   if( whatkey->mod & KMOD_CTRL)
                   {
                   leftPressed =false;
                   ctrl_leftPressed=true;
                   }
                   if( whatkey->mod & KMOD_SHIFT){
                   leftPressed =false;
                   shift_leftPressed=true;
                   }
                   break;
                 case SDLK_RIGHT:
                   rightPressed=true;
                   if( whatkey->mod & KMOD_CTRL)
                   {
                   rightPressed =false;
                   ctrl_rightPressed=true;
                   }
                   if( whatkey->mod & KMOD_SHIFT){
                   rightPressed =false;
                   shift_rightPressed=true;
                   }
                 default:
                   break;
                 case SDLK_p:
                   p_Pressed=true;
                   break; 
                 case SDLK_F12:
                   iplot++;
                   break;
             }
}
コード例 #15
0
ファイル: menu.c プロジェクト: astronautlevel2/Hourglass9
u32 ProcessEntry(MenuEntry* entry)
{
    bool emunand    = entry->param & N_EMUNAND;
    bool nand_force = entry->param & N_FORCEEMU;
    bool warning    = entry->param & N_NANDWRITE;
    
    u32 pad_state;
    u32 res = 0;
    
    // unlock sequence for dangerous features
    if (warning) {
        u32 unlockSequenceEmu[] = { BUTTON_LEFT, BUTTON_RIGHT, BUTTON_DOWN, BUTTON_UP, BUTTON_A };
        u32 unlockSequenceSys[] = { BUTTON_LEFT, BUTTON_UP, BUTTON_RIGHT, BUTTON_UP, BUTTON_A };
        u32 unlockLvlMax = ((emunand) ? sizeof(unlockSequenceEmu) : sizeof(unlockSequenceSys)) / sizeof(u32);
        u32* unlockSequence = (emunand) ? unlockSequenceEmu : unlockSequenceSys;
        u32 unlockLvl = 0;
        #ifdef USE_THEME
        LoadThemeGfx((emunand) ? GFX_DANGER_E : GFX_DANGER_S, false);
        #endif
        DebugClear();
        Debug("You selected \"%s\".", entry->name);
        Debug("This feature writes to the %s.", (emunand) ? "EmuNAND" : "SysNAND");
        Debug("Data will be overwriten, keep backups!");
        Debug("");
        Debug("If you wish to proceed, enter:");
        Debug((emunand) ? "<Left>, <Right>, <Down>, <Up>, <A>" : "<Left>, <Up>, <Right>, <Up>, <A>");
        Debug("");
        Debug("(B to return, START to reboot)");
        while (true) {
            ShowProgress(unlockLvl, unlockLvlMax);
            if (unlockLvl == unlockLvlMax)
                break;
            pad_state = InputWait();
            if (!(pad_state & BUTTON_ANY))
                continue;
            else if (pad_state & unlockSequence[unlockLvl])
                unlockLvl++;
            else if (pad_state & (BUTTON_B | BUTTON_START))
                break;
            else if (unlockLvl == 0 || !(pad_state & unlockSequence[unlockLvl-1]))
                unlockLvl = 0;
        }
        ShowProgress(0, 0);
        if (unlockLvl < unlockLvlMax)
            return pad_state;
    }
    
    // execute this entries function
    #ifdef USE_THEME
    LoadThemeGfx(GFX_PROGRESS, false);
    #endif
    DebugClear();
    res = (SetNand(emunand, nand_force) == 0) ? (*(entry->function))(entry->param) : 1;
    Debug("%s: %s!", entry->name, (res == 0) ? "succeeded" : "failed");
    Debug("");
    Debug("Press B to return, START to reboot.");
    #ifdef USE_THEME
    LoadThemeGfx((res == 0) ? GFX_DONE : GFX_FAILED, false);
    #endif
    while(!((pad_state = InputWait()) & (BUTTON_B | BUTTON_START))) {
        if (pad_state & BUTTON_X) Screenshot(NULL);
        #ifdef LOG_FILE
        else if (pad_state & BUTTON_UP) {
            pad_state = ScrollOutput();
            break;
        }
        #endif
    }
    
    // returns the last known pad_state
    return pad_state;
}
コード例 #16
0
ファイル: menu.c プロジェクト: themrrobert/Decrypt9
u32 ProcessMenu(MenuInfo* info, u32 n_entries_main)
{
    MenuInfo mainMenu;
    MenuInfo* currMenu = &mainMenu;
    MenuInfo* prevMenu[MENU_MAX_DEPTH];
    u32 prevIndex[MENU_MAX_DEPTH];
    u32 index = 0;
    u32 menuLvl = 0;
    
    // build main menu structure from submenus
    memset(&mainMenu, 0x00, sizeof(MenuInfo));
    for (u32 i = 0; i < n_entries_main && i < MENU_MAX_ENTRIES; i++) {
        mainMenu.entries[i].name = info[i].name;
        mainMenu.entries[i].function = NULL;
        mainMenu.entries[i].param = i;
        mainMenu.entries[i].dangerous = 0;
        mainMenu.entries[i].emunand = 0;
    }
    #ifndef BUILD_NAME
    mainMenu.name = "Decrypt9 Main Menu";
    #else
    mainMenu.name = BUILD_NAME;
    #endif
    mainMenu.n_entries = (n_entries_main > MENU_MAX_ENTRIES) ? MENU_MAX_ENTRIES : n_entries_main;
    DrawMenu(&mainMenu, 0, true, false);
    
    // main processing loop
    while (true) {
        bool full_draw = true;
        u32 pad_state = InputWait();
        if ((pad_state & BUTTON_A) && (currMenu->entries[index].function == NULL)) {
            if (menuLvl < MENU_MAX_DEPTH) {
                prevMenu[menuLvl] = currMenu;
                prevIndex[menuLvl] = index;
                menuLvl++;
            }
            currMenu = info + currMenu->entries[index].param;
            index = 0;
        } else if (pad_state & BUTTON_A) {
            pad_state = ProcessEntry(currMenu->entries + index);
        } else if ((pad_state & BUTTON_B) && (menuLvl > 0)) {
            menuLvl--;
            currMenu = prevMenu[menuLvl];
            index = prevIndex[menuLvl];
        } else if (pad_state & BUTTON_DOWN) {
            index = (index == currMenu->n_entries - 1) ? 0 : index + 1;
            full_draw = false;
        } else if (pad_state & BUTTON_UP) {
            index = (index == 0) ? currMenu->n_entries - 1 : index - 1;
            full_draw = false;
        } else if ((pad_state & BUTTON_R1) && (menuLvl == 1)) {
            if (++currMenu - info >= n_entries_main) currMenu = info;
            index = 0;
        } else if ((pad_state & BUTTON_L1) && (menuLvl == 1)) {
            if (--currMenu < info) currMenu = info + n_entries_main - 1;
            index = 0;
        } else if (pad_state & BUTTON_SELECT) {
            pad_state = UnmountSd();
        } else if (pad_state & BUTTON_X) {
            Screenshot(NULL);
        } else {
            full_draw = false;
        }
        if (pad_state & BUTTON_START) {
            break;
        }
        DrawMenu(currMenu, index, full_draw, menuLvl > 0);
    }
    
    return 0;
}
コード例 #17
0
ファイル: RemoteAccessWidget.cpp プロジェクト: edceza/veyon
void RemoteAccessWidget::takeScreenshot()
{
	Screenshot().take( m_computerControlInterface );
}
コード例 #18
0
ファイル: OnMouseCalled.cpp プロジェクト: shengno/Screenshot
/**
 * @brief OnMouse The call back function used to the mouse moving
 * @param Event   The mouse event
 * @param X       The position x of the mouse
 * @param Y       The position y of the mouse
 * @param flag
 * @param Userdata
 *
 *
 * @author sheng
 * @date   2014-08-26
 * @version 0.1
 *
 *
 * @history
 *     <author>       <date>         <version>        <description>
 *      sheng       2014-08-26          0.1         build the module
 *
 *
 */
void OnMouse( int Event, int X, int Y, int flag, void* Userdata)
{
    static int StartedX = -1;
    static int StartedY = -1;
    static int Index = 0;


    // get the Image and the windows name
    UserData* data = static_cast<UserData*>(Userdata);
    cv::Mat* Image = data->OriginImage;
    std::string WindowName = data->WindowName;


    switch (Event)
    {
        case CV_EVENT_LBUTTONDOWN:
            if (StartedX == -1)
            {
                StartedX = X;
                StartedY = Y;
                std::cout << "Left click" << std::endl;
            }
            break;

        case CV_EVENT_LBUTTONUP:
            if (StartedX != -1)
            {
                std::string FileName = PrefixOfFileName + "/" +
                        IntToString(Index) +".jpg";

                // Making the position to be valid
                MakingRectanglePoint(StartedX, StartedY, X, Y);

                // Get the image
                if(!Screenshot(*Image, FileName, StartedX, StartedY, X, Y))
                {
                    std::cout << "Screenshot failed." << std::endl;
                }


                StartedX = -1;
                StartedY = -1;
                Index++;

                // show the orgin image
                cv::imshow(WindowName, *Image);
            }
            break;

        case CV_EVENT_MOUSEMOVE:
            if (StartedX != -1)
            {
                cv::Mat ImageCopy;
                Image->copyTo(ImageCopy);

                // draw rectangle
                DrawRectangle(ImageCopy, StartedX, StartedY, X, Y);

                // show the image
                cv::imshow(WindowName, ImageCopy);

            }
            break;


        default:
            break;
    }
}
コード例 #19
0
ファイル: menu.cpp プロジェクト: kavid/homebrewfilter
static void *
UpdateGUI (void *arg)
{
	int i;

	while(1)
	{
		if(guiHalt)
		{
			LWP_SuspendThread(guithread);
		}
		else
		{
			UpdatePads();
			mainWindow->Draw();

			#ifdef HW_RVL
		//	for(i=3; i >= 0; i--) // so that player 1's cursor appears on top!
		//	{
				if(userInput[0].wpad->ir.valid)
					Menu_DrawImg(userInput[0].wpad->ir.x-48, userInput[0].wpad->ir.y-48,
						96, 96, pointer->GetImage(), userInput[0].wpad->ir.angle, 1, 1, 255);
		//	}
			#endif

			Menu_Render();

		//	for(i=0; i < 4; i++)
				mainWindow->Update(&userInput[0]);

			if(ExitRequested)
			{
				for(i = 0; i < 255; i += 15)
				{
					mainWindow->Draw();
					GXColor Color = (GXColor) {0, 0, 0, i};
					Menu_DrawRectangle(0,0,screenwidth,screenheight,&Color,false,true);
					Menu_Render();
				}

				if (boothomebrew)
				{
					LoadHomebrew(Settings.forwarder_path.c_str());

					string startingAppName = Settings.forwarder_path;

					if((signed)startingAppName.rfind("/") != -1)
						startingAppName.erase(startingAppName.rfind("/"));

					startingAppName.erase(0, startingAppName.rfind("/") +1);

					if(IOS_GetVersion() != GetAppIOS(startingAppName))
						addAppIos(Settings.startingAppName, SelectedIOS());
				}
				if (!goneek2o)
					ExitApp();
			}

			// sd check
			if(Settings.device == "sd1")
				check_sd();

			// usb check
			else if(Settings.device == "usb1")
				check_usb();

			// sd und usb check
			else if(Settings.device == "sd_usb")
			{
				check_sd();
				check_usb();
			}

			else if(Settings.device == "dvd")
				check_dvd();
#ifndef VWII
			else if(Settings.device == "gca")
				check_gca();

			else if(Settings.device == "gcb")
				check_gcb();
#endif
			else if(Settings.device == "all")
			{
				check_sd();
				check_usb();
				check_dvd();
#ifndef VWII
				check_gca();
				check_gcb();
#endif
			}

			// screenshoot
			if(WPAD_ButtonsDown(0) & WPAD_BUTTON_1 && WPAD_ButtonsDown(0) & WPAD_BUTTON_2)
				Screenshot();
		}
	}
	return NULL;
}
コード例 #20
0
ファイル: main.cpp プロジェクト: aquach/facebook-grapher
int main (int argc, char** argv) {
    freopen("error.log", "w", stderr);

    cout << "Enter a graph filename: ";

    char filename[1024];
    cin.getline(filename, 1024);

    // Initialize screen buffer
    SDL_Surface *screen;

    if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER) < 0) {
        fprintf(stderr, "Unable to initialize SDL: %s\n", SDL_GetError());
        exit(1);
    }

    SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
    SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 16);
    SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8);
    SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8);
    SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8);
    SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, 8);

    if (!(screen = SDL_SetVideoMode(c_windowWidth, c_windowHeight, 0, SDL_SWSURFACE | SDL_OPENGL))) {
        fprintf(stderr, "Unable to set video mode: %s\n", SDL_GetError());
        exit(1);
    }

    SDL_WM_SetCaption(c_windowTitle, NULL);

    CFont::Initialize();

    grapher = new CGrapher;

    if (strlen(filename) == 0)
        grapher->LoadFile("graph_alex_quach.txt");
    else
        grapher->LoadFile(filename);


    // Begin render loop
    bool quit = false;
    SDL_Event event;
    CTimer frameTimer;
    frameTimer.Start();

    SDL_WM_GrabInput(SDL_GRAB_ON);
    SDL_ShowCursor(SDL_DISABLE);

    while (!quit) {
        while (SDL_PollEvent(&event)) {
            switch (event.type) {
                case SDL_KEYDOWN:
                case SDL_KEYUP:
                    grapher->HandleKeyboard(event.key);
                    if (event.key.keysym.sym == SDLK_PRINT && event.key.type == SDL_KEYDOWN) {
                        Screenshot(screen, "screen.bmp");
                    }
                break;
                case SDL_MOUSEBUTTONUP:
                case SDL_MOUSEBUTTONDOWN:
                    grapher->HandleMouseButton(event.button);
                break;
                case SDL_MOUSEMOTION:
                    grapher->HandleMouseMove(event.motion);
                break;
                case SDL_QUIT:
                    quit = true;
                break;
            }
        }
        if (!frameTimer.IsWithinTime(c_secondsPerFrame)) {
            uint32 elapsedTicks = frameTimer.GetTicks();
            frameTimer.Start();
            grapher->Update(elapsedTicks);
            grapher->Render();
        }
    }

    SDL_Quit();

    return 0;
}
コード例 #21
0
ファイル: Run.cpp プロジェクト: Fissuras/videoventure
// 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)
					{
						CloseWindow();
						SCREEN_FULLSCREEN = !SCREEN_FULLSCREEN;
						OpenWindow();
					}
					break;
				case SDLK_ESCAPE:
					if (curgamestate == STATE_PLAY)
					{
						if (escape)
							EscapeMenuExit();
						else
							EscapeMenuEnter();
					}
					break;
				case SDLK_PAUSE:
					if (event.key.keysym.mod & KMOD_SHIFT)
					{
						paused = true;
						singlestep = true;
					}
					else
					{
						paused = !paused;
					}

					if (paused)
						Pause();
					else
						Resume();
					break;

				case SDLK_PRINT:
					Screenshot();
					break;
				}
				break;
			case SDL_KEYUP:
				input.OnRelease( Input::TYPE_KEYBOARD, event.key.which, event.key.keysym.sym );
				break;
			case SDL_MOUSEMOTION:
				input.OnAxis( Input::TYPE_MOUSE_AXIS, event.motion.which, 0, float(event.motion.x * 2 - SCREEN_WIDTH) / float(SCREEN_HEIGHT) );
				input.OnAxis( Input::TYPE_MOUSE_AXIS, event.motion.which, 1, float(event.motion.y * 2 - SCREEN_HEIGHT) / float(SCREEN_HEIGHT) );
				input.OnAxis( Input::TYPE_MOUSE_AXIS, event.motion.which, 2, event.motion.xrel / 32.0f );
				input.OnAxis( Input::TYPE_MOUSE_AXIS, event.motion.which, 3, event.motion.yrel / 32.0f );
				break;
			case SDL_MOUSEBUTTONDOWN:
				input.OnPress( Input::TYPE_MOUSE_BUTTON, event.button.which, event.button.button );
				break;
			case SDL_MOUSEBUTTONUP:
				input.OnRelease( Input::TYPE_MOUSE_BUTTON, event.button.which, event.button.button );
				break;
			case SDL_JOYAXISMOTION:
				input.OnAxis( Input::TYPE_JOYSTICK_AXIS, event.jaxis.which, event.jaxis.axis, event.jaxis.value / 32767.0f );
				break;
			case SDL_JOYBUTTONDOWN:
				input.OnPress( Input::TYPE_JOYSTICK_BUTTON, event.jaxis.which, event.jbutton.button );
				break;
			case SDL_JOYBUTTONUP:
				input.OnRelease( Input::TYPE_JOYSTICK_BUTTON, event.jbutton.which, event.jbutton.button );
				break;
			case SDL_QUIT:
				setgamestate = STATE_QUIT;
				break;
			}
		}

		// get loop time in ticks
		unsigned int nextticks = SDL_GetTicks();
		float delta = (nextticks - ticks) / 1000.0f;
		ticks = nextticks;
#elif defined(USE_SFML)
	    sf::Event event;
		while (window.GetEvent(event))
		{
			/* Give the console first dibs on event processing */
			if (OGLCONSOLE_SFMLEvent(&event))
				continue;

			// Some code for stopping application on close or when escape is pressed...
			switch (event.Type)
			{
			case sf::Event::Resized:
				glViewport(0, 0, event.Size.Width, event.Size.Height);
				break;
			case sf::Event::KeyPressed:
				input.OnPress( Input::TYPE_KEYBOARD, 0, event.Key.Code );
				switch(event.Key.Code)
				{
				case sf::Key::F4:
					if (event.Key.Alt)
						setgamestate = STATE_QUIT;
					break;
				case sf::Key::Return:
					if (event.Key.Alt)
					{
						CloseWindow();
						SCREEN_FULLSCREEN = !SCREEN_FULLSCREEN;
						OpenWindow();
					}
					break;
				case sf::Key::Escape:
					if (curgamestate == STATE_PLAY)
					{
						if (escape)
							EscapeMenuExit();
						else
							EscapeMenuEnter();
					}
					break;
				case sf::Key::Pause:
					if (event.Key.Shift)
					{
						paused = true;
						singlestep = true;
					}
					else
					{
						paused = !paused;
					}

					if (paused)
						Pause();
					else
						Resume();
					break;
				}
				break;
			case sf::Event::KeyReleased:
				input.OnRelease( Input::TYPE_KEYBOARD, 0, event.Key.Code );
				break;
			case sf::Event::MouseMoved:
				input.OnAxis( Input::TYPE_MOUSE_AXIS, 0, 0, float(int(event.MouseMove.X) * 2 - SCREEN_WIDTH) / float(SCREEN_HEIGHT) );
				input.OnAxis( Input::TYPE_MOUSE_AXIS, 0, 1, float(int(event.MouseMove.Y) * 2 - SCREEN_HEIGHT) / float(SCREEN_HEIGHT) );
				break;
			case sf::Event::MouseButtonPressed:
				input.OnPress( Input::TYPE_MOUSE_BUTTON, 0, event.MouseButton.Button );
				break;
			case sf::Event::MouseButtonReleased:
				input.OnRelease( Input::TYPE_MOUSE_BUTTON, 0, event.MouseButton.Button );
				break;
			case sf::Event::JoyMoved:
				input.OnAxis( Input::TYPE_JOYSTICK_AXIS, event.JoyMove.JoystickId, event.JoyMove.Axis, event.JoyMove.Position / 100.0f );
				break;
			case sf::Event::JoyButtonPressed:
				input.OnPress( Input::TYPE_JOYSTICK_BUTTON, event.JoyButton.JoystickId, event.JoyButton.Button );
				break;
			case sf::Event::JoyButtonReleased:
				input.OnRelease( Input::TYPE_JOYSTICK_BUTTON, event.JoyButton.JoystickId, event.JoyButton.Button );
				break;
			case sf::Event::Closed:
				setgamestate = STATE_QUIT;
				break;
			}
		}

		// get loop time in ticks
		float delta = timer.GetElapsedTime();
		timer.Reset();
		//ticks += delta;
#elif defined(USE_GLFW)
		if (glfwGetJoystickParam(0, GLFW_PRESENT))
		{
			// get joystick axis positions
			int axiscount = glfwGetJoystickParam(0, GLFW_AXES);
			float *axis = static_cast<float *>(_alloca(axiscount * sizeof(float)));
			axiscount = glfwGetJoystickPos(0, axis, axiscount);
			for (int i = 0; i < axiscount; ++i)
				input.OnAxis(Input::TYPE_JOYSTICK_AXIS, 0, i, axis[i]);

			// get joystick button states
			int buttoncount = glfwGetJoystickParam(0, GLFW_BUTTONS);
			unsigned char *button = static_cast<unsigned char *>(_alloca(buttoncount * sizeof(unsigned char)));
			buttoncount = glfwGetJoystickButtons(0, button, buttoncount);
			for (int i = 0; i < buttoncount; ++i)
				input.OnAxis(Input::TYPE_JOYSTICK_BUTTON, 0, i, button[i]);
		}
		
		double nexttime = glfwGetTime();
		float delta = float(nexttime - prevtime);
		prevtime = nexttime;
#endif

		// clamp ticks to something sensible
		// (while debugging, for example)
		if (delta > 0.1f)
			delta = 0.1f;

		// frame time and turns
		if (singlestep)
		{
			// advance 1/60th of a second
			frame_time = TIME_SCALE / 60.0f;
			frame_turns = frame_time * sim_rate;
		}
		else if (paused || escape)
		{
			// freeze time
			frame_time = 0.0f;
			frame_turns = 0.0f;
		}
		else if (FIXED_STEP)
		{
			// advance one simulation step
			frame_time = TIME_SCALE * sim_step;
			frame_turns = TIME_SCALE;
		}
		else
		{
			// advance by frame time
			frame_time = delta * TIME_SCALE;
			frame_turns = frame_time * sim_rate;
		}

		// turns per motion-blur step
		float step_turns = std::min(TIME_SCALE * MOTIONBLUR_TIME * sim_rate, 1.0f) / MOTIONBLUR_STEPS;

		// advance to beginning of motion blur steps
		sim_fraction += frame_turns;
		sim_fraction -= MOTIONBLUR_STEPS * step_turns;

		// for each motion-blur step
		for (int blur = 0; blur < MOTIONBLUR_STEPS; ++blur)
		{
			// clear the screen
			glClear(
				GL_COLOR_BUFFER_BIT
#ifdef ENABLE_DEPTH_TEST
				| GL_DEPTH_BUFFER_BIT
#endif
				);

			// set projection
			glMatrixMode( GL_PROJECTION );
			glLoadIdentity();
			glFrustum( -0.5*VIEW_SIZE*SCREEN_WIDTH/SCREEN_HEIGHT, 0.5*VIEW_SIZE*SCREEN_WIDTH/SCREEN_HEIGHT, 0.5f*VIEW_SIZE, -0.5f*VIEW_SIZE, 256.0f*1.0f, 256.0f*5.0f );

			// set base modelview matrix
			glMatrixMode( GL_MODELVIEW );
			glLoadIdentity();
			glTranslatef( 0.0f, 0.0f, -256.0f );
			glScalef( -1.0f, -1.0f, -1.0f );

			// advance the sim timer
			sim_fraction += step_turns;

			if (escape)
			{
				input.Update();
				input.Step();
			}
			// while simulation turns to run...
			else while ((singlestep || !paused) && sim_fraction >= 1.0f)
			{
				// deduct a turn
				sim_fraction -= 1.0f;
				
				// advance the turn counter
				++sim_turn;

				// save original fraction
				float save_fraction = sim_fraction;

				// switch fraction to simulation mode
				sim_fraction = 0.0f;

#ifdef COLLECT_DEBUG_DRAW
				// collect any debug draw
				glNewList(debugdraw, GL_COMPILE);
#endif

				// seed the random number generator
				Random::Seed(0x92D68CA2 ^ sim_turn);
				(void)Random::Int();

				// update database
				Database::Update();

				if (curgamestate == STATE_PLAY)
				{
					if (playback)
					{
						// quit if out of turns
						if (!inputlognext)
						{
							setgamestate = STATE_SHELL;
							break;
						}

						// get the next turn value
						int turn = -1;
						inputlognext->QueryIntAttribute("turn", &turn);

						// if the turn matches the simulation turn...
						if ((unsigned int)turn == sim_turn)
						{
							// update the control values
							input.Playback(inputlognext);

							// go to the next entry
							inputlognext = inputlognext->NextSiblingElement();
						}
					}
					else if (record)
					{
						// save original input values
						float prev[Input::NUM_LOGICAL];
						memcpy(prev, input.output, sizeof(prev));

						// update input values
						input.Update();

						// if any controls have changed...
						bool changed = false;
						for (int i = 0; i < Input::NUM_LOGICAL; ++i)
						{
							if (input.output[i] != prev[i])
							{
								changed = true; break;
							}
						}
						if (changed)
						{
							// create an input turn entry
							TiXmlElement item( "input" );
							item.SetAttribute( "turn", sim_turn );

							// add changed control values
							input.Record(&item, prev);

							// add the new input entry
							inputlogroot->InsertEndChild(item);
						}
					}
					else
					{
						// update input values
						input.Update();
					}
				}

				// do any pending turn actions
				DoTurn();


				// CONTROL PHASE

#ifdef GET_PERFORMANCE_DETAILS
				control_timer.Start();
#endif

				// control all entities
				Controller::ControlAll(sim_step);

#ifdef GET_PERFORMANCE_DETAILS
				control_timer.Stop();

				simulate_timer.Start();
#endif

				// SIMULATION PHASE
				// (generate forces)
				Simulatable::SimulateAll(sim_step);

#ifdef GET_PERFORMANCE_DETAILS
				simulate_timer.Stop();

				collide_timer.Start();
#endif

				// COLLISION PHASE
				// (apply forces and update positions)
				Collidable::CollideAll(sim_step);

#ifdef GET_PERFORMANCE_DETAILS
				collide_timer.Stop();

				update_timer.Start();
#endif

				// UPDATE PHASE
				// (use updated positions)
				Updatable::UpdateAll(sim_step);

#ifdef GET_PERFORMANCE_DETAILS
				update_timer.Stop();
#endif

				// step inputs for next turn
				input.Step();

#ifdef COLLECT_DEBUG_DRAW
				// finish the draw list
				glEndList();
#endif
				
				// restore original fraction
				sim_fraction = save_fraction;
			}

			// clear single-step
			singlestep = false;

			// seed the random number generator
			FloatInt floatint;
			floatint.f = sim_fraction;
			Random::Seed(0x92D68CA2 ^ sim_turn ^ floatint.u);
			(void)Random::Int();

#ifdef PRINT_SIMULATION_TIMER
			DebugPrint("delta=%f ticks=%d sim_t=%f\n", delta, ticks, sim_fraction);
#endif

#ifdef GET_PERFORMANCE_DETAILS
			render_timer.Start();
#endif

			// RENDERING PHASE

			// push camera transform
			glPushMatrix();

			// get interpolated track position
			Vector2 viewpos(Lerp(camerapos[0], camerapos[1], sim_fraction));

			// set view position
			glTranslatef( -viewpos.x, -viewpos.y, 0 );

			// calculate view area
			AlignedBox2 view;
			view.min.x = viewpos.x - VIEW_SIZE * 0.5f * SCREEN_WIDTH / SCREEN_HEIGHT;
			view.max.x = viewpos.x + VIEW_SIZE * 0.5f * SCREEN_WIDTH / SCREEN_HEIGHT;
			view.min.y = viewpos.y - VIEW_SIZE * 0.5f;
			view.max.y = viewpos.y + VIEW_SIZE * 0.5f;

			// render all entities
			// (send interpolation ratio and offset from simulation time)
			Renderable::RenderAll(view);

			// reset camera transform
			glPopMatrix();

			// if performing motion blur...
			if (MOTIONBLUR_STEPS > 1)
			{
				// accumulate the image
				glAccum(blur ? GL_ACCUM : GL_LOAD, 1.0f / float(MOTIONBLUR_STEPS));
			}

#ifdef GET_PERFORMANCE_DETAILS
			render_timer.Stop();
#endif
		}

#ifdef GET_PERFORMANCE_DETAILS
		render_timer.Start();
#endif

		// if performing motion blur...
		if (MOTIONBLUR_STEPS > 1)
		{
			// return the accumulated image
			glAccum(GL_RETURN, 1);
		}

		// switch blend mode
		glPushAttrib(GL_COLOR_BUFFER_BIT | GL_TEXTURE_BIT);
		glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );

#ifdef GET_PERFORMANCE_DETAILS
		render_timer.Stop();

		overlay_timer.Start();
#endif

#ifdef COLLECT_DEBUG_DRAW
		if (DEBUG_DRAW)
		{
			// push camera transform
			glPushMatrix();

			// get interpolated track position
			Vector2 viewpos(Lerp(camerapos[0], camerapos[1], sim_fraction));

			// set camera to track position
			glTranslatef( -viewpos.x, -viewpos.y, 0 );

			// debug draw
			glCallList(debugdraw);

			// pop camera transform
			glPopMatrix();
		}
#endif

		// push projection transform
		glMatrixMode(GL_PROJECTION);
		glLoadIdentity();
		glOrtho(0, 640, 480, 0, -1, 1);

		// use 640x480 screen coordinates
		glMatrixMode(GL_MODELVIEW);
		glLoadIdentity();

		// render all overlays
		Overlay::RenderAll();

#ifdef GET_PERFORMANCE_DETAILS
		overlay_timer.Stop();

		if (!OPENGL_SWAPCONTROL)
		{
			display_timer.Start();

			// wait for rendering to finish
			glFinish();

			display_timer.Stop();
		}

#ifdef DRAW_PERFORMANCE_DETAILS
		if (PROFILER_OUTPUTSCREEN)
		{
			struct BandInfo
			{
				const LONGLONG * time;
				float r;
				float g;
				float b;
				float a;
			};
			static BandInfo band_info[] =
			{
				{ control_timer.mHistory,	1.0f,	0.0f,	0.0f,	0.5f },
				{ simulate_timer.mHistory,	1.0f,	1.0f,	0.0f,	0.5f },
				{ collide_timer.mHistory,	0.0f,	1.0f,	0.0f,	0.5f },
				{ update_timer.mHistory,	0.0f,	0.5f,	1.0f,	0.5f },
				{ render_timer.mHistory,	1.0f,	0.0f,	1.0f,	0.5f },
				{ overlay_timer.mHistory,	1.0f,	0.5f,	0.0f,	0.5f },
				{ display_timer.mHistory,	0.5f,	0.5f,	0.5f,	0.5f },
			};

			// generate y samples
			float sample_y[SDL_arraysize(band_info)+1][PerfTimer::NUM_SAMPLES];
			int index = PerfTimer::mIndex;
			for (int i = 0; i < PerfTimer::NUM_SAMPLES; ++i)
			{
				float y = 480.0f;
				sample_y[0][i] = y;
				for (int band = 0; band < SDL_arraysize(band_info); ++band)
				{
					y -= 60.0f * 480.0f * band_info[band].time[index] / PerfTimer::mFrequency;
					sample_y[band+1][i] = y;
				}
				if (++index >= PerfTimer::NUM_SAMPLES)
					index = 0;
			}

			glBegin(GL_QUADS);
			for (int band = 0; band < SDL_arraysize(band_info); ++band)
			{
				glColor4fv(&band_info[band].r);
				float x = 0;
				float dx = 640.0f / PerfTimer::NUM_SAMPLES;
				for (int i = 0; i < PerfTimer::NUM_SAMPLES; i++)
				{
					glVertex3f(x, sample_y[band][i], 0);
					glVertex3f(x+dx, sample_y[band][i], 0);
					glVertex3f(x+dx, sample_y[band+1][i], 0);
					glVertex3f(x, sample_y[band+1][i], 0);
					x += dx;
				}
			}
			glEnd();
		}
#endif

#ifdef PRINT_PERFORMANCE_DETAILS
		if (PROFILER_OUTPUTPRINT)
		{
			DebugPrint("C=%d S=%d P=%d U=%d R=%d O=%d D=%d\n",
				control_timer.Microseconds(),
				simulate_timer.Microseconds(),
				collide_timer.Microseconds(),
				update_timer.Microseconds(),
				render_timer.Microseconds(),
				overlay_timer.Microseconds(),
				display_timer.Microseconds());
		}
#endif

		// update frame timer
		total_timer.Stamp();

#if defined(PRINT_PERFORMANCE_FRAMERATE) || defined(DRAW_PERFORMANCE_FRAMERATE)
		if (FRAMERATE_OUTPUTSCREEN || FRAMERATE_OUTPUTPRINT)
		{
			// compute minimum, maximum, and average frame times over the past second
			LONGLONG total_min = LLONG_MAX;
			LONGLONG total_max = LLONG_MIN;
			LONGLONG total_sum = 0;
			LONGLONG total_samples = 0;
			int i = PerfTimer::mIndex;
			do
			{
				total_min = std::min(total_min, total_timer.mHistory[i]);
				total_max = std::max(total_max, total_timer.mHistory[i]);
				total_sum += total_timer.mHistory[i];
				++total_samples;
				i = (i > 0) ? i - 1 : PerfTimer::NUM_SAMPLES - 1;
			}
			while (total_sum <= PerfTimer::mFrequency && i != PerfTimer::mIndex && total_samples != PerfTimer::mCount);
			total_sum /= total_samples;

			// compute frame rates
			double rate_max = (double)PerfTimer::mFrequency / total_min;
			double rate_avg = (double)PerfTimer::mFrequency / total_sum;
			double rate_min = (double)PerfTimer::mFrequency / total_max;

#if defined(DRAW_PERFORMANCE_FRAMERATE)
			if (FRAMERATE_OUTPUTSCREEN)
			{
				// draw frame rate indicator
				glEnable(GL_TEXTURE_2D);
				glBindTexture(GL_TEXTURE_2D, OGLCONSOLE_glFontHandle);

				glBegin(GL_QUADS);

				char fps[16];
				sprintf(fps, "%.2f max", rate_max);
				glColor4f(0.5f, 0.5f, 0.5f, 1.0f);
				OGLCONSOLE_DrawString(fps, 640 - 16 - 8 * strlen(fps), 16, 8, -8, 0);
				sprintf(fps, "%.2f avg", rate_avg);
				glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
				OGLCONSOLE_DrawString(fps, 640 - 16 - 8 * strlen(fps), 24, 8, -8, 0);
				sprintf(fps, "%.2f min", rate_min);
				glColor4f(0.5f, 0.5f, 0.5f, 1.0f);
				OGLCONSOLE_DrawString(fps, 640 - 16 - 8 * strlen(fps), 32, 8, -8, 0);

				glEnd();

				glDisable(GL_TEXTURE_2D);
			}
#endif

#if defined(PRINT_PERFORMANCE_FRAMERATE)
			if (FRAMERATE_OUTPUTPRINT)
			{
				DebugPrint("%.2f<%.2f<%.2f\n", rate_min, rate_avg, rate_max);
			}
#endif
		}
#endif
#endif

		// reset camera transform
		glMatrixMode(GL_PROJECTION);
		glPopMatrix();
		glMatrixMode(GL_MODELVIEW);
		glPopMatrix();

		// restore blend mode
		glPopAttrib();

		/* Render our console */
		OGLCONSOLE_Draw();

		// show the back buffer
		Platform::Present();

#if 0
#ifdef GET_PERFORMANCE_DETAILS
		if (OPENGL_SWAPCONTROL)
#endif
		// wait for rendering to finish
		glFinish();
#endif

		// clear device reset flag
		wasreset = false;
	}
	while( setgamestate == curgamestate );

	if (record)
	{
		// save input log
		inputlog.SaveFile();
	}
}
コード例 #22
0
ファイル: alertlog.cpp プロジェクト: bilenadam/aqtlow
void AlertLog::on_pushButton_Print_clicked()
{
    emit Screenshot(QPixmap::grabWidget(this));
}
コード例 #23
0
ファイル: scene.c プロジェクト: ZakaryWu/iteIndoor
/*************************************************
  Function:		SceneRun
  Description: 	
  Input:		
  Output:		��
  Return:		��
  Others:
*************************************************/
int SceneRun(void)
{
    SDL_Event ev;
    int delay, frames, lastx, lasty, ret;
    uint32_t tick, dblclk, lasttick, mouseDownTick, feetdogtick;
	bool mouseDownDeal = true;
	bool mouseDownResult = false;
	Uint32 pre_type = 0;
	
    /* Watch keystrokes */
    dblclk = frames = lasttick = lastx = lasty = mouseDownTick = feetdogtick = 0;
	
    for (;;)
    {
        bool result = false;
	
        if (CheckQuitValue())
        {
        	debug_log(" CheckQuitValue: %d \n", CheckQuitValue());
            break;
        }

        ProcessCommand();       

        tick = SDL_GetTicks();

		// add by chenbh 2016-10-17 feet dog 2s pertimes		
		if (tick - feetdogtick >= 1500)
		{
			feetdogtick = tick;
			feetdog_task();
		}
		
    #ifdef FPS_ENABLE
        frames++;
        if (tick - lasttick >= 1000)
        {
            printf("fps: %d\n", frames);
            frames = 0;
            lasttick = tick;
        }
    #endif // FPS_ENABLE

        while (SDL_PollEvent(&ev))
        {
            switch (ev.type)
            {            
            	case SDL_KEYDOWN:
					{
						// add by chenbh
						if (ScreenSaverIsScreenSaving() || SceneGetCleanScreenFlg())
						{
							ScreenSaverRefresh();
							g_LcdFuncNoDeal = true;
							break;
						}
						
		                ScreenSaverRefresh();
		                result = ituSceneUpdate(&theScene, ITU_EVENT_KEYDOWN, ev.key.keysym.sym, 0, 0);
						printf("ev.key.keysym.sym: %x\n", ev.key.keysym.sym);
		                switch (ev.key.keysym.sym)
						{						
						    case TK_CENTER:
						        {						            
									TouchManagerKey();
						            result = true;									
						        }
						        break;

						    case TK_MONITOR:
						        {
									TouchMonitorKey();
									result = true;	
									//ScreenOn();
								}						        
						        break;

						    case TK_LOCK:
								{
									#ifdef CFG_SCREENSHOT_ENABLE					
			                        	Screenshot(g_ScreenSurf);
									#else
									{
										Command cmd;
										memset(&cmd, 0, sizeof(Command));

										cmd.id = CMD_KEY_DOWN;
										sprintf(cmd.strarg1, "%d", (ev.key.keysym.sym - TK_LOCK));
										mq_send(g_CommandQueue, (const char*)&cmd, sizeof (Command), 0);
										result = true;
									}
			                		#endif 									
						    	}
								break;

						    case TK_TALK:
						        {
									Command cmd;
									memset(&cmd, 0, sizeof(Command));

									cmd.id = CMD_KEY_DOWN;
									sprintf(cmd.strarg1, "%d", (ev.key.keysym.sym - TK_LOCK));
									mq_send(g_CommandQueue, (const char*)&cmd, sizeof (Command), 0);
									result = true;
								}						        
						        break;

							default:
								break;

						}
						
		                if (result && !ScreenIsOff())
		                    sys_key_beep();		                  
		        }
                break;

            case SDL_KEYUP:
				{
					if (g_LcdFuncNoDeal == false)
					{
                		result = ituSceneUpdate(&theScene, ITU_EVENT_KEYUP, ev.key.keysym.sym, 0, 0);
					}
					g_LcdFuncNoDeal = false;
            	}
                break;

            case SDL_MOUSEMOTION:
				{
					// add by chenbh
					if (ScreenSaverIsScreenSaving())
					{
						ScreenSaverRefresh();
					}
					else
					{
	                	ScreenSaverRefresh();
	                	result = ituSceneUpdate(&theScene, ITU_EVENT_MOUSEMOVE, ev.button.button, ev.button.x, ev.button.y);
					}
					g_LcdFuncNoDeal = false;
            	}
                break;

            case SDL_MOUSEBUTTONDOWN:
				{
					// add by chenbh
					if (ScreenSaverIsScreenSaving())
					{
						ScreenSaverRefresh();
						g_LcdFuncNoDeal = true;
						break;
					}
					
	                ScreenSaverRefresh();
	                {
	                    mouseDownTick = SDL_GetTicks();
	                #ifdef DOUBLE_KEY_ENABLE
	                    if (mouseDownTick - dblclk <= 200)
	                    {
	                        result = ituSceneUpdate(&theScene, ITU_EVENT_MOUSEDOUBLECLICK, ev.button.button, ev.button.x, ev.button.y);
	                        dblclk = 0;
	                    }
	                    else
	                #endif // DOUBLE_KEY_ENABLE					
	                    {
	                        result = ituSceneUpdate(&theScene, ITU_EVENT_MOUSEDOWN, ev.button.button, ev.button.x, ev.button.y);
	                        dblclk = mouseDownTick;
	                        lastx = ev.button.x;
	                        lasty = ev.button.y;
							
	                        if (result && !ScreenIsOff())
	                            sys_key_beep();
	                           
	                    }					
	                }
            	}
                break;

            case SDL_MOUSEBUTTONUP:
				{
					if (g_LcdFuncNoDeal == false)
					{
						if (SDL_GetTicks() - dblclk <= 200)
		                {
		                    int xdiff = abs(ev.button.x - lastx);
		                    int ydiff = abs(ev.button.y - lasty);

		                    if (xdiff >= GESTURE_THRESHOLD && xdiff > ydiff)
		                    {
		                        if (ev.button.x > lastx)
		                        {
		                            printf("mouse: slide to right\n");
		                            result |= ituSceneUpdate(&theScene, ITU_EVENT_TOUCHSLIDERIGHT, 1, ev.button.x, ev.button.y);
		                        }
		                        else
		                        {
		                            printf("mouse: slide to left\n");
		                            result |= ituSceneUpdate(&theScene, ITU_EVENT_TOUCHSLIDELEFT, 1, ev.button.x, ev.button.y);
		                        }
		                    }
		                    else if (ydiff >= GESTURE_THRESHOLD)
		                    {
		                        if (ev.button.y > lasty)
		                        {
		                            printf("mouse: slide to down\n");
		                            result |= ituSceneUpdate(&theScene, ITU_EVENT_TOUCHSLIDEDOWN, 1, ev.button.x, ev.button.y);
		                        }
		                        else
		                        {
		                            printf("mouse: slide to up\n");
		                            result |= ituSceneUpdate(&theScene, ITU_EVENT_TOUCHSLIDEUP, 1, ev.button.x, ev.button.y);
		                        }
		                    }
		                }
		                result |= ituSceneUpdate(&theScene, ITU_EVENT_MOUSEUP, ev.button.button, ev.button.x, ev.button.y);
		                mouseDownTick = 0;
					}					
	               	g_LcdFuncNoDeal = false;
            	}
                break;

            case SDL_FINGERMOTION:
				{
					// add by chenbh
					if (ScreenSaverIsScreenSaving())
					{
						ScreenSaverRefresh();
					}
					else
					{
						ScreenSaverRefresh();
						#ifdef USE_ANDROID_MODE
						if (mouseDownDeal == false && pre_type == SDL_FINGERDOWN)
			            {
			                printf("ANDROID press: %d %d\n", lastx, lasty);
							result = ituSceneUpdate(&theScene, ITU_EVENT_MOUSEDOWN, 1, lastx, lasty);
							mouseDownDeal = true;
							usleep(20*1000);
			            }
						#endif
	                	//printf("touch: move %d, %d\n", ev.tfinger.x, ev.tfinger.y);
	                	result = ituSceneUpdate(&theScene, ITU_EVENT_MOUSEMOVE, 1, ev.tfinger.x, ev.tfinger.y);
					}	
					g_LcdFuncNoDeal = false;
					pre_type = ev.type;
            	}
                break;

            case SDL_FINGERDOWN:
				{
					// add by chenbh
					if (ScreenSaverIsScreenSaving())
					{
						ScreenSaverRefresh();
						g_LcdFuncNoDeal = true;
						break;
					}

					#ifdef USE_ANDROID_MODE
					ScreenSaverRefresh();
	                //printf("touch: down %d, %d\n", ev.tfinger.x, ev.tfinger.y);
                    mouseDownTick = SDL_GetTicks();
			 		dblclk = mouseDownTick;
                    lastx = ev.tfinger.x;
                    lasty = ev.tfinger.y;
					pre_type = ev.type;
					mouseDownDeal = false;
					mouseDownResult = false;
					SceneSetProgressBarCustomData();
					#else
	                ScreenSaverRefresh();
	                //printf("touch: down %d, %d\n", ev.tfinger.x, ev.tfinger.y);
                    mouseDownTick = SDL_GetTicks();
                	#ifdef DOUBLE_KEY_ENABLE
	                    if (mouseDownTick - dblclk <= 200)
	                    {
	                        printf("double touch!\n");
	                        result = ituSceneUpdate(&theScene, ITU_EVENT_MOUSEDOUBLECLICK, 1, ev.tfinger.x, ev.tfinger.y);
	                        dblclk = mouseDownTick = 0;
	                    }
	                    else
                	#endif // DOUBLE_KEY_ENABLE
	                    {
	                        result = ituSceneUpdate(&theScene, ITU_EVENT_MOUSEDOWN, 1, ev.tfinger.x, ev.tfinger.y);
	                        dblclk = mouseDownTick;
	                        lastx = ev.tfinger.x;
	                        lasty = ev.tfinger.y;
							
	                        if (result && !ScreenIsOff())
	                            sys_key_beep();	                            
	                    }
					
					#endif
            	}
                break;

            case SDL_FINGERUP:
				{
					if (g_LcdFuncNoDeal == false)
					{
		                //printf("touch: up %d, %d\n", ev.tfinger.x, ev.tfinger.y);
		                if (SDL_GetTicks() - dblclk <= 300)
		                {
		                    int xdiff = abs(ev.tfinger.x - lastx);
		                    int ydiff = abs(ev.tfinger.y - lasty);

		                    if (xdiff >= GESTURE_THRESHOLD && xdiff > ydiff)
		                    {
		                        if (ev.tfinger.x > lastx)
		                        {
		                            printf("touch: slide to right %d %d\n", ev.tfinger.x, ev.tfinger.y);
		                            result |= ituSceneUpdate(&theScene, ITU_EVENT_TOUCHSLIDERIGHT, 1, ev.tfinger.x, ev.tfinger.y);
		                        }
		                        else
		                        {
		                            printf("touch: slide to left %d %d\n", ev.button.x, ev.button.y);
		                            result |= ituSceneUpdate(&theScene, ITU_EVENT_TOUCHSLIDELEFT, 1, ev.tfinger.x, ev.tfinger.y);
		                        }
		                    }
		                    else if (ydiff >= GESTURE_THRESHOLD)
		                    {
		                        if (ev.tfinger.y > lasty)
		                        {
		                            printf("touch: slide to down %d %d\n", ev.tfinger.x, ev.tfinger.y);
		                            result |= ituSceneUpdate(&theScene, ITU_EVENT_TOUCHSLIDEDOWN, 1, ev.tfinger.x, ev.tfinger.y);
		                        }
		                        else
		                        {
		                            printf("touch: slide to up %d %d\n", ev.tfinger.x, ev.tfinger.y);
		                            result |= ituSceneUpdate(&theScene, ITU_EVENT_TOUCHSLIDEUP, 1, ev.tfinger.x, ev.tfinger.y);
		                        }
		                    }
		                }

						#ifdef USE_ANDROID_MODE
						if (pre_type == SDL_FINGERDOWN)
			            {
			            	if (mouseDownDeal == false)
			            	{
								mouseDownResult = ituSceneUpdate(&theScene, ITU_EVENT_MOUSEDOWN, 1, lastx, lasty);
								result |= mouseDownResult;
								mouseDownDeal = true;
			            	}
							
							if (!ScreenIsOff() && mouseDownResult)
							{
								//added by WuZ in 2016-10-13
								if (!mainLayer)
								{
									mainLayer = ituSceneFindWidget(&theScene, "mainLayer");
									assert(mainLayer);
								}
								
								if (ituWidgetIsVisible(mainLayer))
								{
									if (!mainSOSOffButton)
									{
										mainSOSOffButton = ituSceneFindWidget(&theScene, "mainSOSOffButton");
										assert(mainSOSOffButton);
									}
									if (((lastx > mainSOSOffButton->bg.icon.widget.rect.x && lastx < (mainSOSOffButton->bg.icon.widget.rect.x + mainSOSOffButton->bg.icon.widget.rect.width)) &&
										(lasty > mainSOSOffButton->bg.icon.widget.rect.y && lasty < (mainSOSOffButton->bg.icon.widget.rect.y + mainSOSOffButton->bg.icon.widget.rect.height))))
									{
										
									}
									else
									{
										sys_key_beep();
									}
								}
								else
								{
									sys_key_beep();
								}
							}
							
							result |= ituSceneUpdate(&theScene, ITU_EVENT_TIMER, 0, 0, 0);
					        if (result)
					        {
					            ituSceneDraw(&theScene, g_ScreenSurf);
					            ituFlip(g_ScreenSurf);
					        }								
			            }
						#endif

		                result |= ituSceneUpdate(&theScene, ITU_EVENT_MOUSEUP, 1, ev.tfinger.x, ev.tfinger.y);						
		                mouseDownTick = 0;
					}
					g_LcdFuncNoDeal = false;
					pre_type = ev.type;
            	}
                break;
            }
        }

		if (SYS_MEDIA_NONE != sys_get_media_state())
            ScreenSaverRefresh();
		
        if (!ScreenIsOff())
        {
        	#ifdef USE_ANDROID_MODE
			if (mouseDownTick > 0 && (SDL_GetTicks() - mouseDownTick >= ANDROID_PRESS_DELAY) && 
				pre_type == SDL_FINGERDOWN && mouseDownDeal == false)
            {
                //printf("ANDROID press: %d %d\n", lastx, lasty);
				result = ituSceneUpdate(&theScene, ITU_EVENT_MOUSEDOWN, 1, lastx, lasty);
				mouseDownDeal = true;
				mouseDownResult = result;
            }
			#endif
			
            if (mouseDownTick > 0 && (SDL_GetTicks() - mouseDownTick >= MOUSEDOWN_LONGPRESS_DELAY) && 
				pre_type == SDL_FINGERDOWN)
            {
                printf("long press: %d %d\n", lastx, lasty);
                result |= ituSceneUpdate(&theScene, ITU_EVENT_MOUSELONGPRESS, 255, lastx, lasty);
                mouseDownTick = 0;
            }
            result |= ituSceneUpdate(&theScene, ITU_EVENT_TIMER, 0, 0, 0);

			//printf("aaaaaaaaaaaaaaaaaa %d\n", result);
        	#ifndef _WIN32
            if (result)
        	#endif
            {
                ituSceneDraw(&theScene, g_ScreenSurf);
                ituFlip(g_ScreenSurf);
            }

			if (SYS_MEDIA_NONE == sys_get_media_state())
			{
				ret = ScreenSaverCheck();
	            if (ret == -1)
	            {
	               ScreenProtect();
	            }
				else if (ret == -2)
				{
					ScreenOff();
				}
			}
        }
		else
		{
			result |= ituSceneUpdate(&theScene, ITU_EVENT_TIMER, 0, 0, 0);
			//printf("aaaaaaaaaaaaaaaaaa %d\n", result);
        	#ifndef _WIN32
            if (result)
        	#endif
            {
                ituSceneDraw(&theScene, g_ScreenSurf);
                ituFlip(g_ScreenSurf);
            }
		}
		
		// add by chenbh 
		if ((sys_get_media_state() == SYS_MEDIA_INTERCOM) ||
			(sys_get_media_state() == SYS_MEDIA_MONITOR) ||
			(sys_get_media_state() == SYS_MEDIA_LEAVEWORD_PLAY) ||
			ScreenIsOff())
		{
			delay = MS_PER_FRAME_EXT - (SDL_GetTicks() - tick);
		}
		else
		{
        	delay = MS_PER_FRAME - (SDL_GetTicks() - tick);
		}
        //printf("scene loop delay=%d\n", delay);
        if (delay > 0)
            SDL_Delay(delay);
        else
            sched_yield();
    }

    return g_QuitValue;
}
コード例 #24
0
ファイル: menu.c プロジェクト: PlayerAAA/Decrypt9WIP_ES
u32 ProcessEntry(MenuEntry* entry)
{
    bool emunand    = entry->param & N_EMUNAND;
    bool nand_force = entry->param & N_FORCEEMU;
    bool nand_write = entry->param & N_NANDWRITE;
    bool a9lh_write = (entry->param & N_A9LHWRITE) && ((*(u32*) 0x101401C0) == 0);

    u32 pad_state;
    u32 res = 0;

    // unlock sequence for dangerous features
    if (nand_write || a9lh_write) {
        const u32 unlockSequences[3][5] = {
            { BUTTON_LEFT , BUTTON_RIGHT, BUTTON_DOWN , BUTTON_UP   , BUTTON_A }, // EmuNAND
            { BUTTON_LEFT , BUTTON_UP   , BUTTON_RIGHT, BUTTON_UP   , BUTTON_A }, // SysNAND
            { BUTTON_RIGHT, BUTTON_DOWN , BUTTON_LEFT , BUTTON_DOWN , BUTTON_A }  // A9LH
        };
        const u32 unlockLvlMax = 5;
        u32* unlockSequence = (u32*) &(unlockSequences[(emunand) ? 0 : (a9lh_write) ? 2 : 1]);
        u32 warnColor = (emunand) ? COLOR_YELLOW : COLOR_RED;
        u32 unlockLvl = 0;
        #ifdef USE_THEME
        LoadThemeGfx((emunand) ? GFX_DANGER_E : GFX_DANGER_S, false);
        #endif
        DebugClear();
        Debug("Has seleccionado [%s].", entry->name);
        Debug("");
        if (!a9lh_write) {
            DebugColor(warnColor, "Esta operacion escribira datos en %s.", (emunand) ? "EmuNAND" : "SysNAND");
            DebugColor(warnColor, "¡Esto puede sobreescribir datos importantes!");
        } else {
            DebugColor(warnColor, "ESTO SOBREESCRIBIRA LA INSTALACION!!!");
            DebugColor(warnColor, "DE A9LH EN TU SYSNAND!!!");
        }
        Debug("");
        Debug("Si decides continuar, presiona los siguientes botones:");
        Debug((emunand) ? "<Izquierda>, <Derecha>, <Abajo>, <Arriba>, <A>" : (a9lh_write) ? "<Derecha>, <Abajo>, <Izquierda>, <Abajo>, <A>" :
            "<Izquierda>, <Arriba>, <Derecha>, <Arriba>, <A>");
        Debug("");
        Debug("(B para volver, START para reiniciar)");
        while (true) {
            ShowProgress(unlockLvl, unlockLvlMax);
            if (unlockLvl == unlockLvlMax)
                break;
            pad_state = InputWait();
            if (!(pad_state & BUTTON_ANY))
                continue;
            else if (pad_state & unlockSequence[unlockLvl])
                unlockLvl++;
            else if (pad_state & (BUTTON_B | BUTTON_START))
                break;
            else if (unlockLvl == 0 || !(pad_state & unlockSequence[unlockLvl-1]))
                unlockLvl = 0;
        }
        ShowProgress(0, 0);
        if (unlockLvl < unlockLvlMax)
            return pad_state;
    }

    // execute this entries function
    #ifdef USE_THEME
    LoadThemeGfx(GFX_PROGRESS, false);
    #endif
    DebugClear();
    Debug("Seleccionado: [%s]", entry->name);
    res = (SetNand(emunand, nand_force) == 0) ? (*(entry->function))(entry->param) : 1;
    DebugColor((res == 0) ? COLOR_GREEN : COLOR_RED, "%s: %s!", entry->name, (res == 0) ? "succeeded" : "failed");
    Debug("");
    Debug("B para volver, START para reiniciar.");
    #ifdef USE_THEME
    LoadThemeGfx((res == 0) ? GFX_DONE : GFX_FAILED, false);
    #endif
    while(!((pad_state = InputWait()) & (BUTTON_B | BUTTON_START))) {
        if (pad_state & BUTTON_X) Screenshot(NULL);
        #ifdef LOG_FILE
        else if (pad_state & BUTTON_UP) {
            pad_state = ScrollOutput();
            break;
        }
        #endif
    }

    // returns the last known pad_state
    return pad_state;
}
コード例 #25
0
ファイル: rominfo.cpp プロジェクト: MythTV/mythtv
void RomInfo::SaveToDatabase()
{
    MSqlQuery query(MSqlQuery::InitCon());

    bool inserting = false;

    if (m_id == 0)
        inserting = true;

    if (inserting)
    {
        LOG(VB_GENERAL, LOG_INFO, LOC + QString("Adding %1 - %2").arg(Rompath())
            .arg(Romname()));

        query.prepare("INSERT INTO gamemetadata "
                      "(system, romname, gamename, genre, year, gametype, "
                      "rompath, country, crc_value, diskcount, display, plot, "
                      "publisher, version, fanart, boxart, screenshot) "
                      "VALUES (:SYSTEM, :ROMNAME, :GAMENAME, :GENRE, :YEAR, "
                      ":GAMETYPE, :ROMPATH, :COUNTRY, :CRC32, '1', '1', :PLOT, "
                      ":PUBLISHER, :VERSION, :FANART, :BOXART, :SCREENSHOT)");

        query.bindValue(":SYSTEM",System());
        query.bindValue(":ROMNAME",Romname());
        query.bindValue(":GAMENAME",Gamename());
        query.bindValue(":GENRE",Genre());
        query.bindValue(":YEAR",Year());
        query.bindValue(":GAMETYPE",GameType());
        query.bindValue(":ROMPATH",Rompath());
        query.bindValue(":COUNTRY",Country());
        query.bindValue(":CRC32", QString());
        query.bindValue(":PLOT", Plot());
        query.bindValue(":PUBLISHER", Publisher());
        query.bindValue(":VERSION", Version());
        query.bindValue(":FANART", Fanart());
        query.bindValue(":BOXART", Boxart());
        query.bindValue(":SCREENSHOT", Screenshot());
    }
    else
    {
        query.prepare("UPDATE gamemetadata "
                      "SET version = 'CUSTOM', "
                      "    gamename = :GAMENAME,"
                      "    genre = :GENRE,"
                      "    year = :YEAR,"
                      "    country = :COUNTRY,"
                      "    plot = :PLOT,"
                      "    publisher = :PUBLISHER,"
                      "    favorite = :FAVORITE,"
                      "    screenshot = :SCREENSHOT,"
                      "    fanart = :FANART,"
                      "    boxart = :BOXART, "
                      "    inetref = :INETREF "
                      "WHERE gametype = :GAMETYPE AND "
                      "      romname  = :ROMNAME");
        query.bindValue(":GAMENAME", Gamename());
        query.bindValue(":GENRE", Genre());
        query.bindValue(":YEAR", Year());
        query.bindValue(":COUNTRY", Country());
        query.bindValue(":PLOT", Plot());
        query.bindValue(":PUBLISHER", Publisher());
        query.bindValue(":FAVORITE", Favorite());
        query.bindValue(":SCREENSHOT", Screenshot());
        query.bindValue(":FANART", Fanart());
        query.bindValue(":BOXART", Boxart());
        query.bindValue(":INETREF", Inetref());
        query.bindValue(":GAMETYPE", GameType());
        query.bindValue(":ROMNAME", Romname());
    }

    if (!query.exec())
    {
        MythDB::DBError("RomInfo::SaveToDatabase", query);
        return;
    }
}
コード例 #26
0
ファイル: menu.c プロジェクト: alex34567/Decrypt9
u32 ProcessMenu(MenuInfo* info, u32 n_entries_main)
{
    MenuInfo* currMenu;
    MenuInfo* prevMenu[MENU_MAX_DEPTH];
    u32 prevIndex[MENU_MAX_DEPTH];
    u32 menuLvlMin;
    u32 menuLvl;
    u32 index = 0;
    u32 result = MENU_EXIT_REBOOT;
    
    #ifndef USE_THEME
    MenuInfo mainMenu;
    if (n_entries_main > 1) {
        // build main menu structure from submenus
        if (n_entries_main > MENU_MAX_ENTRIES) // limit number of entries
            n_entries_main = MENU_MAX_ENTRIES;
        memset(&mainMenu, 0x00, sizeof(MenuInfo));
        for (u32 i = 0; i < n_entries_main; i++) {
            mainMenu.entries[i].name = info[i].name;
            mainMenu.entries[i].function = NULL;
            mainMenu.entries[i].param = i;
        }
        mainMenu.n_entries = n_entries_main;
        #ifndef BUILD_NAME
        mainMenu.name = "Decrypt9 Main Menu";
        #else
        mainMenu.name = BUILD_NAME;
        #endif
        currMenu = &mainMenu;
        menuLvlMin = 0;
    } else {
        currMenu = info;
        menuLvlMin = 1;
    }
    DrawMenu(currMenu, 0, true, false);
    #else
    currMenu = info;
    menuLvlMin = 1;
    LoadThemeGfxLogo();
    LoadThemeGfxMenu(0);
    #endif
    menuLvl = menuLvlMin;
    
    // main processing loop
    while (true) {
        bool full_draw = true;
        u32 pad_state = InputWait();
        if ((pad_state & BUTTON_A) && (currMenu->entries[index].function == NULL)) {
            if (menuLvl < MENU_MAX_DEPTH) {
                prevMenu[menuLvl] = currMenu;
                prevIndex[menuLvl] = index;
                menuLvl++;
            }
            currMenu = info + currMenu->entries[index].param;
            index = 0;
        } else if (pad_state & BUTTON_A) {
            pad_state = ProcessEntry(currMenu->entries + index);
        } else if ((pad_state & BUTTON_B) && (menuLvl > menuLvlMin)) {
            menuLvl--;
            currMenu = prevMenu[menuLvl];
            index = prevIndex[menuLvl];
        } else if (pad_state & BUTTON_DOWN) {
            index = (index == currMenu->n_entries - 1) ? 0 : index + 1;
            full_draw = false;
        } else if (pad_state & BUTTON_UP) {
            index = (index == 0) ? currMenu->n_entries - 1 : index - 1;
            full_draw = false;
        } else if ((pad_state & BUTTON_R1) && (menuLvl == 1)) {
            if (++currMenu - info >= n_entries_main) currMenu = info;
            index = 0;
        } else if ((pad_state & BUTTON_L1) && (menuLvl == 1)) {
            if (--currMenu < info) currMenu = info + n_entries_main - 1;
            index = 0;
        } else if (pad_state & BUTTON_SELECT) {
            pad_state = UnmountSd();
        } else if (pad_state & BUTTON_X) {
            (pad_state & (BUTTON_LEFT | BUTTON_RIGHT)) ?
                BatchScreenshot(info, pad_state & BUTTON_RIGHT) : Screenshot(NULL);
        } else {
            full_draw = false;
        }
        if (pad_state & BUTTON_START) {
            result = (pad_state & BUTTON_LEFT) ? MENU_EXIT_POWEROFF : MENU_EXIT_REBOOT;
            break;
        }
        #ifndef USE_THEME
        DrawMenu(currMenu, index, full_draw, menuLvl > menuLvlMin);
        #else
        if (full_draw) LoadThemeGfxLogo();
        LoadThemeGfxMenu(((currMenu - info) * 100) + index);
        #endif
    }
    
    return result;
}
コード例 #27
0
ファイル: rominfo.cpp プロジェクト: pierrchen/mythtv
void RomInfo::UpdateDatabase()
{
    MSqlQuery query(MSqlQuery::InitCon());
    query.prepare("SELECT gamename,genre,year,country,plot,publisher, "
                  "favorite,screenshot,fanart,boxart,inetref "
                  "FROM gamemetadata "
                  "WHERE gametype = :GAMETYPE "
                  "AND romname = :ROMNAME");

    query.bindValue(":GAMETYPE", GameType());
    query.bindValue(":ROMNAME", Romname());

    if (!query.exec())
    {
        MythDB::DBError("RomInfo::UpdateDatabase", query);
        return;
    }

    if (!query.next())
        return;

    QString t_gamename  = query.value(0).toString();
    QString t_genre     = query.value(1).toString();
    QString t_year      = query.value(2).toString();
    QString t_country   = query.value(3).toString();
    QString t_plot      = query.value(4).toString();
    QString t_publisher = query.value(5).toString();
    bool    t_favourite = query.value(6).toBool();
    QString t_screenshot = query.value(7).toString();
    QString t_fanart = query.value(8).toString();
    QString t_boxart = query.value(9).toString();
    QString t_inetref = query.value(10).toString();

    if ((t_gamename  != Gamename())  || (t_genre     != Genre())   ||
            (t_year      != Year())      || (t_country   != Country()) ||
            (t_plot      != Plot())      || (t_publisher != Publisher()) ||
            (t_favourite != Favorite())  || (t_screenshot != Screenshot()) ||
            (t_fanart    != Fanart())    || (t_boxart    != Boxart()) ||
            (t_inetref   != Inetref()))
    {
        query.prepare("UPDATE gamemetadata "
                      "SET version = 'CUSTOM', "
                      "    gamename = :GAMENAME,"
                      "    genre = :GENRE,"
                      "    year = :YEAR,"
                      "    country = :COUNTRY,"
                      "    plot = :PLOT,"
                      "    publisher = :PUBLISHER,"
                      "    favorite = :FAVORITE,"
                      "    screenshot = :SCREENSHOT,"
                      "    fanart = :FANART,"
                      "    boxart = :BOXART, "
                      "    inetref = :INETREF "
                      "WHERE gametype = :GAMETYPE AND "
                      "      romname  = :ROMNAME");
        query.bindValue(":GAMENAME", Gamename());
        query.bindValue(":GENRE", Genre());
        query.bindValue(":YEAR", Year());
        query.bindValue(":COUNTRY", Country());
        query.bindValue(":PLOT", Plot());
        query.bindValue(":PUBLISHER", Publisher());
        query.bindValue(":FAVORITE", Favorite());
        query.bindValue(":SCREENSHOT", Screenshot());
        query.bindValue(":FANART", Fanart());
        query.bindValue(":BOXART", Boxart());
        query.bindValue(":INETREF", Inetref());
        query.bindValue(":GAMETYPE", GameType());
        query.bindValue(":ROMNAME", Romname());

        if (!query.exec())
        {
            MythDB::DBError("RomInfo::UpdateDatabase", query);
            return;
        }
    }
}