소스 검색

added reset()

Nicolas Cannasse 6 년 전
부모
커밋
7947f49dc6
1개의 변경된 파일8개의 추가작업 그리고 1개의 파일을 삭제
  1. 8 1
      hxd/Pad.hx

+ 8 - 1
hxd/Pad.hx

@@ -242,6 +242,13 @@ class Pad {
 		return !buttons[button] && prevButtons[button];
 	}
 
+	public function reset() {
+		xAxis = yAxis = 0;
+		for( i in 0...buttons.length ) buttons[i] = false;
+		for( i in 0...buttons.length ) prevButtons[i] = false;
+		for( i in 0...values.length ) values[i] = 0;
+	}
+
 	public function rumble( strength : Float, time_s : Float ){
 		#if hlsdl
 		d.rumble( strength, Std.int(time_s*1000.) );
@@ -539,7 +546,7 @@ class Pad {
 
 	static function syncPads() {
 		var freshPads : Array<js.html.Gamepad> = [];
-		try freshPads = js.Browser.navigator.getGamepads() catch( e : Dynamic ) {}; 
+		try freshPads = js.Browser.navigator.getGamepads() catch( e : Dynamic ) {};
 		if ( freshPads.length > 0 ) {
 			for ( i in 0...freshPads.length ) {
 				if ( pads[i] != null ) {