コード例 #1
0
ファイル: inputx.c プロジェクト: CrouchingLlama/openlase-mame
static int build_codes(const input_port_entry *input_ports, struct InputCode *codes, int map_lowercase)
{
	UINT32 ports[NUM_SIMUL_KEYS];
	const input_port_entry *ipts[NUM_SIMUL_KEYS];
	int switch_upper, rc = 0;
	unicode_char_t c;

	/* first clear the buffer */
	memset(codes, 0, CODE_BUFFER_SIZE);

	if (!scan_keys(input_ports, codes, ports, ipts, 0, 0))
		goto done;

	if (map_lowercase)
	{
		/* special case; scan to see if upper case characters are specified, but not lower case */
		switch_upper = 1;
		for (c = 'A'; c <= 'Z'; c++)
		{
			if (!inputx_can_post_key(c) || inputx_can_post_key(unicode_tolower(c)))
			{
				switch_upper = 0;
				break;
			}
		}

		if (switch_upper)
			memcpy(&codes['a'], &codes['A'], sizeof(codes[0]) * 26);
	}

	rc = 1;

done:
	return rc;
}
コード例 #2
0
ファイル: processor_input.cpp プロジェクト: Templier/scummvm
void Processor::z_read() {
	zchar buffer[INPUT_BUFFER_SIZE];
	zword addr;
	zchar key;
	zbyte max, size;
	zbyte c;
	int i;

	// Supply default arguments
	if (zargc < 3)
		zargs[2] = 0;

	// Get maximum input size
	addr = zargs[0];

	LOW_BYTE(addr, max);

	if (h_version <= V4)
		max--;

	if (max >= INPUT_BUFFER_SIZE)
		max = INPUT_BUFFER_SIZE - 1;

	// Get initial input size
	if (h_version >= V5) {
		addr++;
		LOW_BYTE(addr, size);
	} else {
		size = 0;
	}

	// Copy initial input to local buffer
	for (i = 0; i < size; i++) {
		addr++;
		LOW_BYTE(addr, c);
		buffer[i] = translate_from_zscii(c);
	}
	buffer[i] = 0;

	// Draw status line for V1 to V3 games
	if (h_version <= V3)
		z_show_status();

	// Read input from current input stream
	key = stream_read_input(
		max, buffer,		// buffer and size
		zargs[2],			// timeout value
		zargs[3],			// timeout routine
		false,				// enable hot keys
		h_version == V6		// no script in V6
	);

	if (key == ZC_BAD)
		return;

	// Perform save_undo for V1 to V4 games
	if (h_version <= V4)
		save_undo();

	// Copy local buffer back to dynamic memory
	for (i = 0; buffer[i] != 0; i++) {
		if (key == ZC_RETURN) {
			buffer[i] = unicode_tolower (buffer[i]);
		}

		storeb((zword)(zargs[0] + ((h_version <= V4) ? 1 : 2) + i), translate_to_zscii(buffer[i]));
	}

	// Add null character (V1-V4) or write input length into 2nd byte
	if (h_version <= V4)
		storeb((zword)(zargs[0] + 1 + i), 0);
	else
		storeb((zword)(zargs[0] + 1), i);

	// Tokenise line if a token buffer is present
	if (key == ZC_RETURN && zargs[1] != 0)
		tokenise_line (zargs[0], zargs[1], 0, false);

	// Store key
	if (h_version >= V5)
		store(translate_to_zscii(key));
}