forked from eden-emu/eden
		
	core: hid: Update motion on a better place
This commit is contained in:
		
							parent
							
								
									36a670a4c9
								
							
						
					
					
						commit
						62acd50c0b
					
				
					 5 changed files with 20 additions and 22 deletions
				
			
		|  | @ -979,7 +979,6 @@ void EmulatedController::SetMotion(const Common::Input::CallbackStatus& callback | |||
|     emulated.SetUserGyroThreshold(raw_status.gyro.x.properties.threshold); | ||||
|     emulated.UpdateRotation(raw_status.delta_timestamp); | ||||
|     emulated.UpdateOrientation(raw_status.delta_timestamp); | ||||
|     force_update_motion = raw_status.force_update; | ||||
| 
 | ||||
|     auto& motion = controller.motion_state[index]; | ||||
|     motion.accel = emulated.GetAcceleration(); | ||||
|  | @ -1618,19 +1617,6 @@ NpadGcTriggerState EmulatedController::GetTriggers() const { | |||
| 
 | ||||
| MotionState EmulatedController::GetMotions() const { | ||||
|     std::unique_lock lock{mutex}; | ||||
| 
 | ||||
|     // Some drivers like mouse motion need constant refreshing
 | ||||
|     if (force_update_motion) { | ||||
|         for (auto& device : motion_devices) { | ||||
|             if (!device) { | ||||
|                 continue; | ||||
|             } | ||||
|             lock.unlock(); | ||||
|             device->ForceUpdate(); | ||||
|             lock.lock(); | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     return controller.motion_state; | ||||
| } | ||||
| 
 | ||||
|  | @ -1696,8 +1682,21 @@ void EmulatedController::DeleteCallback(int key) { | |||
|     callback_list.erase(iterator); | ||||
| } | ||||
| 
 | ||||
| void EmulatedController::TurboButtonUpdate() { | ||||
| void EmulatedController::StatusUpdate() { | ||||
|     turbo_button_state = (turbo_button_state + 1) % (TURBO_BUTTON_DELAY * 2); | ||||
| 
 | ||||
|     // Some drivers like key motion need constant refreshing
 | ||||
|     for (std::size_t index = 0; index < motion_devices.size(); ++index) { | ||||
|         const auto& raw_status = controller.motion_values[index].raw_status; | ||||
|         auto& device = motion_devices[index]; | ||||
|         if (!raw_status.force_update) { | ||||
|             continue; | ||||
|         } | ||||
|         if (!device) { | ||||
|             continue; | ||||
|         } | ||||
|         device->ForceUpdate(); | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| NpadButton EmulatedController::GetTurboButtonMask() const { | ||||
|  |  | |||
|  | @ -415,8 +415,8 @@ public: | |||
|      */ | ||||
|     void DeleteCallback(int key); | ||||
| 
 | ||||
|     /// Swaps the state of the turbo buttons
 | ||||
|     void TurboButtonUpdate(); | ||||
|     /// Swaps the state of the turbo buttons and updates motion input
 | ||||
|     void StatusUpdate(); | ||||
| 
 | ||||
| private: | ||||
|     /// creates input devices from params
 | ||||
|  | @ -528,7 +528,6 @@ private: | |||
|     bool is_configuring{false}; | ||||
|     bool system_buttons_enabled{true}; | ||||
|     f32 motion_sensitivity{Core::HID::MotionInput::IsAtRestStandard}; | ||||
|     bool force_update_motion{false}; | ||||
|     u32 turbo_button_state{0}; | ||||
| 
 | ||||
|     // Temporary values to avoid doing changes while the controller is in configuring mode
 | ||||
|  |  | |||
|  | @ -86,7 +86,7 @@ Common::Input::MotionStatus TransformToMotion(const Common::Input::CallbackStatu | |||
|             .range = 1.0f, | ||||
|             .offset = 0.0f, | ||||
|         }; | ||||
|         status.delta_timestamp = 5000; | ||||
|         status.delta_timestamp = 1000; | ||||
|         status.force_update = true; | ||||
|         status.accel.x = { | ||||
|             .value = 0.0f, | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 german77
						german77