Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pass on the hw button keycodes #46

Merged
merged 1 commit into from
Feb 2, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions src/wcmCommon.c
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,47 @@ static void wcmSendButtons(InputInfoPtr pInfo, const WacomDeviceState* ds, int b

}

static void wcmSendKeys (InputInfoPtr pInfo, unsigned int current, unsigned int previous)
{
unsigned int mask, idx;
WacomDevicePtr priv = (WacomDevicePtr) pInfo->private;

DBG(6, priv, "current=%d previous=%d\n", current, previous);

for (idx = 0, mask = 0x1;
mask && (mask <= current || mask <= previous);
idx++, mask <<= 1)
{
if ((mask & previous) != (mask & current))
{
int key = 0;
int state = !!(mask & current);

switch (idx) {
/* Note: the evdev keycodes are > 255 and
* get dropped by the server. So let's remap
* those to KEY_PROG1-3 instead */
case IDX_KEY_CONTROLPANEL:
key = KEY_PROG1;
break;
case IDX_KEY_ONSCREEN_KEYBOARD:
key = KEY_PROG2;
break;
case IDX_KEY_BUTTONCONFIG:
key = KEY_PROG3;
break;
case IDX_KEY_INFO:
key = KEY_PROG4;
break;
default:
break;
}
if (key)
wcmEmitKeycode(pInfo->dev, key + 8, state);
}
}
}

void wcmEmitKeycode (DeviceIntPtr keydev, int keycode, int state)
{
xf86PostKeyboardEvent (keydev, keycode, state);
Expand Down Expand Up @@ -600,6 +641,8 @@ wcmSendPadEvents(InputInfoPtr pInfo, const WacomDeviceState* ds,
wcmSendButtons(pInfo, ds, ds->buttons, first_val, num_vals, valuators);
}

wcmSendKeys(pInfo, ds->keys, priv->oldState.keys);

if (priv->oldState.proximity && !ds->proximity)
xf86PostProximityEventP(pInfo->dev, 0, first_val, num_vals,
VCOPY(valuators, num_vals));
Expand Down Expand Up @@ -772,9 +815,14 @@ void wcmSendEvents(InputInfoPtr pInfo, const WacomDeviceState* ds)
*/
if(!priv->oldState.proximity)
{
int old_key_state = priv->oldState.keys;

wcmUpdateOldState(pInfo, ds, x, y);
priv->oldState.proximity = 0;
priv->oldState.buttons = 0;

/* keys can happen without proximity */
priv->oldState.keys = old_key_state;
}

valuators[0] = x;
Expand Down Expand Up @@ -835,6 +883,7 @@ wcmCheckSuppress(WacomCommonPtr common,
if (dsOrig->proximity != dsNew->proximity) goto out;

if (dsOrig->buttons != dsNew->buttons) goto out;
if (dsOrig->keys != dsNew->keys) goto out;
if (dsOrig->stripx != dsNew->stripx) goto out;
if (dsOrig->stripy != dsNew->stripy) goto out;

Expand Down
13 changes: 12 additions & 1 deletion src/wcmUSB.c
Original file line number Diff line number Diff line change
Expand Up @@ -1638,7 +1638,18 @@ static void usbParseBTNEvent(WacomCommonPtr common,
case BTN_FORWARD:
ds->buttons = mod_buttons(ds->buttons, 4, event->value);
break;

case KEY_CONTROLPANEL:
ds->keys = mod_buttons(ds->keys, IDX_KEY_CONTROLPANEL, event->value);
break;
case KEY_ONSCREEN_KEYBOARD:
ds->keys = mod_buttons(ds->keys, IDX_KEY_ONSCREEN_KEYBOARD, event->value);
break;
case KEY_BUTTONCONFIG:
ds->keys = mod_buttons(ds->keys, IDX_KEY_BUTTONCONFIG, event->value);
break;
case KEY_INFO:
ds->keys = mod_buttons(ds->keys, IDX_KEY_INFO, event->value);
break;
default:
for (nkeys = 0; nkeys < usbdata->npadkeys; nkeys++)
{
Expand Down
6 changes: 6 additions & 0 deletions src/xf86WacomDefs.h
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,11 @@ struct _WacomModel
#define STRIP_RIGHT_UP 2
#define STRIP_RIGHT_DN 3

#define IDX_KEY_CONTROLPANEL 1
#define IDX_KEY_ONSCREEN_KEYBOARD 2
#define IDX_KEY_BUTTONCONFIG 3
#define IDX_KEY_INFO 4

/******************************************************************************
* WacomDeviceState
*****************************************************************************/
Expand All @@ -236,6 +241,7 @@ struct _WacomDeviceState
int proximity;
int sample; /* wraps every 24 days */
int time;
unsigned int keys; /* bitmask for IDX_KEY_CONTROLPANEL, etc. */
};

static const struct _WacomDeviceState OUTPROX_STATE = {
Expand Down