mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2024-11-14 13:27:45 -07:00
ControllerInterface/Android: Rip out ButtonManager
ButtonManager is very different from how a normal input backend works, and is making it hard for us to improve controller support on Android. The following commits will add a new input backend in its place.
This commit is contained in:
parent
95ce41ac56
commit
0150f521f7
@ -44,7 +44,7 @@ public final class NativeLibrary
|
||||
}
|
||||
|
||||
/**
|
||||
* Button type for use in onTouchEvent
|
||||
* Button type, for legacy use only
|
||||
*/
|
||||
public static final class ButtonType
|
||||
{
|
||||
|
@ -894,21 +894,8 @@ public final class EmulationActivity extends AppCompatActivity implements ThemeP
|
||||
return super.dispatchKeyEvent(event);
|
||||
}
|
||||
|
||||
int action;
|
||||
|
||||
switch (event.getAction())
|
||||
{
|
||||
case KeyEvent.ACTION_DOWN:
|
||||
action = NativeLibrary.ButtonState.PRESSED;
|
||||
break;
|
||||
case KeyEvent.ACTION_UP:
|
||||
action = NativeLibrary.ButtonState.RELEASED;
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
InputDevice input = event.getDevice();
|
||||
return NativeLibrary.onGamePadEvent(input.getDescriptor(), event.getKeyCode(), action);
|
||||
// TODO
|
||||
return false;
|
||||
}
|
||||
|
||||
private void toggleControls()
|
||||
@ -1271,36 +1258,8 @@ public final class EmulationActivity extends AppCompatActivity implements ThemeP
|
||||
return false;
|
||||
}
|
||||
|
||||
if (((event.getSource() & InputDevice.SOURCE_CLASS_JOYSTICK) == 0))
|
||||
{
|
||||
return super.dispatchGenericMotionEvent(event);
|
||||
}
|
||||
|
||||
// Don't attempt to do anything if we are disconnecting a device.
|
||||
if (event.getActionMasked() == MotionEvent.ACTION_CANCEL)
|
||||
return true;
|
||||
|
||||
InputDevice input = event.getDevice();
|
||||
List<InputDevice.MotionRange> motions = input.getMotionRanges();
|
||||
|
||||
for (InputDevice.MotionRange range : motions)
|
||||
{
|
||||
int axis = range.getAxis();
|
||||
float origValue = event.getAxisValue(axis);
|
||||
float value = ControllerMappingHelper.scaleAxis(input, axis, origValue);
|
||||
// If the input is still in the "flat" area, that means it's really zero.
|
||||
// This is used to compensate for imprecision in joysticks.
|
||||
if (Math.abs(value) > range.getFlat())
|
||||
{
|
||||
NativeLibrary.onGamePadMoveEvent(input.getDescriptor(), axis, value);
|
||||
}
|
||||
else
|
||||
{
|
||||
NativeLibrary.onGamePadMoveEvent(input.getDescriptor(), axis, 0.0f);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
// TODO
|
||||
return false;
|
||||
}
|
||||
|
||||
private void showSubMenu(SaveLoadStateFragment.SaveOrLoad saveOrLoad)
|
||||
|
@ -51,8 +51,6 @@
|
||||
#include "DiscIO/ScrubbedBlob.h"
|
||||
#include "DiscIO/Volume.h"
|
||||
|
||||
#include "InputCommon/ControllerInterface/Android/Android.h"
|
||||
#include "InputCommon/ControllerInterface/Touch/ButtonManager.h"
|
||||
#include "InputCommon/GCAdapter.h"
|
||||
|
||||
#include "UICommon/GameFile.h"
|
||||
@ -293,19 +291,20 @@ Java_org_dolphinemu_dolphinemu_NativeLibrary_IsRunningAndUnpaused(JNIEnv*, jclas
|
||||
JNIEXPORT jboolean JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_onGamePadEvent(
|
||||
JNIEnv* env, jclass, jstring jDevice, jint Button, jint Action)
|
||||
{
|
||||
return ButtonManager::GamepadEvent(GetJString(env, jDevice), Button, Action);
|
||||
// TODO
|
||||
return JNI_FALSE;
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_onGamePadMoveEvent(
|
||||
JNIEnv* env, jclass, jstring jDevice, jint Axis, jfloat Value)
|
||||
{
|
||||
ButtonManager::GamepadAxisEvent(GetJString(env, jDevice), Axis, Value);
|
||||
// TODO
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_SetMotionSensorsEnabled(
|
||||
JNIEnv*, jclass, jboolean accelerometer_enabled, jboolean gyroscope_enabled)
|
||||
{
|
||||
ciface::Android::SetMotionSensorsEnabled(accelerometer_enabled, gyroscope_enabled);
|
||||
// TODO
|
||||
}
|
||||
|
||||
JNIEXPORT jstring JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_GetVersionString(JNIEnv* env,
|
||||
@ -583,8 +582,6 @@ static void Run(JNIEnv* env, std::unique_ptr<BootParameters>&& boot, bool riivol
|
||||
|
||||
if (BootManager::BootCore(std::move(boot), wsi))
|
||||
{
|
||||
ButtonManager::Init(SConfig::GetInstance().GetGameID());
|
||||
|
||||
static constexpr int WAIT_STEP = 25;
|
||||
while (Core::GetState() == Core::State::Starting)
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(WAIT_STEP));
|
||||
@ -604,7 +601,6 @@ static void Run(JNIEnv* env, std::unique_ptr<BootParameters>&& boot, bool riivol
|
||||
|
||||
s_game_metadata_is_valid = false;
|
||||
Core::Shutdown();
|
||||
ButtonManager::Shutdown();
|
||||
host_identity_guard.unlock();
|
||||
|
||||
env->CallStaticVoidMethod(IDCache::GetNativeLibraryClass(),
|
||||
|
@ -143,12 +143,8 @@ elseif(ANDROID)
|
||||
target_sources(inputcommon PRIVATE
|
||||
ControllerInterface/Android/Android.cpp
|
||||
ControllerInterface/Android/Android.h
|
||||
ControllerInterface/Touch/ButtonManager.cpp
|
||||
ControllerInterface/Touch/ButtonManager.h
|
||||
ControllerInterface/Touch/InputOverrider.cpp
|
||||
ControllerInterface/Touch/InputOverrider.h
|
||||
ControllerInterface/Touch/Touchscreen.cpp
|
||||
ControllerInterface/Touch/Touchscreen.h
|
||||
)
|
||||
endif()
|
||||
|
||||
|
@ -4,29 +4,10 @@
|
||||
#include "InputCommon/ControllerInterface/Android/Android.h"
|
||||
|
||||
#include "InputCommon/ControllerInterface/ControllerInterface.h"
|
||||
#include "InputCommon/ControllerInterface/Touch/Touchscreen.h"
|
||||
|
||||
namespace ciface::Android
|
||||
{
|
||||
static bool s_accelerometer_enabled = false;
|
||||
static bool s_gyroscope_enabled = false;
|
||||
|
||||
void SetMotionSensorsEnabled(bool accelerometer_enabled, bool gyroscope_enabled)
|
||||
{
|
||||
const bool any_changes =
|
||||
s_accelerometer_enabled != accelerometer_enabled || s_gyroscope_enabled != gyroscope_enabled;
|
||||
|
||||
s_accelerometer_enabled = accelerometer_enabled;
|
||||
s_gyroscope_enabled = gyroscope_enabled;
|
||||
|
||||
if (any_changes)
|
||||
g_controller_interface.RefreshDevices();
|
||||
}
|
||||
|
||||
void PopulateDevices()
|
||||
{
|
||||
for (int i = 0; i < 8; ++i)
|
||||
g_controller_interface.AddDevice(std::make_shared<ciface::Touch::Touchscreen>(
|
||||
i, s_accelerometer_enabled, s_gyroscope_enabled));
|
||||
}
|
||||
} // namespace ciface::Android
|
||||
|
@ -5,7 +5,5 @@
|
||||
|
||||
namespace ciface::Android
|
||||
{
|
||||
void SetMotionSensorsEnabled(bool accelerometer_enabled, bool gyroscope_enabled);
|
||||
|
||||
void PopulateDevices();
|
||||
} // namespace ciface::Android
|
||||
|
@ -1,788 +0,0 @@
|
||||
// Copyright 2013 Dolphin Emulator Project
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#include "InputCommon/ControllerInterface/Touch/ButtonManager.h"
|
||||
|
||||
#include <array>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
|
||||
#include "Common/FileUtil.h"
|
||||
#include "Common/IniFile.h"
|
||||
#include "Common/StringUtil.h"
|
||||
#include "Common/Thread.h"
|
||||
|
||||
namespace ButtonManager
|
||||
{
|
||||
namespace
|
||||
{
|
||||
constexpr char TOUCHSCREEN_KEY[] = "Touchscreen";
|
||||
constexpr std::array<const char*, 155> CONFIG_STRINGS{{
|
||||
// GC
|
||||
"InputA",
|
||||
"InputB",
|
||||
"InputStart",
|
||||
"InputX",
|
||||
"InputY",
|
||||
"InputZ",
|
||||
"DPadUp",
|
||||
"DPadDown",
|
||||
"DPadLeft",
|
||||
"DPadRight",
|
||||
"MainUp",
|
||||
"MainDown",
|
||||
"MainLeft",
|
||||
"MainRight",
|
||||
"CStickUp",
|
||||
"CStickDown",
|
||||
"CStickLeft",
|
||||
"CStickRight",
|
||||
"InputL",
|
||||
"InputR",
|
||||
// Wiimote
|
||||
"WiimoteA",
|
||||
"WiimoteB",
|
||||
"WiimoteMinus",
|
||||
"WiimotePlus",
|
||||
"WiimoteHome",
|
||||
"Wiimote1",
|
||||
"Wiimote2",
|
||||
"WiimoteUp",
|
||||
"WiimoteDown",
|
||||
"WiimoteLeft",
|
||||
"WiimoteRight",
|
||||
"IRUp",
|
||||
"IRDown",
|
||||
"IRLeft",
|
||||
"IRRight",
|
||||
"IRForward",
|
||||
"IRBackward",
|
||||
"IRHide",
|
||||
"SwingUp",
|
||||
"SwingDown",
|
||||
"SwingLeft",
|
||||
"SwingRight",
|
||||
"SwingForward",
|
||||
"SwingBackward",
|
||||
"TiltForward",
|
||||
"TiltBackward",
|
||||
"TiltLeft",
|
||||
"TiltRight",
|
||||
"TiltModifier",
|
||||
"ShakeX",
|
||||
"ShakeY",
|
||||
"ShakeZ",
|
||||
// Nunchuk
|
||||
"NunchukC",
|
||||
"NunchukZ",
|
||||
"NunchukUp",
|
||||
"NunchukDown",
|
||||
"NunchukLeft",
|
||||
"NunchukRight",
|
||||
"NunchukSwingUp",
|
||||
"NunchukSwingDown",
|
||||
"NunchukSwingLeft",
|
||||
"NunchukSwingRight",
|
||||
"NunchukSwingForward",
|
||||
"NunchukSwingBackward",
|
||||
"NunchukTiltForward",
|
||||
"NunchukTiltBackward",
|
||||
"NunchukTiltLeft",
|
||||
"NunchukTiltRight",
|
||||
"NunchukTiltModifier",
|
||||
"NunchukShakeX",
|
||||
"NunchukShakeY",
|
||||
"NunchukShakeZ",
|
||||
// Classic
|
||||
"ClassicA",
|
||||
"ClassicB",
|
||||
"ClassicX",
|
||||
"ClassicY",
|
||||
"ClassicMinus",
|
||||
"ClassicPlus",
|
||||
"ClassicHome",
|
||||
"ClassicZL",
|
||||
"ClassicZR",
|
||||
"ClassicUp",
|
||||
"ClassicDown",
|
||||
"ClassicLeft",
|
||||
"ClassicRight",
|
||||
"ClassicLeftStickUp",
|
||||
"ClassicLeftStickDown",
|
||||
"ClassicLeftStickLeft",
|
||||
"ClassicLeftStickRight",
|
||||
"ClassicRightStickUp",
|
||||
"ClassicRightStickDown",
|
||||
"ClassicRightStickLeft",
|
||||
"ClassicRightStickRight",
|
||||
"ClassicTriggerL",
|
||||
"ClassicTriggerR",
|
||||
// Guitar
|
||||
"GuitarMinus",
|
||||
"GuitarPlus",
|
||||
"GuitarGreen",
|
||||
"GuitarRed",
|
||||
"GuitarYellow",
|
||||
"GuitarBlue",
|
||||
"GuitarOrange",
|
||||
"GuitarStrumUp",
|
||||
"GuitarStrumDown",
|
||||
"GuitarUp",
|
||||
"GuitarDown",
|
||||
"GuitarLeft",
|
||||
"GuitarRight",
|
||||
"GuitarWhammy",
|
||||
// Drums
|
||||
"DrumsMinus",
|
||||
"DrumsPlus",
|
||||
"DrumsRed",
|
||||
"DrumsYellow",
|
||||
"DrumsBlue",
|
||||
"DrumsGreen",
|
||||
"DrumsOrange",
|
||||
"DrumsBass",
|
||||
"DrumsUp",
|
||||
"DrumsDown",
|
||||
"DrumsLeft",
|
||||
"DrumsRight",
|
||||
// Turntable
|
||||
"TurntableGreenLeft",
|
||||
"TurntableRedLeft",
|
||||
"TurntableBlueLeft",
|
||||
"TurntableGreenRight",
|
||||
"TurntableRedRight",
|
||||
"TurntableBlueRight",
|
||||
"TurntableMinus",
|
||||
"TurntablePlus",
|
||||
"TurntableHome",
|
||||
"TurntableEuphoria",
|
||||
"TurntableLeftTLeft",
|
||||
"TurntableLeftTRight",
|
||||
"TurntableRightTLeft",
|
||||
"TurntableRightTRight",
|
||||
"TurntableUp",
|
||||
"TurntableDown",
|
||||
"TurntableLeft",
|
||||
"TurntableRight",
|
||||
"TurntableEffDial",
|
||||
"TurntableCrossLeft",
|
||||
"TurntableCrossRight",
|
||||
// Wiimote IMU
|
||||
"WiimoteAccelLeft",
|
||||
"WiimoteAccelRight",
|
||||
"WiimoteAccelForward",
|
||||
"WiimoteAccelBackward",
|
||||
"WiimoteAccelUp",
|
||||
"WiimoteAccelDown",
|
||||
"WiimoteGyroPitchUp",
|
||||
"WiimoteGyroPitchDown",
|
||||
"WiimoteGyroRollLeft",
|
||||
"WiimoteGyroRollRight",
|
||||
"WiimoteGyroYawLeft",
|
||||
"WiimoteGyroYawRight",
|
||||
// Rumble
|
||||
"Rumble",
|
||||
}};
|
||||
|
||||
constexpr std::array<ButtonType, 155> CONFIG_TYPES{{
|
||||
// GC
|
||||
BUTTON_A,
|
||||
BUTTON_B,
|
||||
BUTTON_START,
|
||||
BUTTON_X,
|
||||
BUTTON_Y,
|
||||
BUTTON_Z,
|
||||
BUTTON_UP,
|
||||
BUTTON_DOWN,
|
||||
BUTTON_LEFT,
|
||||
BUTTON_RIGHT,
|
||||
STICK_MAIN_UP,
|
||||
STICK_MAIN_DOWN,
|
||||
STICK_MAIN_LEFT,
|
||||
STICK_MAIN_RIGHT,
|
||||
STICK_C_UP,
|
||||
STICK_C_DOWN,
|
||||
STICK_C_LEFT,
|
||||
STICK_C_RIGHT,
|
||||
TRIGGER_L,
|
||||
TRIGGER_R,
|
||||
// Wiimote
|
||||
WIIMOTE_BUTTON_A,
|
||||
WIIMOTE_BUTTON_B,
|
||||
WIIMOTE_BUTTON_MINUS,
|
||||
WIIMOTE_BUTTON_PLUS,
|
||||
WIIMOTE_BUTTON_HOME,
|
||||
WIIMOTE_BUTTON_1,
|
||||
WIIMOTE_BUTTON_2,
|
||||
WIIMOTE_UP,
|
||||
WIIMOTE_DOWN,
|
||||
WIIMOTE_LEFT,
|
||||
WIIMOTE_RIGHT,
|
||||
WIIMOTE_IR_UP,
|
||||
WIIMOTE_IR_DOWN,
|
||||
WIIMOTE_IR_LEFT,
|
||||
WIIMOTE_IR_RIGHT,
|
||||
WIIMOTE_IR_FORWARD,
|
||||
WIIMOTE_IR_BACKWARD,
|
||||
WIIMOTE_IR_HIDE,
|
||||
WIIMOTE_SWING_UP,
|
||||
WIIMOTE_SWING_DOWN,
|
||||
WIIMOTE_SWING_LEFT,
|
||||
WIIMOTE_SWING_RIGHT,
|
||||
WIIMOTE_SWING_FORWARD,
|
||||
WIIMOTE_SWING_BACKWARD,
|
||||
WIIMOTE_TILT_FORWARD,
|
||||
WIIMOTE_TILT_BACKWARD,
|
||||
WIIMOTE_TILT_LEFT,
|
||||
WIIMOTE_TILT_RIGHT,
|
||||
WIIMOTE_TILT_MODIFIER,
|
||||
WIIMOTE_SHAKE_X,
|
||||
WIIMOTE_SHAKE_Y,
|
||||
WIIMOTE_SHAKE_Z,
|
||||
// Nunchuk
|
||||
NUNCHUK_BUTTON_C,
|
||||
NUNCHUK_BUTTON_Z,
|
||||
NUNCHUK_STICK_UP,
|
||||
NUNCHUK_STICK_DOWN,
|
||||
NUNCHUK_STICK_LEFT,
|
||||
NUNCHUK_STICK_RIGHT,
|
||||
NUNCHUK_SWING_UP,
|
||||
NUNCHUK_SWING_DOWN,
|
||||
NUNCHUK_SWING_LEFT,
|
||||
NUNCHUK_SWING_RIGHT,
|
||||
NUNCHUK_SWING_FORWARD,
|
||||
NUNCHUK_SWING_BACKWARD,
|
||||
NUNCHUK_TILT_FORWARD,
|
||||
NUNCHUK_TILT_BACKWARD,
|
||||
NUNCHUK_TILT_LEFT,
|
||||
NUNCHUK_TILT_RIGHT,
|
||||
NUNCHUK_TILT_MODIFIER,
|
||||
NUNCHUK_SHAKE_X,
|
||||
NUNCHUK_SHAKE_Y,
|
||||
NUNCHUK_SHAKE_Z,
|
||||
// Classic
|
||||
CLASSIC_BUTTON_A,
|
||||
CLASSIC_BUTTON_B,
|
||||
CLASSIC_BUTTON_X,
|
||||
CLASSIC_BUTTON_Y,
|
||||
CLASSIC_BUTTON_MINUS,
|
||||
CLASSIC_BUTTON_PLUS,
|
||||
CLASSIC_BUTTON_HOME,
|
||||
CLASSIC_BUTTON_ZL,
|
||||
CLASSIC_BUTTON_ZR,
|
||||
CLASSIC_DPAD_UP,
|
||||
CLASSIC_DPAD_DOWN,
|
||||
CLASSIC_DPAD_LEFT,
|
||||
CLASSIC_DPAD_RIGHT,
|
||||
CLASSIC_STICK_LEFT_UP,
|
||||
CLASSIC_STICK_LEFT_DOWN,
|
||||
CLASSIC_STICK_LEFT_LEFT,
|
||||
CLASSIC_STICK_LEFT_RIGHT,
|
||||
CLASSIC_STICK_RIGHT_UP,
|
||||
CLASSIC_STICK_RIGHT_DOWN,
|
||||
CLASSIC_STICK_RIGHT_LEFT,
|
||||
CLASSIC_STICK_RIGHT_RIGHT,
|
||||
CLASSIC_TRIGGER_L,
|
||||
CLASSIC_TRIGGER_R,
|
||||
// Guitar
|
||||
GUITAR_BUTTON_MINUS,
|
||||
GUITAR_BUTTON_PLUS,
|
||||
GUITAR_FRET_GREEN,
|
||||
GUITAR_FRET_RED,
|
||||
GUITAR_FRET_YELLOW,
|
||||
GUITAR_FRET_BLUE,
|
||||
GUITAR_FRET_ORANGE,
|
||||
GUITAR_STRUM_UP,
|
||||
GUITAR_STRUM_DOWN,
|
||||
GUITAR_STICK_UP,
|
||||
GUITAR_STICK_DOWN,
|
||||
GUITAR_STICK_LEFT,
|
||||
GUITAR_STICK_RIGHT,
|
||||
GUITAR_WHAMMY_BAR,
|
||||
// Drums
|
||||
DRUMS_BUTTON_MINUS,
|
||||
DRUMS_BUTTON_PLUS,
|
||||
DRUMS_PAD_RED,
|
||||
DRUMS_PAD_YELLOW,
|
||||
DRUMS_PAD_BLUE,
|
||||
DRUMS_PAD_GREEN,
|
||||
DRUMS_PAD_ORANGE,
|
||||
DRUMS_PAD_BASS,
|
||||
DRUMS_STICK_UP,
|
||||
DRUMS_STICK_DOWN,
|
||||
DRUMS_STICK_LEFT,
|
||||
DRUMS_STICK_RIGHT,
|
||||
// Turntable
|
||||
TURNTABLE_BUTTON_GREEN_LEFT,
|
||||
TURNTABLE_BUTTON_RED_LEFT,
|
||||
TURNTABLE_BUTTON_BLUE_LEFT,
|
||||
TURNTABLE_BUTTON_GREEN_RIGHT,
|
||||
TURNTABLE_BUTTON_RED_RIGHT,
|
||||
TURNTABLE_BUTTON_BLUE_RIGHT,
|
||||
TURNTABLE_BUTTON_MINUS,
|
||||
TURNTABLE_BUTTON_PLUS,
|
||||
TURNTABLE_BUTTON_HOME,
|
||||
TURNTABLE_BUTTON_EUPHORIA,
|
||||
TURNTABLE_TABLE_LEFT_LEFT,
|
||||
TURNTABLE_TABLE_LEFT_RIGHT,
|
||||
TURNTABLE_TABLE_RIGHT_LEFT,
|
||||
TURNTABLE_TABLE_RIGHT_RIGHT,
|
||||
TURNTABLE_STICK_UP,
|
||||
TURNTABLE_STICK_DOWN,
|
||||
TURNTABLE_STICK_LEFT,
|
||||
TURNTABLE_STICK_RIGHT,
|
||||
TURNTABLE_EFFECT_DIAL,
|
||||
TURNTABLE_CROSSFADE_LEFT,
|
||||
TURNTABLE_CROSSFADE_RIGHT,
|
||||
// Wiimote IMU
|
||||
WIIMOTE_ACCEL_LEFT,
|
||||
WIIMOTE_ACCEL_RIGHT,
|
||||
WIIMOTE_ACCEL_FORWARD,
|
||||
WIIMOTE_ACCEL_BACKWARD,
|
||||
WIIMOTE_ACCEL_UP,
|
||||
WIIMOTE_ACCEL_DOWN,
|
||||
WIIMOTE_GYRO_PITCH_UP,
|
||||
WIIMOTE_GYRO_PITCH_DOWN,
|
||||
WIIMOTE_GYRO_ROLL_LEFT,
|
||||
WIIMOTE_GYRO_ROLL_RIGHT,
|
||||
WIIMOTE_GYRO_YAW_LEFT,
|
||||
WIIMOTE_GYRO_YAW_RIGHT,
|
||||
// Rumble
|
||||
RUMBLE,
|
||||
}};
|
||||
|
||||
std::unordered_map<std::string, InputDevice*> m_controllers;
|
||||
|
||||
void AddBind(const std::string& dev, sBind* bind)
|
||||
{
|
||||
auto it = m_controllers.find(dev);
|
||||
if (it != m_controllers.end())
|
||||
{
|
||||
it->second->AddBind(bind);
|
||||
return;
|
||||
}
|
||||
m_controllers[dev] = new InputDevice(dev);
|
||||
m_controllers[dev]->AddBind(bind);
|
||||
}
|
||||
} // Anonymous namespace
|
||||
|
||||
void Init(const std::string& game_id)
|
||||
{
|
||||
// Initialize pad 0(gc 1) and pad 4(wii 1) as touch overlay controller
|
||||
for (int a = 0; a < 5; a += 4)
|
||||
{
|
||||
// GC
|
||||
AddBind(TOUCHSCREEN_KEY, new sBind(a, BUTTON_A, BIND_BUTTON, BUTTON_A, 1.0f));
|
||||
AddBind(TOUCHSCREEN_KEY, new sBind(a, BUTTON_B, BIND_BUTTON, BUTTON_B, 1.0f));
|
||||
AddBind(TOUCHSCREEN_KEY, new sBind(a, BUTTON_START, BIND_BUTTON, BUTTON_START, 1.0f));
|
||||
AddBind(TOUCHSCREEN_KEY, new sBind(a, BUTTON_X, BIND_BUTTON, BUTTON_X, 1.0f));
|
||||
AddBind(TOUCHSCREEN_KEY, new sBind(a, BUTTON_Y, BIND_BUTTON, BUTTON_Y, 1.0f));
|
||||
AddBind(TOUCHSCREEN_KEY, new sBind(a, BUTTON_Z, BIND_BUTTON, BUTTON_Z, 1.0f));
|
||||
AddBind(TOUCHSCREEN_KEY, new sBind(a, BUTTON_UP, BIND_BUTTON, BUTTON_UP, 1.0f));
|
||||
AddBind(TOUCHSCREEN_KEY, new sBind(a, BUTTON_DOWN, BIND_BUTTON, BUTTON_DOWN, 1.0f));
|
||||
AddBind(TOUCHSCREEN_KEY, new sBind(a, BUTTON_LEFT, BIND_BUTTON, BUTTON_LEFT, 1.0f));
|
||||
AddBind(TOUCHSCREEN_KEY, new sBind(a, BUTTON_RIGHT, BIND_BUTTON, BUTTON_RIGHT, 1.0f));
|
||||
|
||||
AddBind(TOUCHSCREEN_KEY, new sBind(a, STICK_MAIN_UP, BIND_AXIS, STICK_MAIN_UP, -1.0f));
|
||||
AddBind(TOUCHSCREEN_KEY, new sBind(a, STICK_MAIN_DOWN, BIND_AXIS, STICK_MAIN_DOWN, 1.0f));
|
||||
AddBind(TOUCHSCREEN_KEY, new sBind(a, STICK_MAIN_LEFT, BIND_AXIS, STICK_MAIN_LEFT, -1.0f));
|
||||
AddBind(TOUCHSCREEN_KEY, new sBind(a, STICK_MAIN_RIGHT, BIND_AXIS, STICK_MAIN_RIGHT, 1.0f));
|
||||
AddBind(TOUCHSCREEN_KEY, new sBind(a, STICK_C_UP, BIND_AXIS, STICK_C_UP, -1.0f));
|
||||
AddBind(TOUCHSCREEN_KEY, new sBind(a, STICK_C_DOWN, BIND_AXIS, STICK_C_DOWN, 1.0f));
|
||||
AddBind(TOUCHSCREEN_KEY, new sBind(a, STICK_C_LEFT, BIND_AXIS, STICK_C_LEFT, -1.0f));
|
||||
AddBind(TOUCHSCREEN_KEY, new sBind(a, STICK_C_RIGHT, BIND_AXIS, STICK_C_RIGHT, 1.0f));
|
||||
AddBind(TOUCHSCREEN_KEY, new sBind(a, TRIGGER_L, BIND_AXIS, TRIGGER_L, 1.0f));
|
||||
AddBind(TOUCHSCREEN_KEY, new sBind(a, TRIGGER_R, BIND_AXIS, TRIGGER_R, 1.0f));
|
||||
|
||||
// Wiimote
|
||||
AddBind(TOUCHSCREEN_KEY, new sBind(a, WIIMOTE_BUTTON_A, BIND_BUTTON, WIIMOTE_BUTTON_A, 1.0f));
|
||||
AddBind(TOUCHSCREEN_KEY, new sBind(a, WIIMOTE_BUTTON_B, BIND_BUTTON, WIIMOTE_BUTTON_B, 1.0f));
|
||||
AddBind(TOUCHSCREEN_KEY,
|
||||
new sBind(a, WIIMOTE_BUTTON_MINUS, BIND_BUTTON, WIIMOTE_BUTTON_MINUS, 1.0f));
|
||||
AddBind(TOUCHSCREEN_KEY,
|
||||
new sBind(a, WIIMOTE_BUTTON_PLUS, BIND_BUTTON, WIIMOTE_BUTTON_PLUS, 1.0f));
|
||||
AddBind(TOUCHSCREEN_KEY,
|
||||
new sBind(a, WIIMOTE_BUTTON_HOME, BIND_BUTTON, WIIMOTE_BUTTON_HOME, 1.0f));
|
||||
AddBind(TOUCHSCREEN_KEY, new sBind(a, WIIMOTE_BUTTON_1, BIND_BUTTON, WIIMOTE_BUTTON_1, 1.0f));
|
||||
AddBind(TOUCHSCREEN_KEY, new sBind(a, WIIMOTE_BUTTON_2, BIND_BUTTON, WIIMOTE_BUTTON_2, 1.0f));
|
||||
AddBind(TOUCHSCREEN_KEY, new sBind(a, WIIMOTE_UP, BIND_BUTTON, WIIMOTE_UP, 1.0f));
|
||||
AddBind(TOUCHSCREEN_KEY, new sBind(a, WIIMOTE_DOWN, BIND_BUTTON, WIIMOTE_DOWN, 1.0f));
|
||||
AddBind(TOUCHSCREEN_KEY, new sBind(a, WIIMOTE_LEFT, BIND_BUTTON, WIIMOTE_LEFT, 1.0f));
|
||||
AddBind(TOUCHSCREEN_KEY, new sBind(a, WIIMOTE_RIGHT, BIND_BUTTON, WIIMOTE_RIGHT, 1.0f));
|
||||
AddBind(TOUCHSCREEN_KEY, new sBind(a, WIIMOTE_IR_HIDE, BIND_BUTTON, WIIMOTE_IR_HIDE, 1.0f));
|
||||
AddBind(TOUCHSCREEN_KEY,
|
||||
new sBind(a, WIIMOTE_TILT_MODIFIER, BIND_BUTTON, WIIMOTE_TILT_MODIFIER, 1.0f));
|
||||
AddBind(TOUCHSCREEN_KEY, new sBind(a, WIIMOTE_SHAKE_X, BIND_BUTTON, WIIMOTE_SHAKE_X, 1.0f));
|
||||
AddBind(TOUCHSCREEN_KEY, new sBind(a, WIIMOTE_SHAKE_Y, BIND_BUTTON, WIIMOTE_SHAKE_Y, 1.0f));
|
||||
AddBind(TOUCHSCREEN_KEY, new sBind(a, WIIMOTE_SHAKE_Z, BIND_BUTTON, WIIMOTE_SHAKE_Z, 1.0f));
|
||||
|
||||
AddBind(TOUCHSCREEN_KEY, new sBind(a, WIIMOTE_IR_UP, BIND_AXIS, WIIMOTE_IR_UP, -1.0f));
|
||||
AddBind(TOUCHSCREEN_KEY, new sBind(a, WIIMOTE_IR_DOWN, BIND_AXIS, WIIMOTE_IR_DOWN, 1.0f));
|
||||
AddBind(TOUCHSCREEN_KEY, new sBind(a, WIIMOTE_IR_LEFT, BIND_AXIS, WIIMOTE_IR_LEFT, -1.0f));
|
||||
AddBind(TOUCHSCREEN_KEY, new sBind(a, WIIMOTE_IR_RIGHT, BIND_AXIS, WIIMOTE_IR_RIGHT, 1.0f));
|
||||
AddBind(TOUCHSCREEN_KEY,
|
||||
new sBind(a, WIIMOTE_IR_FORWARD, BIND_AXIS, WIIMOTE_IR_FORWARD, -1.0f));
|
||||
AddBind(TOUCHSCREEN_KEY,
|
||||
new sBind(a, WIIMOTE_IR_BACKWARD, BIND_AXIS, WIIMOTE_IR_BACKWARD, 1.0f));
|
||||
AddBind(TOUCHSCREEN_KEY, new sBind(a, WIIMOTE_SWING_UP, BIND_AXIS, WIIMOTE_SWING_UP, -1.0f));
|
||||
AddBind(TOUCHSCREEN_KEY, new sBind(a, WIIMOTE_SWING_DOWN, BIND_AXIS, WIIMOTE_SWING_DOWN, 1.0f));
|
||||
AddBind(TOUCHSCREEN_KEY,
|
||||
new sBind(a, WIIMOTE_SWING_LEFT, BIND_AXIS, WIIMOTE_SWING_LEFT, -1.0f));
|
||||
AddBind(TOUCHSCREEN_KEY,
|
||||
new sBind(a, WIIMOTE_SWING_RIGHT, BIND_AXIS, WIIMOTE_SWING_RIGHT, 1.0f));
|
||||
AddBind(TOUCHSCREEN_KEY,
|
||||
new sBind(a, WIIMOTE_SWING_FORWARD, BIND_AXIS, WIIMOTE_SWING_FORWARD, -1.0f));
|
||||
AddBind(TOUCHSCREEN_KEY,
|
||||
new sBind(a, WIIMOTE_SWING_BACKWARD, BIND_AXIS, WIIMOTE_SWING_BACKWARD, 1.0f));
|
||||
AddBind(TOUCHSCREEN_KEY,
|
||||
new sBind(a, WIIMOTE_TILT_FORWARD, BIND_AXIS, WIIMOTE_TILT_FORWARD, -1.0f));
|
||||
AddBind(TOUCHSCREEN_KEY,
|
||||
new sBind(a, WIIMOTE_TILT_BACKWARD, BIND_AXIS, WIIMOTE_TILT_BACKWARD, 1.0f));
|
||||
AddBind(TOUCHSCREEN_KEY, new sBind(a, WIIMOTE_TILT_LEFT, BIND_AXIS, WIIMOTE_TILT_LEFT, -1.0f));
|
||||
AddBind(TOUCHSCREEN_KEY, new sBind(a, WIIMOTE_TILT_RIGHT, BIND_AXIS, WIIMOTE_TILT_RIGHT, 1.0f));
|
||||
|
||||
// Wii: Nunchuk
|
||||
AddBind(TOUCHSCREEN_KEY, new sBind(a, NUNCHUK_BUTTON_C, BIND_BUTTON, NUNCHUK_BUTTON_C, 1.0f));
|
||||
AddBind(TOUCHSCREEN_KEY, new sBind(a, NUNCHUK_BUTTON_Z, BIND_BUTTON, NUNCHUK_BUTTON_Z, 1.0f));
|
||||
AddBind(TOUCHSCREEN_KEY,
|
||||
new sBind(a, NUNCHUK_TILT_MODIFIER, BIND_BUTTON, NUNCHUK_TILT_MODIFIER, 1.0f));
|
||||
AddBind(TOUCHSCREEN_KEY, new sBind(a, NUNCHUK_SHAKE_X, BIND_BUTTON, NUNCHUK_SHAKE_X, 1.0f));
|
||||
AddBind(TOUCHSCREEN_KEY, new sBind(a, NUNCHUK_SHAKE_Y, BIND_BUTTON, NUNCHUK_SHAKE_Y, 1.0f));
|
||||
AddBind(TOUCHSCREEN_KEY, new sBind(a, NUNCHUK_SHAKE_Z, BIND_BUTTON, NUNCHUK_SHAKE_Z, 1.0f));
|
||||
|
||||
AddBind(TOUCHSCREEN_KEY, new sBind(a, NUNCHUK_SWING_UP, BIND_AXIS, NUNCHUK_SWING_UP, -1.0f));
|
||||
AddBind(TOUCHSCREEN_KEY, new sBind(a, NUNCHUK_SWING_DOWN, BIND_AXIS, NUNCHUK_SWING_DOWN, 1.0f));
|
||||
AddBind(TOUCHSCREEN_KEY,
|
||||
new sBind(a, NUNCHUK_SWING_LEFT, BIND_AXIS, NUNCHUK_SWING_LEFT, -1.0f));
|
||||
AddBind(TOUCHSCREEN_KEY,
|
||||
new sBind(a, NUNCHUK_SWING_RIGHT, BIND_AXIS, NUNCHUK_SWING_RIGHT, 1.0f));
|
||||
AddBind(TOUCHSCREEN_KEY,
|
||||
new sBind(a, NUNCHUK_SWING_FORWARD, BIND_AXIS, NUNCHUK_SWING_FORWARD, -1.0f));
|
||||
AddBind(TOUCHSCREEN_KEY,
|
||||
new sBind(a, NUNCHUK_SWING_BACKWARD, BIND_BUTTON, NUNCHUK_SWING_BACKWARD, 1.0f));
|
||||
AddBind(TOUCHSCREEN_KEY,
|
||||
new sBind(a, NUNCHUK_TILT_FORWARD, BIND_AXIS, NUNCHUK_TILT_FORWARD, -1.0f));
|
||||
AddBind(TOUCHSCREEN_KEY,
|
||||
new sBind(a, NUNCHUK_TILT_BACKWARD, BIND_AXIS, NUNCHUK_TILT_BACKWARD, 1.0f));
|
||||
AddBind(TOUCHSCREEN_KEY, new sBind(a, NUNCHUK_TILT_LEFT, BIND_AXIS, NUNCHUK_TILT_LEFT, -1.0f));
|
||||
AddBind(TOUCHSCREEN_KEY, new sBind(a, NUNCHUK_TILT_RIGHT, BIND_AXIS, NUNCHUK_TILT_RIGHT, 1.0f));
|
||||
AddBind(TOUCHSCREEN_KEY, new sBind(a, NUNCHUK_STICK_UP, BIND_AXIS, NUNCHUK_STICK_UP, -1.0f));
|
||||
AddBind(TOUCHSCREEN_KEY, new sBind(a, NUNCHUK_STICK_DOWN, BIND_AXIS, NUNCHUK_STICK_DOWN, 1.0f));
|
||||
AddBind(TOUCHSCREEN_KEY,
|
||||
new sBind(a, NUNCHUK_STICK_LEFT, BIND_AXIS, NUNCHUK_STICK_LEFT, -1.0f));
|
||||
AddBind(TOUCHSCREEN_KEY,
|
||||
new sBind(a, NUNCHUK_STICK_RIGHT, BIND_AXIS, NUNCHUK_STICK_RIGHT, 1.0f));
|
||||
|
||||
// Wii: Classic
|
||||
AddBind(TOUCHSCREEN_KEY, new sBind(a, CLASSIC_BUTTON_A, BIND_BUTTON, CLASSIC_BUTTON_A, 1.0f));
|
||||
AddBind(TOUCHSCREEN_KEY, new sBind(a, CLASSIC_BUTTON_B, BIND_BUTTON, CLASSIC_BUTTON_B, 1.0f));
|
||||
AddBind(TOUCHSCREEN_KEY, new sBind(a, CLASSIC_BUTTON_X, BIND_BUTTON, CLASSIC_BUTTON_X, 1.0f));
|
||||
AddBind(TOUCHSCREEN_KEY, new sBind(a, CLASSIC_BUTTON_Y, BIND_BUTTON, CLASSIC_BUTTON_Y, 1.0f));
|
||||
AddBind(TOUCHSCREEN_KEY,
|
||||
new sBind(a, CLASSIC_BUTTON_MINUS, BIND_BUTTON, CLASSIC_BUTTON_MINUS, 1.0f));
|
||||
AddBind(TOUCHSCREEN_KEY,
|
||||
new sBind(a, CLASSIC_BUTTON_PLUS, BIND_BUTTON, CLASSIC_BUTTON_PLUS, 1.0f));
|
||||
AddBind(TOUCHSCREEN_KEY,
|
||||
new sBind(a, CLASSIC_BUTTON_HOME, BIND_BUTTON, CLASSIC_BUTTON_HOME, 1.0f));
|
||||
AddBind(TOUCHSCREEN_KEY, new sBind(a, CLASSIC_BUTTON_ZL, BIND_BUTTON, CLASSIC_BUTTON_ZL, 1.0f));
|
||||
AddBind(TOUCHSCREEN_KEY, new sBind(a, CLASSIC_BUTTON_ZR, BIND_BUTTON, CLASSIC_BUTTON_ZR, 1.0f));
|
||||
AddBind(TOUCHSCREEN_KEY, new sBind(a, CLASSIC_DPAD_UP, BIND_BUTTON, CLASSIC_DPAD_UP, 1.0f));
|
||||
AddBind(TOUCHSCREEN_KEY, new sBind(a, CLASSIC_DPAD_DOWN, BIND_BUTTON, CLASSIC_DPAD_DOWN, 1.0f));
|
||||
AddBind(TOUCHSCREEN_KEY, new sBind(a, CLASSIC_DPAD_LEFT, BIND_BUTTON, CLASSIC_DPAD_LEFT, 1.0f));
|
||||
AddBind(TOUCHSCREEN_KEY,
|
||||
new sBind(a, CLASSIC_DPAD_RIGHT, BIND_BUTTON, CLASSIC_DPAD_RIGHT, 1.0f));
|
||||
|
||||
AddBind(TOUCHSCREEN_KEY,
|
||||
new sBind(a, CLASSIC_STICK_LEFT_UP, BIND_AXIS, CLASSIC_STICK_LEFT_UP, -1.0f));
|
||||
AddBind(TOUCHSCREEN_KEY,
|
||||
new sBind(a, CLASSIC_STICK_LEFT_DOWN, BIND_AXIS, CLASSIC_STICK_LEFT_DOWN, 1.0f));
|
||||
AddBind(TOUCHSCREEN_KEY,
|
||||
new sBind(a, CLASSIC_STICK_LEFT_LEFT, BIND_AXIS, CLASSIC_STICK_LEFT_LEFT, -1.0f));
|
||||
AddBind(TOUCHSCREEN_KEY,
|
||||
new sBind(a, CLASSIC_STICK_LEFT_RIGHT, BIND_AXIS, CLASSIC_STICK_LEFT_RIGHT, 1.0f));
|
||||
AddBind(TOUCHSCREEN_KEY,
|
||||
new sBind(a, CLASSIC_STICK_RIGHT_UP, BIND_AXIS, CLASSIC_STICK_RIGHT_UP, -1.0f));
|
||||
AddBind(TOUCHSCREEN_KEY,
|
||||
new sBind(a, CLASSIC_STICK_RIGHT_DOWN, BIND_AXIS, CLASSIC_STICK_RIGHT_DOWN, 1.0f));
|
||||
AddBind(TOUCHSCREEN_KEY,
|
||||
new sBind(a, CLASSIC_STICK_RIGHT_LEFT, BIND_AXIS, CLASSIC_STICK_RIGHT_LEFT, -1.0f));
|
||||
AddBind(TOUCHSCREEN_KEY,
|
||||
new sBind(a, CLASSIC_STICK_RIGHT_RIGHT, BIND_AXIS, CLASSIC_STICK_RIGHT_RIGHT, 1.0f));
|
||||
AddBind(TOUCHSCREEN_KEY, new sBind(a, CLASSIC_TRIGGER_L, BIND_AXIS, CLASSIC_TRIGGER_L, 1.0f));
|
||||
AddBind(TOUCHSCREEN_KEY, new sBind(a, CLASSIC_TRIGGER_R, BIND_AXIS, CLASSIC_TRIGGER_R, 1.0f));
|
||||
|
||||
// Wii: Guitar
|
||||
AddBind(TOUCHSCREEN_KEY,
|
||||
new sBind(a, GUITAR_BUTTON_MINUS, BIND_BUTTON, GUITAR_BUTTON_MINUS, 1.0f));
|
||||
AddBind(TOUCHSCREEN_KEY,
|
||||
new sBind(a, GUITAR_BUTTON_PLUS, BIND_BUTTON, GUITAR_BUTTON_PLUS, 1.0f));
|
||||
AddBind(TOUCHSCREEN_KEY, new sBind(a, GUITAR_FRET_GREEN, BIND_BUTTON, GUITAR_FRET_GREEN, 1.0f));
|
||||
AddBind(TOUCHSCREEN_KEY, new sBind(a, GUITAR_FRET_RED, BIND_BUTTON, GUITAR_FRET_RED, 1.0f));
|
||||
AddBind(TOUCHSCREEN_KEY,
|
||||
new sBind(a, GUITAR_FRET_YELLOW, BIND_BUTTON, GUITAR_FRET_YELLOW, 1.0f));
|
||||
AddBind(TOUCHSCREEN_KEY, new sBind(a, GUITAR_FRET_BLUE, BIND_BUTTON, GUITAR_FRET_BLUE, 1.0f));
|
||||
AddBind(TOUCHSCREEN_KEY,
|
||||
new sBind(a, GUITAR_FRET_ORANGE, BIND_BUTTON, GUITAR_FRET_ORANGE, 1.0f));
|
||||
AddBind(TOUCHSCREEN_KEY, new sBind(a, GUITAR_STRUM_UP, BIND_BUTTON, GUITAR_STRUM_UP, 1.0f));
|
||||
AddBind(TOUCHSCREEN_KEY, new sBind(a, GUITAR_STRUM_DOWN, BIND_BUTTON, GUITAR_STRUM_DOWN, 1.0f));
|
||||
|
||||
AddBind(TOUCHSCREEN_KEY, new sBind(a, GUITAR_STICK_UP, BIND_AXIS, GUITAR_STICK_UP, -1.0f));
|
||||
AddBind(TOUCHSCREEN_KEY, new sBind(a, GUITAR_STICK_DOWN, BIND_AXIS, GUITAR_STICK_DOWN, 1.0f));
|
||||
AddBind(TOUCHSCREEN_KEY, new sBind(a, GUITAR_STICK_LEFT, BIND_AXIS, GUITAR_STICK_LEFT, -1.0f));
|
||||
AddBind(TOUCHSCREEN_KEY, new sBind(a, GUITAR_STICK_RIGHT, BIND_AXIS, GUITAR_STICK_RIGHT, 1.0f));
|
||||
AddBind(TOUCHSCREEN_KEY, new sBind(a, GUITAR_WHAMMY_BAR, BIND_AXIS, GUITAR_WHAMMY_BAR, 1.0f));
|
||||
|
||||
// Wii: Drums
|
||||
AddBind(TOUCHSCREEN_KEY,
|
||||
new sBind(a, DRUMS_BUTTON_MINUS, BIND_BUTTON, DRUMS_BUTTON_MINUS, 1.0f));
|
||||
AddBind(TOUCHSCREEN_KEY, new sBind(a, DRUMS_BUTTON_PLUS, BIND_BUTTON, DRUMS_BUTTON_PLUS, 1.0f));
|
||||
AddBind(TOUCHSCREEN_KEY, new sBind(a, DRUMS_PAD_RED, BIND_BUTTON, DRUMS_PAD_RED, 1.0f));
|
||||
AddBind(TOUCHSCREEN_KEY, new sBind(a, DRUMS_PAD_YELLOW, BIND_BUTTON, DRUMS_PAD_YELLOW, 1.0f));
|
||||
AddBind(TOUCHSCREEN_KEY, new sBind(a, DRUMS_PAD_BLUE, BIND_BUTTON, DRUMS_PAD_BLUE, 1.0f));
|
||||
AddBind(TOUCHSCREEN_KEY, new sBind(a, DRUMS_PAD_GREEN, BIND_BUTTON, DRUMS_PAD_GREEN, 1.0f));
|
||||
AddBind(TOUCHSCREEN_KEY, new sBind(a, DRUMS_PAD_ORANGE, BIND_BUTTON, DRUMS_PAD_ORANGE, 1.0f));
|
||||
AddBind(TOUCHSCREEN_KEY, new sBind(a, DRUMS_PAD_BASS, BIND_BUTTON, DRUMS_PAD_BASS, 1.0f));
|
||||
|
||||
AddBind(TOUCHSCREEN_KEY, new sBind(a, DRUMS_STICK_UP, BIND_AXIS, DRUMS_STICK_UP, -1.0f));
|
||||
AddBind(TOUCHSCREEN_KEY, new sBind(a, DRUMS_STICK_DOWN, BIND_AXIS, DRUMS_STICK_DOWN, 1.0f));
|
||||
AddBind(TOUCHSCREEN_KEY, new sBind(a, DRUMS_STICK_LEFT, BIND_AXIS, DRUMS_STICK_LEFT, -1.0f));
|
||||
AddBind(TOUCHSCREEN_KEY, new sBind(a, DRUMS_STICK_RIGHT, BIND_AXIS, DRUMS_STICK_RIGHT, 1.0f));
|
||||
|
||||
// Wii: Turntable
|
||||
AddBind(TOUCHSCREEN_KEY, new sBind(a, TURNTABLE_BUTTON_GREEN_LEFT, BIND_BUTTON,
|
||||
TURNTABLE_BUTTON_GREEN_LEFT, 1.0f));
|
||||
AddBind(TOUCHSCREEN_KEY,
|
||||
new sBind(a, TURNTABLE_BUTTON_RED_LEFT, BIND_BUTTON, TURNTABLE_BUTTON_RED_LEFT, 1.0f));
|
||||
AddBind(TOUCHSCREEN_KEY, new sBind(a, TURNTABLE_BUTTON_BLUE_LEFT, BIND_BUTTON,
|
||||
TURNTABLE_BUTTON_BLUE_LEFT, 1.0f));
|
||||
AddBind(TOUCHSCREEN_KEY, new sBind(a, TURNTABLE_BUTTON_GREEN_RIGHT, BIND_BUTTON,
|
||||
TURNTABLE_BUTTON_GREEN_RIGHT, 1.0f));
|
||||
AddBind(TOUCHSCREEN_KEY, new sBind(a, TURNTABLE_BUTTON_RED_RIGHT, BIND_BUTTON,
|
||||
TURNTABLE_BUTTON_RED_RIGHT, 1.0f));
|
||||
AddBind(TOUCHSCREEN_KEY, new sBind(a, TURNTABLE_BUTTON_BLUE_RIGHT, BIND_BUTTON,
|
||||
TURNTABLE_BUTTON_BLUE_RIGHT, 1.0f));
|
||||
AddBind(TOUCHSCREEN_KEY,
|
||||
new sBind(a, TURNTABLE_BUTTON_MINUS, BIND_BUTTON, TURNTABLE_BUTTON_MINUS, 1.0f));
|
||||
AddBind(TOUCHSCREEN_KEY,
|
||||
new sBind(a, TURNTABLE_BUTTON_PLUS, BIND_BUTTON, TURNTABLE_BUTTON_PLUS, 1.0f));
|
||||
AddBind(TOUCHSCREEN_KEY,
|
||||
new sBind(a, TURNTABLE_BUTTON_HOME, BIND_BUTTON, TURNTABLE_BUTTON_HOME, 1.0f));
|
||||
AddBind(TOUCHSCREEN_KEY,
|
||||
new sBind(a, TURNTABLE_BUTTON_EUPHORIA, BIND_BUTTON, TURNTABLE_BUTTON_EUPHORIA, 1.0f));
|
||||
|
||||
AddBind(TOUCHSCREEN_KEY,
|
||||
new sBind(a, TURNTABLE_TABLE_LEFT_LEFT, BIND_AXIS, TURNTABLE_TABLE_LEFT_LEFT, -1.0f));
|
||||
AddBind(TOUCHSCREEN_KEY,
|
||||
new sBind(a, TURNTABLE_TABLE_LEFT_RIGHT, BIND_AXIS, TURNTABLE_TABLE_LEFT_RIGHT, 1.0f));
|
||||
AddBind(TOUCHSCREEN_KEY,
|
||||
new sBind(a, TURNTABLE_TABLE_RIGHT_LEFT, BIND_AXIS, TURNTABLE_TABLE_RIGHT_LEFT, -1.0f));
|
||||
AddBind(TOUCHSCREEN_KEY, new sBind(a, TURNTABLE_TABLE_RIGHT_RIGHT, BIND_AXIS,
|
||||
TURNTABLE_TABLE_RIGHT_RIGHT, 1.0f));
|
||||
AddBind(TOUCHSCREEN_KEY,
|
||||
new sBind(a, TURNTABLE_STICK_UP, BIND_AXIS, TURNTABLE_STICK_UP, -1.0f));
|
||||
AddBind(TOUCHSCREEN_KEY,
|
||||
new sBind(a, TURNTABLE_STICK_DOWN, BIND_AXIS, TURNTABLE_STICK_DOWN, 1.0f));
|
||||
AddBind(TOUCHSCREEN_KEY,
|
||||
new sBind(a, TURNTABLE_STICK_LEFT, BIND_AXIS, TURNTABLE_STICK_LEFT, -1.0f));
|
||||
AddBind(TOUCHSCREEN_KEY,
|
||||
new sBind(a, TURNTABLE_STICK_RIGHT, BIND_AXIS, TURNTABLE_STICK_RIGHT, 1.0f));
|
||||
AddBind(TOUCHSCREEN_KEY,
|
||||
new sBind(a, TURNTABLE_EFFECT_DIAL, BIND_AXIS, TURNTABLE_EFFECT_DIAL, 1.0f));
|
||||
AddBind(TOUCHSCREEN_KEY,
|
||||
new sBind(a, TURNTABLE_CROSSFADE_LEFT, BIND_AXIS, TURNTABLE_CROSSFADE_LEFT, -1.0f));
|
||||
AddBind(TOUCHSCREEN_KEY,
|
||||
new sBind(a, TURNTABLE_CROSSFADE_RIGHT, BIND_AXIS, TURNTABLE_CROSSFADE_RIGHT, 1.0f));
|
||||
|
||||
// Wiimote IMU
|
||||
AddBind(TOUCHSCREEN_KEY, new sBind(a, WIIMOTE_ACCEL_LEFT, BIND_AXIS, WIIMOTE_ACCEL_LEFT, 1.0f));
|
||||
AddBind(TOUCHSCREEN_KEY,
|
||||
new sBind(a, WIIMOTE_ACCEL_RIGHT, BIND_AXIS, WIIMOTE_ACCEL_RIGHT, -1.0f));
|
||||
AddBind(TOUCHSCREEN_KEY,
|
||||
new sBind(a, WIIMOTE_ACCEL_FORWARD, BIND_AXIS, WIIMOTE_ACCEL_FORWARD, -1.0f));
|
||||
AddBind(TOUCHSCREEN_KEY,
|
||||
new sBind(a, WIIMOTE_ACCEL_BACKWARD, BIND_AXIS, WIIMOTE_ACCEL_BACKWARD, 1.0f));
|
||||
AddBind(TOUCHSCREEN_KEY, new sBind(a, WIIMOTE_ACCEL_UP, BIND_AXIS, WIIMOTE_ACCEL_UP, 1.0f));
|
||||
AddBind(TOUCHSCREEN_KEY,
|
||||
new sBind(a, WIIMOTE_ACCEL_DOWN, BIND_AXIS, WIIMOTE_ACCEL_DOWN, -1.0f));
|
||||
AddBind(TOUCHSCREEN_KEY,
|
||||
new sBind(a, WIIMOTE_GYRO_PITCH_UP, BIND_AXIS, WIIMOTE_GYRO_PITCH_UP, -1.0f));
|
||||
AddBind(TOUCHSCREEN_KEY,
|
||||
new sBind(a, WIIMOTE_GYRO_PITCH_DOWN, BIND_AXIS, WIIMOTE_GYRO_PITCH_DOWN, 1.0f));
|
||||
AddBind(TOUCHSCREEN_KEY,
|
||||
new sBind(a, WIIMOTE_GYRO_ROLL_LEFT, BIND_AXIS, WIIMOTE_GYRO_ROLL_LEFT, 1.0f));
|
||||
AddBind(TOUCHSCREEN_KEY,
|
||||
new sBind(a, WIIMOTE_GYRO_ROLL_RIGHT, BIND_AXIS, WIIMOTE_GYRO_ROLL_RIGHT, -1.0f));
|
||||
AddBind(TOUCHSCREEN_KEY,
|
||||
new sBind(a, WIIMOTE_GYRO_YAW_LEFT, BIND_AXIS, WIIMOTE_GYRO_YAW_LEFT, 1.0f));
|
||||
AddBind(TOUCHSCREEN_KEY,
|
||||
new sBind(a, WIIMOTE_GYRO_YAW_RIGHT, BIND_AXIS, WIIMOTE_GYRO_YAW_RIGHT, -1.0f));
|
||||
}
|
||||
// Init our controller bindings
|
||||
IniFile ini;
|
||||
ini.Load(File::GetUserPath(D_CONFIG_IDX) + std::string("Dolphin.ini"), true);
|
||||
ini.Load(File::GetUserPath(D_GAMESETTINGS_IDX) + std::string(game_id + ".ini"), true);
|
||||
for (u32 a = 0; a < CONFIG_STRINGS.size(); ++a)
|
||||
{
|
||||
for (int pad_id = 0; pad_id < 8; ++pad_id)
|
||||
{
|
||||
std::ostringstream config;
|
||||
config << CONFIG_STRINGS[a] << "_" << pad_id;
|
||||
BindType type;
|
||||
int bindnum;
|
||||
char dev[128]{};
|
||||
bool hasbind = false;
|
||||
char modifier = '+';
|
||||
std::string value;
|
||||
ini.GetOrCreateSection("Android")->Get(config.str(), &value, "None");
|
||||
if (value == "None")
|
||||
continue;
|
||||
if (std::string::npos != value.find("Axis"))
|
||||
{
|
||||
hasbind = true;
|
||||
type = BIND_AXIS;
|
||||
if (value.starts_with("Device ''"))
|
||||
sscanf(value.c_str(), "Device ''-Axis %d%c", &bindnum, &modifier);
|
||||
else
|
||||
sscanf(value.c_str(), "Device '%127[^\']'-Axis %d%c", dev, &bindnum, &modifier);
|
||||
}
|
||||
else if (std::string::npos != value.find("Button"))
|
||||
{
|
||||
hasbind = true;
|
||||
type = BIND_BUTTON;
|
||||
if (value.starts_with("Device ''"))
|
||||
sscanf(value.c_str(), "Device ''-Button %d", &bindnum);
|
||||
else
|
||||
sscanf(value.c_str(), "Device '%127[^\']'-Button %d", dev, &bindnum);
|
||||
}
|
||||
if (hasbind)
|
||||
AddBind(std::string(dev),
|
||||
new sBind(pad_id, CONFIG_TYPES[a], type, bindnum, modifier == '-' ? -1.0f : 1.0f));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool GetButtonPressed(int pad_id, ButtonType button)
|
||||
{
|
||||
bool pressed = m_controllers[TOUCHSCREEN_KEY]->ButtonValue(pad_id, button);
|
||||
|
||||
for (const auto& ctrl : m_controllers)
|
||||
pressed |= ctrl.second->ButtonValue(pad_id, button);
|
||||
|
||||
return pressed;
|
||||
}
|
||||
|
||||
float GetAxisValue(int pad_id, ButtonType axis)
|
||||
{
|
||||
float value = m_controllers[TOUCHSCREEN_KEY]->AxisValue(pad_id, axis);
|
||||
if (value == 0.0f)
|
||||
{
|
||||
for (const auto& ctrl : m_controllers)
|
||||
{
|
||||
value = ctrl.second->AxisValue(pad_id, axis);
|
||||
if (value != 0.0f)
|
||||
return value;
|
||||
}
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
bool GamepadEvent(const std::string& dev, int button, int action)
|
||||
{
|
||||
auto it = m_controllers.find(dev);
|
||||
if (it != m_controllers.end())
|
||||
return it->second->PressEvent(button, action);
|
||||
return false;
|
||||
}
|
||||
|
||||
void GamepadAxisEvent(const std::string& dev, int axis, float value)
|
||||
{
|
||||
auto it = m_controllers.find(dev);
|
||||
if (it != m_controllers.end())
|
||||
it->second->AxisEvent(axis, value);
|
||||
}
|
||||
|
||||
void Shutdown()
|
||||
{
|
||||
for (const auto& controller : m_controllers)
|
||||
delete controller.second;
|
||||
m_controllers.clear();
|
||||
}
|
||||
|
||||
// InputDevice
|
||||
bool InputDevice::PressEvent(int button, int action)
|
||||
{
|
||||
bool handled = false;
|
||||
for (const auto& binding : m_input_binds)
|
||||
{
|
||||
if (binding.second->m_bind == button)
|
||||
{
|
||||
if (binding.second->m_bind_type == BIND_BUTTON)
|
||||
m_buttons[binding.second->m_button_type] = action == BUTTON_PRESSED ? true : false;
|
||||
else
|
||||
m_axes[binding.second->m_button_type] = action == BUTTON_PRESSED ? 1.0f : 0.0f;
|
||||
handled = true;
|
||||
}
|
||||
}
|
||||
return handled;
|
||||
}
|
||||
|
||||
void InputDevice::AxisEvent(int axis, float value)
|
||||
{
|
||||
for (const auto& binding : m_input_binds)
|
||||
{
|
||||
if (binding.second->m_bind == axis)
|
||||
{
|
||||
if (binding.second->m_bind_type == BIND_AXIS)
|
||||
m_axes[binding.second->m_button_type] = value;
|
||||
else
|
||||
m_buttons[binding.second->m_button_type] = value > 0.5f ? true : false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool InputDevice::ButtonValue(int pad_id, ButtonType button) const
|
||||
{
|
||||
const auto binding = m_input_binds.find(std::make_pair(pad_id, button));
|
||||
if (binding == m_input_binds.end())
|
||||
return false;
|
||||
|
||||
if (binding->second->m_bind_type == BIND_BUTTON)
|
||||
{
|
||||
const auto button = m_buttons.find(binding->second->m_button_type);
|
||||
if (button == m_buttons.end())
|
||||
return false;
|
||||
return button->second;
|
||||
}
|
||||
else
|
||||
{
|
||||
const auto axis = m_axes.find(binding->second->m_button_type);
|
||||
if (axis == m_axes.end())
|
||||
return false;
|
||||
return (axis->second * binding->second->m_neg) > 0.5f;
|
||||
}
|
||||
}
|
||||
|
||||
float InputDevice::AxisValue(int pad_id, ButtonType axis) const
|
||||
{
|
||||
const auto binding = m_input_binds.find(std::make_pair(pad_id, axis));
|
||||
if (binding == m_input_binds.end())
|
||||
return 0.0f;
|
||||
|
||||
if (binding->second->m_bind_type == BIND_AXIS)
|
||||
{
|
||||
const auto axis = m_axes.find(binding->second->m_button_type);
|
||||
if (axis == m_axes.end())
|
||||
return 0.0f;
|
||||
return axis->second * binding->second->m_neg;
|
||||
}
|
||||
else
|
||||
{
|
||||
const auto button = m_buttons.find(binding->second->m_button_type);
|
||||
if (button == m_buttons.end())
|
||||
return 0.0f;
|
||||
return button->second == BUTTON_PRESSED ? 1.0f : 0.0f;
|
||||
}
|
||||
}
|
||||
} // namespace ButtonManager
|
@ -1,279 +0,0 @@
|
||||
// Copyright 2013 Dolphin Emulator Project
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
|
||||
namespace ButtonManager
|
||||
{
|
||||
enum ButtonType
|
||||
{
|
||||
// GC
|
||||
BUTTON_A = 0,
|
||||
BUTTON_B = 1,
|
||||
BUTTON_START = 2,
|
||||
BUTTON_X = 3,
|
||||
BUTTON_Y = 4,
|
||||
BUTTON_Z = 5,
|
||||
BUTTON_UP = 6,
|
||||
BUTTON_DOWN = 7,
|
||||
BUTTON_LEFT = 8,
|
||||
BUTTON_RIGHT = 9,
|
||||
STICK_MAIN = 10, // Used on Java Side
|
||||
STICK_MAIN_UP = 11,
|
||||
STICK_MAIN_DOWN = 12,
|
||||
STICK_MAIN_LEFT = 13,
|
||||
STICK_MAIN_RIGHT = 14,
|
||||
STICK_C = 15, // Used on Java Side
|
||||
STICK_C_UP = 16,
|
||||
STICK_C_DOWN = 17,
|
||||
STICK_C_LEFT = 18,
|
||||
STICK_C_RIGHT = 19,
|
||||
TRIGGER_L = 20,
|
||||
TRIGGER_R = 21,
|
||||
// Wiimote
|
||||
WIIMOTE_BUTTON_A = 100,
|
||||
WIIMOTE_BUTTON_B = 101,
|
||||
WIIMOTE_BUTTON_MINUS = 102,
|
||||
WIIMOTE_BUTTON_PLUS = 103,
|
||||
WIIMOTE_BUTTON_HOME = 104,
|
||||
WIIMOTE_BUTTON_1 = 105,
|
||||
WIIMOTE_BUTTON_2 = 106,
|
||||
WIIMOTE_UP = 107,
|
||||
WIIMOTE_DOWN = 108,
|
||||
WIIMOTE_LEFT = 109,
|
||||
WIIMOTE_RIGHT = 110,
|
||||
WIIMOTE_IR = 111, // To Be Used on Java Side
|
||||
WIIMOTE_IR_UP = 112,
|
||||
WIIMOTE_IR_DOWN = 113,
|
||||
WIIMOTE_IR_LEFT = 114,
|
||||
WIIMOTE_IR_RIGHT = 115,
|
||||
WIIMOTE_IR_FORWARD = 116,
|
||||
WIIMOTE_IR_BACKWARD = 117,
|
||||
WIIMOTE_IR_HIDE = 118,
|
||||
WIIMOTE_SWING = 119, // To Be Used on Java Side
|
||||
WIIMOTE_SWING_UP = 120,
|
||||
WIIMOTE_SWING_DOWN = 121,
|
||||
WIIMOTE_SWING_LEFT = 122,
|
||||
WIIMOTE_SWING_RIGHT = 123,
|
||||
WIIMOTE_SWING_FORWARD = 124,
|
||||
WIIMOTE_SWING_BACKWARD = 125,
|
||||
WIIMOTE_TILT = 126, // To Be Used on Java Side
|
||||
WIIMOTE_TILT_FORWARD = 127,
|
||||
WIIMOTE_TILT_BACKWARD = 128,
|
||||
WIIMOTE_TILT_LEFT = 129,
|
||||
WIIMOTE_TILT_RIGHT = 130,
|
||||
WIIMOTE_TILT_MODIFIER = 131,
|
||||
WIIMOTE_SHAKE_X = 132,
|
||||
WIIMOTE_SHAKE_Y = 133,
|
||||
WIIMOTE_SHAKE_Z = 134,
|
||||
// Nunchuk
|
||||
NUNCHUK_BUTTON_C = 200,
|
||||
NUNCHUK_BUTTON_Z = 201,
|
||||
NUNCHUK_STICK = 202, // To Be Used on Java Side
|
||||
NUNCHUK_STICK_UP = 203,
|
||||
NUNCHUK_STICK_DOWN = 204,
|
||||
NUNCHUK_STICK_LEFT = 205,
|
||||
NUNCHUK_STICK_RIGHT = 206,
|
||||
NUNCHUK_SWING = 207, // To Be Used on Java Side
|
||||
NUNCHUK_SWING_UP = 208,
|
||||
NUNCHUK_SWING_DOWN = 209,
|
||||
NUNCHUK_SWING_LEFT = 210,
|
||||
NUNCHUK_SWING_RIGHT = 211,
|
||||
NUNCHUK_SWING_FORWARD = 212,
|
||||
NUNCHUK_SWING_BACKWARD = 213,
|
||||
NUNCHUK_TILT = 214, // To Be Used on Java Side
|
||||
NUNCHUK_TILT_FORWARD = 215,
|
||||
NUNCHUK_TILT_BACKWARD = 216,
|
||||
NUNCHUK_TILT_LEFT = 217,
|
||||
NUNCHUK_TILT_RIGHT = 218,
|
||||
NUNCHUK_TILT_MODIFIER = 219,
|
||||
NUNCHUK_SHAKE_X = 220,
|
||||
NUNCHUK_SHAKE_Y = 221,
|
||||
NUNCHUK_SHAKE_Z = 222,
|
||||
// Classic
|
||||
CLASSIC_BUTTON_A = 300,
|
||||
CLASSIC_BUTTON_B = 301,
|
||||
CLASSIC_BUTTON_X = 302,
|
||||
CLASSIC_BUTTON_Y = 303,
|
||||
CLASSIC_BUTTON_MINUS = 304,
|
||||
CLASSIC_BUTTON_PLUS = 305,
|
||||
CLASSIC_BUTTON_HOME = 306,
|
||||
CLASSIC_BUTTON_ZL = 307,
|
||||
CLASSIC_BUTTON_ZR = 308,
|
||||
CLASSIC_DPAD_UP = 309,
|
||||
CLASSIC_DPAD_DOWN = 310,
|
||||
CLASSIC_DPAD_LEFT = 311,
|
||||
CLASSIC_DPAD_RIGHT = 312,
|
||||
CLASSIC_STICK_LEFT = 313, // To Be Used on Java Side
|
||||
CLASSIC_STICK_LEFT_UP = 314,
|
||||
CLASSIC_STICK_LEFT_DOWN = 315,
|
||||
CLASSIC_STICK_LEFT_LEFT = 316,
|
||||
CLASSIC_STICK_LEFT_RIGHT = 317,
|
||||
CLASSIC_STICK_RIGHT = 318, // To Be Used on Java Side
|
||||
CLASSIC_STICK_RIGHT_UP = 319,
|
||||
CLASSIC_STICK_RIGHT_DOWN = 320,
|
||||
CLASSIC_STICK_RIGHT_LEFT = 321,
|
||||
CLASSIC_STICK_RIGHT_RIGHT = 322,
|
||||
CLASSIC_TRIGGER_L = 323,
|
||||
CLASSIC_TRIGGER_R = 324,
|
||||
// Guitar
|
||||
GUITAR_BUTTON_MINUS = 400,
|
||||
GUITAR_BUTTON_PLUS = 401,
|
||||
GUITAR_FRET_GREEN = 402,
|
||||
GUITAR_FRET_RED = 403,
|
||||
GUITAR_FRET_YELLOW = 404,
|
||||
GUITAR_FRET_BLUE = 405,
|
||||
GUITAR_FRET_ORANGE = 406,
|
||||
GUITAR_STRUM_UP = 407,
|
||||
GUITAR_STRUM_DOWN = 408,
|
||||
GUITAR_STICK = 409, // To Be Used on Java Side
|
||||
GUITAR_STICK_UP = 410,
|
||||
GUITAR_STICK_DOWN = 411,
|
||||
GUITAR_STICK_LEFT = 412,
|
||||
GUITAR_STICK_RIGHT = 413,
|
||||
GUITAR_WHAMMY_BAR = 414,
|
||||
// Drums
|
||||
DRUMS_BUTTON_MINUS = 500,
|
||||
DRUMS_BUTTON_PLUS = 501,
|
||||
DRUMS_PAD_RED = 502,
|
||||
DRUMS_PAD_YELLOW = 503,
|
||||
DRUMS_PAD_BLUE = 504,
|
||||
DRUMS_PAD_GREEN = 505,
|
||||
DRUMS_PAD_ORANGE = 506,
|
||||
DRUMS_PAD_BASS = 507,
|
||||
DRUMS_STICK = 508, // To Be Used on Java Side
|
||||
DRUMS_STICK_UP = 509,
|
||||
DRUMS_STICK_DOWN = 510,
|
||||
DRUMS_STICK_LEFT = 511,
|
||||
DRUMS_STICK_RIGHT = 512,
|
||||
// Turntable
|
||||
TURNTABLE_BUTTON_GREEN_LEFT = 600,
|
||||
TURNTABLE_BUTTON_RED_LEFT = 601,
|
||||
TURNTABLE_BUTTON_BLUE_LEFT = 602,
|
||||
TURNTABLE_BUTTON_GREEN_RIGHT = 603,
|
||||
TURNTABLE_BUTTON_RED_RIGHT = 604,
|
||||
TURNTABLE_BUTTON_BLUE_RIGHT = 605,
|
||||
TURNTABLE_BUTTON_MINUS = 606,
|
||||
TURNTABLE_BUTTON_PLUS = 607,
|
||||
TURNTABLE_BUTTON_HOME = 608,
|
||||
TURNTABLE_BUTTON_EUPHORIA = 609,
|
||||
TURNTABLE_TABLE_LEFT = 610, // To Be Used on Java Side
|
||||
TURNTABLE_TABLE_LEFT_LEFT = 611,
|
||||
TURNTABLE_TABLE_LEFT_RIGHT = 612,
|
||||
TURNTABLE_TABLE_RIGHT = 613, // To Be Used on Java Side
|
||||
TURNTABLE_TABLE_RIGHT_LEFT = 614,
|
||||
TURNTABLE_TABLE_RIGHT_RIGHT = 615,
|
||||
TURNTABLE_STICK = 616, // To Be Used on Java Side
|
||||
TURNTABLE_STICK_UP = 617,
|
||||
TURNTABLE_STICK_DOWN = 618,
|
||||
TURNTABLE_STICK_LEFT = 619,
|
||||
TURNTABLE_STICK_RIGHT = 620,
|
||||
TURNTABLE_EFFECT_DIAL = 621,
|
||||
TURNTABLE_CROSSFADE = 622, // To Be Used on Java Side
|
||||
TURNTABLE_CROSSFADE_LEFT = 623,
|
||||
TURNTABLE_CROSSFADE_RIGHT = 624,
|
||||
// Wiimote IMU
|
||||
WIIMOTE_ACCEL_LEFT = 625,
|
||||
WIIMOTE_ACCEL_RIGHT = 626,
|
||||
WIIMOTE_ACCEL_FORWARD = 627,
|
||||
WIIMOTE_ACCEL_BACKWARD = 628,
|
||||
WIIMOTE_ACCEL_UP = 629,
|
||||
WIIMOTE_ACCEL_DOWN = 630,
|
||||
WIIMOTE_GYRO_PITCH_UP = 631,
|
||||
WIIMOTE_GYRO_PITCH_DOWN = 632,
|
||||
WIIMOTE_GYRO_ROLL_LEFT = 633,
|
||||
WIIMOTE_GYRO_ROLL_RIGHT = 634,
|
||||
WIIMOTE_GYRO_YAW_LEFT = 635,
|
||||
WIIMOTE_GYRO_YAW_RIGHT = 636,
|
||||
// Rumble
|
||||
RUMBLE = 700,
|
||||
};
|
||||
enum ButtonState
|
||||
{
|
||||
BUTTON_RELEASED = 0,
|
||||
BUTTON_PRESSED = 1
|
||||
};
|
||||
enum BindType
|
||||
{
|
||||
BIND_BUTTON = 0,
|
||||
BIND_AXIS
|
||||
};
|
||||
class Button
|
||||
{
|
||||
private:
|
||||
ButtonState m_state;
|
||||
|
||||
public:
|
||||
Button() : m_state(BUTTON_RELEASED) {}
|
||||
void SetState(ButtonState state) { m_state = state; }
|
||||
bool Pressed() const { return m_state == BUTTON_PRESSED; }
|
||||
~Button() {}
|
||||
};
|
||||
class Axis
|
||||
{
|
||||
private:
|
||||
float m_value;
|
||||
|
||||
public:
|
||||
Axis() : m_value(0.0f) {}
|
||||
void SetValue(float value) { m_value = value; }
|
||||
float AxisValue() const { return m_value; }
|
||||
~Axis() {}
|
||||
};
|
||||
|
||||
struct sBind
|
||||
{
|
||||
const int m_pad_id;
|
||||
const ButtonType m_button_type;
|
||||
const BindType m_bind_type;
|
||||
const int m_bind;
|
||||
const float m_neg;
|
||||
sBind(int pad_id, ButtonType button_type, BindType bind_type, int bind, float neg)
|
||||
: m_pad_id(pad_id), m_button_type(button_type), m_bind_type(bind_type), m_bind(bind),
|
||||
m_neg(neg)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
class InputDevice
|
||||
{
|
||||
private:
|
||||
const std::string m_dev;
|
||||
std::map<ButtonType, bool> m_buttons;
|
||||
std::map<ButtonType, float> m_axes;
|
||||
|
||||
// Key is pad_id and ButtonType
|
||||
std::map<std::pair<int, ButtonType>, sBind*> m_input_binds;
|
||||
|
||||
public:
|
||||
InputDevice(std::string dev) : m_dev(dev) {}
|
||||
~InputDevice()
|
||||
{
|
||||
for (const auto& bind : m_input_binds)
|
||||
delete bind.second;
|
||||
m_input_binds.clear();
|
||||
}
|
||||
void AddBind(sBind* bind)
|
||||
{
|
||||
m_input_binds[std::make_pair(bind->m_pad_id, bind->m_button_type)] = bind;
|
||||
}
|
||||
bool PressEvent(int button, int action);
|
||||
void AxisEvent(int axis, float value);
|
||||
bool ButtonValue(int pad_id, ButtonType button) const;
|
||||
float AxisValue(int pad_id, ButtonType axis) const;
|
||||
};
|
||||
|
||||
void Init(const std::string&);
|
||||
|
||||
// pad_id is numbered 0 to 3 for GC pads and 4 to 7 for Wiimotes
|
||||
bool GetButtonPressed(int pad_id, ButtonType button);
|
||||
float GetAxisValue(int pad_id, ButtonType axis);
|
||||
|
||||
bool GamepadEvent(const std::string& dev, int button, int action);
|
||||
void GamepadAxisEvent(const std::string& dev, int axis, float value);
|
||||
|
||||
void Shutdown();
|
||||
} // namespace ButtonManager
|
@ -1,264 +0,0 @@
|
||||
// Copyright 2013 Dolphin Emulator Project
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#include "InputCommon/ControllerInterface/Touch/Touchscreen.h"
|
||||
|
||||
#include <sstream>
|
||||
#include <thread>
|
||||
#ifdef ANDROID
|
||||
#include <jni/AndroidCommon/IDCache.h>
|
||||
#endif
|
||||
|
||||
#include "InputCommon/ControllerInterface/ControllerInterface.h"
|
||||
|
||||
namespace ciface::Touch
|
||||
{
|
||||
// Touchscreens and stuff
|
||||
std::string Touchscreen::GetName() const
|
||||
{
|
||||
return "Touchscreen";
|
||||
}
|
||||
|
||||
std::string Touchscreen::GetSource() const
|
||||
{
|
||||
return "Android";
|
||||
}
|
||||
|
||||
Touchscreen::Touchscreen(int pad_id, bool accelerometer_enabled, bool gyroscope_enabled)
|
||||
: m_pad_id(pad_id)
|
||||
{
|
||||
// GC
|
||||
AddInput(new Button(m_pad_id, ButtonManager::BUTTON_A));
|
||||
AddInput(new Button(m_pad_id, ButtonManager::BUTTON_B));
|
||||
AddInput(new Button(m_pad_id, ButtonManager::BUTTON_START));
|
||||
AddInput(new Button(m_pad_id, ButtonManager::BUTTON_X));
|
||||
AddInput(new Button(m_pad_id, ButtonManager::BUTTON_Y));
|
||||
AddInput(new Button(m_pad_id, ButtonManager::BUTTON_Z));
|
||||
AddInput(new Button(m_pad_id, ButtonManager::BUTTON_UP));
|
||||
AddInput(new Button(m_pad_id, ButtonManager::BUTTON_DOWN));
|
||||
AddInput(new Button(m_pad_id, ButtonManager::BUTTON_LEFT));
|
||||
AddInput(new Button(m_pad_id, ButtonManager::BUTTON_RIGHT));
|
||||
AddInput(new Axis(m_pad_id, ButtonManager::STICK_MAIN_LEFT));
|
||||
AddInput(new Axis(m_pad_id, ButtonManager::STICK_MAIN_RIGHT));
|
||||
AddInput(new Axis(m_pad_id, ButtonManager::STICK_MAIN_UP));
|
||||
AddInput(new Axis(m_pad_id, ButtonManager::STICK_MAIN_DOWN));
|
||||
AddInput(new Axis(m_pad_id, ButtonManager::STICK_C_LEFT));
|
||||
AddInput(new Axis(m_pad_id, ButtonManager::STICK_C_RIGHT));
|
||||
AddInput(new Axis(m_pad_id, ButtonManager::STICK_C_UP));
|
||||
AddInput(new Axis(m_pad_id, ButtonManager::STICK_C_DOWN));
|
||||
AddInput(new Axis(m_pad_id, ButtonManager::TRIGGER_L));
|
||||
AddInput(new Axis(m_pad_id, ButtonManager::TRIGGER_R));
|
||||
|
||||
// Wiimote
|
||||
AddInput(new Button(m_pad_id, ButtonManager::WIIMOTE_BUTTON_A));
|
||||
AddInput(new Button(m_pad_id, ButtonManager::WIIMOTE_BUTTON_B));
|
||||
AddInput(new Button(m_pad_id, ButtonManager::WIIMOTE_BUTTON_MINUS));
|
||||
AddInput(new Button(m_pad_id, ButtonManager::WIIMOTE_BUTTON_PLUS));
|
||||
AddInput(new Button(m_pad_id, ButtonManager::WIIMOTE_BUTTON_HOME));
|
||||
AddInput(new Button(m_pad_id, ButtonManager::WIIMOTE_BUTTON_1));
|
||||
AddInput(new Button(m_pad_id, ButtonManager::WIIMOTE_BUTTON_2));
|
||||
AddInput(new Button(m_pad_id, ButtonManager::WIIMOTE_UP));
|
||||
AddInput(new Button(m_pad_id, ButtonManager::WIIMOTE_DOWN));
|
||||
AddInput(new Button(m_pad_id, ButtonManager::WIIMOTE_LEFT));
|
||||
AddInput(new Button(m_pad_id, ButtonManager::WIIMOTE_RIGHT));
|
||||
AddInput(new Button(m_pad_id, ButtonManager::WIIMOTE_IR_HIDE));
|
||||
AddInput(new Button(m_pad_id, ButtonManager::WIIMOTE_TILT_MODIFIER));
|
||||
AddInput(new Button(m_pad_id, ButtonManager::WIIMOTE_SHAKE_X));
|
||||
AddInput(new Button(m_pad_id, ButtonManager::WIIMOTE_SHAKE_Y));
|
||||
AddInput(new Button(m_pad_id, ButtonManager::WIIMOTE_SHAKE_Z));
|
||||
AddInput(new Axis(m_pad_id, ButtonManager::WIIMOTE_IR_UP));
|
||||
AddInput(new Axis(m_pad_id, ButtonManager::WIIMOTE_IR_DOWN));
|
||||
AddInput(new Axis(m_pad_id, ButtonManager::WIIMOTE_IR_LEFT));
|
||||
AddInput(new Axis(m_pad_id, ButtonManager::WIIMOTE_IR_RIGHT));
|
||||
AddInput(new Axis(m_pad_id, ButtonManager::WIIMOTE_IR_FORWARD));
|
||||
AddInput(new Axis(m_pad_id, ButtonManager::WIIMOTE_IR_BACKWARD));
|
||||
AddInput(new Axis(m_pad_id, ButtonManager::WIIMOTE_SWING_UP));
|
||||
AddInput(new Axis(m_pad_id, ButtonManager::WIIMOTE_SWING_DOWN));
|
||||
AddInput(new Axis(m_pad_id, ButtonManager::WIIMOTE_SWING_LEFT));
|
||||
AddInput(new Axis(m_pad_id, ButtonManager::WIIMOTE_SWING_RIGHT));
|
||||
AddInput(new Axis(m_pad_id, ButtonManager::WIIMOTE_SWING_FORWARD));
|
||||
AddInput(new Axis(m_pad_id, ButtonManager::WIIMOTE_SWING_BACKWARD));
|
||||
AddInput(new Axis(m_pad_id, ButtonManager::WIIMOTE_TILT_LEFT));
|
||||
AddInput(new Axis(m_pad_id, ButtonManager::WIIMOTE_TILT_RIGHT));
|
||||
AddInput(new Axis(m_pad_id, ButtonManager::WIIMOTE_TILT_FORWARD));
|
||||
AddInput(new Axis(m_pad_id, ButtonManager::WIIMOTE_TILT_BACKWARD));
|
||||
|
||||
// Wii ext: Nunchuk
|
||||
AddInput(new Button(m_pad_id, ButtonManager::NUNCHUK_BUTTON_C));
|
||||
AddInput(new Button(m_pad_id, ButtonManager::NUNCHUK_BUTTON_Z));
|
||||
AddInput(new Button(m_pad_id, ButtonManager::NUNCHUK_TILT_MODIFIER));
|
||||
AddInput(new Button(m_pad_id, ButtonManager::NUNCHUK_SHAKE_X));
|
||||
AddInput(new Button(m_pad_id, ButtonManager::NUNCHUK_SHAKE_Y));
|
||||
AddInput(new Button(m_pad_id, ButtonManager::NUNCHUK_SHAKE_Z));
|
||||
AddInput(new Axis(m_pad_id, ButtonManager::NUNCHUK_STICK_LEFT));
|
||||
AddInput(new Axis(m_pad_id, ButtonManager::NUNCHUK_STICK_RIGHT));
|
||||
AddInput(new Axis(m_pad_id, ButtonManager::NUNCHUK_STICK_UP));
|
||||
AddInput(new Axis(m_pad_id, ButtonManager::NUNCHUK_STICK_DOWN));
|
||||
AddInput(new Axis(m_pad_id, ButtonManager::NUNCHUK_SWING_LEFT));
|
||||
AddInput(new Axis(m_pad_id, ButtonManager::NUNCHUK_SWING_RIGHT));
|
||||
AddInput(new Axis(m_pad_id, ButtonManager::NUNCHUK_SWING_UP));
|
||||
AddInput(new Axis(m_pad_id, ButtonManager::NUNCHUK_SWING_DOWN));
|
||||
AddInput(new Axis(m_pad_id, ButtonManager::NUNCHUK_SWING_FORWARD));
|
||||
AddInput(new Axis(m_pad_id, ButtonManager::NUNCHUK_SWING_BACKWARD));
|
||||
AddInput(new Axis(m_pad_id, ButtonManager::NUNCHUK_TILT_LEFT));
|
||||
AddInput(new Axis(m_pad_id, ButtonManager::NUNCHUK_TILT_RIGHT));
|
||||
AddInput(new Axis(m_pad_id, ButtonManager::NUNCHUK_TILT_FORWARD));
|
||||
AddInput(new Axis(m_pad_id, ButtonManager::NUNCHUK_TILT_BACKWARD));
|
||||
|
||||
// Wii ext: Classic
|
||||
AddInput(new Button(m_pad_id, ButtonManager::CLASSIC_BUTTON_A));
|
||||
AddInput(new Button(m_pad_id, ButtonManager::CLASSIC_BUTTON_B));
|
||||
AddInput(new Button(m_pad_id, ButtonManager::CLASSIC_BUTTON_X));
|
||||
AddInput(new Button(m_pad_id, ButtonManager::CLASSIC_BUTTON_Y));
|
||||
AddInput(new Button(m_pad_id, ButtonManager::CLASSIC_BUTTON_MINUS));
|
||||
AddInput(new Button(m_pad_id, ButtonManager::CLASSIC_BUTTON_PLUS));
|
||||
AddInput(new Button(m_pad_id, ButtonManager::CLASSIC_BUTTON_HOME));
|
||||
AddInput(new Button(m_pad_id, ButtonManager::CLASSIC_BUTTON_ZL));
|
||||
AddInput(new Button(m_pad_id, ButtonManager::CLASSIC_BUTTON_ZR));
|
||||
AddInput(new Button(m_pad_id, ButtonManager::CLASSIC_DPAD_UP));
|
||||
AddInput(new Button(m_pad_id, ButtonManager::CLASSIC_DPAD_DOWN));
|
||||
AddInput(new Button(m_pad_id, ButtonManager::CLASSIC_DPAD_LEFT));
|
||||
AddInput(new Button(m_pad_id, ButtonManager::CLASSIC_DPAD_RIGHT));
|
||||
AddInput(new Axis(m_pad_id, ButtonManager::CLASSIC_STICK_LEFT_LEFT));
|
||||
AddInput(new Axis(m_pad_id, ButtonManager::CLASSIC_STICK_LEFT_RIGHT));
|
||||
AddInput(new Axis(m_pad_id, ButtonManager::CLASSIC_STICK_LEFT_UP));
|
||||
AddInput(new Axis(m_pad_id, ButtonManager::CLASSIC_STICK_LEFT_DOWN));
|
||||
AddInput(new Axis(m_pad_id, ButtonManager::CLASSIC_STICK_RIGHT_LEFT));
|
||||
AddInput(new Axis(m_pad_id, ButtonManager::CLASSIC_STICK_RIGHT_RIGHT));
|
||||
AddInput(new Axis(m_pad_id, ButtonManager::CLASSIC_STICK_RIGHT_UP));
|
||||
AddInput(new Axis(m_pad_id, ButtonManager::CLASSIC_STICK_RIGHT_DOWN));
|
||||
AddInput(new Axis(m_pad_id, ButtonManager::CLASSIC_TRIGGER_L));
|
||||
AddInput(new Axis(m_pad_id, ButtonManager::CLASSIC_TRIGGER_R));
|
||||
|
||||
// Wii-ext: Guitar
|
||||
AddInput(new Button(m_pad_id, ButtonManager::GUITAR_BUTTON_MINUS));
|
||||
AddInput(new Button(m_pad_id, ButtonManager::GUITAR_BUTTON_PLUS));
|
||||
AddInput(new Button(m_pad_id, ButtonManager::GUITAR_FRET_GREEN));
|
||||
AddInput(new Button(m_pad_id, ButtonManager::GUITAR_FRET_RED));
|
||||
AddInput(new Button(m_pad_id, ButtonManager::GUITAR_FRET_YELLOW));
|
||||
AddInput(new Button(m_pad_id, ButtonManager::GUITAR_FRET_BLUE));
|
||||
AddInput(new Button(m_pad_id, ButtonManager::GUITAR_FRET_ORANGE));
|
||||
AddInput(new Button(m_pad_id, ButtonManager::GUITAR_STRUM_UP));
|
||||
AddInput(new Button(m_pad_id, ButtonManager::GUITAR_STRUM_DOWN));
|
||||
AddInput(new Axis(m_pad_id, ButtonManager::GUITAR_STICK_LEFT));
|
||||
AddInput(new Axis(m_pad_id, ButtonManager::GUITAR_STICK_RIGHT));
|
||||
AddInput(new Axis(m_pad_id, ButtonManager::GUITAR_STICK_UP));
|
||||
AddInput(new Axis(m_pad_id, ButtonManager::GUITAR_STICK_DOWN));
|
||||
AddInput(new Axis(m_pad_id, ButtonManager::GUITAR_WHAMMY_BAR));
|
||||
|
||||
// Wii-ext: Drums
|
||||
AddInput(new Button(m_pad_id, ButtonManager::DRUMS_BUTTON_MINUS));
|
||||
AddInput(new Button(m_pad_id, ButtonManager::DRUMS_BUTTON_PLUS));
|
||||
AddInput(new Button(m_pad_id, ButtonManager::DRUMS_PAD_RED));
|
||||
AddInput(new Button(m_pad_id, ButtonManager::DRUMS_PAD_YELLOW));
|
||||
AddInput(new Button(m_pad_id, ButtonManager::DRUMS_PAD_BLUE));
|
||||
AddInput(new Button(m_pad_id, ButtonManager::DRUMS_PAD_GREEN));
|
||||
AddInput(new Button(m_pad_id, ButtonManager::DRUMS_PAD_ORANGE));
|
||||
AddInput(new Button(m_pad_id, ButtonManager::DRUMS_PAD_BASS));
|
||||
AddInput(new Axis(m_pad_id, ButtonManager::DRUMS_STICK_LEFT));
|
||||
AddInput(new Axis(m_pad_id, ButtonManager::DRUMS_STICK_RIGHT));
|
||||
AddInput(new Axis(m_pad_id, ButtonManager::DRUMS_STICK_UP));
|
||||
AddInput(new Axis(m_pad_id, ButtonManager::DRUMS_STICK_DOWN));
|
||||
|
||||
// Wii-ext: Turntable
|
||||
AddInput(new Button(m_pad_id, ButtonManager::TURNTABLE_BUTTON_GREEN_LEFT));
|
||||
AddInput(new Button(m_pad_id, ButtonManager::TURNTABLE_BUTTON_RED_LEFT));
|
||||
AddInput(new Button(m_pad_id, ButtonManager::TURNTABLE_BUTTON_BLUE_LEFT));
|
||||
AddInput(new Button(m_pad_id, ButtonManager::TURNTABLE_BUTTON_GREEN_RIGHT));
|
||||
AddInput(new Button(m_pad_id, ButtonManager::TURNTABLE_BUTTON_RED_RIGHT));
|
||||
AddInput(new Button(m_pad_id, ButtonManager::TURNTABLE_BUTTON_BLUE_RIGHT));
|
||||
AddInput(new Button(m_pad_id, ButtonManager::TURNTABLE_BUTTON_MINUS));
|
||||
AddInput(new Button(m_pad_id, ButtonManager::TURNTABLE_BUTTON_PLUS));
|
||||
AddInput(new Button(m_pad_id, ButtonManager::TURNTABLE_BUTTON_HOME));
|
||||
AddInput(new Button(m_pad_id, ButtonManager::TURNTABLE_BUTTON_EUPHORIA));
|
||||
AddInput(new Axis(m_pad_id, ButtonManager::TURNTABLE_TABLE_LEFT_LEFT));
|
||||
AddInput(new Axis(m_pad_id, ButtonManager::TURNTABLE_TABLE_LEFT_RIGHT));
|
||||
AddInput(new Axis(m_pad_id, ButtonManager::TURNTABLE_TABLE_RIGHT_LEFT));
|
||||
AddInput(new Axis(m_pad_id, ButtonManager::TURNTABLE_TABLE_RIGHT_RIGHT));
|
||||
AddInput(new Axis(m_pad_id, ButtonManager::TURNTABLE_STICK_LEFT));
|
||||
AddInput(new Axis(m_pad_id, ButtonManager::TURNTABLE_STICK_RIGHT));
|
||||
AddInput(new Axis(m_pad_id, ButtonManager::TURNTABLE_STICK_UP));
|
||||
AddInput(new Axis(m_pad_id, ButtonManager::TURNTABLE_STICK_DOWN));
|
||||
AddInput(new Axis(m_pad_id, ButtonManager::TURNTABLE_CROSSFADE_LEFT));
|
||||
AddInput(new Axis(m_pad_id, ButtonManager::TURNTABLE_CROSSFADE_RIGHT));
|
||||
AddInput(new Axis(m_pad_id, ButtonManager::TURNTABLE_EFFECT_DIAL));
|
||||
|
||||
// Wiimote IMU
|
||||
// Only add inputs if we actually can receive data from the relevant sensor.
|
||||
// Whether inputs exist affects what WiimoteEmu gets when calling ControlReference::BoundCount.
|
||||
if (accelerometer_enabled)
|
||||
{
|
||||
AddInput(new Axis(m_pad_id, ButtonManager::WIIMOTE_ACCEL_LEFT));
|
||||
AddInput(new Axis(m_pad_id, ButtonManager::WIIMOTE_ACCEL_RIGHT));
|
||||
AddInput(new Axis(m_pad_id, ButtonManager::WIIMOTE_ACCEL_FORWARD));
|
||||
AddInput(new Axis(m_pad_id, ButtonManager::WIIMOTE_ACCEL_BACKWARD));
|
||||
AddInput(new Axis(m_pad_id, ButtonManager::WIIMOTE_ACCEL_UP));
|
||||
AddInput(new Axis(m_pad_id, ButtonManager::WIIMOTE_ACCEL_DOWN));
|
||||
}
|
||||
if (gyroscope_enabled)
|
||||
{
|
||||
AddInput(new Axis(m_pad_id, ButtonManager::WIIMOTE_GYRO_PITCH_UP));
|
||||
AddInput(new Axis(m_pad_id, ButtonManager::WIIMOTE_GYRO_PITCH_DOWN));
|
||||
AddInput(new Axis(m_pad_id, ButtonManager::WIIMOTE_GYRO_ROLL_LEFT));
|
||||
AddInput(new Axis(m_pad_id, ButtonManager::WIIMOTE_GYRO_ROLL_RIGHT));
|
||||
AddInput(new Axis(m_pad_id, ButtonManager::WIIMOTE_GYRO_YAW_LEFT));
|
||||
AddInput(new Axis(m_pad_id, ButtonManager::WIIMOTE_GYRO_YAW_RIGHT));
|
||||
}
|
||||
|
||||
// Rumble
|
||||
AddOutput(new Motor(m_pad_id, ButtonManager::RUMBLE));
|
||||
}
|
||||
// Buttons and stuff
|
||||
|
||||
std::string Touchscreen::Button::GetName() const
|
||||
{
|
||||
std::ostringstream ss;
|
||||
ss << "Button " << static_cast<int>(m_index);
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
ControlState Touchscreen::Button::GetState() const
|
||||
{
|
||||
return ButtonManager::GetButtonPressed(m_pad_id, m_index);
|
||||
}
|
||||
|
||||
std::string Touchscreen::Axis::GetName() const
|
||||
{
|
||||
std::ostringstream ss;
|
||||
ss << "Axis " << static_cast<int>(m_index);
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
ControlState Touchscreen::Axis::GetState() const
|
||||
{
|
||||
return ButtonManager::GetAxisValue(m_pad_id, m_index) * m_neg;
|
||||
}
|
||||
|
||||
Touchscreen::Motor::~Motor()
|
||||
{
|
||||
}
|
||||
|
||||
std::string Touchscreen::Motor::GetName() const
|
||||
{
|
||||
std::ostringstream ss;
|
||||
ss << "Rumble " << static_cast<int>(m_index);
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
void Touchscreen::Motor::SetState(ControlState state)
|
||||
{
|
||||
if (state > 0)
|
||||
{
|
||||
std::thread(Rumble, m_pad_id, state).detach();
|
||||
}
|
||||
}
|
||||
|
||||
void Touchscreen::Motor::Rumble(int pad_id, double state)
|
||||
{
|
||||
#ifdef ANDROID
|
||||
JNIEnv* env = IDCache::GetEnvForThread();
|
||||
env->CallStaticVoidMethod(IDCache::GetNativeLibraryClass(), IDCache::GetDoRumble(), pad_id,
|
||||
state);
|
||||
#endif
|
||||
}
|
||||
} // namespace ciface::Touch
|
@ -1,64 +0,0 @@
|
||||
// Copyright 2008 Dolphin Emulator Project
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "InputCommon/ControllerInterface/ControllerInterface.h"
|
||||
#include "InputCommon/ControllerInterface/Touch/ButtonManager.h"
|
||||
|
||||
namespace ciface::Touch
|
||||
{
|
||||
class Touchscreen : public Core::Device
|
||||
{
|
||||
private:
|
||||
class Button : public Input
|
||||
{
|
||||
public:
|
||||
std::string GetName() const override;
|
||||
Button(int pad_id, ButtonManager::ButtonType index) : m_pad_id(pad_id), m_index(index) {}
|
||||
ControlState GetState() const override;
|
||||
|
||||
private:
|
||||
const int m_pad_id;
|
||||
const ButtonManager::ButtonType m_index;
|
||||
};
|
||||
class Axis : public Input
|
||||
{
|
||||
public:
|
||||
std::string GetName() const override;
|
||||
bool IsDetectable() const override { return false; }
|
||||
Axis(int pad_id, ButtonManager::ButtonType index, float neg = 1.0f)
|
||||
: m_pad_id(pad_id), m_index(index), m_neg(neg)
|
||||
{
|
||||
}
|
||||
ControlState GetState() const override;
|
||||
|
||||
private:
|
||||
const int m_pad_id;
|
||||
const ButtonManager::ButtonType m_index;
|
||||
const float m_neg;
|
||||
};
|
||||
class Motor : public Core::Device::Output
|
||||
{
|
||||
public:
|
||||
Motor(int pad_id, ButtonManager::ButtonType index) : m_pad_id(pad_id), m_index(index) {}
|
||||
~Motor();
|
||||
std::string GetName() const override;
|
||||
void SetState(ControlState state) override;
|
||||
|
||||
private:
|
||||
const int m_pad_id;
|
||||
const ButtonManager::ButtonType m_index;
|
||||
static void Rumble(int pad_id, double state);
|
||||
};
|
||||
|
||||
public:
|
||||
Touchscreen(int pad_id, bool accelerometer_enabled, bool gyroscope_enabled);
|
||||
~Touchscreen() {}
|
||||
std::string GetName() const override;
|
||||
std::string GetSource() const override;
|
||||
|
||||
private:
|
||||
const int m_pad_id;
|
||||
};
|
||||
} // namespace ciface::Touch
|
Loading…
Reference in New Issue
Block a user