Exemple #1
0
static void config_screen_process_key(struct nc_scr *scr, int key)
{
	struct config_screen *screen = config_screen_from_scr(scr);
	bool handled;

	handled = widgetset_process_key(screen->widgetset, key);

	if (!handled) {
		switch (key) {
		case 'x':
		case 27: /* esc */
			screen->exit = true;
			break;
		case 'h':
			screen->show_help = true;
			break;
		}
	}

	if (screen->exit) {
		screen->on_exit(screen->cui);

	} else if (screen->show_help) {
		screen->show_help = false;
		screen->need_redraw = true;
		cui_show_help(screen->cui, _("System Configuration"),
				&config_help_text);

	} else if (handled && !screen->show_subset) {
		pad_refresh(screen);
	}
}
Exemple #2
0
void boot_editor_update(struct boot_editor *boot_editor,
		const struct system_info *sysinfo)
{
	int height;

	if (boot_editor->cui->current != boot_editor_scr(boot_editor)) {
		boot_editor->need_update = true;
		return;
	}

	widgetset_unpost(boot_editor->widgetset);

	height = pad_height(sysinfo ? sysinfo->n_blockdevs : 0);
	if (getmaxy(boot_editor->pad) < height) {
		delwin(boot_editor->pad);
		boot_editor->pad = newpad(height, COLS);
		widgetset_set_windows(boot_editor->widgetset,
				boot_editor->scr.main_ncw,
				boot_editor->pad);
	}

	boot_editor_populate_device_select(boot_editor, sysinfo);

	boot_editor_layout_widgets(boot_editor);

	widgetset_post(boot_editor->widgetset);

	pad_refresh(boot_editor);
}
Exemple #3
0
void sub_periodic(void)
{
	if(!main_pad->wd) return;
	if(sub_current->flags & PERIODIC) {
	dolog("%s: doing plugin (and perhaps builtin) draw\n", __FUNCTION__);
		pad_draw();
	}
	dolog("%s: doing refresh\n", __FUNCTION__);
	pad_refresh();
}
Exemple #4
0
static void key_action(int key)
{
	int i, size;
	if(signal_sent) {
	    print_help();
	    signal_sent = 0;
	}
	/* 
	 * First, try to process the key by object (subwindow, menu) that
	 * could be on top.
	 */
	size = sizeof key_funct/sizeof(int (*)(int));
	for(i = 0; i < size; i++)
		if(key_funct[i](key)) goto SKIP; 
	
	if(current->keys(key)) goto SKIP;
	/* cursor movement */
	size = sizeof key_handlers/sizeof(struct key_handler);
	for(i = 0; i < size; i++) 
		if(key_handlers[i].c == key) {
			key_handlers[i].handler(current);
			if(can_draw()) pad_draw();
			goto SKIP;
		}
	switch(key) {
	case 'c':
		full_cmd ^= 1;
		current->redraw();
		break;
	case '/':
		m_search();
		break;			
	case KBD_F1:
		help();
		break;
	case KBD_ESC:
	case 'q':
		curses_end();
		exit(0);
	default: return;
	}
SKIP:
	dolog("%s: doing refresh\n", __FUNCTION__);
	wnoutrefresh(main_win);
	wnoutrefresh(info_win.wd);
	pad_refresh();
	menu_refresh();
	box_refresh();
	info_refresh();
	doupdate();
}
Exemple #5
0
/* 
 * Needed for SIGWINCH handling.
 */
void pad_resize(void)
{
	set_size(main_pad);
	if(!main_pad->wd) return;
//	wresize(border_wd, main_pad->size_y-PAD_Y+3, main_pad->size_x-PAD_X+3);
	wresize(border_wd, BORDER_ROWS+1, BORDER_COLS+1);
	werase(border_wd);
	box(border_wd, ACS_VLINE, ACS_HLINE);
	print_titles();
	wbkgd(main_pad->wd, COLOR_PAIR(8));
	werase(main_pad->wd);
	pad_draw();
	pad_refresh();
}	
Exemple #6
0
static void boot_editor_widget_focus(struct nc_widget *widget, void *arg)
{
	struct boot_editor *boot_editor = arg;
	int w_y, s_max;

	w_y = widget_y(widget) + widget_focus_y(widget);
	s_max = getmaxy(boot_editor->scr.sub_ncw) - 1;

	if (w_y < boot_editor->scroll_y)
		boot_editor->scroll_y = w_y;

	else if (w_y + boot_editor->scroll_y + 1 > s_max)
		boot_editor->scroll_y = 1 + w_y - s_max;

	else
		return;

	pad_refresh(boot_editor);
}
Exemple #7
0
static void boot_editor_process_key(struct nc_scr *scr, int key)
{
	struct boot_editor *boot_editor = boot_editor_from_scr(scr);
	struct pmenu_item *item;
	struct pb_boot_data *bd;
	bool handled;

	handled = widgetset_process_key(boot_editor->widgetset, key);
	if (handled)
		pad_refresh(boot_editor);

	else if (key == 'x' || key == 27)
		boot_editor->state = STATE_CANCEL;

	else if (key == 'h')
		boot_editor->state = STATE_HELP;

	item = NULL;
	bd = NULL;

	switch (boot_editor->state) {
	case STATE_SAVE:
		item = boot_editor->item;
		bd = boot_editor_prepare_data(boot_editor);
		if (!bd) {
			/* Incomplete entry */
			boot_editor->state = STATE_EDIT;
			break;
		}
		/* fall through */
	case STATE_CANCEL:
		boot_editor->on_exit(boot_editor->cui, item, bd);
		break;
	case STATE_HELP:
		boot_editor->state = STATE_EDIT;
		boot_editor->need_redraw = true;
		cui_show_help(boot_editor->cui, _("Boot Option Editor"),
				&boot_editor_help_text);
		break;
	default:
		break;
	}
}
Exemple #8
0
static int boot_editor_post(struct nc_scr *scr)
{
	struct boot_editor *boot_editor = boot_editor_from_scr(scr);

	if (boot_editor->need_update) {
		boot_editor_update(boot_editor, boot_editor->cui->sysinfo);
		boot_editor->need_update = false;
	} else {
		widgetset_post(boot_editor->widgetset);
	}

	nc_scr_frame_draw(scr);
	if (boot_editor->need_redraw) {
		redrawwin(scr->main_ncw);
		boot_editor->need_redraw = false;
	}
	wrefresh(boot_editor->scr.main_ncw);
	pad_refresh(boot_editor);
	return 0;
}
Exemple #9
0
void ioreg_write(byte r, byte b)
{
	if (!hw.cgb)
	{
		switch (r)
		{
		case RI_VBK:
		case RI_BCPS:
		case RI_OCPS:
		case RI_BCPD:
		case RI_OCPD:
		case RI_SVBK:
		case RI_KEY1:
		case RI_HDMA1:
		case RI_HDMA2:
		case RI_HDMA3:
		case RI_HDMA4:
		case RI_HDMA5:
			return;
		}
	}
	
	switch(r)
	{
	case RI_TIMA:
	case RI_TMA:
	case RI_TAC:
	case RI_SCY:
	case RI_SCX:
	case RI_WY:
	case RI_WX:
		REG(r) = b;
		break;
	case RI_BGP:
		if (R_BGP == b) break;
		pal_write_dmg(0, 0, b);
		pal_write_dmg(8, 1, b);
		R_BGP = b;
		break;
	case RI_OBP0:
		if (R_OBP0 == b) break;
		pal_write_dmg(64, 2, b);
		R_OBP0 = b;
		break;
	case RI_OBP1:
		if (R_OBP1 == b) break;
		pal_write_dmg(72, 3, b);
		R_OBP1 = b;
		break;
	case RI_IF:
	case RI_IE:
		REG(r) = b & 0x1F;
		break;
	case RI_P1:
		REG(r) = b;
		pad_refresh();
		break;
	case RI_SC:
		/* FIXME - this is a hack for stupid roms that probe serial */
		if ((b & 0x81) == 0x81)
		{
			R_SB = 0xff;
			hw_interrupt(IF_SERIAL, IF_SERIAL);
			hw_interrupt(0, IF_SERIAL);
		}
		R_SC = b; /* & 0x7f; */
		break;
	case RI_DIV:
		REG(r) = 0;
		break;
	case RI_LCDC:
		lcdc_change(b);
		break;
	case RI_STAT:
		stat_write(b);
		break;
	case RI_LYC:
		REG(r) = b;
		stat_trigger();
		break;
	case RI_VBK:
		REG(r) = b | 0xFE;
		mem_updatemap();
		break;
	case RI_BCPS:
		R_BCPS = b & 0xBF;
		R_BCPD = lcd.pal[b & 0x3F];
		break;
	case RI_OCPS:
		R_OCPS = b & 0xBF;
		R_OCPD = lcd.pal[64 + (b & 0x3F)];
		break;
	case RI_BCPD:
		R_BCPD = b;
		pal_write(R_BCPS & 0x3F, b);
		if (R_BCPS & 0x80) R_BCPS = (R_BCPS+1) & 0xBF;
		break;
	case RI_OCPD:
		R_OCPD = b;
		pal_write(64 + (R_OCPS & 0x3F), b);
		if (R_OCPS & 0x80) R_OCPS = (R_OCPS+1) & 0xBF;
		break;
	case RI_SVBK:
		REG(r) = b & 0x07;
		mem_updatemap();
		break;
	case RI_DMA:
		hw_dma(b);
		break;
	case RI_KEY1:
		REG(r) = (REG(r) & 0x80) | (b & 0x01);
		break;
	case RI_HDMA1:
		REG(r) = b;
		break;
	case RI_HDMA2:
		REG(r) = b & 0xF0;
		break;
	case RI_HDMA3:
		REG(r) = b & 0x1F;
		break;
	case RI_HDMA4:
		REG(r) = b & 0xF0;
		break;
	case RI_HDMA5:
		hw_hdma_cmd(b);
		break;
	}
	switch (r)
	{
	case RI_BGP:
	case RI_OBP0:
	case RI_OBP1:
		/* printf("palette reg %02X write %02X at LY=%02X\n", r, b, R_LY); */
	case RI_HDMA1:
	case RI_HDMA2:
	case RI_HDMA3:
	case RI_HDMA4:
	case RI_HDMA5:
		/* printf("HDMA %d: %02X\n", r - RI_HDMA1 + 1, b); */
		break;
	}
	/* printf("reg %02X => %02X (%02X)\n", r, REG(r), b); */
}
Exemple #10
0
void gbcHandleInput(unsigned int keys)
{
	hw.pad = keys;
    pad_refresh();
}