mirror of
https://gitlab.freedesktop.org/libevdev/libevdev.git
synced 2025-12-21 13:10:08 +01:00
Use a macro for type_to_mask
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
parent
6019083a1a
commit
31961e8d59
1 changed files with 21 additions and 34 deletions
|
|
@ -53,30 +53,26 @@ set_bit_state(unsigned long *array, int bit, int state)
|
||||||
clear_bit(array, bit);
|
clear_bit(array, bit);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define max_mask(uc, lc) \
|
||||||
|
case EV_##uc: \
|
||||||
|
*mask = dev->lc##_bits; \
|
||||||
|
max = libevdev_get_event_type_max(type); \
|
||||||
|
break;
|
||||||
|
|
||||||
|
|
||||||
static inline int
|
static inline int
|
||||||
type_to_mask_const(const struct libevdev *dev, unsigned int type, const unsigned long **mask)
|
type_to_mask_const(const struct libevdev *dev, unsigned int type, const unsigned long **mask)
|
||||||
{
|
{
|
||||||
int max;
|
int max;
|
||||||
|
|
||||||
switch(type) {
|
switch(type) {
|
||||||
case EV_ABS:
|
max_mask(ABS, abs);
|
||||||
*mask = dev->abs_bits;
|
max_mask(REL, rel);
|
||||||
max = ABS_MAX;
|
max_mask(KEY, key);
|
||||||
break;
|
max_mask(LED, led);
|
||||||
case EV_REL:
|
|
||||||
*mask = dev->rel_bits;
|
|
||||||
max = REL_MAX;
|
|
||||||
break;
|
|
||||||
case EV_KEY:
|
|
||||||
*mask = dev->key_bits;
|
|
||||||
max = KEY_MAX;
|
|
||||||
break;
|
|
||||||
case EV_LED:
|
|
||||||
*mask = dev->led_bits;
|
|
||||||
max = LED_MAX;
|
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
return -1;
|
max = -1;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return max;
|
return max;
|
||||||
|
|
@ -88,27 +84,18 @@ type_to_mask(struct libevdev *dev, unsigned int type, unsigned long **mask)
|
||||||
int max;
|
int max;
|
||||||
|
|
||||||
switch(type) {
|
switch(type) {
|
||||||
case EV_ABS:
|
max_mask(ABS, abs);
|
||||||
*mask = dev->abs_bits;
|
max_mask(REL, rel);
|
||||||
max = ABS_MAX;
|
max_mask(KEY, key);
|
||||||
break;
|
max_mask(LED, led);
|
||||||
case EV_REL:
|
|
||||||
*mask = dev->rel_bits;
|
|
||||||
max = REL_MAX;
|
|
||||||
break;
|
|
||||||
case EV_KEY:
|
|
||||||
*mask = dev->key_bits;
|
|
||||||
max = KEY_MAX;
|
|
||||||
break;
|
|
||||||
case EV_LED:
|
|
||||||
*mask = dev->led_bits;
|
|
||||||
max = LED_MAX;
|
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
return -1;
|
max = -1;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return max;
|
return max;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#undef max_mask
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue