mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-01-19 12:22:32 +00:00
Some work towards better control handling, includes stickyfix from native
This commit is contained in:
parent
33abcdafd6
commit
afa21588d7
@ -104,14 +104,18 @@ void Core_RunLoop()
|
||||
UpdateScreenScale();
|
||||
{
|
||||
{
|
||||
lock_guard guard(input_state.lock);
|
||||
#ifdef _WIN32
|
||||
lock_guard guard(input_state.lock);
|
||||
input_state.pad_buttons = 0;
|
||||
input_state.pad_lstick_x = 0;
|
||||
input_state.pad_lstick_y = 0;
|
||||
// Temporary hack.
|
||||
if (GetAsyncKeyState(VK_ESCAPE)) {
|
||||
input_state.pad_buttons |= PAD_BUTTON_MENU;
|
||||
} else {
|
||||
input_state.pad_buttons &= ~PAD_BUTTON_MENU;
|
||||
}
|
||||
host->PollControllers(input_state);
|
||||
#endif
|
||||
}
|
||||
NativeUpdate(input_state);
|
||||
|
@ -444,9 +444,6 @@ void hleEnterVblank(u64 userdata, int cyclesLate) {
|
||||
|
||||
void hleAfterFlip(u64 userdata, int cyclesLate)
|
||||
{
|
||||
// This checks input on PC. Fine to do even if not calling BeginFrame.
|
||||
host->BeginFrame();
|
||||
|
||||
gpu->BeginFrame(); // doesn't really matter if begin or end of frame.
|
||||
}
|
||||
|
||||
|
@ -21,6 +21,8 @@
|
||||
#include <string>
|
||||
#include "../Globals.h"
|
||||
|
||||
struct InputState;
|
||||
|
||||
class PMixer
|
||||
{
|
||||
public:
|
||||
@ -48,6 +50,7 @@ public:
|
||||
virtual void InitSound(PMixer *mixer) = 0;
|
||||
virtual void UpdateSound() {}
|
||||
virtual void ShutdownSound() = 0;
|
||||
virtual void PollControllers(InputState &input_state) {}
|
||||
|
||||
//this is sent from EMU thread! Make sure that Host handles it properly!
|
||||
virtual void BootDone() {}
|
||||
|
@ -112,7 +112,6 @@ public:
|
||||
virtual void SetDebugMode(bool mode) { }
|
||||
|
||||
virtual bool InitGL(std::string *error_message) { return true; }
|
||||
virtual void BeginFrame() {}
|
||||
virtual void ShutdownGL() {}
|
||||
|
||||
virtual void InitSound(PMixer *mixer);
|
||||
|
@ -1,14 +1,17 @@
|
||||
#pragma once
|
||||
|
||||
#include <list>
|
||||
#include <memory>
|
||||
|
||||
#include "../Common/CommonTypes.h"
|
||||
#include "../Core/HLE/sceCtrl.h"
|
||||
|
||||
#pragma once
|
||||
struct InputState;
|
||||
|
||||
class InputDevice
|
||||
{
|
||||
public:
|
||||
virtual int UpdateState() = 0;
|
||||
virtual int UpdateState(InputState &input_state) = 0;
|
||||
};
|
||||
|
||||
#include <windows.h>
|
||||
#include <list>
|
||||
#include <memory>
|
||||
std::list<std::shared_ptr<InputDevice>> getInputDevices();
|
||||
|
@ -1,3 +1,4 @@
|
||||
#include "input/input_state.h"
|
||||
#include "KeyboardDevice.h"
|
||||
#include "../Common/CommonTypes.h"
|
||||
#include "../Core/HLE/sceCtrl.h"
|
||||
@ -18,6 +19,21 @@ static const unsigned short key_ctrl_map[] = {
|
||||
VK_RIGHT, CTRL_RIGHT,
|
||||
};
|
||||
|
||||
static const unsigned short key_pad_map[] = {
|
||||
VK_SPACE, PAD_BUTTON_START,
|
||||
'V', PAD_BUTTON_SELECT,
|
||||
'A', PAD_BUTTON_X,
|
||||
'S', PAD_BUTTON_Y,
|
||||
'X', PAD_BUTTON_B,
|
||||
'Z', PAD_BUTTON_A,
|
||||
'Q', PAD_BUTTON_LBUMPER,
|
||||
'W', PAD_BUTTON_RBUMPER,
|
||||
VK_UP, PAD_BUTTON_UP,
|
||||
VK_DOWN, PAD_BUTTON_DOWN,
|
||||
VK_LEFT, PAD_BUTTON_LEFT,
|
||||
VK_RIGHT, PAD_BUTTON_RIGHT,
|
||||
};
|
||||
|
||||
static const unsigned short analog_ctrl_map[] = {
|
||||
'I', CTRL_UP,
|
||||
'K', CTRL_DOWN,
|
||||
@ -25,7 +41,7 @@ static const unsigned short analog_ctrl_map[] = {
|
||||
'L', CTRL_RIGHT,
|
||||
};
|
||||
|
||||
int KeyboardDevice::UpdateState() {
|
||||
int KeyboardDevice::UpdateState(InputState &input_state) {
|
||||
bool alternate = GetAsyncKeyState(VK_SHIFT) != 0;
|
||||
static u32 alternator = 0;
|
||||
bool doAlternate = alternate && (alternator++ % 10) < 5;
|
||||
@ -33,9 +49,11 @@ int KeyboardDevice::UpdateState() {
|
||||
for (int i = 0; i < sizeof(key_ctrl_map)/sizeof(key_ctrl_map[0]); i += 2) {
|
||||
if (!GetAsyncKeyState(key_ctrl_map[i]) || doAlternate)
|
||||
__CtrlButtonUp(key_ctrl_map[i+1]);
|
||||
else {
|
||||
else
|
||||
__CtrlButtonDown(key_ctrl_map[i+1]);
|
||||
}
|
||||
|
||||
//if (GetAsyncKeyState(key_pad_map[i]) && !doAlternate)
|
||||
// input_state.pad_buttons |= key_pad_map[i+1];
|
||||
}
|
||||
|
||||
float analogX = 0;
|
||||
@ -61,6 +79,8 @@ int KeyboardDevice::UpdateState() {
|
||||
}
|
||||
}
|
||||
|
||||
__CtrlSetAnalog(analogX, analogY);
|
||||
// __CtrlSetAnalog(analogX, analogY);
|
||||
input_state.pad_lstick_x = analogX;
|
||||
input_state.pad_lstick_y = analogY;
|
||||
return 0;
|
||||
}
|
@ -3,5 +3,5 @@
|
||||
|
||||
class KeyboardDevice : public InputDevice {
|
||||
public:
|
||||
virtual int UpdateState();
|
||||
virtual int UpdateState(InputState &input_state);
|
||||
};
|
||||
|
@ -129,10 +129,10 @@ void WindowsHost::SetDebugMode(bool mode)
|
||||
}
|
||||
|
||||
|
||||
void WindowsHost::BeginFrame()
|
||||
void WindowsHost::PollControllers(InputState &input_state)
|
||||
{
|
||||
for (auto iter = this->input.begin(); iter != this->input.end(); iter++)
|
||||
if ((*iter)->UpdateState() == 0)
|
||||
if ((*iter)->UpdateState(input_state) == 0)
|
||||
break; // *iter is std::shared_ptr, **iter is InputDevice
|
||||
}
|
||||
|
||||
|
@ -37,7 +37,7 @@ public:
|
||||
void AddSymbol(std::string name, u32 addr, u32 size, int type);
|
||||
|
||||
bool InitGL(std::string *error_message);
|
||||
void BeginFrame();
|
||||
void PollControllers(InputState &input_state);
|
||||
void ShutdownGL();
|
||||
|
||||
void InitSound(PMixer *mixer);
|
||||
|
@ -1,7 +1,6 @@
|
||||
#include "stdafx.h"
|
||||
#include "XinputDevice.h"
|
||||
#include <limits.h>
|
||||
#include <iostream>
|
||||
|
||||
#include "XinputDevice.h"
|
||||
|
||||
#ifndef XUSER_MAX_COUNT
|
||||
#define XUSER_MAX_COUNT 4
|
||||
@ -19,7 +18,7 @@ struct Stick {
|
||||
};
|
||||
static Stick NormalizedDeadzoneFilter(XINPUT_STATE &state);
|
||||
|
||||
int XinputDevice::UpdateState() {
|
||||
int XinputDevice::UpdateState(InputState &input_state) {
|
||||
if (this->check_delay-- > 0) return -1;
|
||||
XINPUT_STATE state;
|
||||
ZeroMemory( &state, sizeof(XINPUT_STATE) );
|
||||
|
@ -7,7 +7,7 @@ class XinputDevice :
|
||||
{
|
||||
public:
|
||||
XinputDevice();
|
||||
virtual int UpdateState();
|
||||
virtual int UpdateState(InputState &input_state);
|
||||
private:
|
||||
void ApplyDiff(XINPUT_STATE &state);
|
||||
int gamepad_idx;
|
||||
|
@ -34,7 +34,6 @@ public:
|
||||
virtual void SetDebugMode(bool mode) { }
|
||||
|
||||
virtual bool InitGL(std::string *error_message) {return true;}
|
||||
virtual void BeginFrame() {}
|
||||
virtual void ShutdownGL() {}
|
||||
|
||||
virtual void InitSound(PMixer *mixer) {}
|
||||
|
@ -213,11 +213,6 @@ bool WindowsHeadlessHost::ResizeGL()
|
||||
return true;
|
||||
}
|
||||
|
||||
void WindowsHeadlessHost::BeginFrame()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void WindowsHeadlessHost::SwapBuffers()
|
||||
{
|
||||
::SwapBuffers(hDC);
|
||||
|
@ -29,7 +29,6 @@ class WindowsHeadlessHost : public HeadlessHost
|
||||
{
|
||||
public:
|
||||
virtual void InitGL();
|
||||
virtual void BeginFrame();
|
||||
virtual void ShutdownGL();
|
||||
virtual bool isGLWorking() { return glOkay; }
|
||||
|
||||
|
2
native
2
native
@ -1 +1 @@
|
||||
Subproject commit 34c4700adb67b405fe7b1f6804cca41d49eb165e
|
||||
Subproject commit 435392b137e7c80ff40db8b2af2feac6019f970e
|
Loading…
x
Reference in New Issue
Block a user