summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/core/hle/service/hid/irs_ring_lifo.h2
-rw-r--r--src/core/hle/service/hid/irsensor/clustering_processor.cpp24
2 files changed, 14 insertions, 12 deletions
diff --git a/src/core/hle/service/hid/irs_ring_lifo.h b/src/core/hle/service/hid/irs_ring_lifo.h
index a31e61037..255d1d296 100644
--- a/src/core/hle/service/hid/irs_ring_lifo.h
+++ b/src/core/hle/service/hid/irs_ring_lifo.h
@@ -36,7 +36,7 @@ struct Lifo {
36 } 36 }
37 37
38 void WriteNextEntry(const State& new_state) { 38 void WriteNextEntry(const State& new_state) {
39 if (buffer_count < max_buffer_size) { 39 if (buffer_count < static_cast<s64>(max_buffer_size)) {
40 buffer_count++; 40 buffer_count++;
41 } 41 }
42 sampling_number++; 42 sampling_number++;
diff --git a/src/core/hle/service/hid/irsensor/clustering_processor.cpp b/src/core/hle/service/hid/irsensor/clustering_processor.cpp
index 57e1831b4..e5b999b9f 100644
--- a/src/core/hle/service/hid/irsensor/clustering_processor.cpp
+++ b/src/core/hle/service/hid/irsensor/clustering_processor.cpp
@@ -127,10 +127,10 @@ ClusteringProcessor::ClusteringData ClusteringProcessor::GetClusterProperties(st
127 }; 127 };
128 128
129 for (const auto new_point : new_points) { 129 for (const auto new_point : new_points) {
130 if (new_point.x < 0 || new_point.x >= width) { 130 if (new_point.x >= width) {
131 continue; 131 continue;
132 } 132 }
133 if (new_point.y < 0 || new_point.y >= height) { 133 if (new_point.y >= height) {
134 continue; 134 continue;
135 } 135 }
136 if (GetPixel(data, new_point.x, new_point.y) < current_config.object_intensity_min) { 136 if (GetPixel(data, new_point.x, new_point.y) < current_config.object_intensity_min) {
@@ -169,12 +169,14 @@ ClusteringProcessor::ClusteringData ClusteringProcessor::GetPixelProperties(
169 169
170ClusteringProcessor::ClusteringData ClusteringProcessor::MergeCluster( 170ClusteringProcessor::ClusteringData ClusteringProcessor::MergeCluster(
171 const ClusteringData a, const ClusteringData b) const { 171 const ClusteringData a, const ClusteringData b) const {
172 const u32 pixel_count = a.pixel_count + b.pixel_count; 172 const f32 a_pixel_count = static_cast<f32>(a.pixel_count);
173 const f32 b_pixel_count = static_cast<f32>(b.pixel_count);
174 const f32 pixel_count = a_pixel_count + b_pixel_count;
173 const f32 average_intensitiy = 175 const f32 average_intensitiy =
174 (a.average_intensity * a.pixel_count + b.average_intensity * b.pixel_count) / pixel_count; 176 (a.average_intensity * a_pixel_count + b.average_intensity * b_pixel_count) / pixel_count;
175 const Core::IrSensor::IrsCentroid centroid = { 177 const Core::IrSensor::IrsCentroid centroid = {
176 .x = (a.centroid.x * a.pixel_count + b.centroid.x * b.pixel_count) / pixel_count, 178 .x = (a.centroid.x * a_pixel_count + b.centroid.x * b_pixel_count) / pixel_count,
177 .y = (a.centroid.y * a.pixel_count + b.centroid.y * b.pixel_count) / pixel_count, 179 .y = (a.centroid.y * a_pixel_count + b.centroid.y * b_pixel_count) / pixel_count,
178 }; 180 };
179 s16 bound_start_x = a.bound.x < b.bound.x ? a.bound.x : b.bound.x; 181 s16 bound_start_x = a.bound.x < b.bound.x ? a.bound.x : b.bound.x;
180 s16 bound_start_y = a.bound.y < b.bound.y ? a.bound.y : b.bound.y; 182 s16 bound_start_y = a.bound.y < b.bound.y ? a.bound.y : b.bound.y;
@@ -186,16 +188,16 @@ ClusteringProcessor::ClusteringData ClusteringProcessor::MergeCluster(
186 const Core::IrSensor::IrsRect bound = { 188 const Core::IrSensor::IrsRect bound = {
187 .x = bound_start_x, 189 .x = bound_start_x,
188 .y = bound_start_y, 190 .y = bound_start_y,
189 .width = a_bound_end_x > b_bound_end_x ? a_bound_end_x - bound_start_x 191 .width = a_bound_end_x > b_bound_end_x ? static_cast<s16>(a_bound_end_x - bound_start_x)
190 : b_bound_end_x - bound_start_x, 192 : static_cast<s16>(b_bound_end_x - bound_start_x),
191 .height = a_bound_end_y > b_bound_end_y ? a_bound_end_y - bound_start_y 193 .height = a_bound_end_y > b_bound_end_y ? static_cast<s16>(a_bound_end_y - bound_start_y)
192 : b_bound_end_y - bound_start_y, 194 : static_cast<s16>(b_bound_end_y - bound_start_y),
193 }; 195 };
194 196
195 return { 197 return {
196 .average_intensity = average_intensitiy, 198 .average_intensity = average_intensitiy,
197 .centroid = centroid, 199 .centroid = centroid,
198 .pixel_count = pixel_count, 200 .pixel_count = static_cast<u32>(pixel_count),
199 .bound = bound, 201 .bound = bound,
200 }; 202 };
201} 203}