Skip to content

Commit

Permalink
mouse: Increase number of buttons supported from 5 to 7
Browse files Browse the repository at this point in the history
Full support for mouse with wheel and thumb buttons

N.B. 5 buttons was still hardcoded in ButtonTranslator.cpp
  • Loading branch information
cjmayo committed Mar 3, 2015
1 parent ec963fa commit a4198f4
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 4 deletions.
2 changes: 1 addition & 1 deletion system/keymaps/mouse.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<!-- 0: left -->
<!-- 1: right -->
<!-- 2: middle -->
<!-- 3/4: extra -->
<!-- 3/4/5/6: extra -->

<keymap>
<global>
Expand Down
3 changes: 2 additions & 1 deletion xbmc/input/ButtonTranslator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include "utils/URIUtils.h"
#include "input/Key.h"
#include "guilib/WindowIDs.h"
#include "input/MouseStat.h"
#include "input/XBMC_keysym.h"
#include "input/XBMC_keytable.h"
#include "filesystem/File.h"
Expand Down Expand Up @@ -1620,7 +1621,7 @@ uint32_t CButtonTranslator::TranslateMouseCommand(TiXmlElement *pButton)
else
{
int id = 0;
if ((pButton->QueryIntAttribute("id", &id) == TIXML_SUCCESS) && id>=0 && id<=4)
if ((pButton->QueryIntAttribute("id", &id) == TIXML_SUCCESS) && id>=0 && id<MOUSE_MAX_BUTTON)
{
buttonId += id;
}
Expand Down
4 changes: 4 additions & 0 deletions xbmc/input/MouseStat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ void CMouseStat::HandleEvent(XBMC_Event& newEvent)
if (newEvent.button.button == XBMC_BUTTON_MIDDLE) m_mouseState.button[MOUSE_MIDDLE_BUTTON] = true;
if (newEvent.button.button == XBMC_BUTTON_X1) m_mouseState.button[MOUSE_EXTRA_BUTTON1] = true;
if (newEvent.button.button == XBMC_BUTTON_X2) m_mouseState.button[MOUSE_EXTRA_BUTTON2] = true;
if (newEvent.button.button == XBMC_BUTTON_X3) m_mouseState.button[MOUSE_EXTRA_BUTTON3] = true;
if (newEvent.button.button == XBMC_BUTTON_X4) m_mouseState.button[MOUSE_EXTRA_BUTTON4] = true;
if (newEvent.button.button == XBMC_BUTTON_WHEELUP) m_mouseState.dz = 1;
if (newEvent.button.button == XBMC_BUTTON_WHEELDOWN) m_mouseState.dz = -1;
}
Expand All @@ -85,6 +87,8 @@ void CMouseStat::HandleEvent(XBMC_Event& newEvent)
if (newEvent.button.button == XBMC_BUTTON_MIDDLE) m_mouseState.button[MOUSE_MIDDLE_BUTTON] = false;
if (newEvent.button.button == XBMC_BUTTON_X1) m_mouseState.button[MOUSE_EXTRA_BUTTON1] = false;
if (newEvent.button.button == XBMC_BUTTON_X2) m_mouseState.button[MOUSE_EXTRA_BUTTON2] = false;
if (newEvent.button.button == XBMC_BUTTON_X3) m_mouseState.button[MOUSE_EXTRA_BUTTON3] = false;
if (newEvent.button.button == XBMC_BUTTON_X4) m_mouseState.button[MOUSE_EXTRA_BUTTON4] = false;
if (newEvent.button.button == XBMC_BUTTON_WHEELUP) m_mouseState.dz = 0;
if (newEvent.button.button == XBMC_BUTTON_WHEELDOWN) m_mouseState.dz = 0;
}
Expand Down
18 changes: 16 additions & 2 deletions xbmc/input/MouseStat.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,21 @@
#define XBMC_BUTTON_WHEELDOWN 5
#define XBMC_BUTTON_X1 6
#define XBMC_BUTTON_X2 7
#define XBMC_BUTTON_X3 8
#define XBMC_BUTTON_X4 9
#define XBMC_BUTTON_LMASK XBMC_BUTTON(XBMC_BUTTON_LEFT)
#define XBMC_BUTTON_MMASK XBMC_BUTTON(XBMC_BUTTON_MIDDLE)
#define XBMC_BUTTON_RMASK XBMC_BUTTON(XBMC_BUTTON_RIGHT)
#define XBMC_BUTTON_X1MASK XBMC_BUTTON(XBMC_BUTTON_X1)
#define XBMC_BUTTON_X2MASK XBMC_BUTTON(XBMC_BUTTON_X2)
#define XBMC_BUTTON_X3MASK XBMC_BUTTON(XBMC_BUTTON_X3)
#define XBMC_BUTTON_X4MASK XBMC_BUTTON(XBMC_BUTTON_X4)

#define MOUSE_MINIMUM_MOVEMENT 2
#define MOUSE_DOUBLE_CLICK_LENGTH 500L
#define MOUSE_ACTIVE_LENGTH 5000L

#define MOUSE_MAX_BUTTON 5
#define MOUSE_MAX_BUTTON 7

enum MOUSE_STATE
{
Expand All @@ -50,7 +54,17 @@ enum MOUSE_STATE
MOUSE_STATE_DRAG, /*! < A drag operation is being performed */
MOUSE_STATE_CLICK /*! < A mousebutton is being clicked */
};
enum MOUSE_BUTTON { MOUSE_LEFT_BUTTON = 0, MOUSE_RIGHT_BUTTON, MOUSE_MIDDLE_BUTTON, MOUSE_EXTRA_BUTTON1, MOUSE_EXTRA_BUTTON2 };

enum MOUSE_BUTTON
{
MOUSE_LEFT_BUTTON = 0,
MOUSE_RIGHT_BUTTON,
MOUSE_MIDDLE_BUTTON,
MOUSE_EXTRA_BUTTON1,
MOUSE_EXTRA_BUTTON2,
MOUSE_EXTRA_BUTTON3,
MOUSE_EXTRA_BUTTON4
};

// this holds everything we know about the current state of the mouse
struct MouseState
Expand Down

0 comments on commit a4198f4

Please sign in to comment.