Ejemplo n.º 1
0
inline bool ui_menu::exclusive_input_pressed(int key, int repeat)
{
	if (menu_event.iptkey == IPT_INVALID && ui_input_pressed_repeat(machine(), key, repeat))
	{
		menu_event.iptkey = key;
		return true;
	}
	return false;
}
Ejemplo n.º 2
0
static void palette_handle_keys(running_machine &machine, ui_gfx_state *state)
{
	int rowcount, screencount;
	int total;

	/* handle zoom (minus,plus) */
	if (ui_input_pressed(machine, IPT_UI_ZOOM_OUT))
		state->palette.count /= 2;
	if (ui_input_pressed(machine, IPT_UI_ZOOM_IN))
		state->palette.count *= 2;

	/* clamp within range */
	if (state->palette.count <= 4)
		state->palette.count = 4;
	if (state->palette.count > 64)
		state->palette.count = 64;

	/* handle colormap selection (open bracket,close bracket) */
	if (ui_input_pressed(machine, IPT_UI_PREV_GROUP))
		state->palette.which--;
	if (ui_input_pressed(machine, IPT_UI_NEXT_GROUP))
		state->palette.which++;

	/* clamp within range */
	if (state->palette.which < 0)
		state->palette.which = 0;
	if (state->palette.which > (int)(machine.colortable != NULL))
		state->palette.which = (int)(machine.colortable != NULL);

	/* cache some info in locals */
	total = state->palette.which ? colortable_palette_get_size(machine.colortable) : machine.total_colors();

	/* determine number of entries per row and total */
	rowcount = state->palette.count;
	screencount = rowcount * rowcount;

	/* handle keyboard navigation */
	if (ui_input_pressed_repeat(machine, IPT_UI_UP, 4))
		state->palette.offset -= rowcount;
	if (ui_input_pressed_repeat(machine, IPT_UI_DOWN, 4))
		state->palette.offset += rowcount;
	if (ui_input_pressed_repeat(machine, IPT_UI_PAGE_UP, 6))
		state->palette.offset -= screencount;
	if (ui_input_pressed_repeat(machine, IPT_UI_PAGE_DOWN, 6))
		state->palette.offset += screencount;
	if (ui_input_pressed_repeat(machine, IPT_UI_HOME, 4))
		state->palette.offset = 0;
	if (ui_input_pressed_repeat(machine, IPT_UI_END, 4))
		state->palette.offset = total;

	/* clamp within range */
	if (state->palette.offset + screencount > ((total + rowcount - 1) / rowcount) * rowcount)
		state->palette.offset = ((total + rowcount - 1) / rowcount) * rowcount - screencount;
	if (state->palette.offset < 0)
		state->palette.offset = 0;
}
Ejemplo n.º 3
0
static void tilemap_handle_keys(running_machine &machine, ui_gfx_state *state, int viswidth, int visheight)
{
	ui_gfx_state oldstate = *state;
	UINT32 mapwidth, mapheight;
	int step;

	/* handle tilemap selection (open bracket,close bracket) */
	if (ui_input_pressed(machine, IPT_UI_PREV_GROUP))
		state->tilemap.which--;
	if (ui_input_pressed(machine, IPT_UI_NEXT_GROUP))
		state->tilemap.which++;

	/* clamp within range */
	if (state->tilemap.which < 0)
		state->tilemap.which = 0;
	if (state->tilemap.which >= machine.tilemap().count())
		state->tilemap.which = machine.tilemap().count() - 1;

	/* cache some info in locals */
	tilemap_t *tilemap = machine.tilemap().find(state->tilemap.which);
	mapwidth = tilemap->width();
	mapheight = tilemap->height();

	/* handle zoom (minus,plus) */
	if (ui_input_pressed(machine, IPT_UI_ZOOM_OUT))
		state->tilemap.zoom--;
	if (ui_input_pressed(machine, IPT_UI_ZOOM_IN))
		state->tilemap.zoom++;

	/* clamp within range */
	if (state->tilemap.zoom < 0)
		state->tilemap.zoom = 0;
	if (state->tilemap.zoom > 8)
		state->tilemap.zoom = 8;
	if (state->tilemap.zoom != oldstate.tilemap.zoom)
	{
		if (state->tilemap.zoom != 0)
			popmessage("Zoom = %d", state->tilemap.zoom);
		else
			popmessage("Zoom Auto");
	}

	/* handle rotation (R) */
	if (ui_input_pressed(machine, IPT_UI_ROTATE))
		state->tilemap.rotate = orientation_add(ROT90, state->tilemap.rotate);

	/* handle navigation (up,down,left,right) */
	step = 8;
	if (machine.input().code_pressed(KEYCODE_LSHIFT)) step = 1;
	if (machine.input().code_pressed(KEYCODE_LCONTROL)) step = 64;
	if (ui_input_pressed_repeat(machine, IPT_UI_UP, 4))
		state->tilemap.yoffs -= step;
	if (ui_input_pressed_repeat(machine, IPT_UI_DOWN, 4))
		state->tilemap.yoffs += step;
	if (ui_input_pressed_repeat(machine, IPT_UI_LEFT, 6))
		state->tilemap.xoffs -= step;
	if (ui_input_pressed_repeat(machine, IPT_UI_RIGHT, 6))
		state->tilemap.xoffs += step;

	/* clamp within range */
	while (state->tilemap.xoffs < 0)
		state->tilemap.xoffs += mapwidth;
	while (state->tilemap.xoffs >= mapwidth)
		state->tilemap.xoffs -= mapwidth;
	while (state->tilemap.yoffs < 0)
		state->tilemap.yoffs += mapheight;
	while (state->tilemap.yoffs >= mapheight)
		state->tilemap.yoffs -= mapheight;

	/* if something changed, we need to force an update to the bitmap */
	if (state->tilemap.which != oldstate.tilemap.which ||
		state->tilemap.xoffs != oldstate.tilemap.xoffs ||
		state->tilemap.yoffs != oldstate.tilemap.yoffs ||
		state->tilemap.rotate != oldstate.tilemap.rotate)
	{
		state->bitmap_dirty = TRUE;
	}
}
Ejemplo n.º 4
0
static void gfxset_handle_keys(running_machine &machine, ui_gfx_state *state, int xcells, int ycells)
{
	ui_gfx_state oldstate = *state;
	gfx_element *gfx;
	int temp, set;

	/* handle gfxset selection (open bracket,close bracket) */
	if (ui_input_pressed(machine, IPT_UI_PREV_GROUP))
	{
		for (temp = state->gfxset.set - 1; temp >= 0; temp--)
			if (machine.gfx[temp] != NULL)
				break;
		if (temp >= 0)
			state->gfxset.set = temp;
	}
	if (ui_input_pressed(machine, IPT_UI_NEXT_GROUP))
	{
		for (temp = state->gfxset.set + 1; temp < MAX_GFX_ELEMENTS; temp++)
			if (machine.gfx[temp] != NULL)
				break;
		if (temp < MAX_GFX_ELEMENTS)
			state->gfxset.set = temp;
	}

	/* cache some info in locals */
	set = state->gfxset.set;
	gfx = machine.gfx[set];

	/* handle cells per line (minus,plus) */
	if (ui_input_pressed(machine, IPT_UI_ZOOM_OUT))
		state->gfxset.count[set] = xcells - 1;
	if (ui_input_pressed(machine, IPT_UI_ZOOM_IN))
		state->gfxset.count[set] = xcells + 1;

	/* clamp within range */
	if (state->gfxset.count[set] < 2)
		state->gfxset.count[set] = 2;
	if (state->gfxset.count[set] > 32)
		state->gfxset.count[set] = 32;

	/* handle rotation (R) */
	if (ui_input_pressed(machine, IPT_UI_ROTATE))
		state->gfxset.rotate[set] = orientation_add(ROT90, state->gfxset.rotate[set]);

	/* handle navigation within the cells (up,down,pgup,pgdown) */
	if (ui_input_pressed_repeat(machine, IPT_UI_UP, 4))
		state->gfxset.offset[set] -= xcells;
	if (ui_input_pressed_repeat(machine, IPT_UI_DOWN, 4))
		state->gfxset.offset[set] += xcells;
	if (ui_input_pressed_repeat(machine, IPT_UI_PAGE_UP, 6))
		state->gfxset.offset[set] -= xcells * ycells;
	if (ui_input_pressed_repeat(machine, IPT_UI_PAGE_DOWN, 6))
		state->gfxset.offset[set] += xcells * ycells;
	if (ui_input_pressed_repeat(machine, IPT_UI_HOME, 4))
		state->gfxset.offset[set] = 0;
	if (ui_input_pressed_repeat(machine, IPT_UI_END, 4))
		state->gfxset.offset[set] = gfx->elements();

	/* clamp within range */
	if (state->gfxset.offset[set] + xcells * ycells > ((gfx->elements() + xcells - 1) / xcells) * xcells)
		state->gfxset.offset[set] = ((gfx->elements() + xcells - 1) / xcells) * xcells - xcells * ycells;
	if (state->gfxset.offset[set] < 0)
		state->gfxset.offset[set] = 0;

	/* handle color selection (left,right) */
	if (ui_input_pressed_repeat(machine, IPT_UI_LEFT, 4))
		state->gfxset.color[set] -= 1;
	if (ui_input_pressed_repeat(machine, IPT_UI_RIGHT, 4))
		state->gfxset.color[set] += 1;

	/* clamp within range */
	if (state->gfxset.color[set] >= (int)gfx->colors())
		state->gfxset.color[set] = gfx->colors() - 1;
	if (state->gfxset.color[set] < 0)
		state->gfxset.color[set] = 0;

	/* if something changed, we need to force an update to the bitmap */
	if (state->gfxset.set != oldstate.gfxset.set ||
		state->gfxset.offset[set] != oldstate.gfxset.offset[set] ||
		state->gfxset.rotate[set] != oldstate.gfxset.rotate[set] ||
		state->gfxset.color[set] != oldstate.gfxset.color[set] ||
		state->gfxset.count[set] != oldstate.gfxset.count[set])
	{
		state->bitmap_dirty = TRUE;
	}
}
Ejemplo n.º 5
0
void ui_menu::handle_keys(UINT32 flags)
{
	int ignorepause = ui_menu::stack_has_special_main_menu();
	int ignoreright;
	int ignoreleft;
	int code;

	// bail if no items
	if (numitems == 0)
		return;

	// if we hit select, return TRUE or pop the stack, depending on the item
	if (exclusive_input_pressed(IPT_UI_SELECT, 0))
	{
		if (selected == numitems - 1)
		{
			menu_event.iptkey = IPT_UI_CANCEL;
			ui_menu::stack_pop(machine());
		}
		return;
	}

	// hitting cancel also pops the stack
	if (exclusive_input_pressed(IPT_UI_CANCEL, 0))
	{
		ui_menu::stack_pop(machine());
		return;
	}

	// validate the current selection
	validate_selection(1);

	// swallow left/right keys if they are not appropriate
	ignoreleft = ((item[selected].flags & MENU_FLAG_LEFT_ARROW) == 0);
	ignoreright = ((item[selected].flags & MENU_FLAG_RIGHT_ARROW) == 0);

	// accept left/right keys as-is with repeat
	if (!ignoreleft && exclusive_input_pressed(IPT_UI_LEFT, (flags & UI_MENU_PROCESS_LR_REPEAT) ? 6 : 0))
		return;
	if (!ignoreright && exclusive_input_pressed(IPT_UI_RIGHT, (flags & UI_MENU_PROCESS_LR_REPEAT) ? 6 : 0))
		return;

	// up backs up by one item
	if (exclusive_input_pressed(IPT_UI_UP, 6))
	{
		selected = (selected + numitems - 1) % numitems;
		validate_selection(-1);
	}

	// down advances by one item
	if (exclusive_input_pressed(IPT_UI_DOWN, 6))
	{
		selected = (selected + 1) % numitems;
		validate_selection(1);
	}

	// page up backs up by visitems
	if (exclusive_input_pressed(IPT_UI_PAGE_UP, 6))
	{
		selected -= visitems - 1;
		validate_selection(1);
	}

	// page down advances by visitems
	if (exclusive_input_pressed(IPT_UI_PAGE_DOWN, 6))
	{
		selected += visitems - 1;
		validate_selection(-1);
	}

	// home goes to the start
	if (exclusive_input_pressed(IPT_UI_HOME, 0))
	{
		selected = 0;
		validate_selection(1);
	}

	// end goes to the last
	if (exclusive_input_pressed(IPT_UI_END, 0))
	{
		selected = numitems - 1;
		validate_selection(-1);
	}

	// pause enables/disables pause
	if (!ignorepause && exclusive_input_pressed(IPT_UI_PAUSE, 0))
	{
		if (machine().paused())
			machine().resume();
		else
			machine().pause();
	}

	// handle a toggle cheats request
	if (ui_input_pressed_repeat(machine(), IPT_UI_TOGGLE_CHEAT, 0))
		machine().cheat().set_enable(!machine().cheat().enabled());

	// see if any other UI keys are pressed
	if (menu_event.iptkey == IPT_INVALID)
		for (code = IPT_UI_FIRST + 1; code < IPT_UI_LAST; code++)
		{
			if (code == IPT_UI_CONFIGURE || (code == IPT_UI_LEFT && ignoreleft) || (code == IPT_UI_RIGHT && ignoreright) || (code == IPT_UI_PAUSE && ignorepause))
				continue;
			if (exclusive_input_pressed(code, 0))
				break;
		}
}
Ejemplo n.º 6
0
bool ui_input_pressed(running_machine &machine, int code)
{
    return ui_input_pressed_repeat(machine, code, 0);
}
Ejemplo n.º 7
0
static void gfxset_handle_keys(running_machine &machine, ui_gfx_state &state, int xcells, int ycells)
{
	// handle gfxset selection (open bracket,close bracket)
	if (ui_input_pressed(machine, IPT_UI_PREV_GROUP))
	{
		if (state.gfxset.set > 0)
			state.gfxset.set--;
		else if (state.gfxset.devindex > 0)
		{
			state.gfxset.devindex--;
			state.gfxset.set = state.gfxdev[state.gfxset.devindex].setcount - 1;
		}
		state.bitmap_dirty = true;
	}
	if (ui_input_pressed(machine, IPT_UI_NEXT_GROUP))
	{
		if (state.gfxset.set < state.gfxdev[state.gfxset.devindex].setcount - 1)
			state.gfxset.set++;
		else if (state.gfxset.devindex < state.gfxset.devcount - 1)
		{
			state.gfxset.devindex++;
			state.gfxset.set = 0;
		}
		state.bitmap_dirty = true;
	}

	// cache some info in locals
	int dev = state.gfxset.devindex;
	int set = state.gfxset.set;
	ui_gfx_info &info = state.gfxdev[dev];
	gfx_element &gfx = *info.interface->gfx(set);

	// handle cells per line (minus,plus)
	if (ui_input_pressed(machine, IPT_UI_ZOOM_OUT))
	{ info.columns[set] = xcells - 1; state.bitmap_dirty = true; }

	if (ui_input_pressed(machine, IPT_UI_ZOOM_IN))
	{ info.columns[set] = xcells + 1; state.bitmap_dirty = true; }

	// clamp within range
	if (info.columns[set] < 2)
	{ info.columns[set] = 2; state.bitmap_dirty = true; }
	if (info.columns[set] > 128)
	{ info.columns[set] = 128; state.bitmap_dirty = true; }

	// handle rotation (R)
	if (ui_input_pressed(machine, IPT_UI_ROTATE))
	{
		info.rotate[set] = orientation_add(ROT90, info.rotate[set]);
		state.bitmap_dirty = true;
	}

	// handle navigation within the cells (up,down,pgup,pgdown)
	if (ui_input_pressed_repeat(machine, IPT_UI_UP, 4))
	{ info.offset[set] -= xcells; state.bitmap_dirty = true; }
	if (ui_input_pressed_repeat(machine, IPT_UI_DOWN, 4))
	{ info.offset[set] += xcells; state.bitmap_dirty = true; }
	if (ui_input_pressed_repeat(machine, IPT_UI_PAGE_UP, 6))
	{ info.offset[set] -= xcells * ycells; state.bitmap_dirty = true; }
	if (ui_input_pressed_repeat(machine, IPT_UI_PAGE_DOWN, 6))
	{ info.offset[set] += xcells * ycells; state.bitmap_dirty = true; }
	if (ui_input_pressed_repeat(machine, IPT_UI_HOME, 4))
	{ info.offset[set] = 0; state.bitmap_dirty = true; }
	if (ui_input_pressed_repeat(machine, IPT_UI_END, 4))
	{ info.offset[set] = gfx.elements(); state.bitmap_dirty = true; }

	// clamp within range
	if (info.offset[set] + xcells * ycells > ((gfx.elements() + xcells - 1) / xcells) * xcells)
	{
		info.offset[set] = ((gfx.elements() + xcells - 1) / xcells) * xcells - xcells * ycells;
		state.bitmap_dirty = true;
	}
	if (info.offset[set] < 0)
	{ info.offset[set] = 0; state.bitmap_dirty = true; }

	// handle color selection (left,right)
	if (ui_input_pressed_repeat(machine, IPT_UI_LEFT, 4))
	{ info.color[set] -= 1; state.bitmap_dirty = true; }
	if (ui_input_pressed_repeat(machine, IPT_UI_RIGHT, 4))
	{ info.color[set] += 1; state.bitmap_dirty = true; }

	// clamp within range
	if (info.color[set] >= (int)gfx.colors())
	{ info.color[set] = gfx.colors() - 1; state.bitmap_dirty = true; }
	if (info.color[set] < 0)
	{ info.color[set] = 0; state.bitmap_dirty = true; }
}
Ejemplo n.º 8
0
static void palette_handle_keys(running_machine &machine, ui_gfx_state &state)
{
	palette_device *palette = state.palette.device;
	int rowcount, screencount;
	int total;

	// handle zoom (minus,plus)
	if (ui_input_pressed(machine, IPT_UI_ZOOM_OUT))
		state.palette.columns /= 2;
	if (ui_input_pressed(machine, IPT_UI_ZOOM_IN))
		state.palette.columns *= 2;

	// clamp within range
	if (state.palette.columns <= 4)
		state.palette.columns = 4;
	if (state.palette.columns > 64)
		state.palette.columns = 64;

	// handle colormap selection (open bracket,close bracket)
	if (ui_input_pressed(machine, IPT_UI_PREV_GROUP))
	{
		if (state.palette.which)
			state.palette.which = 0;
		else if (state.palette.devindex > 0)
		{
			state.palette.devindex--;
			palette_set_device(machine, state);
			palette = state.palette.device;
			state.palette.which = (palette->indirect_entries() > 0);
		}
	}
	if (ui_input_pressed(machine, IPT_UI_NEXT_GROUP))
	{
		if (!state.palette.which && palette->indirect_entries() > 0)
			state.palette.which = 1;
		else if (state.palette.devindex < state.palette.devcount - 1)
		{
			state.palette.devindex++;
			palette_set_device(machine, state);
			palette = state.palette.device;
			state.palette.which = 0;
		}
	}

	// cache some info in locals
	total = state.palette.which ? palette->indirect_entries() : palette->entries();

	// determine number of entries per row and total
	rowcount = state.palette.columns;
	screencount = rowcount * rowcount;

	// handle keyboard navigation
	if (ui_input_pressed_repeat(machine, IPT_UI_UP, 4))
		state.palette.offset -= rowcount;
	if (ui_input_pressed_repeat(machine, IPT_UI_DOWN, 4))
		state.palette.offset += rowcount;
	if (ui_input_pressed_repeat(machine, IPT_UI_PAGE_UP, 6))
		state.palette.offset -= screencount;
	if (ui_input_pressed_repeat(machine, IPT_UI_PAGE_DOWN, 6))
		state.palette.offset += screencount;
	if (ui_input_pressed_repeat(machine, IPT_UI_HOME, 4))
		state.palette.offset = 0;
	if (ui_input_pressed_repeat(machine, IPT_UI_END, 4))
		state.palette.offset = total;

	// clamp within range
	if (state.palette.offset + screencount > ((total + rowcount - 1) / rowcount) * rowcount)
		state.palette.offset = ((total + rowcount - 1) / rowcount) * rowcount - screencount;
	if (state.palette.offset < 0)
		state.palette.offset = 0;
}
Ejemplo n.º 9
0
static void tilemap_handle_keys(running_machine &machine, ui_gfx_state &state, int viswidth, int visheight)
{
	UINT32 mapwidth, mapheight;
	int step;

	// handle tilemap selection (open bracket,close bracket)
	if (ui_input_pressed(machine, IPT_UI_PREV_GROUP) && state.tilemap.which > 0)
	{ state.tilemap.which--; state.bitmap_dirty = true; }
	if (ui_input_pressed(machine, IPT_UI_NEXT_GROUP) && state.tilemap.which < machine.tilemap().count() - 1)
	{ state.tilemap.which++; state.bitmap_dirty = true; }

	// cache some info in locals
	tilemap_t *tilemap = machine.tilemap().find(state.tilemap.which);
	mapwidth = tilemap->width();
	mapheight = tilemap->height();

	// handle zoom (minus,plus)
	if (ui_input_pressed(machine, IPT_UI_ZOOM_OUT) && state.tilemap.zoom > 0)
	{
		state.tilemap.zoom--;
		state.bitmap_dirty = true;
		if (state.tilemap.zoom != 0)
			machine.popmessage("Zoom = %d", state.tilemap.zoom);
		else
			machine.popmessage("Zoom Auto");
	}
	if (ui_input_pressed(machine, IPT_UI_ZOOM_IN) && state.tilemap.zoom < 8)
	{
		state.tilemap.zoom++;
		state.bitmap_dirty = true;
		machine.popmessage("Zoom = %d", state.tilemap.zoom);
	}

	// handle rotation (R)
	if (ui_input_pressed(machine, IPT_UI_ROTATE))
	{
		state.tilemap.rotate = orientation_add(ROT90, state.tilemap.rotate);
		state.bitmap_dirty = true;
	}

	// handle navigation (up,down,left,right)
	step = 8;
	if (machine.input().code_pressed(KEYCODE_LSHIFT)) step = 1;
	if (machine.input().code_pressed(KEYCODE_LCONTROL)) step = 64;
	if (ui_input_pressed_repeat(machine, IPT_UI_UP, 4))
	{ state.tilemap.yoffs -= step; state.bitmap_dirty = true; }
	if (ui_input_pressed_repeat(machine, IPT_UI_DOWN, 4))
	{ state.tilemap.yoffs += step; state.bitmap_dirty = true; }
	if (ui_input_pressed_repeat(machine, IPT_UI_LEFT, 6))
	{ state.tilemap.xoffs -= step; state.bitmap_dirty = true; }
	if (ui_input_pressed_repeat(machine, IPT_UI_RIGHT, 6))
	{ state.tilemap.xoffs += step; state.bitmap_dirty = true; }

	// clamp within range
	while (state.tilemap.xoffs < 0)
		state.tilemap.xoffs += mapwidth;
	while (state.tilemap.xoffs >= mapwidth)
		state.tilemap.xoffs -= mapwidth;
	while (state.tilemap.yoffs < 0)
		state.tilemap.yoffs += mapheight;
	while (state.tilemap.yoffs >= mapheight)
		state.tilemap.yoffs -= mapheight;
}