Update Files
This commit is contained in:
		
							
								
								
									
										31
									
								
								Kha/Backends/Kinc-hxcpp/kha/input/Sensor.hx
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										31
									
								
								Kha/Backends/Kinc-hxcpp/kha/input/Sensor.hx
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,31 @@ | ||||
| package kha.input; | ||||
|  | ||||
| @:keep | ||||
| class Sensor { | ||||
| 	static var accelerometer: Sensor = new Sensor(); | ||||
| 	static var gyroscope: Sensor = new Sensor(); | ||||
|  | ||||
| 	var listeners: Array<Float->Float->Float->Void> = new Array(); | ||||
|  | ||||
| 	public static function get(type: SensorType): Sensor { | ||||
| 		switch (type) { | ||||
| 			case Accelerometer: | ||||
| 				return accelerometer; | ||||
| 			case Gyroscope: | ||||
| 				return gyroscope; | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	public function notify(listener: Float->Float->Float->Void): Void { | ||||
| 		listeners.push(listener); | ||||
| 	} | ||||
|  | ||||
| 	function new() {} | ||||
|  | ||||
| 	public static function _changed(type: Int, x: Float, y: Float, z: Float): Void { | ||||
| 		var sensor = get(type == 0 ? SensorType.Accelerometer : SensorType.Gyroscope); | ||||
| 		for (listener in sensor.listeners) { | ||||
| 			listener(x, y, z); | ||||
| 		} | ||||
| 	} | ||||
| } | ||||
		Reference in New Issue
	
	Block a user