From 4865be9cef3de9c366ef0769820b933a75f59d97 Mon Sep 17 00:00:00 2001 From: inspuration Date: Thu, 29 May 2014 01:59:09 -0400 Subject: [PATCH] Working WASD in citra_qt --- src/citra_qt/bootmanager.cpp | 41 ++++++++++++++++++++++++++++++++++++ src/core/hw/user_input.cpp | 4 ++-- src/core/hw/user_input.h | 3 +++ 3 files changed, 46 insertions(+), 2 deletions(-) diff --git a/src/citra_qt/bootmanager.cpp b/src/citra_qt/bootmanager.cpp index f85116419..8c5451c08 100644 --- a/src/citra_qt/bootmanager.cpp +++ b/src/citra_qt/bootmanager.cpp @@ -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); } \ No newline at end of file diff --git a/src/core/hw/user_input.cpp b/src/core/hw/user_input.cpp index eee52d096..5cc5c4479 100644 --- a/src/core/hw/user_input.cpp +++ b/src/core/hw/user_input.cpp @@ -10,7 +10,7 @@ namespace USER_INPUT { template 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(u32 addr, const u8 data); void setButtonReg(u32 buttonData) { - Write(PADDR_BUTTONS, buttonData); + Memory::Write32(PADDR_BUTTONS, buttonData); } /// Update hardware diff --git a/src/core/hw/user_input.h b/src/core/hw/user_input.h index f89f9dc85..b21da5815 100644 --- a/src/core/hw/user_input.h +++ b/src/core/hw/user_input.h @@ -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 inline void Write(u32 addr, const T data); + void setButtonReg(u32 buttonData); + /// Update hardware void Update();