Working WASD in citra_qt
This commit is contained in:
parent
85f31fdfc5
commit
4865be9cef
3 changed files with 46 additions and 2 deletions
|
@ -7,6 +7,7 @@
|
|||
#include "core/core.h"
|
||||
#include "core/loader.h"
|
||||
#include "core/hw/hw.h"
|
||||
#include "core/hw/user_input.h"
|
||||
|
||||
#include "video_core/video_core.h"
|
||||
|
||||
|
@ -119,6 +120,8 @@ GRenderWindow::GRenderWindow(QWidget* parent) : QWidget(parent), emu_thread(this
|
|||
setLayout(layout);
|
||||
|
||||
BackupGeometry();
|
||||
|
||||
buttonReg = 0x0;
|
||||
}
|
||||
|
||||
GRenderWindow::~GRenderWindow()
|
||||
|
@ -198,6 +201,25 @@ void GRenderWindow::keyPressEvent(QKeyEvent* event)
|
|||
if (!key_processed)
|
||||
QWidget::keyPressEvent(event);
|
||||
*/
|
||||
|
||||
|
||||
if (event->key() == Qt::Key_W)
|
||||
{
|
||||
buttonReg |= USER_INPUT::PAD_UP;
|
||||
}
|
||||
else if (event->key() == Qt::Key_A)
|
||||
{
|
||||
buttonReg |= USER_INPUT::PAD_LEFT;
|
||||
}
|
||||
else if (event->key() == Qt::Key_S)
|
||||
{
|
||||
buttonReg |= USER_INPUT::PAD_DOWN;
|
||||
}
|
||||
else if (event->key() == Qt::Key_D)
|
||||
{
|
||||
buttonReg |= USER_INPUT::PAD_RIGHT;
|
||||
}
|
||||
USER_INPUT::setButtonReg(buttonReg);
|
||||
}
|
||||
|
||||
void GRenderWindow::keyReleaseEvent(QKeyEvent* event)
|
||||
|
@ -211,4 +233,23 @@ void GRenderWindow::keyReleaseEvent(QKeyEvent* event)
|
|||
if (!key_processed)
|
||||
QWidget::keyPressEvent(event);
|
||||
*/
|
||||
|
||||
|
||||
if (event->key() == Qt::Key_W)
|
||||
{
|
||||
buttonReg &= 0xffffffff ^ USER_INPUT::PAD_UP;
|
||||
}
|
||||
else if (event->key() == Qt::Key_A)
|
||||
{
|
||||
buttonReg &= 0xffffffff ^ USER_INPUT::PAD_LEFT;
|
||||
}
|
||||
else if (event->key() == Qt::Key_S)
|
||||
{
|
||||
buttonReg &= 0xffffffff ^ USER_INPUT::PAD_DOWN;
|
||||
}
|
||||
else if (event->key() == Qt::Key_D)
|
||||
{
|
||||
buttonReg &= 0xffffffff ^ USER_INPUT::PAD_RIGHT;
|
||||
}
|
||||
USER_INPUT::setButtonReg(buttonReg);
|
||||
}
|
|
@ -10,7 +10,7 @@ namespace USER_INPUT {
|
|||
|
||||
template <typename T>
|
||||
inline void Write(u32 addr, const T data) {
|
||||
ERROR_LOG(NDMA, "unknown Write%d 0x%08X @ 0x%08X", sizeof(data) * 8, data, addr);
|
||||
ERROR_LOG(USER_INPUT, "unknown Write%d 0x%08X @ 0x%08X", sizeof(data) * 8, data, addr);
|
||||
}
|
||||
|
||||
// Explicitly instantiate template functions because we aren't defining this in the header:
|
||||
|
@ -26,7 +26,7 @@ namespace USER_INPUT {
|
|||
template void Write<u8>(u32 addr, const u8 data);
|
||||
|
||||
void setButtonReg(u32 buttonData) {
|
||||
Write<u32>(PADDR_BUTTONS, buttonData);
|
||||
Memory::Write32(PADDR_BUTTONS, buttonData);
|
||||
}
|
||||
|
||||
/// Update hardware
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#pragma once
|
||||
|
||||
#include "common/common_types.h"
|
||||
#include "core\mem_map.h"
|
||||
|
||||
|
||||
namespace USER_INPUT {
|
||||
|
@ -40,6 +41,8 @@ namespace USER_INPUT {
|
|||
template <typename T>
|
||||
inline void Write(u32 addr, const T data);
|
||||
|
||||
void setButtonReg(u32 buttonData);
|
||||
|
||||
/// Update hardware
|
||||
void Update();
|
||||
|
||||
|
|
Loading…
Reference in a new issue