no longer sending fake events for unmapped logical buttons.
This commit is contained in:
parent
f49b186722
commit
305b01edf9
|
@ -114,17 +114,23 @@ CXWindowsSecondaryScreen::keyUp(KeyID key, KeyModifierMask mask)
|
||||||
void
|
void
|
||||||
CXWindowsSecondaryScreen::mouseDown(ButtonID button)
|
CXWindowsSecondaryScreen::mouseDown(ButtonID button)
|
||||||
{
|
{
|
||||||
|
const unsigned int xButton = mapButton(button);
|
||||||
|
if (xButton != 0) {
|
||||||
CDisplayLock display(m_screen);
|
CDisplayLock display(m_screen);
|
||||||
XTestFakeButtonEvent(display, mapButton(button), True, CurrentTime);
|
XTestFakeButtonEvent(display, xButton, True, CurrentTime);
|
||||||
XSync(display, False);
|
XSync(display, False);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
CXWindowsSecondaryScreen::mouseUp(ButtonID button)
|
CXWindowsSecondaryScreen::mouseUp(ButtonID button)
|
||||||
{
|
{
|
||||||
|
const unsigned int xButton = mapButton(button);
|
||||||
|
if (xButton != 0) {
|
||||||
CDisplayLock display(m_screen);
|
CDisplayLock display(m_screen);
|
||||||
XTestFakeButtonEvent(display, mapButton(button), False, CurrentTime);
|
XTestFakeButtonEvent(display, xButton, False, CurrentTime);
|
||||||
XSync(display, False);
|
XSync(display, False);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -137,7 +143,10 @@ void
|
||||||
CXWindowsSecondaryScreen::mouseWheel(SInt32 delta)
|
CXWindowsSecondaryScreen::mouseWheel(SInt32 delta)
|
||||||
{
|
{
|
||||||
// choose button depending on rotation direction
|
// choose button depending on rotation direction
|
||||||
const unsigned int button = (delta >= 0) ? 4 : 5;
|
const unsigned int xButton = mapButton((delta >= 0) ? 4 : 5);
|
||||||
|
if (xButton == 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// now use absolute value of delta
|
// now use absolute value of delta
|
||||||
if (delta < 0) {
|
if (delta < 0) {
|
||||||
|
@ -147,8 +156,8 @@ CXWindowsSecondaryScreen::mouseWheel(SInt32 delta)
|
||||||
// send as many clicks as necessary
|
// send as many clicks as necessary
|
||||||
CDisplayLock display(m_screen);
|
CDisplayLock display(m_screen);
|
||||||
for (; delta >= 120; delta -= 120) {
|
for (; delta >= 120; delta -= 120) {
|
||||||
XTestFakeButtonEvent(display, button, True, CurrentTime);
|
XTestFakeButtonEvent(display, xButton, True, CurrentTime);
|
||||||
XTestFakeButtonEvent(display, button, False, CurrentTime);
|
XTestFakeButtonEvent(display, xButton, False, CurrentTime);
|
||||||
}
|
}
|
||||||
XSync(display, False);
|
XSync(display, False);
|
||||||
}
|
}
|
||||||
|
@ -359,8 +368,17 @@ CXWindowsSecondaryScreen::setToggleState(KeyModifierMask mask)
|
||||||
unsigned int
|
unsigned int
|
||||||
CXWindowsSecondaryScreen::mapButton(ButtonID id) const
|
CXWindowsSecondaryScreen::mapButton(ButtonID id) const
|
||||||
{
|
{
|
||||||
// FIXME -- should use button mapping?
|
if (id < 1 || id > sizeof(m_buttons) / sizeof(m_buttons[0])) {
|
||||||
|
// out of range
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
else if (m_buttons[id - 1] == 0) {
|
||||||
|
// button not mapped
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
else {
|
||||||
return static_cast<unsigned int>(id);
|
return static_cast<unsigned int>(id);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
KeyModifierMask
|
KeyModifierMask
|
||||||
|
@ -830,6 +848,17 @@ CXWindowsSecondaryScreen::updateKeys()
|
||||||
{
|
{
|
||||||
CDisplayLock display(m_screen);
|
CDisplayLock display(m_screen);
|
||||||
|
|
||||||
|
// get pointer mapping
|
||||||
|
static const UInt32 maxButtons = sizeof(m_buttons) / sizeof(m_buttons[0]);
|
||||||
|
unsigned char tmpButtons[sizeof(m_buttons) / sizeof(m_buttons[0])];
|
||||||
|
UInt32 numButtons = XGetPointerMapping(display, tmpButtons, maxButtons);
|
||||||
|
for (UInt32 i = 0; i < maxButtons; ++i) {
|
||||||
|
m_buttons[i] = 0;
|
||||||
|
}
|
||||||
|
for (UInt32 i = 0; i < numButtons; ++i) {
|
||||||
|
m_buttons[tmpButtons[i] - 1] = i + 1;
|
||||||
|
}
|
||||||
|
|
||||||
// ask server which keys are pressed
|
// ask server which keys are pressed
|
||||||
char keys[32];
|
char keys[32];
|
||||||
XQueryKeymap(display, keys);
|
XQueryKeymap(display, keys);
|
||||||
|
|
|
@ -113,6 +113,10 @@ private:
|
||||||
// set entries indicate keys that are pressed. indexed by keycode.
|
// set entries indicate keys that are pressed. indexed by keycode.
|
||||||
bool m_keys[256];
|
bool m_keys[256];
|
||||||
|
|
||||||
|
// logical to physical button mapping. m_buttons[i] gives the
|
||||||
|
// physical button for logical button i+1.
|
||||||
|
unsigned char m_buttons[5];
|
||||||
|
|
||||||
// current active modifiers (X key masks)
|
// current active modifiers (X key masks)
|
||||||
unsigned int m_mask;
|
unsigned int m_mask;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue