void game::on_event(const SDL_Event& event) { if (event.type == SDL_MOUSEBUTTONDOWN && event.button.button == SDL_BUTTON_LEFT) { if (in_board()) { if (m_active_special) { const int digit = m_board.get_digit(m_selx, m_sely); // Attempt a special move if (m_active_special->m_type == special_move::nuke && digit == -1) { clear_3x3(m_selx, m_sely); m_active_special->m_type = special_move::none; } if (m_active_special->m_type == special_move::clear_digit && digit != -1) { for (int y = 0; y != 9; ++y) for (int x = 0; x != 9; ++x) if (m_board.get_digit(x, y) == digit) m_board.set_digit(x, y, -1); m_active_special->m_type = special_move::none; } m_active_special = 0; } else { do_digit(); } if (m_queue.digits_left() == 0 || m_board.get_filled() == 0) end_game(); } for (int i = 0; i != 3; ++i) if (m_specials[i].m_button.click(event.button) && m_specials[i].m_type != special_move::none) do_special(m_specials[i]); if (m_quit.click(event.button)) m_sm.set_next_state("title"); } if (event.type == SDL_MOUSEMOTION) { // Check if the cursor is inside the board int mx = event.motion.x; int my = event.motion.y; if (mx >= board_xpos && mx < (board_xpos + 32 * 9) && my >= board_ypos && my < (board_ypos + 32 * 9)) { m_selx = (mx - board_xpos) / 32; m_sely = (my - board_ypos) / 32; } else { m_selx = -1; m_sely = -1; } m_quit.motion(event.motion); for (int i = 0; i != 3; ++i) if (m_specials[i].m_type != special_move::none) m_specials[i].m_button.motion(event.motion); } }
static ide_startstop_t start_request (ide_drive_t *drive, struct request *rq) { ide_startstop_t startstop; BUG_ON(!blk_rq_started(rq)); #ifdef DEBUG printk("%s: start_request: current=0x%08lx\n", drive->hwif->name, (unsigned long) rq); #endif /* bail early if we've exceeded max_failures */ if (drive->max_failures && (drive->failures > drive->max_failures)) { rq->cmd_flags |= REQ_FAILED; goto kill_rq; } if (blk_pm_request(rq)) ide_check_pm_state(drive, rq); SELECT_DRIVE(drive); if (ide_wait_stat(&startstop, drive, drive->ready_stat, ATA_BUSY | ATA_DRQ, WAIT_READY)) { printk(KERN_ERR "%s: drive not ready for command\n", drive->name); return startstop; } if (!drive->special.all) { struct ide_driver *drv; /* * We reset the drive so we need to issue a SETFEATURES. * Do it _after_ do_special() restored device parameters. */ if (drive->current_speed == 0xff) ide_config_drive_speed(drive, drive->desired_speed); if (rq->cmd_type == REQ_TYPE_ATA_TASKFILE) return execute_drive_cmd(drive, rq); else if (blk_pm_request(rq)) { struct request_pm_state *pm = rq->data; #ifdef DEBUG_PM printk("%s: start_power_step(step: %d)\n", drive->name, pm->pm_step); #endif startstop = ide_start_power_step(drive, rq); if (startstop == ide_stopped && pm->pm_step == IDE_PM_COMPLETED) ide_complete_pm_request(drive, rq); return startstop; } else if (!rq->rq_disk && blk_special_request(rq)) /* * TODO: Once all ULDs have been modified to * check for specific op codes rather than * blindly accepting any special request, the * check for ->rq_disk above may be replaced * by a more suitable mechanism or even * dropped entirely. */ return ide_special_rq(drive, rq); drv = *(struct ide_driver **)rq->rq_disk->private_data; return drv->do_request(drive, rq, rq->sector); } return do_special(drive); kill_rq: ide_kill_rq(drive, rq); return ide_stopped; }