MCPcopy Create free account
hub / github.com/PCSX2/pcsx2 / KeyPress

Method KeyPress

pcsx2-qt/Debugger/Memory/MemoryView.cpp:540–671  ·  view source on GitHub ↗

We need both key and keychar because `key` is easy to use, but is case insensitive

Source from the content-addressed store, hash-verified

538
539// We need both key and keychar because `key` is easy to use, but is case insensitive
540bool MemoryViewTable::KeyPress(int key, QChar keychar, DebugInterface& cpu)
541{
542 if (!cpu.isValidAddress(selectedAddress))
543 return false;
544
545 bool pressHandled = false;
546
547 const bool keyCharIsText = keychar.isLetterOrNumber() || keychar.isSpace();
548
549 if (selectedText)
550 {
551 if (keyCharIsText || (!keychar.isNonCharacter() && keychar.category() != QChar::Other_Control))
552 {
553 const QPointer<MemoryViewTable> table(this);
554 Host::RunOnCPUThread([table, address = selectedAddress, &cpu, val = keychar.toLatin1()] {
555 cpu.Write8(address, val);
556
557 QtHost::RunOnUIThread([table, address]() {
558 if (!table)
559 return;
560
561 table->UpdateSelectedAddress(address + 1);
562 table->parent->update();
563 });
564 });
565 pressHandled = true;
566 }
567
568 switch (key)
569 {
570 case Qt::Key::Key_Backspace:
571 case Qt::Key::Key_Escape:
572 {
573 const QPointer<MemoryViewTable> table(this);
574 Host::RunOnCPUThread([table, address = selectedAddress, &cpu] {
575 cpu.Write8(address, 0);
576
577 QtHost::RunOnUIThread([table] {
578 if (!table)
579 return;
580
581 table->BackwardSelection();
582 table->parent->update();
583 });
584 });
585 pressHandled = true;
586 break;
587 }
588 case Qt::Key::Key_Right:
589 ForwardSelection();
590 pressHandled = true;
591 break;
592 case Qt::Key::Key_Left:
593 BackwardSelection();
594 pressHandled = true;
595 break;
596 default:
597 break;

Callers 1

keyPressEventMethod · 0.80

Calls 5

isValidAddressMethod · 0.80
UpdateSelectedAddressMethod · 0.80
BackwardSelectionMethod · 0.80
Write8Method · 0.45
updateMethod · 0.45

Tested by

no test coverage detected