X360 controller: Left thumb speedup, right thumb menu, keyboard still works

This commit is contained in:
Henrik Rydgard 2013-03-31 11:30:50 +02:00
parent 9f26334953
commit 2301ad0b7c
10 changed files with 27 additions and 34 deletions

View File

@ -33,7 +33,7 @@ enum GPUCore {
struct CoreParameter
{
CoreParameter() : collectEmuLog(0) {}
CoreParameter() : collectEmuLog(0), unthrottle(false) {}
// 0 = Interpreter
// 1 = Jit
// 2 = JitIL
@ -63,4 +63,7 @@ struct CoreParameter
// Actual pixel output resolution (for use by glViewport and the like)
int pixelWidth;
int pixelHeight;
// Can be modified at runtime.
bool unthrottle;
};

View File

@ -300,11 +300,8 @@ void DebugStats()
// Let's collect all the throttling and frameskipping logic here.
void DoFrameTiming(bool &throttle, bool &skipFrame) {
#ifdef _WIN32
throttle = !GetAsyncKeyState(VK_TAB);
#else
throttle = true;
#endif
throttle = !PSP_CoreParameter().unthrottle;
skipFrame = false;
if (PSP_CoreParameter().headLess)
throttle = false;

View File

@ -207,7 +207,13 @@ void EmuScreen::update(InputState &input) {
__CtrlSetAnalog(stick_x, stick_y);
if (input.pad_buttons_down & (PAD_BUTTON_MENU | PAD_BUTTON_BACK)) {
if (input.pad_buttons & PAD_BUTTON_LEFT_THUMB) {
PSP_CoreParameter().unthrottle = true;
} else {
PSP_CoreParameter().unthrottle = false;
}
if (input.pad_buttons_down & (PAD_BUTTON_MENU | PAD_BUTTON_BACK | PAD_BUTTON_RIGHT_THUMB)) {
if (g_Config.bBufferedRendering)
fbo_unbind();
screenManager()->push(new PauseScreen());

View File

@ -303,7 +303,6 @@ void NativeInit(int argc, const char *argv[], const char *savegame_directory, co
void NativeInitGraphics()
{
INFO_LOG(BOOT, "NativeInitGraphics - should only be called once!");
gl_lost_manager_init();
ui_draw2d.SetAtlas(&ui_atlas);

View File

@ -4,22 +4,8 @@
#include "../Core/HLE/sceCtrl.h"
#include "WinUser.h"
static const unsigned short key_ctrl_map[] = {
VK_SPACE, CTRL_START,
'V', CTRL_SELECT,
'A', CTRL_SQUARE,
'S', CTRL_TRIANGLE,
'X', CTRL_CIRCLE,
'Z', CTRL_CROSS,
'Q', CTRL_LTRIGGER,
'W', CTRL_RTRIGGER,
VK_UP, CTRL_UP,
VK_DOWN, CTRL_DOWN,
VK_LEFT, CTRL_LEFT,
VK_RIGHT, CTRL_RIGHT,
};
static const unsigned short key_pad_map[] = {
static const unsigned int key_pad_map[] = {
VK_TAB, PAD_BUTTON_LEFT_THUMB,
VK_SPACE, PAD_BUTTON_START,
'V', PAD_BUTTON_SELECT,
'A', PAD_BUTTON_X,
@ -46,7 +32,7 @@ int KeyboardDevice::UpdateState(InputState &input_state) {
static u32 alternator = 0;
bool doAlternate = alternate && (alternator++ % 10) < 5;
for (int i = 0; i < sizeof(key_ctrl_map)/sizeof(key_ctrl_map[0]); i += 2) {
for (int i = 0; i < sizeof(key_pad_map)/sizeof(key_pad_map[0]); i += 2) {
if (GetAsyncKeyState(key_pad_map[i]) && !doAlternate) {
input_state.pad_buttons |= key_pad_map[i+1];
}

View File

@ -132,8 +132,7 @@ void WindowsHost::SetDebugMode(bool mode)
void WindowsHost::PollControllers(InputState &input_state)
{
for (auto iter = this->input.begin(); iter != this->input.end(); iter++)
if ((*iter)->UpdateState(input_state) == 0)
break; // *iter is std::shared_ptr, **iter is InputDevice
(*iter)->UpdateState(input_state);
}
void WindowsHost::BootDone()

View File

@ -85,7 +85,9 @@ static Stick NormalizedDeadzoneFilter(short x, short y) {
return left;
}
static const unsigned short xinput_ctrl_map[] = {
// Yes, this maps more than the PSP has, but that's fine as this lets us
// map buttons to extra functionality like speedup.
static const unsigned int xinput_ctrl_map[] = {
XINPUT_GAMEPAD_DPAD_UP, PAD_BUTTON_UP,
XINPUT_GAMEPAD_DPAD_DOWN, PAD_BUTTON_DOWN,
XINPUT_GAMEPAD_DPAD_LEFT, PAD_BUTTON_LEFT,
@ -98,7 +100,10 @@ static const unsigned short xinput_ctrl_map[] = {
XINPUT_GAMEPAD_B, PAD_BUTTON_B,
XINPUT_GAMEPAD_X, PAD_BUTTON_X,
XINPUT_GAMEPAD_Y, PAD_BUTTON_Y,
XINPUT_GAMEPAD_LEFT_THUMB, PAD_BUTTON_LEFT_THUMB,
XINPUT_GAMEPAD_RIGHT_THUMB, PAD_BUTTON_RIGHT_THUMB,
};
static inline u32 CtrlForXinput(int xinput) {
for (int i = 0; i < sizeof(xinput_ctrl_map)/sizeof(xinput_ctrl_map[0]); i += 2)
if (xinput_ctrl_map[i] == xinput) return (u32) xinput_ctrl_map[i+1];
@ -106,11 +111,8 @@ static inline u32 CtrlForXinput(int xinput) {
}
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)
if (state.Gamepad.wButtons & i)
input_state.pad_buttons |= CtrlForXinput(i);
}
}

View File

@ -70,6 +70,7 @@ void RunTests()
coreParam.pixelHeight = 272;
coreParam.useMediaEngine = false;
coreParam.collectEmuLog = &output;
coreParam.unthrottle = true;
#ifdef IOS
std::string baseDirectory = g_Config.flashDirectory + "../";

View File

@ -16,4 +16,4 @@ public class PpssppActivity extends NativeActivity {
return false;
}
}

2
native

@ -1 +1 @@
Subproject commit 22e648bb1a5e8fe6e427efc906194edbb9ce6ed8
Subproject commit 79e14282ecf006caef6fe12d19358952741ad7fc