device: don't use class-shared structure for gesture indexes

This commit is contained in:
Peter F. Patel-Schneider 2022-01-13 11:10:57 -05:00
parent 25523315ab
commit a9c4950389
1 changed files with 5 additions and 7 deletions

View File

@ -787,10 +787,7 @@ ACTION_ID._fallback = lambda x: 'unknown:%04X' % x
class Gesture: class Gesture:
def __init__(self, device, low, high, next_index):
gesture_index = {}
def __init__(self, device, low, high):
self._device = device self._device = device
self.id = low self.id = low
self.gesture = GESTURE[low] self.gesture = GESTURE[low]
@ -802,8 +799,7 @@ class Gesture:
self.default_enabled = high & 0x20 self.default_enabled = high & 0x20
self.index = None self.index = None
if self.can_be_enabled or self.default_enabled: if self.can_be_enabled or self.default_enabled:
self.index = Gesture.gesture_index.get(device, 0) self.index = next_index
Gesture.gesture_index[device] = self.index + 1
self.offset, self.mask = self._offset_mask() self.offset, self.mask = self._offset_mask()
def _offset_mask(self): # offset and mask def _offset_mask(self): # offset and mask
@ -931,6 +927,7 @@ class Gestures:
self.params = {} self.params = {}
self.specs = {} self.specs = {}
index = 0 index = 0
next_gesture_index = 0
field_high = 0x00 field_high = 0x00
while field_high != 0x01: # end of fields while field_high != 0x01: # end of fields
# retrieve the next eight fields # retrieve the next eight fields
@ -943,7 +940,8 @@ class Gestures:
if field_high == 0x1: # end of fields if field_high == 0x1: # end of fields
break break
elif field_high & 0x80: elif field_high & 0x80:
gesture = Gesture(device, field_low, field_high) gesture = Gesture(device, field_low, field_high, next_gesture_index)
next_gesture_index = next_gesture_index if gesture.index is None else next_gesture_index + 1
self.gestures[gesture.gesture] = gesture self.gestures[gesture.gesture] = gesture
elif field_high & 0xF0 == 0x30 or field_high & 0xF0 == 0x20: elif field_high & 0xF0 == 0x30 or field_high & 0xF0 == 0x20:
param = Param(device, field_low, field_high) param = Param(device, field_low, field_high)