| 
									
										
										
										
											2017-02-08 22:15:43 -05:00
										 |  |  | // Copyright 2017 Dolphin Emulator Project
 | 
					
						
							|  |  |  | // Licensed under GPLv2+
 | 
					
						
							|  |  |  | // Refer to the license.txt file included.
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include "InputCommon/ControllerEmu/ControlGroup/Triggers.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include <algorithm>
 | 
					
						
							|  |  |  | #include <cstddef>
 | 
					
						
							|  |  |  | #include <memory>
 | 
					
						
							|  |  |  | #include <string>
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include "Common/Common.h"
 | 
					
						
							|  |  |  | #include "InputCommon/ControlReference/ControlReference.h"
 | 
					
						
							|  |  |  | #include "InputCommon/ControllerEmu/Control/Control.h"
 | 
					
						
							| 
									
										
										
										
											2017-02-26 12:00:24 -08:00
										 |  |  | #include "InputCommon/ControllerEmu/Setting/NumericSetting.h"
 | 
					
						
							| 
									
										
										
										
											2017-02-08 22:15:43 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  | namespace ControllerEmu | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2017-02-25 00:35:02 -05:00
										 |  |  | Triggers::Triggers(const std::string& name_) : ControlGroup(name_, GroupType::Triggers) | 
					
						
							| 
									
										
										
										
											2017-02-08 22:15:43 -05:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2019-03-26 19:31:03 -05:00
										 |  |  |   AddDeadzoneSetting(&m_deadzone_setting, 50); | 
					
						
							| 
									
										
										
										
											2017-02-08 22:15:43 -05:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-13 12:06:49 -04:00
										 |  |  | Triggers::StateData Triggers::GetState() | 
					
						
							| 
									
										
										
										
											2017-02-08 22:15:43 -05:00
										 |  |  | { | 
					
						
							|  |  |  |   const size_t trigger_count = controls.size(); | 
					
						
							| 
									
										
										
										
											2019-03-26 19:31:03 -05:00
										 |  |  |   const ControlState deadzone = m_deadzone_setting.GetValue() / 100; | 
					
						
							| 
									
										
										
										
											2017-02-08 22:15:43 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-13 12:06:49 -04:00
										 |  |  |   StateData result(trigger_count); | 
					
						
							|  |  |  |   for (size_t i = 0; i < trigger_count; ++i) | 
					
						
							| 
									
										
										
										
											2019-03-29 14:39:48 -05:00
										 |  |  |     result.data[i] = ApplyDeadzone(controls[i]->control_ref->State(), deadzone); | 
					
						
							| 
									
										
										
										
											2018-07-13 12:06:49 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  |   return result; | 
					
						
							| 
									
										
										
										
											2017-02-08 22:15:43 -05:00
										 |  |  | } | 
					
						
							|  |  |  | }  // namespace ControllerEmu
 |