Beispiel #1
0
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;
		}
	}
}
Beispiel #2
0
/**
 * Handles Click event for list in mentat window.
 *
 * @param w The widget.
 */
bool GUI_Mentat_List_Click(Widget *w)
{
    uint16 index;
    Widget *w2;

    index = s_selectedHelpSubject + 3;

    if (w->index != index) {
        w2 = GUI_Widget_Get_ByIndex(g_widgetMentatTail, index);

        GUI_Widget_MakeNormal(w, false);
        GUI_Widget_MakeNormal(w2, false);

        if (w2->stringID == 0x31) {
            w2->fgColourDown   = 15;
            w2->fgColourNormal = 15;

            GUI_Widget_Draw(w2);
        }

        if (w->stringID == 0x31) {
            w->fgColourDown   = 8;
            w->fgColourNormal = 8;

            GUI_Widget_Draw(w);
        }

        s_selectedHelpSubject = w->index - 3;
        return true;
    }

    if ((w->state.buttonState & 0x11) == 0 && !s_selectMentatHelp) return true;

    if (w->stringID != 0x31) return true;

    GUI_Widget_MakeNormal(w, false);

    GUI_Mentat_ShowHelp();

    GUI_Mentat_Draw(true);

    Input_HandleInput(0x841);
    Input_HandleInput(0x842);
    return false;
}
Beispiel #3
0
/**
 * Handle movement of the mouse.
 * @param newButtonState State of the mouse buttons.
 * @param mouseX Horizontal position of the mouse cursor.
 * @param mouseY Vertical position of the mouse cursor.
 */
void Mouse_HandleMovement(uint16 newButtonState, uint16 mouseX, uint16 mouseY)
{
	g_mouseLock = 0x1;

	g_mouseX = mouseX;
	g_mouseY = mouseY;
	if (g_mouseMode != INPUT_MOUSE_MODE_PLAY && g_mouseMode != INPUT_MOUSE_MODE_NORMAL && (g_inputFlags & INPUT_FLAG_NO_CLICK) == 0) {
		Input_HandleInput(Mouse_CheckButtons(newButtonState));
	}

	Mouse_CheckMovement(mouseX, mouseY);
}
Beispiel #4
0
/**
 * Handle the new mouse event.
 */
void Mouse_EventHandler(uint16 mousePosX, uint16 mousePosY, bool mouseButtonLeft, bool mouseButtonRight)
{
	uint8 newButtonState = (mouseButtonLeft ? 0x1 : 0x0) | (mouseButtonRight ? 0x2 : 0x0);

	if (g_var_7097 == 0 && (g_mouseMode != INPUT_MOUSE_MODE_RECORD || g_fileOperation == 0)) {
		if (g_mouseMode == INPUT_MOUSE_MODE_NORMAL && (g_inputFlags & INPUT_FLAG_NO_CLICK) == 0) {
			Input_HandleInput(Mouse_CheckButtons(newButtonState));
		}

		if (g_mouseMode != INPUT_MOUSE_MODE_PLAY && g_mouseLock == 0) {
			Mouse_HandleMovement(newButtonState, mousePosX, mousePosY);
		}
	}
}
Beispiel #5
0
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);
}
Beispiel #6
0
void GUI_Mentat_List_Click_Close() {
	GUI_Mentat_Draw(true);

	Input_HandleInput(0x841);
	Input_HandleInput(0x842);
}
Beispiel #7
0
void Mouse_SetMouseMode(uint8 mouseMode, const char *filename)
{
	switch (mouseMode) {
		default: break;

		case INPUT_MOUSE_MODE_NORMAL:
			g_mouseMode = mouseMode;
			if (g_mouseFileID != 0xFF) {
				Input_Flags_ClearBits(INPUT_FLAG_KEY_RELEASE);
				File_Close(g_mouseFileID);
			}
			g_mouseFileID = 0xFF;
			g_var_701B = true;
			break;

		case INPUT_MOUSE_MODE_RECORD:
			if (g_mouseFileID != 0xFF) break;

			File_Delete(filename);
			File_Create(filename);

			Tools_RandomLCG_Seed(0x21433412);

			g_mouseFileID = File_Open(filename, 3);

			g_mouseMode = mouseMode;

			Input_Flags_SetBits(INPUT_FLAG_KEY_RELEASE);

			Input_HandleInput(0x2D);
			break;

		case INPUT_MOUSE_MODE_PLAY:
			if (g_mouseFileID == 0xFF) {
				g_mouseFileID = File_Open(filename, 1);

				Tools_RandomLCG_Seed(0x21433412);
			}

			g_var_701B = true;

			File_Read(g_mouseFileID, &g_var_7013, 2);
			if (File_Read(g_mouseFileID, &g_var_7015, 2) != 2) break;;

			if ((g_var_7013 >= 0x41 && g_var_7013 <= 0x44) || g_var_7013 == 0x2D) {
				File_Read(g_mouseFileID, &g_var_7017, 2);
				if (File_Read(g_mouseFileID, &g_var_7019, 2) == 2) {
					g_mouseX = g_var_7017;
					g_mouseY = g_var_7019;
					g_prevButtonState = 0;

					GUI_Mouse_Hide_Safe();
					GUI_Mouse_Show_Safe();

					g_var_701B = false;
					break;
				}
				g_var_701B = true;
				break;
			}
			g_var_701B = false;
			break;
	}

	g_timerInput = 0;
	g_mouseMode = mouseMode;
}