mirror of
https://github.com/izzy2lost/dolphin.git
synced 2026-06-19 01:16:48 -07:00
InputCommon: Decouple ButtonManager and Touchscreen from Android
Changes were also made for codestyle compliance.
This commit is contained in:
@@ -3,10 +3,8 @@
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#include "InputCommon/ControllerInterface/Android/Android.h"
|
||||
#include <jni/AndroidCommon/IDCache.h>
|
||||
#include <sstream>
|
||||
#include <thread>
|
||||
#include "InputCommon/ControllerInterface/ControllerInterface.h"
|
||||
#include "InputCommon/ControllerInterface/Touch/Touchscreen.h"
|
||||
|
||||
namespace ciface::Android
|
||||
{
|
||||
@@ -28,251 +26,7 @@ void SetMotionSensorsEnabled(bool accelerometer_enabled, bool gyroscope_enabled)
|
||||
void PopulateDevices()
|
||||
{
|
||||
for (int i = 0; i < 8; ++i)
|
||||
g_controller_interface.AddDevice(std::make_shared<Touchscreen>(i));
|
||||
}
|
||||
|
||||
// Touchscreens and stuff
|
||||
std::string Touchscreen::GetName() const
|
||||
{
|
||||
return "Touchscreen";
|
||||
}
|
||||
|
||||
std::string Touchscreen::GetSource() const
|
||||
{
|
||||
return "Android";
|
||||
}
|
||||
|
||||
Touchscreen::Touchscreen(int padID) : _padID(padID)
|
||||
{
|
||||
// GC
|
||||
AddInput(new Button(_padID, ButtonManager::BUTTON_A));
|
||||
AddInput(new Button(_padID, ButtonManager::BUTTON_B));
|
||||
AddInput(new Button(_padID, ButtonManager::BUTTON_START));
|
||||
AddInput(new Button(_padID, ButtonManager::BUTTON_X));
|
||||
AddInput(new Button(_padID, ButtonManager::BUTTON_Y));
|
||||
AddInput(new Button(_padID, ButtonManager::BUTTON_Z));
|
||||
AddInput(new Button(_padID, ButtonManager::BUTTON_UP));
|
||||
AddInput(new Button(_padID, ButtonManager::BUTTON_DOWN));
|
||||
AddInput(new Button(_padID, ButtonManager::BUTTON_LEFT));
|
||||
AddInput(new Button(_padID, ButtonManager::BUTTON_RIGHT));
|
||||
AddInput(new Axis(_padID, ButtonManager::STICK_MAIN_LEFT));
|
||||
AddInput(new Axis(_padID, ButtonManager::STICK_MAIN_RIGHT));
|
||||
AddInput(new Axis(_padID, ButtonManager::STICK_MAIN_UP));
|
||||
AddInput(new Axis(_padID, ButtonManager::STICK_MAIN_DOWN));
|
||||
AddInput(new Axis(_padID, ButtonManager::STICK_C_LEFT));
|
||||
AddInput(new Axis(_padID, ButtonManager::STICK_C_RIGHT));
|
||||
AddInput(new Axis(_padID, ButtonManager::STICK_C_UP));
|
||||
AddInput(new Axis(_padID, ButtonManager::STICK_C_DOWN));
|
||||
AddInput(new Axis(_padID, ButtonManager::TRIGGER_L));
|
||||
AddInput(new Axis(_padID, ButtonManager::TRIGGER_R));
|
||||
|
||||
// Wiimote
|
||||
AddInput(new Button(_padID, ButtonManager::WIIMOTE_BUTTON_A));
|
||||
AddInput(new Button(_padID, ButtonManager::WIIMOTE_BUTTON_B));
|
||||
AddInput(new Button(_padID, ButtonManager::WIIMOTE_BUTTON_MINUS));
|
||||
AddInput(new Button(_padID, ButtonManager::WIIMOTE_BUTTON_PLUS));
|
||||
AddInput(new Button(_padID, ButtonManager::WIIMOTE_BUTTON_HOME));
|
||||
AddInput(new Button(_padID, ButtonManager::WIIMOTE_BUTTON_1));
|
||||
AddInput(new Button(_padID, ButtonManager::WIIMOTE_BUTTON_2));
|
||||
AddInput(new Button(_padID, ButtonManager::WIIMOTE_UP));
|
||||
AddInput(new Button(_padID, ButtonManager::WIIMOTE_DOWN));
|
||||
AddInput(new Button(_padID, ButtonManager::WIIMOTE_LEFT));
|
||||
AddInput(new Button(_padID, ButtonManager::WIIMOTE_RIGHT));
|
||||
AddInput(new Button(_padID, ButtonManager::WIIMOTE_IR_HIDE));
|
||||
AddInput(new Button(_padID, ButtonManager::WIIMOTE_TILT_MODIFIER));
|
||||
AddInput(new Button(_padID, ButtonManager::WIIMOTE_SHAKE_X));
|
||||
AddInput(new Button(_padID, ButtonManager::WIIMOTE_SHAKE_Y));
|
||||
AddInput(new Button(_padID, ButtonManager::WIIMOTE_SHAKE_Z));
|
||||
AddInput(new Axis(_padID, ButtonManager::WIIMOTE_IR_UP));
|
||||
AddInput(new Axis(_padID, ButtonManager::WIIMOTE_IR_DOWN));
|
||||
AddInput(new Axis(_padID, ButtonManager::WIIMOTE_IR_LEFT));
|
||||
AddInput(new Axis(_padID, ButtonManager::WIIMOTE_IR_RIGHT));
|
||||
AddInput(new Axis(_padID, ButtonManager::WIIMOTE_IR_FORWARD));
|
||||
AddInput(new Axis(_padID, ButtonManager::WIIMOTE_IR_BACKWARD));
|
||||
AddInput(new Axis(_padID, ButtonManager::WIIMOTE_SWING_UP));
|
||||
AddInput(new Axis(_padID, ButtonManager::WIIMOTE_SWING_DOWN));
|
||||
AddInput(new Axis(_padID, ButtonManager::WIIMOTE_SWING_LEFT));
|
||||
AddInput(new Axis(_padID, ButtonManager::WIIMOTE_SWING_RIGHT));
|
||||
AddInput(new Axis(_padID, ButtonManager::WIIMOTE_SWING_FORWARD));
|
||||
AddInput(new Axis(_padID, ButtonManager::WIIMOTE_SWING_BACKWARD));
|
||||
AddInput(new Axis(_padID, ButtonManager::WIIMOTE_TILT_LEFT));
|
||||
AddInput(new Axis(_padID, ButtonManager::WIIMOTE_TILT_RIGHT));
|
||||
AddInput(new Axis(_padID, ButtonManager::WIIMOTE_TILT_FORWARD));
|
||||
AddInput(new Axis(_padID, ButtonManager::WIIMOTE_TILT_BACKWARD));
|
||||
|
||||
// Wii ext: Nunchuk
|
||||
AddInput(new Button(_padID, ButtonManager::NUNCHUK_BUTTON_C));
|
||||
AddInput(new Button(_padID, ButtonManager::NUNCHUK_BUTTON_Z));
|
||||
AddInput(new Button(_padID, ButtonManager::NUNCHUK_TILT_MODIFIER));
|
||||
AddInput(new Button(_padID, ButtonManager::NUNCHUK_SHAKE_X));
|
||||
AddInput(new Button(_padID, ButtonManager::NUNCHUK_SHAKE_Y));
|
||||
AddInput(new Button(_padID, ButtonManager::NUNCHUK_SHAKE_Z));
|
||||
AddInput(new Axis(_padID, ButtonManager::NUNCHUK_STICK_LEFT));
|
||||
AddInput(new Axis(_padID, ButtonManager::NUNCHUK_STICK_RIGHT));
|
||||
AddInput(new Axis(_padID, ButtonManager::NUNCHUK_STICK_UP));
|
||||
AddInput(new Axis(_padID, ButtonManager::NUNCHUK_STICK_DOWN));
|
||||
AddInput(new Axis(_padID, ButtonManager::NUNCHUK_SWING_LEFT));
|
||||
AddInput(new Axis(_padID, ButtonManager::NUNCHUK_SWING_RIGHT));
|
||||
AddInput(new Axis(_padID, ButtonManager::NUNCHUK_SWING_UP));
|
||||
AddInput(new Axis(_padID, ButtonManager::NUNCHUK_SWING_DOWN));
|
||||
AddInput(new Axis(_padID, ButtonManager::NUNCHUK_SWING_FORWARD));
|
||||
AddInput(new Axis(_padID, ButtonManager::NUNCHUK_SWING_BACKWARD));
|
||||
AddInput(new Axis(_padID, ButtonManager::NUNCHUK_TILT_LEFT));
|
||||
AddInput(new Axis(_padID, ButtonManager::NUNCHUK_TILT_RIGHT));
|
||||
AddInput(new Axis(_padID, ButtonManager::NUNCHUK_TILT_FORWARD));
|
||||
AddInput(new Axis(_padID, ButtonManager::NUNCHUK_TILT_BACKWARD));
|
||||
|
||||
// Wii ext: Classic
|
||||
AddInput(new Button(_padID, ButtonManager::CLASSIC_BUTTON_A));
|
||||
AddInput(new Button(_padID, ButtonManager::CLASSIC_BUTTON_B));
|
||||
AddInput(new Button(_padID, ButtonManager::CLASSIC_BUTTON_X));
|
||||
AddInput(new Button(_padID, ButtonManager::CLASSIC_BUTTON_Y));
|
||||
AddInput(new Button(_padID, ButtonManager::CLASSIC_BUTTON_MINUS));
|
||||
AddInput(new Button(_padID, ButtonManager::CLASSIC_BUTTON_PLUS));
|
||||
AddInput(new Button(_padID, ButtonManager::CLASSIC_BUTTON_HOME));
|
||||
AddInput(new Button(_padID, ButtonManager::CLASSIC_BUTTON_ZL));
|
||||
AddInput(new Button(_padID, ButtonManager::CLASSIC_BUTTON_ZR));
|
||||
AddInput(new Button(_padID, ButtonManager::CLASSIC_DPAD_UP));
|
||||
AddInput(new Button(_padID, ButtonManager::CLASSIC_DPAD_DOWN));
|
||||
AddInput(new Button(_padID, ButtonManager::CLASSIC_DPAD_LEFT));
|
||||
AddInput(new Button(_padID, ButtonManager::CLASSIC_DPAD_RIGHT));
|
||||
AddInput(new Axis(_padID, ButtonManager::CLASSIC_STICK_LEFT_LEFT));
|
||||
AddInput(new Axis(_padID, ButtonManager::CLASSIC_STICK_LEFT_RIGHT));
|
||||
AddInput(new Axis(_padID, ButtonManager::CLASSIC_STICK_LEFT_UP));
|
||||
AddInput(new Axis(_padID, ButtonManager::CLASSIC_STICK_LEFT_DOWN));
|
||||
AddInput(new Axis(_padID, ButtonManager::CLASSIC_STICK_RIGHT_LEFT));
|
||||
AddInput(new Axis(_padID, ButtonManager::CLASSIC_STICK_RIGHT_RIGHT));
|
||||
AddInput(new Axis(_padID, ButtonManager::CLASSIC_STICK_RIGHT_UP));
|
||||
AddInput(new Axis(_padID, ButtonManager::CLASSIC_STICK_RIGHT_DOWN));
|
||||
AddInput(new Axis(_padID, ButtonManager::CLASSIC_TRIGGER_L));
|
||||
AddInput(new Axis(_padID, ButtonManager::CLASSIC_TRIGGER_R));
|
||||
|
||||
// Wii-ext: Guitar
|
||||
AddInput(new Button(_padID, ButtonManager::GUITAR_BUTTON_MINUS));
|
||||
AddInput(new Button(_padID, ButtonManager::GUITAR_BUTTON_PLUS));
|
||||
AddInput(new Button(_padID, ButtonManager::GUITAR_FRET_GREEN));
|
||||
AddInput(new Button(_padID, ButtonManager::GUITAR_FRET_RED));
|
||||
AddInput(new Button(_padID, ButtonManager::GUITAR_FRET_YELLOW));
|
||||
AddInput(new Button(_padID, ButtonManager::GUITAR_FRET_BLUE));
|
||||
AddInput(new Button(_padID, ButtonManager::GUITAR_FRET_ORANGE));
|
||||
AddInput(new Button(_padID, ButtonManager::GUITAR_STRUM_UP));
|
||||
AddInput(new Button(_padID, ButtonManager::GUITAR_STRUM_DOWN));
|
||||
AddInput(new Axis(_padID, ButtonManager::GUITAR_STICK_LEFT));
|
||||
AddInput(new Axis(_padID, ButtonManager::GUITAR_STICK_RIGHT));
|
||||
AddInput(new Axis(_padID, ButtonManager::GUITAR_STICK_UP));
|
||||
AddInput(new Axis(_padID, ButtonManager::GUITAR_STICK_DOWN));
|
||||
AddInput(new Axis(_padID, ButtonManager::GUITAR_WHAMMY_BAR));
|
||||
|
||||
// Wii-ext: Drums
|
||||
AddInput(new Button(_padID, ButtonManager::DRUMS_BUTTON_MINUS));
|
||||
AddInput(new Button(_padID, ButtonManager::DRUMS_BUTTON_PLUS));
|
||||
AddInput(new Button(_padID, ButtonManager::DRUMS_PAD_RED));
|
||||
AddInput(new Button(_padID, ButtonManager::DRUMS_PAD_YELLOW));
|
||||
AddInput(new Button(_padID, ButtonManager::DRUMS_PAD_BLUE));
|
||||
AddInput(new Button(_padID, ButtonManager::DRUMS_PAD_GREEN));
|
||||
AddInput(new Button(_padID, ButtonManager::DRUMS_PAD_ORANGE));
|
||||
AddInput(new Button(_padID, ButtonManager::DRUMS_PAD_BASS));
|
||||
AddInput(new Axis(_padID, ButtonManager::DRUMS_STICK_LEFT));
|
||||
AddInput(new Axis(_padID, ButtonManager::DRUMS_STICK_RIGHT));
|
||||
AddInput(new Axis(_padID, ButtonManager::DRUMS_STICK_UP));
|
||||
AddInput(new Axis(_padID, ButtonManager::DRUMS_STICK_DOWN));
|
||||
|
||||
// Wii-ext: Turntable
|
||||
AddInput(new Button(_padID, ButtonManager::TURNTABLE_BUTTON_GREEN_LEFT));
|
||||
AddInput(new Button(_padID, ButtonManager::TURNTABLE_BUTTON_RED_LEFT));
|
||||
AddInput(new Button(_padID, ButtonManager::TURNTABLE_BUTTON_BLUE_LEFT));
|
||||
AddInput(new Button(_padID, ButtonManager::TURNTABLE_BUTTON_GREEN_RIGHT));
|
||||
AddInput(new Button(_padID, ButtonManager::TURNTABLE_BUTTON_RED_RIGHT));
|
||||
AddInput(new Button(_padID, ButtonManager::TURNTABLE_BUTTON_BLUE_RIGHT));
|
||||
AddInput(new Button(_padID, ButtonManager::TURNTABLE_BUTTON_MINUS));
|
||||
AddInput(new Button(_padID, ButtonManager::TURNTABLE_BUTTON_PLUS));
|
||||
AddInput(new Button(_padID, ButtonManager::TURNTABLE_BUTTON_HOME));
|
||||
AddInput(new Button(_padID, ButtonManager::TURNTABLE_BUTTON_EUPHORIA));
|
||||
AddInput(new Axis(_padID, ButtonManager::TURNTABLE_TABLE_LEFT_LEFT));
|
||||
AddInput(new Axis(_padID, ButtonManager::TURNTABLE_TABLE_LEFT_RIGHT));
|
||||
AddInput(new Axis(_padID, ButtonManager::TURNTABLE_TABLE_RIGHT_LEFT));
|
||||
AddInput(new Axis(_padID, ButtonManager::TURNTABLE_TABLE_RIGHT_RIGHT));
|
||||
AddInput(new Axis(_padID, ButtonManager::TURNTABLE_STICK_LEFT));
|
||||
AddInput(new Axis(_padID, ButtonManager::TURNTABLE_STICK_RIGHT));
|
||||
AddInput(new Axis(_padID, ButtonManager::TURNTABLE_STICK_UP));
|
||||
AddInput(new Axis(_padID, ButtonManager::TURNTABLE_STICK_DOWN));
|
||||
AddInput(new Axis(_padID, ButtonManager::TURNTABLE_CROSSFADE_LEFT));
|
||||
AddInput(new Axis(_padID, ButtonManager::TURNTABLE_CROSSFADE_RIGHT));
|
||||
AddInput(new Axis(_padID, 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 (s_accelerometer_enabled)
|
||||
{
|
||||
AddInput(new Axis(_padID, ButtonManager::WIIMOTE_ACCEL_LEFT));
|
||||
AddInput(new Axis(_padID, ButtonManager::WIIMOTE_ACCEL_RIGHT));
|
||||
AddInput(new Axis(_padID, ButtonManager::WIIMOTE_ACCEL_FORWARD));
|
||||
AddInput(new Axis(_padID, ButtonManager::WIIMOTE_ACCEL_BACKWARD));
|
||||
AddInput(new Axis(_padID, ButtonManager::WIIMOTE_ACCEL_UP));
|
||||
AddInput(new Axis(_padID, ButtonManager::WIIMOTE_ACCEL_DOWN));
|
||||
}
|
||||
if (s_gyroscope_enabled)
|
||||
{
|
||||
AddInput(new Axis(_padID, ButtonManager::WIIMOTE_GYRO_PITCH_UP));
|
||||
AddInput(new Axis(_padID, ButtonManager::WIIMOTE_GYRO_PITCH_DOWN));
|
||||
AddInput(new Axis(_padID, ButtonManager::WIIMOTE_GYRO_ROLL_LEFT));
|
||||
AddInput(new Axis(_padID, ButtonManager::WIIMOTE_GYRO_ROLL_RIGHT));
|
||||
AddInput(new Axis(_padID, ButtonManager::WIIMOTE_GYRO_YAW_LEFT));
|
||||
AddInput(new Axis(_padID, ButtonManager::WIIMOTE_GYRO_YAW_RIGHT));
|
||||
}
|
||||
|
||||
// Rumble
|
||||
AddOutput(new Motor(_padID, ButtonManager::RUMBLE));
|
||||
}
|
||||
// Buttons and stuff
|
||||
|
||||
std::string Touchscreen::Button::GetName() const
|
||||
{
|
||||
std::ostringstream ss;
|
||||
ss << "Button " << (int)_index;
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
ControlState Touchscreen::Button::GetState() const
|
||||
{
|
||||
return ButtonManager::GetButtonPressed(_padID, _index);
|
||||
}
|
||||
|
||||
std::string Touchscreen::Axis::GetName() const
|
||||
{
|
||||
std::ostringstream ss;
|
||||
ss << "Axis " << (int)_index;
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
ControlState Touchscreen::Axis::GetState() const
|
||||
{
|
||||
return ButtonManager::GetAxisValue(_padID, _index) * _neg;
|
||||
}
|
||||
|
||||
Touchscreen::Motor::~Motor()
|
||||
{
|
||||
}
|
||||
|
||||
std::string Touchscreen::Motor::GetName() const
|
||||
{
|
||||
std::ostringstream ss;
|
||||
ss << "Rumble " << (int)_index;
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
void Touchscreen::Motor::SetState(ControlState state)
|
||||
{
|
||||
if (state > 0)
|
||||
{
|
||||
std::thread(Rumble, _padID, state).detach();
|
||||
}
|
||||
}
|
||||
|
||||
void Touchscreen::Motor::Rumble(int padID, double state)
|
||||
{
|
||||
JNIEnv* env = IDCache::GetEnvForThread();
|
||||
env->CallStaticVoidMethod(IDCache::GetNativeLibraryClass(), IDCache::GetDoRumble(), padID, state);
|
||||
g_controller_interface.AddDevice(std::make_shared<ciface::Touch::Touchscreen>(
|
||||
i, s_accelerometer_enabled, s_gyroscope_enabled));
|
||||
}
|
||||
} // namespace ciface::Android
|
||||
|
||||
@@ -4,66 +4,9 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "InputCommon/ControllerInterface/ControllerInterface.h"
|
||||
#include "jni/ButtonManager.h"
|
||||
|
||||
namespace ciface::Android
|
||||
{
|
||||
void SetMotionSensorsEnabled(bool accelerometer_enabled, bool gyroscope_enabled);
|
||||
|
||||
void PopulateDevices();
|
||||
|
||||
class Touchscreen : public Core::Device
|
||||
{
|
||||
private:
|
||||
class Button : public Input
|
||||
{
|
||||
public:
|
||||
std::string GetName() const;
|
||||
Button(int padID, ButtonManager::ButtonType index) : _padID(padID), _index(index) {}
|
||||
ControlState GetState() const;
|
||||
|
||||
private:
|
||||
const int _padID;
|
||||
const ButtonManager::ButtonType _index;
|
||||
};
|
||||
class Axis : public Input
|
||||
{
|
||||
public:
|
||||
std::string GetName() const;
|
||||
bool IsDetectable() override { return false; }
|
||||
Axis(int padID, ButtonManager::ButtonType index, float neg = 1.0f)
|
||||
: _padID(padID), _index(index), _neg(neg)
|
||||
{
|
||||
}
|
||||
ControlState GetState() const;
|
||||
|
||||
private:
|
||||
const int _padID;
|
||||
const ButtonManager::ButtonType _index;
|
||||
const float _neg;
|
||||
};
|
||||
class Motor : public Core::Device::Output
|
||||
{
|
||||
public:
|
||||
Motor(int padID, ButtonManager::ButtonType index) : _padID(padID), _index(index) {}
|
||||
~Motor();
|
||||
std::string GetName() const override;
|
||||
void SetState(ControlState state) override;
|
||||
|
||||
private:
|
||||
const int _padID;
|
||||
const ButtonManager::ButtonType _index;
|
||||
static void Rumble(int padID, double state);
|
||||
};
|
||||
|
||||
public:
|
||||
Touchscreen(int padID);
|
||||
~Touchscreen() {}
|
||||
std::string GetName() const;
|
||||
std::string GetSource() const;
|
||||
|
||||
private:
|
||||
const int _padID;
|
||||
};
|
||||
} // namespace ciface::Android
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,276 @@
|
||||
// Copyright 2013 Dolphin Emulator Project
|
||||
// Licensed under GPLv2+
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#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() { 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() { 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_axises;
|
||||
|
||||
// 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);
|
||||
float AxisValue(int pad_id, ButtonType axis);
|
||||
};
|
||||
|
||||
void Init(const std::string&);
|
||||
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
|
||||
@@ -0,0 +1,264 @@
|
||||
// Copyright 2013 Dolphin Emulator Project
|
||||
// Licensed under GPLv2+
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#ifdef ANDROID
|
||||
#include <jni/AndroidCommon/IDCache.h>
|
||||
#endif
|
||||
|
||||
#include <sstream>
|
||||
#include <thread>
|
||||
#include "InputCommon/ControllerInterface/ControllerInterface.h"
|
||||
#include "InputCommon/ControllerInterface/Touch/Touchscreen.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
|
||||
@@ -0,0 +1,65 @@
|
||||
// Copyright 2008 Dolphin Emulator Project
|
||||
// Licensed under GPLv2+
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#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;
|
||||
Button(int pad_id, ButtonManager::ButtonType index) : m_pad_id(pad_id), m_index(index) {}
|
||||
ControlState GetState() const;
|
||||
|
||||
private:
|
||||
const int m_pad_id;
|
||||
const ButtonManager::ButtonType m_index;
|
||||
};
|
||||
class Axis : public Input
|
||||
{
|
||||
public:
|
||||
std::string GetName() const;
|
||||
bool IsDetectable() 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;
|
||||
|
||||
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;
|
||||
std::string GetSource() const;
|
||||
|
||||
private:
|
||||
const int m_pad_id;
|
||||
};
|
||||
} // namespace ciface::Touch
|
||||
Reference in New Issue
Block a user