コード例 #1
0
ファイル: input.c プロジェクト: damajor/play-dune
void Input_EventHandler(uint8 key)
{
	uint8 state;
	uint8 i;
	uint16 flags; /* Mask for allowed input types. See InputFlagsEnum. */

	flags = g_inputFlags;
	state = 0;

	if (key == 0xE0) {
		s_input_extendedKey = true;
		return;
	}

	/* Key up */
	if ((key & 0x80) != 0) {
		key &= 0x7F;
		state |= 0x08;
	}

	if (s_input_extendedKey) {
		s_input_extendedKey = false;

		for (i = 0; i < lengthof(s_translateExtendedMap); i++) {
			if (s_translateExtendedMap[i] == key) {
				key = s_translateMap[i];
				break;
			}
		}
		if (i == 16) return;
	} else if (key == 0x7A) {
		key = 0x80;
	} else {
		key = s_keyTranslate[key & 0x7F];
	}

	if ((s_activeInputMap[7] & 0x4) != 0) return;
	if ((s_activeInputMap[7] & 0x50) != 0) state |= 0x04;

	key = Input_Keyboard_Translate(key) & 0xFF;

	if ((s_activeInputMap[7] & 0x2) != 0) state |= 0x01;

	if (state == 0x06 && key == 0x68) return;
	if (state == 0x06 && key == 0x4C) return;

	Input_HandleInput((state << 8) | key);

	for (i = 0; i < lengthof(s_keymapIgnore); i++) {
		if (s_keymapIgnore[i] == key) return;
	}
	for (i = 0; i < lengthof(s_otherKeys); i++) {
		if (s_otherKeys[i] == key) {
			if ((s_otherFlags[i] & flags) != 0) return;
			break;
		}
	}
}
コード例 #2
0
ファイル: input.c プロジェクト: drnovice/OpenDUNE
void Input_EventHandler(uint8 key)
{
	uint8 state;
	uint8 i;

	state = 0;

	if (key == 0xE0) {
		s_input_extendedKey = true;
		return;
	}

	/* Key up */
	if ((key & 0x80) != 0) {
		key &= 0x7F;
		state |= 0x08;
	}

	if (s_input_extendedKey) {
		s_input_extendedKey = false;

		for (i = 0; i < lengthof(s_translateExtendedMap); i++) {
			if (s_translateExtendedMap[i] == key) {
				key = s_translateMap[i];
				break;
			}
		}
		if (i == 16) return;
	} else if (key == 0x7A) {
		key = 0x80;
	} else {
		key = s_keyTranslate[key & 0x7F];
	}

	if ((s_activeInputMap[7] & 0x4) != 0) return;
	if ((s_activeInputMap[7] & 0x50) != 0) state |= 0x04;

	key = Input_Keyboard_Translate(key) & 0xFF;

	if ((s_activeInputMap[7] & 0x2) != 0) state |= 0x01;

	if (state == 0x06 && key == 0x68) return;
	if (state == 0x06 && key == 0x4C) return;

	Input_HandleInput((state << 8) | key);
}