Enable -Wshadow for input code
To avoid common programming mistakes, enable -Wshadow for input code.
This requires several refactors, such as using range-based for loops and
avoiding repeating variable names that are already in scope.
To allow for -Wshadow, we convert to unordered_map and use a range-based
loop.
Bug: 142017994
Test: atest libinput_tests inputflinger_tests
Change-Id: Icb65045d3322eccc312bca63287e38897d9f9ff6
diff --git a/services/inputflinger/reader/mapper/JoystickInputMapper.h b/services/inputflinger/reader/mapper/JoystickInputMapper.h
index 29d5652..0cf60a2 100644
--- a/services/inputflinger/reader/mapper/JoystickInputMapper.h
+++ b/services/inputflinger/reader/mapper/JoystickInputMapper.h
@@ -36,6 +36,26 @@
private:
struct Axis {
+ explicit Axis(const RawAbsoluteAxisInfo& rawAxisInfo, const AxisInfo& axisInfo,
+ bool explicitlyMapped, float scale, float offset, float highScale,
+ float highOffset, float min, float max, float flat, float fuzz,
+ float resolution, float filter)
+ : rawAxisInfo(rawAxisInfo),
+ axisInfo(axisInfo),
+ explicitlyMapped(explicitlyMapped),
+ scale(scale),
+ offset(offset),
+ highScale(highScale),
+ highOffset(highOffset),
+ min(min),
+ max(max),
+ flat(flat),
+ fuzz(fuzz),
+ resolution(resolution),
+ filter(filter) {
+ resetValue();
+ }
+
RawAbsoluteAxisInfo rawAxisInfo;
AxisInfo axisInfo;
@@ -58,26 +78,6 @@
float highCurrentValue; // current value of high split
float highNewValue; // most recent value of high split
- void initialize(const RawAbsoluteAxisInfo& rawAxisInfo, const AxisInfo& axisInfo,
- bool explicitlyMapped, float scale, float offset, float highScale,
- float highOffset, float min, float max, float flat, float fuzz,
- float resolution) {
- this->rawAxisInfo = rawAxisInfo;
- this->axisInfo = axisInfo;
- this->explicitlyMapped = explicitlyMapped;
- this->scale = scale;
- this->offset = offset;
- this->highScale = highScale;
- this->highOffset = highOffset;
- this->min = min;
- this->max = max;
- this->flat = flat;
- this->fuzz = fuzz;
- this->resolution = resolution;
- this->filter = 0;
- resetValue();
- }
-
void resetValue() {
this->currentValue = 0;
this->newValue = 0;
@@ -90,7 +90,7 @@
bool explicitlyMapped);
// Axes indexed by raw ABS_* axis index.
- KeyedVector<int32_t, Axis> mAxes;
+ std::unordered_map<int32_t, Axis> mAxes;
void sync(nsecs_t when, bool force);