mirror of
https://github.com/X11Libre/xf86-input-evdev.git
synced 2026-04-14 11:44:16 +00:00
Add EVDEV_MAXBUTTONS instead of checking against 32.
Numbers are so lame, defines are all the rage now I've heard.
This commit is contained in:
committed by
Peter Hutterer
parent
9793de8137
commit
4e121b297e
@@ -40,7 +40,6 @@
|
||||
|
||||
#include "evdev.h"
|
||||
|
||||
#define MSE_MAXBUTTONS 32
|
||||
#define WHEEL_NOT_CONFIGURED 0
|
||||
|
||||
static Atom prop_wheel_emu;
|
||||
@@ -162,8 +161,8 @@ EvdevWheelEmuHandleButtonMap(InputInfoPtr pInfo, WheelAxisPtr pAxis, char* axis_
|
||||
char *msg = NULL;
|
||||
|
||||
if ((sscanf(option_string, "%d %d", &up_button, &down_button) == 2) &&
|
||||
((up_button > 0) && (up_button <= MSE_MAXBUTTONS)) &&
|
||||
((down_button > 0) && (down_button <= MSE_MAXBUTTONS))) {
|
||||
((up_button > 0) && (up_button <= EVDEV_MAXBUTTONS)) &&
|
||||
((down_button > 0) && (down_button <= EVDEV_MAXBUTTONS))) {
|
||||
|
||||
/* Use xstrdup to allocate a string for us */
|
||||
msg = xstrdup("buttons XX and YY");
|
||||
@@ -211,7 +210,7 @@ EvdevWheelEmuPreInit(InputInfoPtr pInfo)
|
||||
wheelButton = xf86SetIntOption(pInfo->options,
|
||||
"EmulateWheelButton", 4);
|
||||
|
||||
if ((wheelButton < 0) || (wheelButton > MSE_MAXBUTTONS)) {
|
||||
if ((wheelButton < 0) || (wheelButton > EVDEV_MAXBUTTONS)) {
|
||||
xf86Msg(X_WARNING, "%s: Invalid EmulateWheelButton value: %d\n",
|
||||
pInfo->name, wheelButton);
|
||||
xf86Msg(X_WARNING, "%s: Wheel emulation disabled.\n", pInfo->name);
|
||||
@@ -457,7 +456,7 @@ EvdevWheelEmuSetProperty(DeviceIntPtr dev, Atom atom, XIPropertyValuePtr val)
|
||||
else if (atom == prop_wheel_button)
|
||||
{
|
||||
int bt = *((CARD8*)val->data);
|
||||
if (bt < 0 || bt >= MSE_MAXBUTTONS)
|
||||
if (bt < 0 || bt >= EVDEV_MAXBUTTONS)
|
||||
return FALSE;
|
||||
pEvdev->emulateWheel.button = bt;
|
||||
} else if (atom == prop_wheel_xmap)
|
||||
|
||||
@@ -854,11 +854,11 @@ EvdevInitButtonMapping(InputInfoPtr pInfo)
|
||||
int btn = 0;
|
||||
|
||||
xf86Msg(X_CONFIG, "%s: ButtonMapping '%s'\n", pInfo->name, mapping);
|
||||
while (s && *s != '\0' && nbuttons < 32)
|
||||
while (s && *s != '\0' && nbuttons < EVDEV_MAXBUTTONS)
|
||||
{
|
||||
btn = strtol(mapping, &s, 10);
|
||||
|
||||
if (s == mapping || btn < 0 || btn > 32)
|
||||
if (s == mapping || btn < 0 || btn > EVDEV_MAXBUTTONS)
|
||||
{
|
||||
xf86Msg(X_ERROR,
|
||||
"%s: ... Invalid button mapping. Using defaults\n",
|
||||
@@ -1256,7 +1256,7 @@ EvdevUtilButtonEventToButtonNumber(int code)
|
||||
}
|
||||
}
|
||||
|
||||
if (button > 32)
|
||||
if (button > EVDEV_MAXBUTTONS)
|
||||
return 0;
|
||||
|
||||
return button;
|
||||
|
||||
@@ -40,6 +40,8 @@
|
||||
#include <X11/extensions/XKBstr.h>
|
||||
#endif
|
||||
|
||||
#define EVDEV_MAXBUTTONS 32
|
||||
|
||||
/* axis specific data for wheel emulation */
|
||||
typedef struct {
|
||||
int up_button;
|
||||
|
||||
Reference in New Issue
Block a user