Beispiel #1
0
LRESULT debugview_info::view_proc(UINT message, WPARAM wparam, LPARAM lparam)
{
	// handle a few messages
	switch (message)
	{
	// paint: redraw the last bitmap
	case WM_PAINT:
		{
			PAINTSTRUCT pstruct;
			HDC const dc = BeginPaint(m_wnd, &pstruct);
			draw_contents(dc);
			EndPaint(m_wnd, &pstruct);
			break;
		}

	// keydown: handle debugger keys
	case WM_SYSKEYDOWN:
		if (wparam != VK_F10)
			return DefWindowProc(m_wnd, message, wparam, lparam);
			// (fall through)
	case WM_KEYDOWN:
		{
			if (m_owner.handle_key(wparam, lparam))
			{
				m_owner.set_ignore_char_lparam(lparam);
			}
			else
			{
				switch (wparam)
				{
				case VK_UP:
					m_view->process_char(DCH_UP);
					m_owner.set_ignore_char_lparam(lparam);
					break;

				case VK_DOWN:
					m_view->process_char(DCH_DOWN);
					m_owner.set_ignore_char_lparam(lparam);
					break;

				case VK_LEFT:
					if (GetAsyncKeyState(VK_CONTROL) & 0x8000)
						m_view->process_char(DCH_CTRLLEFT);
					else
						m_view->process_char(DCH_LEFT);
					m_owner.set_ignore_char_lparam(lparam);
					break;

				case VK_RIGHT:
					if (GetAsyncKeyState(VK_CONTROL) & 0x8000)
						m_view->process_char(DCH_CTRLRIGHT);
					else
						m_view->process_char(DCH_RIGHT);
					m_owner.set_ignore_char_lparam(lparam);
					break;

				case VK_PRIOR:
					m_view->process_char(DCH_PUP);
					m_owner.set_ignore_char_lparam(lparam);
					break;

				case VK_NEXT:
					m_view->process_char(DCH_PDOWN);
					m_owner.set_ignore_char_lparam(lparam);
					break;

				case VK_HOME:
					if (GetAsyncKeyState(VK_CONTROL) & 0x8000)
						m_view->process_char(DCH_CTRLHOME);
					else
						m_view->process_char(DCH_HOME);
					m_owner.set_ignore_char_lparam(lparam);
					break;

				case VK_END:
					if (GetAsyncKeyState(VK_CONTROL) & 0x8000)
						m_view->process_char(DCH_CTRLEND);
					else
						m_view->process_char(DCH_END);
					m_owner.set_ignore_char_lparam(lparam);
					break;

				case VK_ESCAPE:
					m_owner.set_default_focus();
					m_owner.set_ignore_char_lparam(lparam);
					break;

				case VK_TAB:
					if (GetAsyncKeyState(VK_SHIFT) & 0x8000)
						m_owner.prev_view(this);
					else
						m_owner.next_view(this);
					m_owner.set_ignore_char_lparam(lparam);
					break;
				}
			}
			break;
		}

	// char: ignore chars associated with keys we've handled
	case WM_CHAR:
		if (m_owner.check_ignore_char_lparam(lparam))
		{
			if (waiting_for_debugger() || !seq_pressed())
			{
				if (wparam >= 32 && wparam < 127)
				{
					if (m_view->cursor_supported())
						m_view->set_cursor_visible(true);
					m_view->process_char(wparam);
				}
				else
				{
					return DefWindowProc(m_wnd, message, wparam, lparam);
				}
			}
		}
		break;

	// gaining focus
	case WM_SETFOCUS:
		if (m_view->cursor_supported())
			m_view->set_cursor_visible(true);
		break;

	// losing focus
	case WM_KILLFOCUS:
		if (m_view->cursor_supported())
			m_view->set_cursor_visible(false);
		break;

	// mouse click
	case WM_LBUTTONDOWN:
		{
			debug_view_xy topleft = m_view->visible_position();
			debug_view_xy newpos;
			newpos.x = topleft.x + GET_X_LPARAM(lparam) / metrics().debug_font_width();
			newpos.y = topleft.y + GET_Y_LPARAM(lparam) / metrics().debug_font_height();
			m_view->process_click(DCK_LEFT_CLICK, newpos);
			SetFocus(m_wnd);
			break;
		}

	// hscroll
	case WM_HSCROLL:
		{
			debug_view_xy topleft = m_view->visible_position();
			topleft.x = process_scroll(LOWORD(wparam), (HWND)lparam);
			m_view->set_visible_position(topleft);
			machine().debug_view().flush_osd_updates();
			break;
		}

	// vscroll
	case WM_VSCROLL:
		{
			debug_view_xy topleft = m_view->visible_position();
			topleft.y = process_scroll(LOWORD(wparam), (HWND)lparam);
			m_view->set_visible_position(topleft);
			machine().debug_view().flush_osd_updates();
			break;
		}

	// everything else: defaults
	default:
		return DefWindowProc(m_wnd, message, wparam, lparam);
	}

	return 0;
}
Beispiel #2
0
LRESULT editwin_info::edit_proc(UINT message, WPARAM wparam, LPARAM lparam)
{
	TCHAR buffer[MAX_EDIT_STRING];

	// handle a few messages
	switch (message)
	{
	// key down: handle navigation in the attached view
	case WM_SYSKEYDOWN:
		if (wparam != VK_F10)
			return CallWindowProc(m_original_editproc, m_editwnd, message, wparam, lparam);
		// (fall through)
	case WM_KEYDOWN:
		switch (wparam)
		{
		case VK_UP:
			if (m_last_history < (m_history_count - 1))
				m_last_history++;
			else
				m_last_history = 0;
			SendMessage(m_editwnd, WM_SETTEXT, (WPARAM)0, (LPARAM)&m_history[m_last_history][0]);
			SendMessage(m_editwnd, EM_SETSEL, (WPARAM)MAX_EDIT_STRING, (LPARAM)MAX_EDIT_STRING);
			break;

		case VK_DOWN:
			if (m_last_history > 0)
				m_last_history--;
			else if (m_history_count > 0)
				m_last_history = m_history_count - 1;
			else
				m_last_history = 0;
			SendMessage(m_editwnd, WM_SETTEXT, (WPARAM)0, (LPARAM)&m_history[m_last_history][0]);
			SendMessage(m_editwnd, EM_SETSEL, (WPARAM)MAX_EDIT_STRING, (LPARAM)MAX_EDIT_STRING);
			break;

		case VK_PRIOR:
			if (m_views[0] != nullptr)
				m_views[0]->send_pageup();
			break;

		case VK_NEXT:
			if (m_views[0] != nullptr)
				m_views[0]->send_pagedown();
			break;

		case VK_TAB:
			if (GetAsyncKeyState(VK_SHIFT) & 0x8000)
				prev_view(nullptr);
			else
				next_view(nullptr);
			set_ignore_char_lparam(lparam);
			break;

		default:
			if (handle_key(wparam, lparam))
				set_ignore_char_lparam(lparam);
			else
				return CallWindowProc(m_original_editproc, m_editwnd, message, wparam, lparam);
			break;
		}
		break;

	// char: handle the return key
	case WM_CHAR:

		// ignore chars associated with keys we've handled
		if (check_ignore_char_lparam(lparam))
		{
			if (waiting_for_debugger() || !seq_pressed())
			{
				switch (wparam)
				{
				case 13:
					{
						// fetch the text
						SendMessage(m_editwnd, WM_GETTEXT, (WPARAM)ARRAY_LENGTH(buffer), (LPARAM)buffer);

						// add to the history if it's not a repeat of the last one
						if (buffer[0] != 0 && _tcscmp(buffer, &m_history[0][0]))
						{
							memmove(&m_history[1][0], &m_history[0][0], (HISTORY_LENGTH - 1) * MAX_EDIT_STRING * sizeof(TCHAR));
							_tcscpy(&m_history[0][0], buffer);
							if (m_history_count < HISTORY_LENGTH)
								m_history_count++;
						}
						m_last_history = m_history_count - 1;

						// process
						{
							auto utf8_buffer = osd::text::from_tstring(buffer);
							process_string(utf8_buffer.c_str());
						}
						break;
					}

				case 27:
					{
						// fetch the text
						SendMessage(m_editwnd, WM_GETTEXT, (WPARAM)sizeof(buffer), (LPARAM)buffer);

						// if it's not empty, clear the text
						if (_tcslen(buffer) > 0)
						{
							set_ignore_char_lparam(lparam);
							set_editwnd_text(m_edit_defstr.c_str());
							editwnd_select_all();
						}
						break;
					}

				default:
					return CallWindowProc(m_original_editproc, m_editwnd, message, wparam, lparam);
				}
			}
		}
		break;

	// everything else: defaults
	default:
		return CallWindowProc(m_original_editproc, m_editwnd, message, wparam, lparam);
	}

	return 0;
}
Beispiel #3
0
LRESULT debugwin_info::window_proc(UINT message, WPARAM wparam, LPARAM lparam)
{
	// handle a few messages
	switch (message)
	{
	// paint: draw bezels as necessary
	case WM_PAINT:
		{
			PAINTSTRUCT pstruct;
			HDC dc = BeginPaint(m_wnd, &pstruct);
			draw_contents(dc);
			EndPaint(m_wnd, &pstruct);
			break;
		}

	// keydown: handle debugger keys
	case WM_KEYDOWN:
		if (handle_key(wparam, lparam))
			set_ignore_char_lparam(lparam);
		break;

	// char: ignore chars associated with keys we've handled
	case WM_CHAR:
		if (check_ignore_char_lparam(lparam))
		{
			if (waiting_for_debugger() || !seq_pressed())
				return DefWindowProc(m_wnd, message, wparam, lparam);
		}
		break;

	// activate: set the focus
	case WM_ACTIVATE:
		if (wparam != WA_INACTIVE)
			set_default_focus();
		break;

	// get min/max info: set the minimum window size
	case WM_GETMINMAXINFO:
		{
			MINMAXINFO *minmax = (MINMAXINFO *)lparam;
			minmax->ptMinTrackSize.x = m_minwidth;
			minmax->ptMinTrackSize.y = m_minheight;
			minmax->ptMaxSize.x = minmax->ptMaxTrackSize.x = m_maxwidth;
			minmax->ptMaxSize.y = minmax->ptMaxTrackSize.y = m_maxheight;
			break;
		}

	// sizing: recompute child window locations
	case WM_SIZE:
	case WM_SIZING:
		recompute_children();
		InvalidateRect(m_wnd, NULL, FALSE);
		break;

	// mouse wheel: forward to the first view
	case WM_MOUSEWHEEL:
		{
			static int units_carryover = 0;

			UINT lines_per_click;
			if (!SystemParametersInfo(SPI_GETWHEELSCROLLLINES, 0, &lines_per_click, 0))
				lines_per_click = 3;

			int const units = GET_WHEEL_DELTA_WPARAM(wparam) + units_carryover;
			int const clicks = units / WHEEL_DELTA;
			units_carryover = units % WHEEL_DELTA;

			int const delta = clicks * lines_per_click;
			int viewnum = 0;
			POINT point;

			// figure out which view we are hovering over
			GetCursorPos(&point);
			ScreenToClient(m_wnd, &point);
			HWND const child = ChildWindowFromPoint(m_wnd, point);
			if (child)
			{
				for (viewnum = 0; viewnum < MAX_VIEWS; viewnum++)
				{
					if ((m_views[viewnum] != NULL) && m_views[viewnum]->owns_window(child))
						break;
				}
				if (viewnum == MAX_VIEWS)
					break;
			}

			// send the appropriate message to this view's scrollbar
			if (m_views[viewnum] != NULL)
				m_views[viewnum]->send_vscroll(delta);

			break;
		}

	// activate: set the focus
	case WM_INITMENU:
		update_menu();
		break;

	// command: handle a comment
	case WM_COMMAND:
		if (!handle_command(wparam, lparam))
			return DefWindowProc(m_wnd, message, wparam, lparam);
		break;

	// close: close the window if it's not the main console
	case WM_CLOSE:
		if (m_is_main_console)
		{
			debugger().hide_all();
			debug_cpu_get_visible_cpu(machine())->debug()->go();
		}
		else
		{
			destroy();
		}
		break;

	// destroy: close down the window
	case WM_NCDESTROY:
		m_wnd = NULL;
		debugger().remove_window(*this);
		break;

	// everything else: defaults
	default:
		return DefWindowProc(m_wnd, message, wparam, lparam);
	}

	return 0;
}
Beispiel #4
0
LRESULT editwin_info::edit_proc(UINT message, WPARAM wparam, LPARAM lparam)
{
	// handle a few messages
	switch (message)
	{
	// key down: handle navigation in the attached view
	case WM_SYSKEYDOWN:
		if (wparam != VK_F10)
			return CallWindowProc(m_original_editproc, m_editwnd, message, wparam, lparam);
		// (fall through)
	case WM_KEYDOWN:
		switch (wparam)
		{
		case VK_UP:
			if (!m_history.empty())
			{
				m_last_history++;
				if (m_last_history >= m_history.size())
					m_last_history = 0;
				auto const &entry(m_history[m_last_history]);
				SendMessage(m_editwnd, WM_SETTEXT, WPARAM(0), LPARAM(entry.c_str()));
				SendMessage(m_editwnd, EM_SETSEL, WPARAM(entry.length()), LPARAM(entry.length()));
			}
			break;

		case VK_DOWN:
			if (!m_history.empty())
			{
				if (m_last_history > 0)
					m_last_history--;
				else
					m_last_history = m_history.size() - 1;
				auto const &entry(m_history[m_last_history]);
				SendMessage(m_editwnd, WM_SETTEXT, WPARAM(0), LPARAM(entry.c_str()));
				SendMessage(m_editwnd, EM_SETSEL, WPARAM(entry.length()), LPARAM(entry.length()));
			}
			break;

		case VK_PRIOR:
			if (m_views[0] != nullptr)
				m_views[0]->send_pageup();
			break;

		case VK_NEXT:
			if (m_views[0] != nullptr)
				m_views[0]->send_pagedown();
			break;

		case VK_TAB:
			if (GetAsyncKeyState(VK_SHIFT) & 0x8000)
				prev_view(nullptr);
			else
				next_view(nullptr);
			set_ignore_char_lparam(lparam);
			break;

		default:
			if (handle_key(wparam, lparam))
				set_ignore_char_lparam(lparam);
			else
				return CallWindowProc(m_original_editproc, m_editwnd, message, wparam, lparam);
			break;
		}
		break;

	// char: handle the return key
	case WM_CHAR:

		// ignore chars associated with keys we've handled
		if (check_ignore_char_lparam(lparam))
		{
			if (waiting_for_debugger() || !seq_pressed())
			{
				TCHAR buffer[MAX_EDIT_STRING];

				switch (wparam)
				{
				case 13: // carriage return
					{
						// fetch the text
						SendMessage(m_editwnd, WM_GETTEXT, WPARAM(ARRAY_LENGTH(buffer)), LPARAM(buffer));

						// add to the history if it's not a repeat of the last one
						if (buffer[0] && (m_history.empty() || _tcscmp(buffer, m_history[0].c_str())))
						{
							while (m_history.size() >= HISTORY_LENGTH)
								m_history.pop_back();
							m_history.emplace_front(buffer);
						}
						m_last_history = m_history.size() - 1;

						// process
						{
							auto utf8_buffer = osd::text::from_tstring(buffer);
							process_string(utf8_buffer.c_str());
						}
					}
					break;

				case 27: // escape
					{
						// fetch the text
						SendMessage(m_editwnd, WM_GETTEXT, WPARAM(sizeof(buffer)), LPARAM(buffer));

						// if it's not empty, clear the text
						if (_tcslen(buffer) > 0)
						{
							set_ignore_char_lparam(lparam);
							set_editwnd_text(m_edit_defstr.c_str());
							editwnd_select_all();
						}
					}
					break;

				default:
					return CallWindowProc(m_original_editproc, m_editwnd, message, wparam, lparam);
				}
			}
		}
		break;

	// everything else: defaults
	default:
		return CallWindowProc(m_original_editproc, m_editwnd, message, wparam, lparam);
	}

	return 0;
}
Beispiel #5
0
bool debugwin_info::handle_key(WPARAM wparam, LPARAM lparam)
{
	/* ignore any keys that are received while the debug key is down */
	if (!waiting_for_debugger() && seq_pressed())
		return true;

	switch (wparam)
	{
	case VK_F3:
		if (GetAsyncKeyState(VK_SHIFT) & 0x8000)
			SendMessage(m_wnd, WM_COMMAND, ID_HARD_RESET, 0);
		else
			SendMessage(m_wnd, WM_COMMAND, ID_SOFT_RESET, 0);
		return true;

	case VK_F4:
		if (GetAsyncKeyState(VK_MENU) & 0x8000)
		{
			/* ajg - never gets here since 'alt' seems to be captured somewhere else - menu maybe? */
			SendMessage(m_wnd, WM_COMMAND, ID_EXIT, 0);
			return true;
		}
		break;

	case VK_F5:
		SendMessage(m_wnd, WM_COMMAND, ID_RUN, 0);
		return true;

	case VK_F6:
		SendMessage(m_wnd, WM_COMMAND, ID_NEXT_CPU, 0);
		return true;

	case VK_F7:
		SendMessage(m_wnd, WM_COMMAND, ID_RUN_IRQ, 0);
		return true;

	case VK_F8:
		SendMessage(m_wnd, WM_COMMAND, ID_RUN_VBLANK, 0);
		return true;

	case VK_F10:
		SendMessage(m_wnd, WM_COMMAND, ID_STEP_OVER, 0);
		return true;

	case VK_F11:
		if (GetAsyncKeyState(VK_SHIFT) & 0x8000)
			SendMessage(m_wnd, WM_COMMAND, ID_STEP_OUT, 0);
		else
			SendMessage(m_wnd, WM_COMMAND, ID_STEP, 0);
		return true;

	case VK_F12:
		SendMessage(m_wnd, WM_COMMAND, ID_RUN_AND_HIDE, 0);
		return true;

	case 'M':
		if (GetAsyncKeyState(VK_CONTROL) & 0x8000)
		{
			SendMessage(m_wnd, WM_COMMAND, ID_NEW_MEMORY_WND, 0);
			return true;
		}
		break;

	case 'D':
		if (GetAsyncKeyState(VK_CONTROL) & 0x8000)
		{
			SendMessage(m_wnd, WM_COMMAND, ID_NEW_DISASM_WND, 0);
			return true;
		}
		break;

	case 'L':
		if (GetAsyncKeyState(VK_CONTROL) & 0x8000)
		{
			SendMessage(m_wnd, WM_COMMAND, ID_NEW_LOG_WND, 0);
			return true;
		}
		break;

	case 'B':
		if (GetAsyncKeyState(VK_CONTROL) & 0x8000)
		{
			SendMessage(m_wnd, WM_COMMAND, ID_NEW_POINTS_WND, 0);
			return true;
		}
		break;
	}

	return false;
}