mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-07-25 00:04:49 +02:00
Polish the new workaround, seems to be nice and simple.
This commit is contained in:
@@ -200,7 +200,7 @@ UI::EventReturn ControlMapper::OnAdd(UI::EventParams ¶ms) {
|
||||
UI::EventReturn ControlMapper::OnAddMouse(UI::EventParams ¶ms) {
|
||||
action_ = ADD;
|
||||
g_Config.bMapMouse = true;
|
||||
scrm_->push(new KeyMappingNewKeyDialog(pspKey_, true, std::bind(&ControlMapper::MappedCallback, this, std::placeholders::_1)));
|
||||
scrm_->push(new KeyMappingNewMouseKeyDialog(pspKey_, true, std::bind(&ControlMapper::MappedCallback, this, std::placeholders::_1)));
|
||||
return UI::EVENT_DONE;
|
||||
}
|
||||
|
||||
@@ -318,7 +318,7 @@ bool KeyMappingNewKeyDialog::key(const KeyInput &key) {
|
||||
if (mapped_)
|
||||
return false;
|
||||
if (key.flags & KEY_DOWN) {
|
||||
if (key.keyCode == NKCODE_EXT_MOUSEBUTTON_1 && !g_Config.bMapMouse) {
|
||||
if (key.keyCode == NKCODE_EXT_MOUSEBUTTON_1) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -331,6 +331,34 @@ bool KeyMappingNewKeyDialog::key(const KeyInput &key) {
|
||||
return true;
|
||||
}
|
||||
|
||||
void KeyMappingNewMouseKeyDialog::CreatePopupContents(UI::ViewGroup *parent) {
|
||||
using namespace UI;
|
||||
|
||||
I18NCategory *km = GetI18NCategory("KeyMapping");
|
||||
|
||||
parent->Add(new TextView(std::string(km->T("You can press ESC to cancel.")), new LinearLayoutParams(Margins(10, 0))));
|
||||
}
|
||||
|
||||
bool KeyMappingNewMouseKeyDialog::key(const KeyInput &key) {
|
||||
if (mapped_)
|
||||
return false;
|
||||
if (key.flags & KEY_DOWN) {
|
||||
if (key.keyCode == NKCODE_ESCAPE) {
|
||||
TriggerFinish(DR_OK);
|
||||
g_Config.bMapMouse = false;
|
||||
return false;
|
||||
}
|
||||
|
||||
mapped_ = true;
|
||||
KeyDef kdf(key.deviceId, key.keyCode);
|
||||
TriggerFinish(DR_OK);
|
||||
g_Config.bMapMouse = false;
|
||||
if (callback_)
|
||||
callback_(kdf);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool IgnoreAxisForMapping(int axis) {
|
||||
switch (axis) {
|
||||
// Ignore the accelerometer for mapping for now.
|
||||
@@ -376,6 +404,30 @@ bool KeyMappingNewKeyDialog::axis(const AxisInput &axis) {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool KeyMappingNewMouseKeyDialog::axis(const AxisInput &axis) {
|
||||
if (mapped_)
|
||||
return false;
|
||||
if (IgnoreAxisForMapping(axis.axisId))
|
||||
return false;
|
||||
|
||||
if (axis.value > AXIS_BIND_THRESHOLD) {
|
||||
mapped_ = true;
|
||||
KeyDef kdf(axis.deviceId, KeyMap::TranslateKeyCodeFromAxis(axis.axisId, 1));
|
||||
TriggerFinish(DR_OK);
|
||||
if (callback_)
|
||||
callback_(kdf);
|
||||
}
|
||||
|
||||
if (axis.value < -AXIS_BIND_THRESHOLD) {
|
||||
mapped_ = true;
|
||||
KeyDef kdf(axis.deviceId, KeyMap::TranslateKeyCodeFromAxis(axis.axisId, -1));
|
||||
TriggerFinish(DR_OK);
|
||||
if (callback_)
|
||||
callback_(kdf);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
class JoystickHistoryView : public UI::InertView {
|
||||
public:
|
||||
JoystickHistoryView(int xAxis, int xDevice, int xDir, int yAxis, int yDevice, int yDir, UI::LayoutParams *layoutParams = nullptr)
|
||||
|
||||
Reference in New Issue
Block a user