mirror of
https://github.com/hrydgard/ppsspp.git
synced 2024-11-23 13:30:02 +00:00
More work on control
This commit is contained in:
parent
afa21588d7
commit
634e324975
@ -112,13 +112,13 @@ void Core_RunLoop()
|
||||
// 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);
|
||||
UpdateInputState(&input_state);
|
||||
#endif
|
||||
}
|
||||
NativeUpdate(input_state);
|
||||
EndInputState(&input_state);
|
||||
}
|
||||
NativeRender();
|
||||
// Simple throttling to not burn the GPU in the menu.
|
||||
|
@ -169,7 +169,9 @@ void EmuScreen::update(InputState &input) {
|
||||
return;
|
||||
|
||||
// First translate touches into native pad input.
|
||||
if (g_Config.bShowTouchControls)
|
||||
UpdateGamepad(input);
|
||||
|
||||
UpdateInputState(&input);
|
||||
|
||||
// Then translate pad input into PSP pad input. Also, add in tilt.
|
||||
|
@ -47,13 +47,9 @@ int KeyboardDevice::UpdateState(InputState &input_state) {
|
||||
bool doAlternate = alternate && (alternator++ % 10) < 5;
|
||||
|
||||
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
|
||||
__CtrlButtonDown(key_ctrl_map[i+1]);
|
||||
|
||||
//if (GetAsyncKeyState(key_pad_map[i]) && !doAlternate)
|
||||
// input_state.pad_buttons |= key_pad_map[i+1];
|
||||
if (GetAsyncKeyState(key_pad_map[i]) && !doAlternate) {
|
||||
input_state.pad_buttons |= key_pad_map[i+1];
|
||||
}
|
||||
}
|
||||
|
||||
float analogX = 0;
|
||||
@ -79,8 +75,7 @@ int KeyboardDevice::UpdateState(InputState &input_state) {
|
||||
}
|
||||
}
|
||||
|
||||
// __CtrlSetAnalog(analogX, analogY);
|
||||
input_state.pad_lstick_x = analogX;
|
||||
input_state.pad_lstick_y = analogY;
|
||||
input_state.pad_lstick_x += analogX;
|
||||
input_state.pad_lstick_y += analogY;
|
||||
return 0;
|
||||
}
|
@ -108,14 +108,18 @@ namespace MainWindow
|
||||
|
||||
void GetWindowRectAtZoom(int zoom, RECT &rcInner, RECT &rcOuter) {
|
||||
// GetWindowRect(hwndMain, &rcInner);
|
||||
rcInner.left = g_Config.iWindowX;
|
||||
rcInner.top = g_Config.iWindowY;
|
||||
rcInner.left = 0;
|
||||
rcInner.top = 0;
|
||||
|
||||
rcInner.right=480*zoom + rcInner.left;//+client edge
|
||||
rcInner.bottom=272*zoom + rcInner.top; //+client edge
|
||||
rcInner.right=480*zoom;//+client edge
|
||||
rcInner.bottom=272*zoom; //+client edge
|
||||
|
||||
rcOuter=rcInner;
|
||||
AdjustWindowRect(&rcOuter, WS_OVERLAPPEDWINDOW, TRUE);
|
||||
rcOuter.right += g_Config.iWindowX - rcOuter.left;
|
||||
rcOuter.bottom += g_Config.iWindowY - rcOuter.top;
|
||||
rcOuter.left = g_Config.iWindowX;
|
||||
rcOuter.top = g_Config.iWindowY;
|
||||
}
|
||||
|
||||
void SavePosition() {
|
||||
|
@ -1,6 +1,6 @@
|
||||
#include <limits.h>
|
||||
|
||||
#include "XinputDevice.h"
|
||||
#include "input/input_state.h"
|
||||
|
||||
#ifndef XUSER_MAX_COUNT
|
||||
#define XUSER_MAX_COUNT 4
|
||||
@ -16,7 +16,7 @@ struct Stick {
|
||||
float x;
|
||||
float y;
|
||||
};
|
||||
static Stick NormalizedDeadzoneFilter(XINPUT_STATE &state);
|
||||
static Stick NormalizedDeadzoneFilter(short x, short y);
|
||||
|
||||
int XinputDevice::UpdateState(InputState &input_state) {
|
||||
if (this->check_delay-- > 0) return -1;
|
||||
@ -38,9 +38,13 @@ int XinputDevice::UpdateState(InputState &input_state) {
|
||||
}
|
||||
|
||||
if ( dwResult == ERROR_SUCCESS ) {
|
||||
this->ApplyDiff(state);
|
||||
Stick left = NormalizedDeadzoneFilter(state);
|
||||
__CtrlSetAnalog(left.x, left.y);
|
||||
ApplyDiff(state, input_state);
|
||||
Stick left = NormalizedDeadzoneFilter(state.Gamepad.sThumbLX, state.Gamepad.sThumbLY);
|
||||
Stick right = NormalizedDeadzoneFilter(state.Gamepad.sThumbRX, state.Gamepad.sThumbRY);
|
||||
input_state.pad_lstick_x += left.x;
|
||||
input_state.pad_lstick_y += left.y;
|
||||
input_state.pad_rstick_x += right.x;
|
||||
input_state.pad_rstick_y += right.y;
|
||||
this->prevState = state;
|
||||
this->check_delay = 0;
|
||||
return 0;
|
||||
@ -53,11 +57,11 @@ int XinputDevice::UpdateState(InputState &input_state) {
|
||||
}
|
||||
|
||||
// We only filter the left stick since PSP has no analog triggers or right stick
|
||||
static Stick NormalizedDeadzoneFilter(XINPUT_STATE &state) {
|
||||
static Stick NormalizedDeadzoneFilter(short x, short y) {
|
||||
static const short DEADZONE = XINPUT_GAMEPAD_LEFT_THUMB_DEADZONE;
|
||||
Stick left;
|
||||
left.x = state.Gamepad.sThumbLX;
|
||||
left.y = state.Gamepad.sThumbLY;
|
||||
left.x = x;
|
||||
left.y = y;
|
||||
|
||||
float magnitude = sqrt(left.x*left.x + left.y*left.y);
|
||||
|
||||
@ -82,18 +86,18 @@ static Stick NormalizedDeadzoneFilter(XINPUT_STATE &state) {
|
||||
}
|
||||
|
||||
static const unsigned short xinput_ctrl_map[] = {
|
||||
XINPUT_GAMEPAD_DPAD_UP, CTRL_UP,
|
||||
XINPUT_GAMEPAD_DPAD_DOWN, CTRL_DOWN,
|
||||
XINPUT_GAMEPAD_DPAD_LEFT, CTRL_LEFT,
|
||||
XINPUT_GAMEPAD_DPAD_RIGHT, CTRL_RIGHT,
|
||||
XINPUT_GAMEPAD_START, CTRL_START,
|
||||
XINPUT_GAMEPAD_BACK, CTRL_SELECT,
|
||||
XINPUT_GAMEPAD_LEFT_SHOULDER, CTRL_LTRIGGER,
|
||||
XINPUT_GAMEPAD_RIGHT_SHOULDER, CTRL_RTRIGGER,
|
||||
XINPUT_GAMEPAD_A, CTRL_CROSS,
|
||||
XINPUT_GAMEPAD_B, CTRL_CIRCLE,
|
||||
XINPUT_GAMEPAD_X, CTRL_SQUARE,
|
||||
XINPUT_GAMEPAD_Y, CTRL_TRIANGLE,
|
||||
XINPUT_GAMEPAD_DPAD_UP, PAD_BUTTON_UP,
|
||||
XINPUT_GAMEPAD_DPAD_DOWN, PAD_BUTTON_DOWN,
|
||||
XINPUT_GAMEPAD_DPAD_LEFT, PAD_BUTTON_LEFT,
|
||||
XINPUT_GAMEPAD_DPAD_RIGHT, PAD_BUTTON_RIGHT,
|
||||
XINPUT_GAMEPAD_START, PAD_BUTTON_START,
|
||||
XINPUT_GAMEPAD_BACK, PAD_BUTTON_SELECT,
|
||||
XINPUT_GAMEPAD_LEFT_SHOULDER, PAD_BUTTON_LBUMPER,
|
||||
XINPUT_GAMEPAD_RIGHT_SHOULDER, PAD_BUTTON_RBUMPER,
|
||||
XINPUT_GAMEPAD_A, PAD_BUTTON_A,
|
||||
XINPUT_GAMEPAD_B, PAD_BUTTON_B,
|
||||
XINPUT_GAMEPAD_X, PAD_BUTTON_X,
|
||||
XINPUT_GAMEPAD_Y, PAD_BUTTON_Y,
|
||||
};
|
||||
static inline u32 CtrlForXinput(int xinput) {
|
||||
for (int i = 0; i < sizeof(xinput_ctrl_map)/sizeof(xinput_ctrl_map[0]); i += 2)
|
||||
@ -101,14 +105,12 @@ static inline u32 CtrlForXinput(int xinput) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
void XinputDevice::ApplyDiff(XINPUT_STATE &state) {
|
||||
void XinputDevice::ApplyDiff(XINPUT_STATE &state, InputState &input_state) {
|
||||
unsigned short pressed = state.Gamepad.wButtons & ~this->prevState.Gamepad.wButtons;
|
||||
unsigned short released = ~state.Gamepad.wButtons & this->prevState.Gamepad.wButtons;
|
||||
|
||||
for (int i = 1; i < USHRT_MAX; i <<= 1) {
|
||||
if (pressed & i)
|
||||
__CtrlButtonDown(CtrlForXinput(i));
|
||||
if (released & i)
|
||||
__CtrlButtonUp(CtrlForXinput(i));
|
||||
input_state.pad_buttons |= CtrlForXinput(i);
|
||||
}
|
||||
}
|
@ -9,7 +9,7 @@ public:
|
||||
XinputDevice();
|
||||
virtual int UpdateState(InputState &input_state);
|
||||
private:
|
||||
void ApplyDiff(XINPUT_STATE &state);
|
||||
void ApplyDiff(XINPUT_STATE &state, InputState &input_state);
|
||||
int gamepad_idx;
|
||||
int check_delay;
|
||||
XINPUT_STATE prevState;
|
||||
|
2
native
2
native
@ -1 +1 @@
|
||||
Subproject commit 435392b137e7c80ff40db8b2af2feac6019f970e
|
||||
Subproject commit d7a58a31543230acc2c3850cf2523f1e40bf85ec
|
Loading…
Reference in New Issue
Block a user