mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-04-16 14:42:52 +00:00
[Android] Fix gamepad input.
This commit is contained in:
parent
c21003feab
commit
50df037bb5
@ -53,10 +53,10 @@
|
|||||||
<string name="input_overlay_layout">入力オーバーレイレイアウト</string>
|
<string name="input_overlay_layout">入力オーバーレイレイアウト</string>
|
||||||
<string name="input_overlay_layout_desc">入力オーバーレイのためのボタンのレイアウト。</string>
|
<string name="input_overlay_layout_desc">入力オーバーレイのためのボタンのレイアウト。</string>
|
||||||
<string name="gamecube_bindings">ゲームキューブコントローラの入力バインディング</string>
|
<string name="gamecube_bindings">ゲームキューブコントローラの入力バインディング</string>
|
||||||
<string name="controller_1">コントローラ1</string>
|
<string name="controller_0">コントローラ1</string>
|
||||||
<string name="controller_2">コントローラ2</string>
|
<string name="controller_1">コントローラ2</string>
|
||||||
<string name="controller_3">コントローラ3</string>
|
<string name="controller_2">コントローラ3</string>
|
||||||
<string name="controller_4">コントローラ4</string>
|
<string name="controller_3">コントローラ4</string>
|
||||||
<string name="enable_controller">コントローラを有効</string>
|
<string name="enable_controller">コントローラを有効</string>
|
||||||
<string name="wiimote_bindings">Wiiリモコンの入力バインディング</string>
|
<string name="wiimote_bindings">Wiiリモコンの入力バインディング</string>
|
||||||
<string name="wiimote_1">Wiiリモコン1</string>
|
<string name="wiimote_1">Wiiリモコン1</string>
|
||||||
|
@ -53,10 +53,10 @@
|
|||||||
<string name="input_overlay_layout">Input Overlay Layout</string>
|
<string name="input_overlay_layout">Input Overlay Layout</string>
|
||||||
<string name="input_overlay_layout_desc">Button layout for the input overlay.</string>
|
<string name="input_overlay_layout_desc">Button layout for the input overlay.</string>
|
||||||
<string name="gamecube_bindings">Gamecube Controller Bindings</string>
|
<string name="gamecube_bindings">Gamecube Controller Bindings</string>
|
||||||
<string name="controller_1">Controller 1</string>
|
<string name="controller_0">Controller 1</string>
|
||||||
<string name="controller_2">Controller 2</string>
|
<string name="controller_1">Controller 2</string>
|
||||||
<string name="controller_3">Controller 3</string>
|
<string name="controller_2">Controller 3</string>
|
||||||
<string name="controller_4">Controller 4</string>
|
<string name="controller_3">Controller 4</string>
|
||||||
<string name="enable_controller">Enable controller</string>
|
<string name="enable_controller">Enable controller</string>
|
||||||
<string name="wiimote_bindings">Wiimote Bindings</string>
|
<string name="wiimote_bindings">Wiimote Bindings</string>
|
||||||
<string name="wiimote_1">Wiimote 1</string>
|
<string name="wiimote_1">Wiimote 1</string>
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -52,7 +52,7 @@ public final class InputConfigFragment extends PreferenceFragment
|
|||||||
"WiimoteDPadUp", "WiimoteDPadDown", "WiimoteDPadLeft", "WiimoteDPadRight"
|
"WiimoteDPadUp", "WiimoteDPadDown", "WiimoteDPadLeft", "WiimoteDPadRight"
|
||||||
};
|
};
|
||||||
|
|
||||||
for (int i = 1; i <= 4; i++)
|
for (int i = 0; i < 4; i++)
|
||||||
{
|
{
|
||||||
// Loop through the keys for all 4 GameCube controllers.
|
// Loop through the keys for all 4 GameCube controllers.
|
||||||
for (String key : gamecubeKeys)
|
for (String key : gamecubeKeys)
|
||||||
|
@ -150,7 +150,7 @@ namespace ButtonManager
|
|||||||
{
|
{
|
||||||
m_axises[std::make_pair(padID, axis)]->SetValue(value);
|
m_axises[std::make_pair(padID, axis)]->SetValue(value);
|
||||||
}
|
}
|
||||||
void GamepadEvent(std::string dev, ButtonType button, int action)
|
void GamepadEvent(std::string dev, int button, int action)
|
||||||
{
|
{
|
||||||
auto it = m_controllers.find(dev);
|
auto it = m_controllers.find(dev);
|
||||||
if (it != m_controllers.end())
|
if (it != m_controllers.end())
|
||||||
@ -161,7 +161,7 @@ namespace ButtonManager
|
|||||||
m_controllers[dev] = new InputDevice(dev);
|
m_controllers[dev] = new InputDevice(dev);
|
||||||
m_controllers[dev]->PressEvent(button, action);
|
m_controllers[dev]->PressEvent(button, action);
|
||||||
}
|
}
|
||||||
void GamepadAxisEvent(std::string dev, ButtonType axis, float value)
|
void GamepadAxisEvent(std::string dev, int axis, float value)
|
||||||
{
|
{
|
||||||
auto it = m_controllers.find(dev);
|
auto it = m_controllers.find(dev);
|
||||||
if (it != m_controllers.end())
|
if (it != m_controllers.end())
|
||||||
@ -183,17 +183,17 @@ namespace ButtonManager
|
|||||||
}
|
}
|
||||||
|
|
||||||
// InputDevice
|
// InputDevice
|
||||||
void InputDevice::PressEvent(ButtonType button, int action)
|
void InputDevice::PressEvent(int button, int action)
|
||||||
{
|
{
|
||||||
if (_binds.find(button) == _binds.end())
|
if (_inputbinds.find(button) == _inputbinds.end())
|
||||||
return;
|
return;
|
||||||
_buttons[_binds[button]->_bind] = action == 0 ? true : false;
|
_buttons[_inputbinds[button]->_buttontype] = action == 0 ? true : false;
|
||||||
}
|
}
|
||||||
void InputDevice::AxisEvent(ButtonType axis, float value)
|
void InputDevice::AxisEvent(int axis, float value)
|
||||||
{
|
{
|
||||||
if (_binds.find(axis) == _binds.end())
|
if (_inputbinds.find(axis) == _inputbinds.end())
|
||||||
return;
|
return;
|
||||||
_axises[_binds[axis]->_bind] = value;
|
_axises[_inputbinds[axis]->_buttontype] = value;
|
||||||
}
|
}
|
||||||
bool InputDevice::ButtonValue(int padID, ButtonType button)
|
bool InputDevice::ButtonValue(int padID, ButtonType button)
|
||||||
{
|
{
|
||||||
@ -203,7 +203,7 @@ namespace ButtonManager
|
|||||||
if (it->second->_padID != padID)
|
if (it->second->_padID != padID)
|
||||||
return false;
|
return false;
|
||||||
if (it->second->_bindtype == BIND_BUTTON)
|
if (it->second->_bindtype == BIND_BUTTON)
|
||||||
return _buttons[it->second->_bind];
|
return _buttons[it->second->_buttontype];
|
||||||
else
|
else
|
||||||
return AxisValue(padID, button);
|
return AxisValue(padID, button);
|
||||||
}
|
}
|
||||||
@ -217,7 +217,7 @@ namespace ButtonManager
|
|||||||
if (it->second->_bindtype == BIND_BUTTON)
|
if (it->second->_bindtype == BIND_BUTTON)
|
||||||
return ButtonValue(padID, axis);
|
return ButtonValue(padID, axis);
|
||||||
else
|
else
|
||||||
return _axises[it->second->_bind] * it->second->_neg;
|
return _axises[it->second->_buttontype] * it->second->_neg;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -99,9 +99,10 @@ namespace ButtonManager
|
|||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
const std::string _dev;
|
const std::string _dev;
|
||||||
std::map<int, bool> _buttons;
|
std::map<ButtonType, bool> _buttons;
|
||||||
std::map<int, float> _axises;
|
std::map<ButtonType, float> _axises;
|
||||||
std::map<ButtonType, sBind*> _binds;
|
std::map<ButtonType, sBind*> _binds;
|
||||||
|
std::map<int, sBind*> _inputbinds;
|
||||||
public:
|
public:
|
||||||
InputDevice(std::string dev)
|
InputDevice(std::string dev)
|
||||||
: _dev(dev) {}
|
: _dev(dev) {}
|
||||||
@ -110,9 +111,9 @@ namespace ButtonManager
|
|||||||
for (auto it = _binds.begin(); it != _binds.end(); ++it)
|
for (auto it = _binds.begin(); it != _binds.end(); ++it)
|
||||||
delete it->second;
|
delete it->second;
|
||||||
}
|
}
|
||||||
void AddBind(sBind *bind) { _binds[bind->_buttontype] = bind; }
|
void AddBind(sBind *bind) { _binds[bind->_buttontype] = bind; _inputbinds[bind->_bind] = bind; }
|
||||||
void PressEvent(ButtonType button, int action);
|
void PressEvent(int button, int action);
|
||||||
void AxisEvent(ButtonType axis, float value);
|
void AxisEvent(int axis, float value);
|
||||||
bool ButtonValue(int padID, ButtonType button);
|
bool ButtonValue(int padID, ButtonType button);
|
||||||
float AxisValue(int padID, ButtonType axis);
|
float AxisValue(int padID, ButtonType axis);
|
||||||
};
|
};
|
||||||
@ -122,7 +123,7 @@ namespace ButtonManager
|
|||||||
float GetAxisValue(int padID, ButtonType axis);
|
float GetAxisValue(int padID, ButtonType axis);
|
||||||
void TouchEvent(int padID, ButtonType button, int action);
|
void TouchEvent(int padID, ButtonType button, int action);
|
||||||
void TouchAxisEvent(int padID, ButtonType axis, float value);
|
void TouchAxisEvent(int padID, ButtonType axis, float value);
|
||||||
void GamepadEvent(std::string dev, ButtonType button, int action);
|
void GamepadEvent(std::string dev, int button, int action);
|
||||||
void GamepadAxisEvent(std::string dev, ButtonType axis, float value);
|
void GamepadAxisEvent(std::string dev, int axis, float value);
|
||||||
void Shutdown();
|
void Shutdown();
|
||||||
}
|
}
|
||||||
|
@ -249,14 +249,14 @@ JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_onGamePadEve
|
|||||||
{
|
{
|
||||||
const char *Device = env->GetStringUTFChars(jDevice, NULL);
|
const char *Device = env->GetStringUTFChars(jDevice, NULL);
|
||||||
std::string strDevice = std::string(Device);
|
std::string strDevice = std::string(Device);
|
||||||
ButtonManager::GamepadEvent(strDevice, (ButtonManager::ButtonType)Button, Action);
|
ButtonManager::GamepadEvent(strDevice, Button, Action);
|
||||||
env->ReleaseStringUTFChars(jDevice, Device);
|
env->ReleaseStringUTFChars(jDevice, Device);
|
||||||
}
|
}
|
||||||
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_onGamePadMoveEvent(JNIEnv *env, jobject obj, jstring jDevice, jint Axis, jfloat Value)
|
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_onGamePadMoveEvent(JNIEnv *env, jobject obj, jstring jDevice, jint Axis, jfloat Value)
|
||||||
{
|
{
|
||||||
const char *Device = env->GetStringUTFChars(jDevice, NULL);
|
const char *Device = env->GetStringUTFChars(jDevice, NULL);
|
||||||
std::string strDevice = std::string(Device);
|
std::string strDevice = std::string(Device);
|
||||||
ButtonManager::GamepadAxisEvent(strDevice, (ButtonManager::ButtonType)Axis, Value);
|
ButtonManager::GamepadAxisEvent(strDevice, Axis, Value);
|
||||||
env->ReleaseStringUTFChars(jDevice, Device);
|
env->ReleaseStringUTFChars(jDevice, Device);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user