From 34692ab826abc8f8faa61bdb2280b742424528f1 Mon Sep 17 00:00:00 2001 From: "Jasper St. Pierre" Date: Sat, 7 Dec 2013 15:14:29 -0500 Subject: Remove unnecessary Src/ folders --- .../ControllerInterface/Xlib/XInput2.cpp | 378 +++++++++++++++++++++ 1 file changed, 378 insertions(+) create mode 100644 Source/Core/InputCommon/ControllerInterface/Xlib/XInput2.cpp (limited to 'Source/Core/InputCommon/ControllerInterface/Xlib/XInput2.cpp') diff --git a/Source/Core/InputCommon/ControllerInterface/Xlib/XInput2.cpp b/Source/Core/InputCommon/ControllerInterface/Xlib/XInput2.cpp new file mode 100644 index 0000000000..23cadd3ee6 --- /dev/null +++ b/Source/Core/InputCommon/ControllerInterface/Xlib/XInput2.cpp @@ -0,0 +1,378 @@ +// Copyright 2013 Max Eliaser +// Licensed under the GNU General Public License, version 2 or higher. +// Refer to the license.txt file included. + + +#include "XInput2.h" +#include +#include + +// This is an input plugin using the XInput 2.0 extension to the X11 protocol, +// loosely based on the old XLib plugin. (Has nothing to do with the XInput +// API on Windows.) + +// This plugin creates one KeyboardMouse object for each master pointer/ +// keyboard pair. Each KeyboardMouse object exports four types of controls: +// * Mouse button controls: hardcoded at five of them, but could be made to +// support infinitely many mouse buttons in theory; XInput2 has no limit. +// * Mouse cursor controls: one for each cardinal direction. Calculated by +// comparing the absolute position of the mouse pointer on screen to the +// center of the emulator window. +// * Mouse axis controls: one for each cardinal direction. Calculated using +// a running average of relative mouse motion on each axis. +// * Key controls: these correspond to a limited subset of the keyboard +// keys. + + +// Mouse axis control tuning. Unlike absolute mouse position, relative mouse +// motion data needs to be tweaked and smoothed out a bit to be usable. + +// Mouse axis control output is simply divided by this number. In practice, +// that just means you can use a smaller "dead zone" if you bind axis controls +// to a joystick. No real need to make this customizable. +#define MOUSE_AXIS_SENSITIVITY 8.0f + +// The mouse axis controls use a weighted running average. Each frame, the new +// value is the average of the old value and the amount of relative mouse +// motion during that frame. The old value is weighted by a ratio of +// MOUSE_AXIS_SMOOTHING:1 compared to the new value. Increasing +// MOUSE_AXIS_SMOOTHING makes the controls smoother, decreasing it makes them +// more responsive. This might be useful as a user-customizable option. +#define MOUSE_AXIS_SMOOTHING 1.5f + +namespace ciface +{ +namespace XInput2 +{ + +// This function will add zero or more KeyboardMouse objects to devices. +void Init(std::vector& devices, void* const hwnd) +{ + Display* dpy; + + dpy = XOpenDisplay(NULL); + + // xi_opcode is important; it will be used to identify XInput events by + // the polling loop in UpdateInput. + int xi_opcode, event, error; + + // verify that the XInput extension is available + if (!XQueryExtension(dpy, "XInputExtension", &xi_opcode, &event, &error)) + return; + + // verify that the XInput extension is at at least version 2.0 + int major = 2, minor = 0; + + if (XIQueryVersion(dpy, &major, &minor) != Success) + return; + + // register all master devices with Dolphin + + XIDeviceInfo* all_masters; + XIDeviceInfo* current_master; + int num_masters; + + all_masters = XIQueryDevice(dpy, XIAllMasterDevices, &num_masters); + + for (int i = 0; i < num_masters; i++) + { + current_master = &all_masters[i]; + if (current_master->use == XIMasterPointer) + // Since current_master is a master pointer, its attachment must + // be a master keyboard. + devices.push_back(new KeyboardMouse((Window)hwnd, xi_opcode, current_master->deviceid, current_master->attachment)); + } + + XCloseDisplay(dpy); + + XIFreeDeviceInfo(all_masters); +} + +// Apply the event mask to the device and all its slaves. Only used in the +// constructor. Remember, each KeyboardMouse has its own copy of the event +// stream, which is how multiple event masks can "coexist." +void KeyboardMouse::SelectEventsForDevice(Window window, XIEventMask *mask, int deviceid) +{ + // Set the event mask for the master device. + + mask->deviceid = deviceid; + XISelectEvents(m_display, window, mask, 1); + + // Query all the master device's slaves and set the same event mask for + // those too. There are two reasons we want to do this. For mouse devices, + // we want the raw motion events, and only slaves (i.e. physical hardware + // devices) emit those. For keyboard devices, selecting slaves avoids + // dealing with key focus. + + XIDeviceInfo* all_slaves; + XIDeviceInfo* current_slave; + int num_slaves; + + all_slaves = XIQueryDevice(m_display, XIAllDevices, &num_slaves); + + for (int i = 0; i < num_slaves; i++) + { + current_slave = &all_slaves[i]; + if ((current_slave->use != XISlavePointer && current_slave->use != XISlaveKeyboard) || current_slave->attachment != deviceid) + continue; + mask->deviceid = current_slave->deviceid; + XISelectEvents(m_display, window, mask, 1); + } + + XIFreeDeviceInfo(all_slaves); +} + +KeyboardMouse::KeyboardMouse(Window window, int opcode, int pointer, int keyboard) + : m_window(window), xi_opcode(opcode), pointer_deviceid(pointer), keyboard_deviceid(keyboard) +{ + memset(&m_state, 0, sizeof(m_state)); + + // The cool thing about each KeyboardMouse object having its own Display + // is that each one gets its own separate copy of the X11 event stream, + // which it can individually filter to get just the events it's interested + // in. So be aware that each KeyboardMouse object actually has its own X11 + // "context." + m_display = XOpenDisplay(NULL); + + int min_keycode, max_keycode; + XDisplayKeycodes(m_display, &min_keycode, &max_keycode); + + int unused; // should always be 1 + XIDeviceInfo* pointer_device = XIQueryDevice(m_display, pointer_deviceid, &unused); + name = std::string(pointer_device->name); + XIFreeDeviceInfo(pointer_device); + + XIEventMask mask; + unsigned char mask_buf[(XI_LASTEVENT + 7)/8]; + + mask.mask_len = sizeof(mask_buf); + mask.mask = mask_buf; + memset(mask_buf, 0, sizeof(mask_buf)); + + XISetMask(mask_buf, XI_ButtonPress); + XISetMask(mask_buf, XI_ButtonRelease); + XISetMask(mask_buf, XI_RawMotion); + XISetMask(mask_buf, XI_KeyPress); + XISetMask(mask_buf, XI_KeyRelease); + + SelectEventsForDevice(DefaultRootWindow(m_display), &mask, pointer_deviceid); + SelectEventsForDevice(DefaultRootWindow(m_display), &mask, keyboard_deviceid); + + // Keyboard Keys + for (int i = min_keycode; i <= max_keycode; ++i) + { + Key* temp_key = new Key(m_display, i, m_state.keyboard); + if (temp_key->m_keyname.length()) + AddInput(temp_key); + else + delete temp_key; + } + + // Mouse Buttons + for (int i = 0; i < 5; i++) + AddInput(new Button(i, m_state.buttons)); + + // Mouse Cursor, X-/+ and Y-/+ + for (int i = 0; i != 4; ++i) + AddInput(new Cursor(!!(i & 2), !!(i & 1), (&m_state.cursor.x)[!!(i & 2)])); + + // Mouse Axis, X-/+ and Y-/+ + for (int i = 0; i != 4; ++i) + AddInput(new Axis(!!(i & 2), !!(i & 1), (&m_state.axis.x)[!!(i & 2)])); +} + +KeyboardMouse::~KeyboardMouse() +{ + XCloseDisplay(m_display); +} + +// Update the mouse cursor controls +void KeyboardMouse::UpdateCursor() +{ + double root_x, root_y, win_x, win_y; + Window root, child; + + // unused-- we're not interested in button presses here, as those are + // updated using events + XIButtonState button_state; + XIModifierState mods; + XIGroupState group; + + XIQueryPointer(m_display, pointer_deviceid, m_window, &root, &child, &root_x, &root_y, &win_x, &win_y, &button_state, &mods, &group); + + free (button_state.mask); + + XWindowAttributes win_attribs; + XGetWindowAttributes(m_display, m_window, &win_attribs); + + // the mouse position as a range from -1 to 1 + m_state.cursor.x = win_x / (float)win_attribs.width * 2 - 1; + m_state.cursor.y = win_y / (float)win_attribs.height * 2 - 1; +} + +bool KeyboardMouse::UpdateInput() +{ + XFlush(m_display); + + // Get the absolute position of the mouse pointer + UpdateCursor(); + + // for the axis controls + float delta_x = 0.0f, delta_y = 0.0f; + double delta_delta; + + // Iterate through the event queue - update the axis controls, mouse + // button controls, and keyboard controls. + XEvent event; + while (XPending(m_display)) + { + XNextEvent(m_display, &event); + + if (event.xcookie.type != GenericEvent) + continue; + if (event.xcookie.extension != xi_opcode) + continue; + if (!XGetEventData(m_display, &event.xcookie)) + continue; + + // only one of these will get used + XIDeviceEvent* dev_event = (XIDeviceEvent*)event.xcookie.data; + XIRawEvent* raw_event = (XIRawEvent*)event.xcookie.data; + + switch (event.xcookie.evtype) + { + case XI_ButtonPress: + m_state.buttons |= 1<<(dev_event->detail-1); + break; + case XI_ButtonRelease: + m_state.buttons &= ~(1<<(dev_event->detail-1)); + break; + case XI_KeyPress: + m_state.keyboard[dev_event->detail / 8] |= 1<<(dev_event->detail % 8); + break; + case XI_KeyRelease: + m_state.keyboard[dev_event->detail / 8] &= ~(1<<(dev_event->detail % 8)); + break; + case XI_RawMotion: + // always safe because there is always at least one byte in + // raw_event->valuators.mask, and if a bit is set in the mask, + // then the value in raw_values is also available. + if (XIMaskIsSet(raw_event->valuators.mask, 0)) + { + delta_delta = raw_event->raw_values[0]; + // test for inf and nan + if (delta_delta == delta_delta && 1+delta_delta != delta_delta) + delta_x += delta_delta; + } + if (XIMaskIsSet(raw_event->valuators.mask, 1)) + { + delta_delta = raw_event->raw_values[1]; + // test for inf and nan + if (delta_delta == delta_delta && 1+delta_delta != delta_delta) + delta_y += delta_delta; + } + break; + } + + XFreeEventData(m_display, &event.xcookie); + } + + // apply axis smoothing + m_state.axis.x *= MOUSE_AXIS_SMOOTHING; + m_state.axis.x += delta_x; + m_state.axis.x /= MOUSE_AXIS_SMOOTHING+1.0f; + m_state.axis.y *= MOUSE_AXIS_SMOOTHING; + m_state.axis.y += delta_y; + m_state.axis.y /= MOUSE_AXIS_SMOOTHING+1.0f; + + return true; +} + +bool KeyboardMouse::UpdateOutput() +{ + return true; +} + +std::string KeyboardMouse::GetName() const +{ + // This is the name string we got from the X server for this master + // pointer/keyboard pair. + return name; +} + +std::string KeyboardMouse::GetSource() const +{ + return "XInput2"; +} + +int KeyboardMouse::GetId() const +{ + return -1; +} + +KeyboardMouse::Key::Key(Display* const display, KeyCode keycode, const char* keyboard) + : m_display(display), m_keyboard(keyboard), m_keycode(keycode) +{ + int i = 0; + KeySym keysym = 0; + do + { + keysym = XkbKeycodeToKeysym(m_display, keycode, i, 0); + i++; + } + while (keysym == NoSymbol && i < 8); + + // Convert to upper case for the keyname + if (keysym >= 97 && keysym <= 122) + keysym -= 32; + + // 0x0110ffff is the top of the unicode character range according + // to keysymdef.h although it is probably more than we need. + if (keysym == NoSymbol || keysym > 0x0110ffff || + XKeysymToString(keysym) == NULL) + m_keyname = std::string(); + else + m_keyname = std::string(XKeysymToString(keysym)); +} + +ControlState KeyboardMouse::Key::GetState() const +{ + return (m_keyboard[m_keycode / 8] & (1 << (m_keycode % 8))) != 0; +} + +KeyboardMouse::Button::Button(unsigned int index, unsigned int& buttons) + : m_buttons(buttons), m_index(index) +{ + // this will be a problem if we remove the hardcoded five-button limit + name = std::string("Click ") + (char)('1' + m_index); +} + +ControlState KeyboardMouse::Button::GetState() const +{ + return ((m_buttons & (1 << m_index)) != 0); +} + +KeyboardMouse::Cursor::Cursor(u8 index, bool positive, const float& cursor) + : m_cursor(cursor), m_index(index), m_positive(positive) +{ + name = std::string("Cursor ") + (char)('X' + m_index) + (m_positive ? '+' : '-'); +} + +ControlState KeyboardMouse::Cursor::GetState() const +{ + return std::max(0.0f, m_cursor / (m_positive ? 1.0f : -1.0f)); +} + +KeyboardMouse::Axis::Axis(u8 index, bool positive, const float& axis) + : m_axis(axis), m_index(index), m_positive(positive) +{ + name = std::string("Axis ") + (char)('X' + m_index) + (m_positive ? '+' : '-'); +} + +ControlState KeyboardMouse::Axis::GetState() const +{ + return std::max(0.0f, m_axis / (m_positive ? MOUSE_AXIS_SENSITIVITY : -MOUSE_AXIS_SENSITIVITY)); +} + +} +} -- cgit v1.2.3 From 6c4ee1753aa2b9e620138801b479365b0569317c Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sun, 16 Feb 2014 15:30:18 -0500 Subject: Fix some vertical alignments ie. uses spaces for alignment. --- .../ControllerInterface/Xlib/XInput2.cpp | 25 ++++++++++------------ 1 file changed, 11 insertions(+), 14 deletions(-) (limited to 'Source/Core/InputCommon/ControllerInterface/Xlib/XInput2.cpp') diff --git a/Source/Core/InputCommon/ControllerInterface/Xlib/XInput2.cpp b/Source/Core/InputCommon/ControllerInterface/Xlib/XInput2.cpp index 23cadd3ee6..4da005fa65 100644 --- a/Source/Core/InputCommon/ControllerInterface/Xlib/XInput2.cpp +++ b/Source/Core/InputCommon/ControllerInterface/Xlib/XInput2.cpp @@ -30,7 +30,7 @@ // Mouse axis control output is simply divided by this number. In practice, // that just means you can use a smaller "dead zone" if you bind axis controls // to a joystick. No real need to make this customizable. -#define MOUSE_AXIS_SENSITIVITY 8.0f +#define MOUSE_AXIS_SENSITIVITY 8.0f // The mouse axis controls use a weighted running average. Each frame, the new // value is the average of the old value and the amount of relative mouse @@ -38,7 +38,7 @@ // MOUSE_AXIS_SMOOTHING:1 compared to the new value. Increasing // MOUSE_AXIS_SMOOTHING makes the controls smoother, decreasing it makes them // more responsive. This might be useful as a user-customizable option. -#define MOUSE_AXIS_SMOOTHING 1.5f +#define MOUSE_AXIS_SMOOTHING 1.5f namespace ciface { @@ -48,9 +48,7 @@ namespace XInput2 // This function will add zero or more KeyboardMouse objects to devices. void Init(std::vector& devices, void* const hwnd) { - Display* dpy; - - dpy = XOpenDisplay(NULL); + Display* dpy = XOpenDisplay(NULL); // xi_opcode is important; it will be used to identify XInput events by // the polling loop in UpdateInput. @@ -68,9 +66,9 @@ void Init(std::vector& devices, void* const hwnd) // register all master devices with Dolphin - XIDeviceInfo* all_masters; - XIDeviceInfo* current_master; - int num_masters; + XIDeviceInfo* all_masters; + XIDeviceInfo* current_master; + int num_masters; all_masters = XIQueryDevice(dpy, XIAllMasterDevices, &num_masters); @@ -94,7 +92,6 @@ void Init(std::vector& devices, void* const hwnd) void KeyboardMouse::SelectEventsForDevice(Window window, XIEventMask *mask, int deviceid) { // Set the event mask for the master device. - mask->deviceid = deviceid; XISelectEvents(m_display, window, mask, 1); @@ -104,9 +101,9 @@ void KeyboardMouse::SelectEventsForDevice(Window window, XIEventMask *mask, int // devices) emit those. For keyboard devices, selecting slaves avoids // dealing with key focus. - XIDeviceInfo* all_slaves; - XIDeviceInfo* current_slave; - int num_slaves; + XIDeviceInfo* all_slaves; + XIDeviceInfo* current_slave; + int num_slaves; all_slaves = XIQueryDevice(m_display, XIAllDevices, &num_slaves); @@ -142,8 +139,8 @@ KeyboardMouse::KeyboardMouse(Window window, int opcode, int pointer, int keyboar name = std::string(pointer_device->name); XIFreeDeviceInfo(pointer_device); - XIEventMask mask; - unsigned char mask_buf[(XI_LASTEVENT + 7)/8]; + XIEventMask mask; + unsigned char mask_buf[(XI_LASTEVENT + 7)/8]; mask.mask_len = sizeof(mask_buf); mask.mask = mask_buf; -- cgit v1.2.3 From 2afe2152712981e21d6bda6f029292ed2b1cf91e Mon Sep 17 00:00:00 2001 From: Lioncash Date: Mon, 17 Feb 2014 05:18:15 -0500 Subject: Convert all includes to relative paths. --- Source/Core/InputCommon/ControllerInterface/Xlib/XInput2.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'Source/Core/InputCommon/ControllerInterface/Xlib/XInput2.cpp') diff --git a/Source/Core/InputCommon/ControllerInterface/Xlib/XInput2.cpp b/Source/Core/InputCommon/ControllerInterface/Xlib/XInput2.cpp index 4da005fa65..802346b81d 100644 --- a/Source/Core/InputCommon/ControllerInterface/Xlib/XInput2.cpp +++ b/Source/Core/InputCommon/ControllerInterface/Xlib/XInput2.cpp @@ -2,10 +2,10 @@ // Licensed under the GNU General Public License, version 2 or higher. // Refer to the license.txt file included. - -#include "XInput2.h" -#include #include +#include + +#include "InputCommon/ControllerInterface/Xlib/XInput2.h" // This is an input plugin using the XInput 2.0 extension to the X11 protocol, // loosely based on the old XLib plugin. (Has nothing to do with the XInput -- cgit v1.2.3 From d802d392811be44d34ae9cd23f616db93e54c50f Mon Sep 17 00:00:00 2001 From: Tillmann Karras Date: Sun, 9 Mar 2014 21:14:26 +0100 Subject: clang-modernize -use-nullptr and s/\bNULL\b/nullptr/g for *.cpp/h/mm files not compiled on my machine --- Source/Core/InputCommon/ControllerInterface/Xlib/XInput2.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'Source/Core/InputCommon/ControllerInterface/Xlib/XInput2.cpp') diff --git a/Source/Core/InputCommon/ControllerInterface/Xlib/XInput2.cpp b/Source/Core/InputCommon/ControllerInterface/Xlib/XInput2.cpp index 802346b81d..9fb9e96f6e 100644 --- a/Source/Core/InputCommon/ControllerInterface/Xlib/XInput2.cpp +++ b/Source/Core/InputCommon/ControllerInterface/Xlib/XInput2.cpp @@ -48,7 +48,7 @@ namespace XInput2 // This function will add zero or more KeyboardMouse objects to devices. void Init(std::vector& devices, void* const hwnd) { - Display* dpy = XOpenDisplay(NULL); + Display* dpy = XOpenDisplay(nullptr); // xi_opcode is important; it will be used to identify XInput events by // the polling loop in UpdateInput. @@ -129,7 +129,7 @@ KeyboardMouse::KeyboardMouse(Window window, int opcode, int pointer, int keyboar // which it can individually filter to get just the events it's interested // in. So be aware that each KeyboardMouse object actually has its own X11 // "context." - m_display = XOpenDisplay(NULL); + m_display = XOpenDisplay(nullptr); int min_keycode, max_keycode; XDisplayKeycodes(m_display, &min_keycode, &max_keycode); @@ -326,7 +326,7 @@ KeyboardMouse::Key::Key(Display* const display, KeyCode keycode, const char* key // 0x0110ffff is the top of the unicode character range according // to keysymdef.h although it is probably more than we need. if (keysym == NoSymbol || keysym > 0x0110ffff || - XKeysymToString(keysym) == NULL) + XKeysymToString(keysym) == nullptr) m_keyname = std::string(); else m_keyname = std::string(XKeysymToString(keysym)); -- cgit v1.2.3 From 46057db37d086c47ff6c69f200f66648fa0e6c84 Mon Sep 17 00:00:00 2001 From: Rohit Nirmal Date: Thu, 18 Sep 2014 23:17:41 -0500 Subject: Fix build failing when disabling precompiled headers. --- Source/Core/InputCommon/ControllerInterface/Xlib/XInput2.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'Source/Core/InputCommon/ControllerInterface/Xlib/XInput2.cpp') diff --git a/Source/Core/InputCommon/ControllerInterface/Xlib/XInput2.cpp b/Source/Core/InputCommon/ControllerInterface/Xlib/XInput2.cpp index 9fb9e96f6e..efb2301956 100644 --- a/Source/Core/InputCommon/ControllerInterface/Xlib/XInput2.cpp +++ b/Source/Core/InputCommon/ControllerInterface/Xlib/XInput2.cpp @@ -3,6 +3,7 @@ // Refer to the license.txt file included. #include +#include #include #include "InputCommon/ControllerInterface/Xlib/XInput2.h" -- cgit v1.2.3 From 7f6284c2fcea9d543b0eec44ea0f3ad36bd0c0aa Mon Sep 17 00:00:00 2001 From: comex Date: Thu, 2 Oct 2014 02:20:46 -0400 Subject: Change a bunch of reference function arguments to pointers. Per the coding style and sanity. --- .../InputCommon/ControllerInterface/Xlib/XInput2.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'Source/Core/InputCommon/ControllerInterface/Xlib/XInput2.cpp') diff --git a/Source/Core/InputCommon/ControllerInterface/Xlib/XInput2.cpp b/Source/Core/InputCommon/ControllerInterface/Xlib/XInput2.cpp index efb2301956..13ace15997 100644 --- a/Source/Core/InputCommon/ControllerInterface/Xlib/XInput2.cpp +++ b/Source/Core/InputCommon/ControllerInterface/Xlib/XInput2.cpp @@ -168,15 +168,15 @@ KeyboardMouse::KeyboardMouse(Window window, int opcode, int pointer, int keyboar // Mouse Buttons for (int i = 0; i < 5; i++) - AddInput(new Button(i, m_state.buttons)); + AddInput(new Button(i, &m_state.buttons)); // Mouse Cursor, X-/+ and Y-/+ for (int i = 0; i != 4; ++i) - AddInput(new Cursor(!!(i & 2), !!(i & 1), (&m_state.cursor.x)[!!(i & 2)])); + AddInput(new Cursor(!!(i & 2), !!(i & 1), (i & 2) ? &m_state.cursor.y : &m_state.cursor.x)); // Mouse Axis, X-/+ and Y-/+ for (int i = 0; i != 4; ++i) - AddInput(new Axis(!!(i & 2), !!(i & 1), (&m_state.axis.x)[!!(i & 2)])); + AddInput(new Axis(!!(i & 2), !!(i & 1), (i & 2) ? &m_state.axis.y : &m_state.axis.x)); } KeyboardMouse::~KeyboardMouse() @@ -338,7 +338,7 @@ ControlState KeyboardMouse::Key::GetState() const return (m_keyboard[m_keycode / 8] & (1 << (m_keycode % 8))) != 0; } -KeyboardMouse::Button::Button(unsigned int index, unsigned int& buttons) +KeyboardMouse::Button::Button(unsigned int index, unsigned int* buttons) : m_buttons(buttons), m_index(index) { // this will be a problem if we remove the hardcoded five-button limit @@ -347,10 +347,10 @@ KeyboardMouse::Button::Button(unsigned int index, unsigned int& buttons) ControlState KeyboardMouse::Button::GetState() const { - return ((m_buttons & (1 << m_index)) != 0); + return ((*m_buttons & (1 << m_index)) != 0); } -KeyboardMouse::Cursor::Cursor(u8 index, bool positive, const float& cursor) +KeyboardMouse::Cursor::Cursor(u8 index, bool positive, const float* cursor) : m_cursor(cursor), m_index(index), m_positive(positive) { name = std::string("Cursor ") + (char)('X' + m_index) + (m_positive ? '+' : '-'); @@ -358,10 +358,10 @@ KeyboardMouse::Cursor::Cursor(u8 index, bool positive, const float& cursor) ControlState KeyboardMouse::Cursor::GetState() const { - return std::max(0.0f, m_cursor / (m_positive ? 1.0f : -1.0f)); + return std::max(0.0f, *m_cursor / (m_positive ? 1.0f : -1.0f)); } -KeyboardMouse::Axis::Axis(u8 index, bool positive, const float& axis) +KeyboardMouse::Axis::Axis(u8 index, bool positive, const float* axis) : m_axis(axis), m_index(index), m_positive(positive) { name = std::string("Axis ") + (char)('X' + m_index) + (m_positive ? '+' : '-'); @@ -369,7 +369,7 @@ KeyboardMouse::Axis::Axis(u8 index, bool positive, const float& axis) ControlState KeyboardMouse::Axis::GetState() const { - return std::max(0.0f, m_axis / (m_positive ? MOUSE_AXIS_SENSITIVITY : -MOUSE_AXIS_SENSITIVITY)); + return std::max(0.0f, *m_axis / (m_positive ? MOUSE_AXIS_SENSITIVITY : -MOUSE_AXIS_SENSITIVITY)); } } -- cgit v1.2.3 From 367a42dcfdf61e5fcd3e3444190ed25d4d8fc114 Mon Sep 17 00:00:00 2001 From: "Jasper St. Pierre" Date: Thu, 13 Nov 2014 00:53:24 -0800 Subject: ControllerInterface: Implement dummy UpdateInput / UpdateOutputs Make the implementation here a bit easier. --- Source/Core/InputCommon/ControllerInterface/Xlib/XInput2.cpp | 5 ----- 1 file changed, 5 deletions(-) (limited to 'Source/Core/InputCommon/ControllerInterface/Xlib/XInput2.cpp') diff --git a/Source/Core/InputCommon/ControllerInterface/Xlib/XInput2.cpp b/Source/Core/InputCommon/ControllerInterface/Xlib/XInput2.cpp index 13ace15997..4d7cc26b4d 100644 --- a/Source/Core/InputCommon/ControllerInterface/Xlib/XInput2.cpp +++ b/Source/Core/InputCommon/ControllerInterface/Xlib/XInput2.cpp @@ -286,11 +286,6 @@ bool KeyboardMouse::UpdateInput() return true; } -bool KeyboardMouse::UpdateOutput() -{ - return true; -} - std::string KeyboardMouse::GetName() const { // This is the name string we got from the X server for this master -- cgit v1.2.3 From f2787f620eebbbfb746f59cfbd0318210297061b Mon Sep 17 00:00:00 2001 From: "Jasper St. Pierre" Date: Thu, 13 Nov 2014 00:55:14 -0800 Subject: ControllerInterface: Make UpdateInput / UpdateOutput return void The return values here have never been checked, so it doesn't make sense to return a value to begin with. --- Source/Core/InputCommon/ControllerInterface/Xlib/XInput2.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'Source/Core/InputCommon/ControllerInterface/Xlib/XInput2.cpp') diff --git a/Source/Core/InputCommon/ControllerInterface/Xlib/XInput2.cpp b/Source/Core/InputCommon/ControllerInterface/Xlib/XInput2.cpp index 4d7cc26b4d..1d7d080d7e 100644 --- a/Source/Core/InputCommon/ControllerInterface/Xlib/XInput2.cpp +++ b/Source/Core/InputCommon/ControllerInterface/Xlib/XInput2.cpp @@ -208,7 +208,7 @@ void KeyboardMouse::UpdateCursor() m_state.cursor.y = win_y / (float)win_attribs.height * 2 - 1; } -bool KeyboardMouse::UpdateInput() +void KeyboardMouse::UpdateInput() { XFlush(m_display); @@ -282,8 +282,6 @@ bool KeyboardMouse::UpdateInput() m_state.axis.y *= MOUSE_AXIS_SMOOTHING; m_state.axis.y += delta_y; m_state.axis.y /= MOUSE_AXIS_SMOOTHING+1.0f; - - return true; } std::string KeyboardMouse::GetName() const -- cgit v1.2.3 From 6d9986846ceeaf805ba70b7014127bfbbd66beea Mon Sep 17 00:00:00 2001 From: Tillmann Karras Date: Mon, 25 May 2015 13:11:41 +0200 Subject: Simplify some more license headers --- Source/Core/InputCommon/ControllerInterface/Xlib/XInput2.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Source/Core/InputCommon/ControllerInterface/Xlib/XInput2.cpp') diff --git a/Source/Core/InputCommon/ControllerInterface/Xlib/XInput2.cpp b/Source/Core/InputCommon/ControllerInterface/Xlib/XInput2.cpp index 1d7d080d7e..e4983e80bb 100644 --- a/Source/Core/InputCommon/ControllerInterface/Xlib/XInput2.cpp +++ b/Source/Core/InputCommon/ControllerInterface/Xlib/XInput2.cpp @@ -1,5 +1,5 @@ // Copyright 2013 Max Eliaser -// Licensed under the GNU General Public License, version 2 or higher. +// Licensed under GPLv2+ // Refer to the license.txt file included. #include -- cgit v1.2.3