From 2721fdf8a94e2e49f907eda24a1406d2225acaf6 Mon Sep 17 00:00:00 2001 From: Scott Mansell Date: Mon, 29 Jun 2015 12:17:35 +1200 Subject: Linux: Add an evdev based controller backend, to replace SDL. --- Source/Core/InputCommon/CMakeLists.txt | 5 + .../ControllerInterface/ControllerInterface.cpp | 6 + .../ControllerInterface/ControllerInterface.h | 3 + .../ControllerInterface/evdev/evdev.cpp | 264 +++++++++++++++++++++ .../InputCommon/ControllerInterface/evdev/evdev.h | 86 +++++++ 5 files changed, 364 insertions(+) create mode 100644 Source/Core/InputCommon/ControllerInterface/evdev/evdev.cpp create mode 100644 Source/Core/InputCommon/ControllerInterface/evdev/evdev.h (limited to 'Source/Core/InputCommon') diff --git a/Source/Core/InputCommon/CMakeLists.txt b/Source/Core/InputCommon/CMakeLists.txt index 75679b6a9f..549865b8e9 100644 --- a/Source/Core/InputCommon/CMakeLists.txt +++ b/Source/Core/InputCommon/CMakeLists.txt @@ -37,6 +37,11 @@ elseif(ANDROID) ControllerInterface/Android/Android.cpp) endif() +if(LIBEVDEV_FOUND AND LIBUDEV_FOUND) + set(SRCS ${SRCS} ControllerInterface/evdev/evdev.cpp) + set(LIBS ${LIBS} ${LIBEVDEV_LIBRARY} ${LIBUDEV_LIBRARY}) +endif() + if(SDL_FOUND OR SDL2_FOUND) set(SRCS ${SRCS} ControllerInterface/SDL/SDL.cpp) if (SDL2_FOUND) diff --git a/Source/Core/InputCommon/ControllerInterface/ControllerInterface.cpp b/Source/Core/InputCommon/ControllerInterface/ControllerInterface.cpp index 6b8b11fd3a..0631069e16 100644 --- a/Source/Core/InputCommon/ControllerInterface/ControllerInterface.cpp +++ b/Source/Core/InputCommon/ControllerInterface/ControllerInterface.cpp @@ -26,6 +26,9 @@ #ifdef CIFACE_USE_ANDROID #include "InputCommon/ControllerInterface/Android/Android.h" #endif +#ifdef CIFACE_USE_EVDEV + #include "InputCommon/ControllerInterface/evdev/evdev.h" +#endif using namespace ciface::ExpressionParser; @@ -69,6 +72,9 @@ void ControllerInterface::Initialize(void* const hwnd) #ifdef CIFACE_USE_ANDROID ciface::Android::Init(m_devices); #endif +#ifdef CIFACE_USE_EVDEV + ciface::evdev::Init(m_devices); +#endif m_is_init = true; } diff --git a/Source/Core/InputCommon/ControllerInterface/ControllerInterface.h b/Source/Core/InputCommon/ControllerInterface/ControllerInterface.h index 408a36fefa..3aca18e95c 100644 --- a/Source/Core/InputCommon/ControllerInterface/ControllerInterface.h +++ b/Source/Core/InputCommon/ControllerInterface/ControllerInterface.h @@ -35,6 +35,9 @@ #if defined(HAVE_SDL) && HAVE_SDL #define CIFACE_USE_SDL #endif +#if defined(HAVE_LIBEVDEV) && defined(HAVE_LIBUDEV) + #define CIFACE_USE_EVDEV +#endif // // ControllerInterface diff --git a/Source/Core/InputCommon/ControllerInterface/evdev/evdev.cpp b/Source/Core/InputCommon/ControllerInterface/evdev/evdev.cpp new file mode 100644 index 0000000000..2f4d53e234 --- /dev/null +++ b/Source/Core/InputCommon/ControllerInterface/evdev/evdev.cpp @@ -0,0 +1,264 @@ +// Copyright 2015 Dolphin Emulator Project +// Licensed under GPLv2+ +// Refer to the license.txt file included. + +#include +#include + +#include "Common/Logging/Log.h" +#include "InputCommon/ControllerInterface/evdev/evdev.h" + + +namespace ciface +{ +namespace evdev +{ + +void Init(std::vector &controllerDevices) +{ + int num_controllers = 0; + + // We use Udev to find any devices. In the future this will allow for hotplugging. + // But for now it is essentially iterating over /dev/input/event0 to event31. However if the + // naming scheme is ever updated in the future, this *should* be forwards compatable. + + struct udev* udev = udev_new(); + _assert_msg_(PAD, udev != 0, "Couldn't initilize libudev."); + + // List all input devices + udev_enumerate* enumerate = udev_enumerate_new(udev); + udev_enumerate_add_match_subsystem(enumerate, "input"); + udev_enumerate_scan_devices(enumerate); + udev_list_entry* devices = udev_enumerate_get_list_entry(enumerate); + + // Iterate over all input devices + udev_list_entry* dev_list_entry; + udev_list_entry_foreach(dev_list_entry, devices) + { + const char* path = udev_list_entry_get_name(dev_list_entry); + + udev_device* dev = udev_device_new_from_syspath(udev, path); + + const char* devnode = udev_device_get_devnode(dev); + // We only care about devices which we have read/write access to. + if (access(devnode, W_OK) == 0) + { + // Unfortunately udev gives us no way to filter out the non event device interfaces. + // So we open it and see if it works with evdev ioctls or not. + evdevDevice* input = new evdevDevice(devnode, num_controllers); + + if (input->IsInteresting()) + { + controllerDevices.push_back(input); + num_controllers++; + } + else + { + // Either it wasn't a evdev device, or it didn't have at least 8 buttons or two axis. + delete input; + } + } + udev_device_unref(dev); + } + udev_enumerate_unref(enumerate); + udev_unref(udev); +} + +evdevDevice::evdevDevice(const std::string &devnode, int id) : m_devfile(devnode), m_id(id) +{ + // The device file will be read on one of the main threads, so we open in non-blocking mode. + m_fd = open(devnode.c_str(), O_RDWR|O_NONBLOCK); + int ret = libevdev_new_from_fd(m_fd, &m_dev); + + if (ret != 0) + { + // This useally fails because the device node isn't an evdev device, such as /dev/input/js0 + m_initialized = false; + close(m_fd); + return; + } + + m_name = libevdev_get_name(m_dev); + + // Controller buttons (and keyboard keys) + int num_buttons = 0; + for (int key = 0; key < KEY_MAX; key++) + if (libevdev_has_event_code(m_dev, EV_KEY, key)) + AddInput(new Button(num_buttons++, key, m_dev)); + + // Absolute axis (thumbsticks) + int num_axis = 0; + for (int axis = 0; axis < 0x100; axis++) + if (libevdev_has_event_code(m_dev, EV_ABS, axis)) + { + AddAnalogInputs(new Axis(num_axis, axis, false, m_dev), + new Axis(num_axis, axis, true, m_dev)); + num_axis++; + } + + // Force feedback + if (libevdev_has_event_code(m_dev, EV_FF, FF_PERIODIC)) + { + for (auto type : {FF_SINE, FF_SQUARE, FF_TRIANGLE, FF_SAW_UP, FF_SAW_DOWN}) + if (libevdev_has_event_code(m_dev, EV_FF, type)) + AddOutput(new ForceFeedback(type, m_dev)); + } + if (libevdev_has_event_code(m_dev, EV_FF, FF_RUMBLE)) + { + AddOutput(new ForceFeedback(FF_RUMBLE, m_dev)); + } + + // TODO: Add leds as output devices + + m_initialized = true; + m_interesting = num_axis >= 2 || num_buttons >= 8; +} + +evdevDevice::~evdevDevice() +{ + if (m_initialized) + { + libevdev_free(m_dev); + close(m_fd); + } +} + +void evdevDevice::UpdateInput() +{ + // Run through all evdev events + // libevdev will keep track of the actual controller state internally which can be queried + // later with libevdev_fetch_event_value() + input_event ev; + int rc = LIBEVDEV_READ_STATUS_SUCCESS; + do + { + if (rc == LIBEVDEV_READ_STATUS_SYNC) + rc = libevdev_next_event(m_dev, LIBEVDEV_READ_FLAG_SYNC, &ev); + else + rc = libevdev_next_event(m_dev, LIBEVDEV_READ_FLAG_NORMAL, &ev); + } while (rc >= 0); +} + + +std::string evdevDevice::Button::GetName() const +{ + // Buttons below 0x100 are mostly keyboard keys, and the names make sense + if (m_code < 0x100) + { + const char* name = libevdev_event_code_get_name(EV_KEY, m_code); + if (name) + return std::string(name); + } + // But controllers use codes above 0x100, and the standard label often doesn't match. + // We are better off with Button 0 and so on. + return "Button " + std::to_string(m_index); +} + +ControlState evdevDevice::Button::GetState() const +{ + int value = 0; + libevdev_fetch_event_value(m_dev, EV_KEY, m_code, &value); + return value; +} + +evdevDevice::Axis::Axis(u8 index, u16 code, bool upper, libevdev* dev) : + m_code(code), m_index(index), m_upper(upper), m_dev(dev) +{ + m_range = libevdev_get_abs_maximum(m_dev, m_code); +} + +std::string evdevDevice::Axis::GetName() const +{ + return "Axis " + std::to_string(m_index) + (m_upper ? "+" : "-"); +} + +ControlState evdevDevice::Axis::GetState() const +{ + int value = 0; + libevdev_fetch_event_value(m_dev, EV_ABS, m_code, &value); + if (m_upper) + return std::max(0.0, double(value) / double(m_range) - 0.5) * 2.0; + else + return (0.5 - std::min(0.5, double(value) / double(m_range))) * 2.0; +} + +std::string evdevDevice::ForceFeedback::GetName() const +{ + // We have some default names. + switch (m_type) + { + case FF_SINE: + return "Sine"; + case FF_TRIANGLE: + return "Triangle"; + case FF_SQUARE: + return "Square"; + case FF_RUMBLE: + return "LeftRight"; + default: + { + const char* name = libevdev_event_code_get_name(EV_FF, m_type); + if (name) + return std::string(name); + return "Unknown"; + } + } +} + +void evdevDevice::ForceFeedback::SetState(ControlState state) +{ + // libevdev doesn't have nice helpers for forcefeedback + // we will use the file descriptors directly. + + if (state > 0) // Upload and start an effect. + { + ff_effect effect; + + effect.id = -1; + effect.direction = 0; // down + effect.replay.length = 500; // 500ms + effect.replay.delay = 0; + effect.trigger.button = 0; // don't trigger on button press + effect.trigger.interval = 0; + + // This is the the interface that XInput uses, with 2 motors of differing sizes/frequencies that + // are controlled seperatally + if (m_type == FF_RUMBLE) + { + effect.type = FF_RUMBLE; + // max ranges tuned to 'feel' similar in magnitude to triangle/sine on xbox360 controller + effect.u.rumble.strong_magnitude = u16(state * 0x4000); + effect.u.rumble.weak_magnitude = u16(state * 0xFFFF); + } + else // FF_PERIODIC, a more generic interface. + { + effect.type = FF_PERIODIC; + effect.u.periodic.waveform = m_type; + effect.u.periodic.phase = 0x7fff; // 180 degrees + effect.u.periodic.offset = 0; + effect.u.periodic.period = 10; + effect.u.periodic.magnitude = s16(state * 0x7FFF); + effect.u.periodic.envelope.attack_length = 0; // no attack + effect.u.periodic.envelope.attack_level = 0; + effect.u.periodic.envelope.fade_length = 0; + effect.u.periodic.envelope.fade_level = 0; + } + + ioctl(m_fd, EVIOCSFF, &effect); + m_id = effect.id; + + input_event play; + play.type = EV_FF; + play.code = m_id; + play.value = 1; + + write(m_fd, (const void*) &play, sizeof(play)); + } + else if (m_id != -1) // delete the effect (which also stops it) + { + ioctl(m_id, EVIOCRMFF, m_id); + } +} + +} +} diff --git a/Source/Core/InputCommon/ControllerInterface/evdev/evdev.h b/Source/Core/InputCommon/ControllerInterface/evdev/evdev.h new file mode 100644 index 0000000000..7290fbc379 --- /dev/null +++ b/Source/Core/InputCommon/ControllerInterface/evdev/evdev.h @@ -0,0 +1,86 @@ +// Copyright 2015 Dolphin Emulator Project +// Licensed under GPLv2+ +// Refer to the license.txt file included. + +#pragma once + +#include +#include +#include + +#include "InputCommon/ControllerInterface/Device.h" + +namespace ciface +{ +namespace evdev +{ + +void Init(std::vector& devices); + +class evdevDevice : public Core::Device +{ +private: + class Button : public Core::Device::Input + { + public: + std::string GetName() const override; + Button(u8 index, u16 code, libevdev* dev) : m_index(index), m_code(code), m_dev(dev) {} + ControlState GetState() const override; + private: + const u8 m_index; + const u16 m_code; + libevdev* m_dev; + }; + + class Axis : public Core::Device::Input + { + public: + std::string GetName() const override; + Axis(u8 index, u16 code, bool upper, libevdev* dev); + ControlState GetState() const override; + private: + const u16 m_code; + const u8 m_index; + const bool m_upper; + int m_range; + libevdev* m_dev; + }; + + class ForceFeedback : public Core::Device::Output + { + public: + std::string GetName() const override; + ForceFeedback(u16 type, libevdev* dev) : m_type(type), m_dev(dev), m_id(-1) { m_fd = libevdev_get_fd(dev); } + void SetState(ControlState state) override; + private: + const u16 m_type; + libevdev* m_dev; + int m_fd; + int m_id; + }; + +public: + void UpdateInput() override; + + evdevDevice(const std::string &devnode, int id); + ~evdevDevice(); + + std::string GetName() const override { return m_name; } + int GetId() const override { return m_id; } + std::string GetSource() const override { return "evdev"; } + + bool IsInteresting() const { return m_initialized && m_interesting; } + +private: + const std::string m_devfile; + int m_fd; + libevdev* m_dev; + std::string m_name; + const int m_id; + bool m_initialized; + bool m_interesting; +}; + +} + +} -- cgit v1.2.3 From 77183899e0526a343b8429cf04a1c07b31aafc34 Mon Sep 17 00:00:00 2001 From: Scott Mansell Date: Wed, 1 Jul 2015 00:37:26 +1200 Subject: evdev: Support axis with ranges which extend below zero. --- Source/Core/InputCommon/ControllerInterface/evdev/evdev.cpp | 12 +++++++++--- Source/Core/InputCommon/ControllerInterface/evdev/evdev.h | 1 + 2 files changed, 10 insertions(+), 3 deletions(-) (limited to 'Source/Core/InputCommon') diff --git a/Source/Core/InputCommon/ControllerInterface/evdev/evdev.cpp b/Source/Core/InputCommon/ControllerInterface/evdev/evdev.cpp index 2f4d53e234..9b31da73c4 100644 --- a/Source/Core/InputCommon/ControllerInterface/evdev/evdev.cpp +++ b/Source/Core/InputCommon/ControllerInterface/evdev/evdev.cpp @@ -164,7 +164,8 @@ ControlState evdevDevice::Button::GetState() const evdevDevice::Axis::Axis(u8 index, u16 code, bool upper, libevdev* dev) : m_code(code), m_index(index), m_upper(upper), m_dev(dev) { - m_range = libevdev_get_abs_maximum(m_dev, m_code); + m_min = libevdev_get_abs_minimum(m_dev, m_code); + m_range = libevdev_get_abs_maximum(m_dev, m_code) + abs(m_min); } std::string evdevDevice::Axis::GetName() const @@ -176,10 +177,15 @@ ControlState evdevDevice::Axis::GetState() const { int value = 0; libevdev_fetch_event_value(m_dev, EV_ABS, m_code, &value); + + // Value from 0.0 to 1.0 + ControlState fvalue = double(value - m_min) / double(m_range); + + // Split into two axis, each covering half the range from 0.0 to 1.0 if (m_upper) - return std::max(0.0, double(value) / double(m_range) - 0.5) * 2.0; + return std::max(0.0, fvalue - 0.5) * 2.0; else - return (0.5 - std::min(0.5, double(value) / double(m_range))) * 2.0; + return (0.5 - std::min(0.5, fvalue)) * 2.0; } std::string evdevDevice::ForceFeedback::GetName() const diff --git a/Source/Core/InputCommon/ControllerInterface/evdev/evdev.h b/Source/Core/InputCommon/ControllerInterface/evdev/evdev.h index 7290fbc379..d1555c8cce 100644 --- a/Source/Core/InputCommon/ControllerInterface/evdev/evdev.h +++ b/Source/Core/InputCommon/ControllerInterface/evdev/evdev.h @@ -43,6 +43,7 @@ private: const u8 m_index; const bool m_upper; int m_range; + int m_min; libevdev* m_dev; }; -- cgit v1.2.3 From 64b51df55d378c457b3e324b64a16c113d54ff5f Mon Sep 17 00:00:00 2001 From: Tillmann Karras Date: Sat, 4 Jul 2015 14:14:15 +0200 Subject: evdev: fix -Wunused-private-field warning --- Source/Core/InputCommon/ControllerInterface/evdev/evdev.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'Source/Core/InputCommon') diff --git a/Source/Core/InputCommon/ControllerInterface/evdev/evdev.h b/Source/Core/InputCommon/ControllerInterface/evdev/evdev.h index d1555c8cce..c6c65e312d 100644 --- a/Source/Core/InputCommon/ControllerInterface/evdev/evdev.h +++ b/Source/Core/InputCommon/ControllerInterface/evdev/evdev.h @@ -51,11 +51,10 @@ private: { public: std::string GetName() const override; - ForceFeedback(u16 type, libevdev* dev) : m_type(type), m_dev(dev), m_id(-1) { m_fd = libevdev_get_fd(dev); } + ForceFeedback(u16 type, libevdev* dev) : m_type(type), m_id(-1) { m_fd = libevdev_get_fd(dev); } void SetState(ControlState state) override; private: const u16 m_type; - libevdev* m_dev; int m_fd; int m_id; }; -- cgit v1.2.3 From 6e969133f5e0f5fe9551a0ace39b242c5c3aac78 Mon Sep 17 00:00:00 2001 From: Scott Mansell Date: Mon, 6 Jul 2015 07:57:31 +1200 Subject: evdev: Delete rumble effects on the correct file descriptor. Was using m_id insted of m_fd. Also re-arrange the code so rumble effects always get deleted instead of just on stop commands. --- .../Core/InputCommon/ControllerInterface/evdev/evdev.cpp | 15 +++++++++++++-- Source/Core/InputCommon/ControllerInterface/evdev/evdev.h | 1 + 2 files changed, 14 insertions(+), 2 deletions(-) (limited to 'Source/Core/InputCommon') diff --git a/Source/Core/InputCommon/ControllerInterface/evdev/evdev.cpp b/Source/Core/InputCommon/ControllerInterface/evdev/evdev.cpp index 9b31da73c4..6ee55ba0e5 100644 --- a/Source/Core/InputCommon/ControllerInterface/evdev/evdev.cpp +++ b/Source/Core/InputCommon/ControllerInterface/evdev/evdev.cpp @@ -216,6 +216,12 @@ void evdevDevice::ForceFeedback::SetState(ControlState state) // libevdev doesn't have nice helpers for forcefeedback // we will use the file descriptors directly. + if (m_id != -1) // delete the previous effect (which also stops it) + { + ioctl(m_fd, EVIOCRMFF, m_id); + m_id = -1; + } + if (state > 0) // Upload and start an effect. { ff_effect effect; @@ -260,9 +266,14 @@ void evdevDevice::ForceFeedback::SetState(ControlState state) write(m_fd, (const void*) &play, sizeof(play)); } - else if (m_id != -1) // delete the effect (which also stops it) +} + +evdevDevice::ForceFeedback::~ForceFeedback() +{ + // delete the uploaded effect, so we don't leak it. + if (m_id != -1) { - ioctl(m_id, EVIOCRMFF, m_id); + ioctl(m_fd, EVIOCRMFF, m_id); } } diff --git a/Source/Core/InputCommon/ControllerInterface/evdev/evdev.h b/Source/Core/InputCommon/ControllerInterface/evdev/evdev.h index d1555c8cce..2926e44805 100644 --- a/Source/Core/InputCommon/ControllerInterface/evdev/evdev.h +++ b/Source/Core/InputCommon/ControllerInterface/evdev/evdev.h @@ -52,6 +52,7 @@ private: public: std::string GetName() const override; ForceFeedback(u16 type, libevdev* dev) : m_type(type), m_dev(dev), m_id(-1) { m_fd = libevdev_get_fd(dev); } + ~ForceFeedback(); void SetState(ControlState state) override; private: const u16 m_type; -- cgit v1.2.3 From c38ae5236e082c0b635085fced60559170ee9a8e Mon Sep 17 00:00:00 2001 From: Rohit Nirmal Date: Wed, 8 Jul 2015 13:09:08 -0500 Subject: Fix building with PCH disabled. --- Source/Core/InputCommon/ControllerInterface/evdev/evdev.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'Source/Core/InputCommon') diff --git a/Source/Core/InputCommon/ControllerInterface/evdev/evdev.cpp b/Source/Core/InputCommon/ControllerInterface/evdev/evdev.cpp index 9b31da73c4..75384393b6 100644 --- a/Source/Core/InputCommon/ControllerInterface/evdev/evdev.cpp +++ b/Source/Core/InputCommon/ControllerInterface/evdev/evdev.cpp @@ -2,6 +2,7 @@ // Licensed under GPLv2+ // Refer to the license.txt file included. +#include #include #include -- cgit v1.2.3 From a8227ad9b1430d8891f1c6221374dadd94a3a534 Mon Sep 17 00:00:00 2001 From: Ryan Houdek Date: Tue, 21 Jul 2015 21:28:32 -0500 Subject: Add Wiimote support to the Android backend. Not actually wired up to the Android UI for configuration. --- .../ControllerInterface/Android/Android.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'Source/Core/InputCommon') diff --git a/Source/Core/InputCommon/ControllerInterface/Android/Android.cpp b/Source/Core/InputCommon/ControllerInterface/Android/Android.cpp index b0539b520f..24c6efebe9 100644 --- a/Source/Core/InputCommon/ControllerInterface/Android/Android.cpp +++ b/Source/Core/InputCommon/ControllerInterface/Android/Android.cpp @@ -17,6 +17,10 @@ void Init( std::vector& devices ) devices.push_back(new Touchscreen(1)); devices.push_back(new Touchscreen(2)); devices.push_back(new Touchscreen(3)); + devices.push_back(new Touchscreen(4)); + devices.push_back(new Touchscreen(5)); + devices.push_back(new Touchscreen(6)); + devices.push_back(new Touchscreen(7)); } // Touchscreens and stuff @@ -37,6 +41,7 @@ int Touchscreen::GetId() const 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)); @@ -53,6 +58,19 @@ Touchscreen::Touchscreen(int padID) AddAnalogInputs(new Axis(_padID, ButtonManager::STICK_C_UP), new Axis(_padID, ButtonManager::STICK_C_DOWN)); AddAnalogInputs(new Axis(_padID, ButtonManager::TRIGGER_L), new Axis(_padID, ButtonManager::TRIGGER_L)); AddAnalogInputs(new Axis(_padID, ButtonManager::TRIGGER_R), 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)); } // Buttons and stuff -- cgit v1.2.3 From 1cb07b1c4827d6c8252ca6e263f33becc980a986 Mon Sep 17 00:00:00 2001 From: sigmabeta Date: Thu, 23 Jul 2015 23:17:16 -0400 Subject: Android: Wiimote UI Fixup --- Source/Core/InputCommon/ControllerInterface/Android/Android.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Source/Core/InputCommon') diff --git a/Source/Core/InputCommon/ControllerInterface/Android/Android.cpp b/Source/Core/InputCommon/ControllerInterface/Android/Android.cpp index 24c6efebe9..7cf0f628bd 100644 --- a/Source/Core/InputCommon/ControllerInterface/Android/Android.cpp +++ b/Source/Core/InputCommon/ControllerInterface/Android/Android.cpp @@ -36,7 +36,7 @@ std::string Touchscreen::GetSource() const int Touchscreen::GetId() const { - return 0; + return _padID; } Touchscreen::Touchscreen(int padID) : _padID(padID) -- cgit v1.2.3 From 7ee0e756335bc9fa4ca17cafc9aa8b37371a903a Mon Sep 17 00:00:00 2001 From: Lioncash Date: Thu, 30 Jul 2015 06:47:02 -0400 Subject: Remove unnecessary virtual keywords --- .../ControllerInterface/ExpressionParser.cpp | 24 +++++++++++----------- 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'Source/Core/InputCommon') diff --git a/Source/Core/InputCommon/ControllerInterface/ExpressionParser.cpp b/Source/Core/InputCommon/ControllerInterface/ExpressionParser.cpp index 9837ea74cb..40d61b0e77 100644 --- a/Source/Core/InputCommon/ControllerInterface/ExpressionParser.cpp +++ b/Source/Core/InputCommon/ControllerInterface/ExpressionParser.cpp @@ -254,22 +254,22 @@ public: ControlExpression(ControlQualifier qualifier_, Device::Control *control_) : qualifier(qualifier_), control(control_) {} - virtual ControlState GetValue() override + ControlState GetValue() override { return control->ToInput()->GetGatedState(); } - virtual void SetValue(ControlState value) override + void SetValue(ControlState value) override { control->ToOutput()->SetGatedState(value); } - virtual int CountNumControls() override + int CountNumControls() override { return 1; } - virtual operator std::string() override + operator std::string() override { return "`" + (std::string)qualifier + "`"; } @@ -289,7 +289,7 @@ public: delete rhs; } - virtual ControlState GetValue() override + ControlState GetValue() override { ControlState lhsValue = lhs->GetValue(); ControlState rhsValue = rhs->GetValue(); @@ -307,7 +307,7 @@ public: } } - virtual void SetValue(ControlState value) override + void SetValue(ControlState value) override { // Don't do anything special with the op we have. // Treat "A & B" the same as "A | B". @@ -315,12 +315,12 @@ public: rhs->SetValue(value); } - virtual int CountNumControls() override + int CountNumControls() override { return lhs->CountNumControls() + rhs->CountNumControls(); } - virtual operator std::string() override + operator std::string() override { return OpName(op) + "(" + (std::string)(*lhs) + ", " + (std::string)(*rhs) + ")"; } @@ -338,7 +338,7 @@ public: delete inner; } - virtual ControlState GetValue() override + ControlState GetValue() override { ControlState value = inner->GetValue(); switch (op) @@ -351,7 +351,7 @@ public: } } - virtual void SetValue(ControlState value) override + void SetValue(ControlState value) override { switch (op) { @@ -364,12 +364,12 @@ public: } } - virtual int CountNumControls() override + int CountNumControls() override { return inner->CountNumControls(); } - virtual operator std::string() override + operator std::string() override { return OpName(op) + "(" + (std::string)(*inner) + ")"; } -- cgit v1.2.3 From 244e5224a7a9e4f4b125fd7ea9b53f6e913c76e5 Mon Sep 17 00:00:00 2001 From: "Admiral H. Curtiss" Date: Fri, 24 Jul 2015 06:11:49 +0200 Subject: Wiimote: Extend emulated Wiimote reconnect-on-button-press to attachments. --- Source/Core/InputCommon/ControllerEmu.h | 1 + 1 file changed, 1 insertion(+) (limited to 'Source/Core/InputCommon') diff --git a/Source/Core/InputCommon/ControllerEmu.h b/Source/Core/InputCommon/ControllerEmu.h index 0737556c69..a7ee642252 100644 --- a/Source/Core/InputCommon/ControllerEmu.h +++ b/Source/Core/InputCommon/ControllerEmu.h @@ -424,6 +424,7 @@ public: ~Extension() {} void GetState(u8* const data); + bool IsButtonPressed() const; std::vector> attachments; -- cgit v1.2.3 From 2722f3f337f2a0b6b7d01f4c45a362d75f779664 Mon Sep 17 00:00:00 2001 From: Gabriel Corona Date: Sun, 2 Aug 2015 01:29:06 +0200 Subject: Stable device identifier for evdev --- .../ControllerInterface/evdev/evdev.cpp | 23 +++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) (limited to 'Source/Core/InputCommon') diff --git a/Source/Core/InputCommon/ControllerInterface/evdev/evdev.cpp b/Source/Core/InputCommon/ControllerInterface/evdev/evdev.cpp index 25fa21a74b..e7a0ae2525 100644 --- a/Source/Core/InputCommon/ControllerInterface/evdev/evdev.cpp +++ b/Source/Core/InputCommon/ControllerInterface/evdev/evdev.cpp @@ -15,8 +15,28 @@ namespace ciface namespace evdev { +static std::string GetName(const std::string& devnode) +{ + int fd = open(devnode.c_str(), O_RDWR|O_NONBLOCK); + libevdev* dev = nullptr; + int ret = libevdev_new_from_fd(fd, &dev); + if (ret != 0) + { + close(fd); + return std::string(); + } + std::string res = libevdev_get_name(dev); + libevdev_free(dev); + close(fd); + return std::move(res); +} + void Init(std::vector &controllerDevices) { + // this is used to number the joysticks + // multiple joysticks with the same name shall get unique ids starting at 0 + std::map name_counts; + int num_controllers = 0; // We use Udev to find any devices. In the future this will allow for hotplugging. @@ -46,7 +66,8 @@ void Init(std::vector &controllerDevices) { // Unfortunately udev gives us no way to filter out the non event device interfaces. // So we open it and see if it works with evdev ioctls or not. - evdevDevice* input = new evdevDevice(devnode, num_controllers); + std::string name = GetName(devnode); + evdevDevice* input = new evdevDevice(devnode, name_counts[name]++); if (input->IsInteresting()) { -- cgit v1.2.3 From 5a05187b3be39a590ad43a7943088d5d5a082569 Mon Sep 17 00:00:00 2001 From: Tillmann Karras Date: Tue, 4 Aug 2015 10:58:24 +0200 Subject: Fix some warnings reorder, sign-compare, pessimizing-move --- Source/Core/InputCommon/ControllerInterface/evdev/evdev.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Source/Core/InputCommon') diff --git a/Source/Core/InputCommon/ControllerInterface/evdev/evdev.cpp b/Source/Core/InputCommon/ControllerInterface/evdev/evdev.cpp index e7a0ae2525..9e62a02378 100644 --- a/Source/Core/InputCommon/ControllerInterface/evdev/evdev.cpp +++ b/Source/Core/InputCommon/ControllerInterface/evdev/evdev.cpp @@ -28,7 +28,7 @@ static std::string GetName(const std::string& devnode) std::string res = libevdev_get_name(dev); libevdev_free(dev); close(fd); - return std::move(res); + return res; } void Init(std::vector &controllerDevices) -- cgit v1.2.3 From ac54bbe02d00e82e39bd50239b24a8fa322adb0a Mon Sep 17 00:00:00 2001 From: Rohit Nirmal Date: Tue, 4 Aug 2015 12:59:34 -0500 Subject: Fix building with PCH disabled. --- Source/Core/InputCommon/ControllerInterface/evdev/evdev.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'Source/Core/InputCommon') diff --git a/Source/Core/InputCommon/ControllerInterface/evdev/evdev.cpp b/Source/Core/InputCommon/ControllerInterface/evdev/evdev.cpp index 9e62a02378..d329189832 100644 --- a/Source/Core/InputCommon/ControllerInterface/evdev/evdev.cpp +++ b/Source/Core/InputCommon/ControllerInterface/evdev/evdev.cpp @@ -4,6 +4,7 @@ #include #include +#include #include #include "Common/Logging/Log.h" -- cgit v1.2.3 From b3ff66dc7a2efd251977e142b224dac69eccd3f9 Mon Sep 17 00:00:00 2001 From: Tillmann Karras Date: Sat, 15 Aug 2015 12:51:34 +0200 Subject: evdev: don't pass null path to the kernel --- Source/Core/InputCommon/ControllerInterface/evdev/evdev.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Source/Core/InputCommon') diff --git a/Source/Core/InputCommon/ControllerInterface/evdev/evdev.cpp b/Source/Core/InputCommon/ControllerInterface/evdev/evdev.cpp index d329189832..3d45244847 100644 --- a/Source/Core/InputCommon/ControllerInterface/evdev/evdev.cpp +++ b/Source/Core/InputCommon/ControllerInterface/evdev/evdev.cpp @@ -63,7 +63,7 @@ void Init(std::vector &controllerDevices) const char* devnode = udev_device_get_devnode(dev); // We only care about devices which we have read/write access to. - if (access(devnode, W_OK) == 0) + if (devnode && access(devnode, W_OK) == 0) { // Unfortunately udev gives us no way to filter out the non event device interfaces. // So we open it and see if it works with evdev ioctls or not. -- cgit v1.2.3 From aa7208e2708d540c8d43209556157e85de53c375 Mon Sep 17 00:00:00 2001 From: Shawn Hoffman Date: Mon, 16 Mar 2015 16:42:36 -0700 Subject: [windows] Update projects to vs2015. --- Source/Core/InputCommon/InputCommon.vcxproj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'Source/Core/InputCommon') diff --git a/Source/Core/InputCommon/InputCommon.vcxproj b/Source/Core/InputCommon/InputCommon.vcxproj index 1ef940178e..347c06e770 100644 --- a/Source/Core/InputCommon/InputCommon.vcxproj +++ b/Source/Core/InputCommon/InputCommon.vcxproj @@ -1,5 +1,5 @@  - + Debug @@ -16,7 +16,7 @@ StaticLibrary - v120 + v140 Unicode -- cgit v1.2.3 From 633be0387d7aa7f4bf9a57179e46bcb746c6a92f Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sat, 5 Sep 2015 16:06:25 -0400 Subject: General: Remove unimplemented function prototypes --- Source/Core/InputCommon/ControllerInterface/Device.h | 2 -- 1 file changed, 2 deletions(-) (limited to 'Source/Core/InputCommon') diff --git a/Source/Core/InputCommon/ControllerInterface/Device.h b/Source/Core/InputCommon/ControllerInterface/Device.h index c27910af5d..7e6172149f 100644 --- a/Source/Core/InputCommon/ControllerInterface/Device.h +++ b/Source/Core/InputCommon/ControllerInterface/Device.h @@ -61,8 +61,6 @@ public: virtual ControlState GetState() const = 0; - bool ShouldHaveInput(); - ControlState GetGatedState() { if (InputGateOn()) -- cgit v1.2.3 From 22635c1800c7c4fd803b3954e20777c43fd590ba Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sat, 5 Sep 2015 22:32:05 -0400 Subject: Add missing override specifiers --- .../ControllerInterface/DInput/DInputJoystick.h | 24 ++++++++-------- .../DInput/DInputKeyboardMouse.h | 32 +++++++++++----------- .../ForceFeedback/ForceFeedbackDevice.h | 3 +- .../ControllerInterface/XInput/XInput.cpp | 2 +- .../ControllerInterface/XInput/XInput.h | 30 ++++++++++---------- 5 files changed, 46 insertions(+), 45 deletions(-) (limited to 'Source/Core/InputCommon') diff --git a/Source/Core/InputCommon/ControllerInterface/DInput/DInputJoystick.h b/Source/Core/InputCommon/ControllerInterface/DInput/DInputJoystick.h index c89ba509d3..3064051101 100644 --- a/Source/Core/InputCommon/ControllerInterface/DInput/DInputJoystick.h +++ b/Source/Core/InputCommon/ControllerInterface/DInput/DInputJoystick.h @@ -20,9 +20,9 @@ private: class Button : public Input { public: - std::string GetName() const; - Button(u8 index, const BYTE& button) : m_index(index), m_button(button) {} - ControlState GetState() const; + Button(u8 index, const BYTE& button) : m_button(button), m_index(index) {} + std::string GetName() const override; + ControlState GetState() const override; private: const BYTE& m_button; const u8 m_index; @@ -31,9 +31,9 @@ private: class Axis : public Input { public: - std::string GetName() const; - Axis(u8 index, const LONG& axis, LONG base, LONG range) : m_index(index), m_axis(axis), m_base(base), m_range(range) {} - ControlState GetState() const; + Axis(u8 index, const LONG& axis, LONG base, LONG range) : m_axis(axis), m_base(base), m_range(range), m_index(index) {} + std::string GetName() const override; + ControlState GetState() const override; private: const LONG& m_axis; const LONG m_base, m_range; @@ -43,9 +43,9 @@ private: class Hat : public Input { public: - std::string GetName() const; - Hat(u8 index, const DWORD& hat, u8 direction) : m_index(index), m_hat(hat), m_direction(direction) {} - ControlState GetState() const; + Hat(u8 index, const DWORD& hat, u8 direction) : m_hat(hat), m_direction(direction), m_index(index) {} + std::string GetName() const override; + ControlState GetState() const override; private: const DWORD& m_hat; const u8 m_index, m_direction; @@ -57,9 +57,9 @@ public: Joystick(const LPDIRECTINPUTDEVICE8 device, const unsigned int index); ~Joystick(); - std::string GetName() const; - int GetId() const; - std::string GetSource() const; + std::string GetName() const override; + int GetId() const override; + std::string GetSource() const override; private: const LPDIRECTINPUTDEVICE8 m_device; diff --git a/Source/Core/InputCommon/ControllerInterface/DInput/DInputKeyboardMouse.h b/Source/Core/InputCommon/ControllerInterface/DInput/DInputKeyboardMouse.h index db4d363df0..14d885ff94 100644 --- a/Source/Core/InputCommon/ControllerInterface/DInput/DInputKeyboardMouse.h +++ b/Source/Core/InputCommon/ControllerInterface/DInput/DInputKeyboardMouse.h @@ -32,9 +32,9 @@ private: class Key : public Input { public: - std::string GetName() const; - Key(u8 index, const BYTE& key) : m_index(index), m_key(key) {} - ControlState GetState() const; + Key(u8 index, const BYTE& key) : m_key(key), m_index(index) {} + std::string GetName() const override; + ControlState GetState() const override; private: const BYTE& m_key; const u8 m_index; @@ -43,9 +43,9 @@ private: class Button : public Input { public: - std::string GetName() const; - Button(u8 index, const BYTE& button) : m_index(index), m_button(button) {} - ControlState GetState() const; + Button(u8 index, const BYTE& button) : m_button(button), m_index(index) {} + std::string GetName() const override; + ControlState GetState() const override; private: const BYTE& m_button; const u8 m_index; @@ -54,9 +54,9 @@ private: class Axis : public Input { public: - std::string GetName() const; - Axis(u8 index, const LONG& axis, LONG range) : m_index(index), m_axis(axis), m_range(range) {} - ControlState GetState() const; + Axis(u8 index, const LONG& axis, LONG range) : m_axis(axis), m_range(range), m_index(index) {} + std::string GetName() const override; + ControlState GetState() const override; private: const LONG& m_axis; const LONG m_range; @@ -66,10 +66,10 @@ private: class Cursor : public Input { public: - std::string GetName() const; - bool IsDetectable() { return false; } - Cursor(u8 index, const ControlState& axis, const bool positive) : m_index(index), m_axis(axis), m_positive(positive) {} - ControlState GetState() const; + Cursor(u8 index, const ControlState& axis, const bool positive) : m_axis(axis), m_index(index), m_positive(positive) {} + std::string GetName() const override; + bool IsDetectable() override { return false; } + ControlState GetState() const override; private: const ControlState& m_axis; const u8 m_index; @@ -82,9 +82,9 @@ public: KeyboardMouse(const LPDIRECTINPUTDEVICE8 kb_device, const LPDIRECTINPUTDEVICE8 mo_device); ~KeyboardMouse(); - std::string GetName() const; - int GetId() const; - std::string GetSource() const; + std::string GetName() const override; + int GetId() const override; + std::string GetSource() const override; private: const LPDIRECTINPUTDEVICE8 m_kb_device; diff --git a/Source/Core/InputCommon/ControllerInterface/ForceFeedback/ForceFeedbackDevice.h b/Source/Core/InputCommon/ControllerInterface/ForceFeedback/ForceFeedbackDevice.h index a528c00602..57364bd160 100644 --- a/Source/Core/InputCommon/ControllerInterface/ForceFeedback/ForceFeedbackDevice.h +++ b/Source/Core/InputCommon/ControllerInterface/ForceFeedback/ForceFeedbackDevice.h @@ -29,9 +29,10 @@ private: class Force : public Output { public: - std::string GetName() const; Force(const std::string& name, LPDIRECTINPUTEFFECT iface); ~Force(); + + std::string GetName() const override; void SetState(ControlState state); void Update(); void Stop(); diff --git a/Source/Core/InputCommon/ControllerInterface/XInput/XInput.cpp b/Source/Core/InputCommon/ControllerInterface/XInput/XInput.cpp index 0e2c0bcad3..1ee374d483 100644 --- a/Source/Core/InputCommon/ControllerInterface/XInput/XInput.cpp +++ b/Source/Core/InputCommon/ControllerInterface/XInput/XInput.cpp @@ -122,7 +122,7 @@ void DeInit() } Device::Device(const XINPUT_CAPABILITIES& caps, u8 index) - : m_index(index), m_subtype(caps.SubType) + : m_subtype(caps.SubType), m_index(index) { ZeroMemory(&m_state_out, sizeof(m_state_out)); diff --git a/Source/Core/InputCommon/ControllerInterface/XInput/XInput.h b/Source/Core/InputCommon/ControllerInterface/XInput/XInput.h index 5dcfb0cee5..59a3f6ff79 100644 --- a/Source/Core/InputCommon/ControllerInterface/XInput/XInput.h +++ b/Source/Core/InputCommon/ControllerInterface/XInput/XInput.h @@ -32,9 +32,9 @@ private: class Button : public Core::Device::Input { public: - std::string GetName() const; - Button(u8 index, const WORD& buttons) : m_index(index), m_buttons(buttons) {} - ControlState GetState() const; + Button(u8 index, const WORD& buttons) : m_buttons(buttons), m_index(index) {} + std::string GetName() const override; + ControlState GetState() const override; private: const WORD& m_buttons; u8 m_index; @@ -43,9 +43,9 @@ private: class Axis : public Core::Device::Input { public: - std::string GetName() const; - Axis(u8 index, const SHORT& axis, SHORT range) : m_index(index), m_axis(axis), m_range(range) {} - ControlState GetState() const; + Axis(u8 index, const SHORT& axis, SHORT range) : m_axis(axis), m_range(range), m_index(index) {} + std::string GetName() const override; + ControlState GetState() const override; private: const SHORT& m_axis; const SHORT m_range; @@ -55,9 +55,9 @@ private: class Trigger : public Core::Device::Input { public: - std::string GetName() const; - Trigger(u8 index, const BYTE& trigger, BYTE range) : m_index(index), m_trigger(trigger), m_range(range) {} - ControlState GetState() const; + Trigger(u8 index, const BYTE& trigger, BYTE range) : m_trigger(trigger), m_range(range), m_index(index) {} + std::string GetName() const override; + ControlState GetState() const override; private: const BYTE& m_trigger; const BYTE m_range; @@ -67,9 +67,9 @@ private: class Motor : public Core::Device::Output { public: - std::string GetName() const; - Motor(u8 index, Device* parent, WORD &motor, WORD range) : m_index(index), m_parent(parent), m_motor(motor), m_range(range) {} - void SetState(ControlState state); + Motor(u8 index, Device* parent, WORD &motor, WORD range) : m_motor(motor), m_range(range), m_index(index), m_parent(parent) {} + std::string GetName() const override; + void SetState(ControlState state) override; private: WORD& m_motor; const WORD m_range; @@ -82,9 +82,9 @@ public: Device(const XINPUT_CAPABILITIES& capabilities, u8 index); - std::string GetName() const; - int GetId() const; - std::string GetSource() const; + std::string GetName() const override; + int GetId() const override; + std::string GetSource() const override; void UpdateMotors(); -- cgit v1.2.3 From 88c9c6d0861827ad476683afe01f19868d14cd38 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Wed, 9 Sep 2015 22:41:47 -0400 Subject: ExpressionParser: Make all control paths return a value in operator std::string --- Source/Core/InputCommon/ControllerInterface/ExpressionParser.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'Source/Core/InputCommon') diff --git a/Source/Core/InputCommon/ControllerInterface/ExpressionParser.cpp b/Source/Core/InputCommon/ControllerInterface/ExpressionParser.cpp index 40d61b0e77..bcb2c95a96 100644 --- a/Source/Core/InputCommon/ControllerInterface/ExpressionParser.cpp +++ b/Source/Core/InputCommon/ControllerInterface/ExpressionParser.cpp @@ -63,8 +63,6 @@ public: { switch (type) { - case TOK_INVALID: - return "Invalid"; case TOK_DISCARD: return "Discard"; case TOK_EOF: @@ -83,7 +81,11 @@ public: return "+"; case TOK_CONTROL: return "Device(" + (std::string)qualifier + ")"; + case TOK_INVALID: + break; } + + return "Invalid"; } }; -- cgit v1.2.3 From cbd539eb3d34b6be3df54ea414b77130cc225b3c Mon Sep 17 00:00:00 2001 From: JosJuice Date: Sat, 12 Sep 2015 22:45:06 +0200 Subject: Use official names for GameCube controller sticks Main Stick is changed to Control Stick and C-Stick is changed to C Stick. A new ui_name variable is added to ControlGroup so that the UI strings in DolphinWX can be updated without breaking backwards compatibility with config INIs and other things that use names as IDs. --- Source/Core/InputCommon/ControllerEmu.cpp | 6 +++++- Source/Core/InputCommon/ControllerEmu.h | 7 ++++++- 2 files changed, 11 insertions(+), 2 deletions(-) (limited to 'Source/Core/InputCommon') diff --git a/Source/Core/InputCommon/ControllerEmu.cpp b/Source/Core/InputCommon/ControllerEmu.cpp index f1d33c65c3..a95da19100 100644 --- a/Source/Core/InputCommon/ControllerEmu.cpp +++ b/Source/Core/InputCommon/ControllerEmu.cpp @@ -143,7 +143,11 @@ void ControllerEmu::SaveConfig(IniFile::Section *sec, const std::string& base) } ControllerEmu::AnalogStick::AnalogStick(const char* const _name, ControlState default_radius) - : ControlGroup(_name, GROUP_TYPE_STICK) + : AnalogStick(_name, _name, GROUP_TYPE_STICK) +{} + +ControllerEmu::AnalogStick::AnalogStick(const char* const _name, const char* const _ui_name, ControlState default_radius) + : ControlGroup(_name, _ui_name, GROUP_TYPE_STICK) { for (auto& named_direction : named_directions) controls.emplace_back(new Input(named_direction)); diff --git a/Source/Core/InputCommon/ControllerEmu.h b/Source/Core/InputCommon/ControllerEmu.h index a7ee642252..db6e23f636 100644 --- a/Source/Core/InputCommon/ControllerEmu.h +++ b/Source/Core/InputCommon/ControllerEmu.h @@ -145,13 +145,17 @@ public: } }; - ControlGroup(const std::string& _name, const unsigned int _type = GROUP_TYPE_OTHER) : name(_name), type(_type) {} + ControlGroup(const std::string& _name, const unsigned int _type = GROUP_TYPE_OTHER) + : name(_name), ui_name(_name), type(_type) {} + ControlGroup(const std::string& _name, const std::string& _ui_name, const unsigned int _type = GROUP_TYPE_OTHER) + : name(_name), ui_name(_ui_name), type(_type) {} virtual ~ControlGroup() {} virtual void LoadConfig(IniFile::Section *sec, const std::string& defdev = "", const std::string& base = "" ); virtual void SaveConfig(IniFile::Section *sec, const std::string& defdev = "", const std::string& base = "" ); const std::string name; + const std::string ui_name; const unsigned int type; std::vector> controls; @@ -164,6 +168,7 @@ public: public: // The GameCube controller and Wiimote attachments have a different default radius AnalogStick(const char* const _name, ControlState default_radius); + AnalogStick(const char* const _name, const char* const _ui_name, ControlState default_radius); void GetState(ControlState* const x, ControlState* const y) { -- cgit v1.2.3 From c3332604fa2e8dd7b41d8f28883fe3606261db32 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Thu, 17 Sep 2015 15:13:41 -0400 Subject: ControllerInterface: Fix -Winconsistent-missing-override warnings on OSX --- .../ForceFeedback/ForceFeedbackDevice.h | 2 +- .../ControllerInterface/OSX/OSXJoystick.h | 20 +++++++++++--------- .../ControllerInterface/OSX/OSXKeyboard.h | 14 +++++++------- 3 files changed, 19 insertions(+), 17 deletions(-) (limited to 'Source/Core/InputCommon') diff --git a/Source/Core/InputCommon/ControllerInterface/ForceFeedback/ForceFeedbackDevice.h b/Source/Core/InputCommon/ControllerInterface/ForceFeedback/ForceFeedbackDevice.h index 57364bd160..f49198f037 100644 --- a/Source/Core/InputCommon/ControllerInterface/ForceFeedback/ForceFeedbackDevice.h +++ b/Source/Core/InputCommon/ControllerInterface/ForceFeedback/ForceFeedbackDevice.h @@ -33,7 +33,7 @@ private: ~Force(); std::string GetName() const override; - void SetState(ControlState state); + void SetState(ControlState state) override; void Update(); void Stop(); private: diff --git a/Source/Core/InputCommon/ControllerInterface/OSX/OSXJoystick.h b/Source/Core/InputCommon/ControllerInterface/OSX/OSXJoystick.h index c0fdec5537..d0ed715130 100644 --- a/Source/Core/InputCommon/ControllerInterface/OSX/OSXJoystick.h +++ b/Source/Core/InputCommon/ControllerInterface/OSX/OSXJoystick.h @@ -20,10 +20,10 @@ private: class Button : public Input { public: - std::string GetName() const; Button(IOHIDElementRef element, IOHIDDeviceRef device) : m_element(element), m_device(device) {} - ControlState GetState() const; + std::string GetName() const override; + ControlState GetState() const override; private: const IOHIDElementRef m_element; const IOHIDDeviceRef m_device; @@ -37,9 +37,10 @@ private: positive = 0, negative }; - std::string GetName() const; + Axis(IOHIDElementRef element, IOHIDDeviceRef device, direction dir); - ControlState GetState() const; + std::string GetName() const override; + ControlState GetState() const override; private: const IOHIDElementRef m_element; @@ -60,9 +61,10 @@ private: down, left }; - std::string GetName() const; + Hat(IOHIDElementRef element, IOHIDDeviceRef device, direction dir); - ControlState GetState() const; + std::string GetName() const override; + ControlState GetState() const override; private: const IOHIDElementRef m_element; @@ -75,9 +77,9 @@ public: Joystick(IOHIDDeviceRef device, std::string name, int index); ~Joystick(); - std::string GetName() const; - std::string GetSource() const; - int GetId() const; + std::string GetName() const override; + std::string GetSource() const override; + int GetId() const override; private: const IOHIDDeviceRef m_device; diff --git a/Source/Core/InputCommon/ControllerInterface/OSX/OSXKeyboard.h b/Source/Core/InputCommon/ControllerInterface/OSX/OSXKeyboard.h index 4be67a503c..d404f90684 100644 --- a/Source/Core/InputCommon/ControllerInterface/OSX/OSXKeyboard.h +++ b/Source/Core/InputCommon/ControllerInterface/OSX/OSXKeyboard.h @@ -19,9 +19,9 @@ private: class Key : public Input { public: - std::string GetName() const; Key(IOHIDElementRef element, IOHIDDeviceRef device); - ControlState GetState() const; + std::string GetName() const override; + ControlState GetState() const override; private: const IOHIDElementRef m_element; const IOHIDDeviceRef m_device; @@ -31,10 +31,10 @@ private: class Cursor : public Input { public: - std::string GetName() const; - bool IsDetectable() { return false; } Cursor(u8 index, const float& axis, const bool positive) : m_axis(axis), m_index(index), m_positive(positive) {} - ControlState GetState() const; + std::string GetName() const override; + bool IsDetectable() override { return false; } + ControlState GetState() const override; private: const float& m_axis; const u8 m_index; @@ -44,9 +44,9 @@ private: class Button : public Input { public: - std::string GetName() const; Button(u8 index, const unsigned char& button) : m_button(button), m_index(index) {} - ControlState GetState() const; + std::string GetName() const override; + ControlState GetState() const override; private: const unsigned char& m_button; const u8 m_index; -- cgit v1.2.3 From 19ac565e0dafccd3728b58a0d92cdc0cb74e4be0 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sat, 26 Sep 2015 16:39:47 -0400 Subject: Common: Move asserts to their own header --- Source/Core/InputCommon/ControllerInterface/evdev/evdev.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'Source/Core/InputCommon') diff --git a/Source/Core/InputCommon/ControllerInterface/evdev/evdev.cpp b/Source/Core/InputCommon/ControllerInterface/evdev/evdev.cpp index 3d45244847..d88a44b7ef 100644 --- a/Source/Core/InputCommon/ControllerInterface/evdev/evdev.cpp +++ b/Source/Core/InputCommon/ControllerInterface/evdev/evdev.cpp @@ -7,6 +7,7 @@ #include #include +#include "Common/Assert.h" #include "Common/Logging/Log.h" #include "InputCommon/ControllerInterface/evdev/evdev.h" -- cgit v1.2.3