@@ -292,8 +292,8 @@ func InitTouchHandler(
292292 abs_last_map .Store ("RS_Y" , 0.5 )
293293
294294 screenSizeX := config_json .Get ("SCREEN" ).Get ("SIZE" ).GetIndex (0 ).MustInt ()
295- global_screen_x = int32 (screenSizeX )
296295 screenSizeY := config_json .Get ("SCREEN" ).Get ("SIZE" ).GetIndex (1 ).MustInt ()
296+ global_screen_x = int32 (screenSizeX )
297297 global_screen_y = int32 (screenSizeY )
298298 KEYBOARD_SWITCH_KEY_NAME_S := make (map [string ]bool )
299299 for _ , key := range config_json .Get ("MOUSE" ).Get ("SWITCH_KEYS" ).MustStringArray () {
@@ -376,6 +376,8 @@ func (self *TouchHandler) reloadConfigure(mapperFilePath string) {
376376 config_json , _ := simplejson .NewJson (content )
377377 screenSizeX := config_json .Get ("SCREEN" ).Get ("SIZE" ).GetIndex (0 ).MustInt ()
378378 screenSizeY := config_json .Get ("SCREEN" ).Get ("SIZE" ).GetIndex (1 ).MustInt ()
379+ global_screen_x = int32 (screenSizeX )
380+ global_screen_y = int32 (screenSizeY )
379381 self .config = config_json
380382 self .screen_x = int32 (screenSizeX )
381383 self .screen_y = int32 (screenSizeY )
@@ -417,17 +419,17 @@ func (self *TouchHandler) get_scaled_pos(x int32, y int32) (int32, int32) {
417419 return int32 (int64 (x ) * 0x7ffffffe / int64 (self .rel_screen_x )), int32 (int64 (y ) * 0x7ffffffe / int64 (self .rel_screen_y ))
418420}
419421
420- func (self * TouchHandler ) touch_require (x int32 , y int32 , scale uint8 ) int32 {
422+ func (self * TouchHandler ) touch_require (x int32 , y int32 , scale bool ) int32 {
421423 self .touch_control_lock .Lock ()
422424 defer self .touch_control_lock .Unlock ()
423425 for i , v := range self .allocated_id {
424426 if ! v {
425427 self .allocated_id [i ] = true
426- if scale == 0 {
427- self .send_touch_control_pack (TouchActionRequire , int32 (i ), x , y )
428- } else {
428+ if scale {
429429 scaled_x , scaled_y := self .get_scaled_pos (x , y )
430430 self .send_touch_control_pack (TouchActionRequire , int32 (i ), scaled_x , scaled_y )
431+ } else {
432+ self .send_touch_control_pack (TouchActionRequire , int32 (i ), x , y )
431433 }
432434 logger .Debugf ("touch require [%v] => (%v,%v)" , i , x , y )
433435 return int32 (i )
@@ -447,16 +449,16 @@ func (self *TouchHandler) touch_release(id int32) int32 {
447449 return - 1
448450}
449451
450- func (self * TouchHandler ) touch_move (id int32 , x int32 , y int32 , scale uint8 ) {
452+ func (self * TouchHandler ) touch_move (id int32 , x int32 , y int32 , scale bool ) {
451453 self .touch_control_lock .Lock ()
452454 defer self .touch_control_lock .Unlock ()
453455 logger .Debugf ("touch move to (%v,%v) [%v]" , x , y , id )
454456 if id != - 1 {
455- if scale == 0 {
456- self .send_touch_control_pack (TouchActionMove , id , x , y )
457- } else {
457+ if scale {
458458 scaled_x , scaled_y := self .get_scaled_pos (x , y )
459459 self .send_touch_control_pack (TouchActionMove , id , scaled_x , scaled_y )
460+ } else {
461+ self .send_touch_control_pack (TouchActionMove , id , x , y )
460462 }
461463
462464 }
@@ -511,7 +513,7 @@ func (self *TouchHandler) handel_view_move(offset_x int32, offset_y int32) { //
511513 self .auto_release_view_count = 0
512514 if self .view_id == - 1 {
513515 self .view_current_x , self .view_current_y = self .get_scaled_pos (self .view_init_x + rand_offset (), self .view_init_y + rand_offset ())
514- self .view_id = self .touch_require (self .view_current_x , self .view_current_y , 0 )
516+ self .view_id = self .touch_require (self .view_current_x , self .view_current_y , false )
515517 }
516518 self .view_current_x += offset_x * self .view_speed_x
517519 self .view_current_y += offset_y * self .view_speed_y
@@ -541,14 +543,14 @@ func (self *TouchHandler) handel_view_move(offset_x int32, offset_y int32) { //
541543 // 采用了0x7ffffffe作为边界的情况下,所情况有都为有界
542544 if self .view_current_x < 0 || self .view_current_y < 0 { //出现负数 表示到达边界
543545 self .view_current_x , self .view_current_y = self .get_scaled_pos (self .view_init_x + rand_offset (), self .view_init_y + rand_offset ())
544- tmp_view_id := self .touch_require (self .view_current_x , self .view_current_y , 0 )
546+ tmp_view_id := self .touch_require (self .view_current_x , self .view_current_y , false )
545547 self .view_current_x += offset_x * self .view_speed_x
546548 self .view_current_y += offset_y * self .view_speed_y
547- self .touch_move (tmp_view_id , self .view_current_x , self .view_current_y , 0 )
549+ self .touch_move (tmp_view_id , self .view_current_x , self .view_current_y , false )
548550 self .touch_release (self .view_id )
549551 self .view_id = tmp_view_id
550552 } else {
551- self .touch_move (self .view_id , self .view_current_x , self .view_current_y , 0 )
553+ self .touch_move (self .view_id , self .view_current_x , self .view_current_y , false )
552554 }
553555
554556}
@@ -585,9 +587,9 @@ func (self *TouchHandler) handel_wheel_action(action int8, abs_x int32, abs_y in
585587 }
586588 } else if action == Wheel_action_move { //移动
587589 if self .wheel_id == - 1 { //如果在移动之前没有按下
588- self .wheel_id = self .touch_require (self .wheel_init_x , self .wheel_init_y , touch_pos_scale )
590+ self .wheel_id = self .touch_require (self .wheel_init_x , self .wheel_init_y , true )
589591 }
590- self .touch_move (self .wheel_id , abs_x , abs_y , touch_pos_scale )
592+ self .touch_move (self .wheel_id , abs_x , abs_y , true )
591593 }
592594 self .wheel_lock .Unlock ()
593595}
@@ -718,7 +720,7 @@ func (self *TouchHandler) execute_key_action(start time.Time, key_name string, u
718720 if up_down == DOWN {
719721 x := int32 (action .Get ("POS" ).GetIndex (0 ).MustFloat64 ()* float64 (self .rel_screen_x )) + rand_offset ()
720722 y := int32 (action .Get ("POS" ).GetIndex (1 ).MustFloat64 ()* float64 (self .rel_screen_y )) + rand_offset ()
721- self .key_action_state_save .Store (key_name , self .touch_require (x , y , touch_pos_scale ))
723+ self .key_action_state_save .Store (key_name , self .touch_require (x , y , true ))
722724 } else if up_down == UP {
723725 tid := state .(int32 )
724726 self .touch_release (tid )
@@ -729,7 +731,7 @@ func (self *TouchHandler) execute_key_action(start time.Time, key_name string, u
729731 go (func () {
730732 x := int32 (action .Get ("POS" ).GetIndex (0 ).MustFloat64 ()* float64 (self .rel_screen_x )) + rand_offset ()
731733 y := int32 (action .Get ("POS" ).GetIndex (1 ).MustFloat64 ()* float64 (self .rel_screen_y )) + rand_offset ()
732- tid := self .touch_require (x , y , touch_pos_scale )
734+ tid := self .touch_require (x , y , true )
733735 time .Sleep (time .Duration (8 ) * time .Millisecond ) //8ms 120HZ下一次
734736 self .touch_release (tid )
735737 })()
@@ -744,7 +746,7 @@ func (self *TouchHandler) execute_key_action(start time.Time, key_name string, u
744746 self .key_action_state_save .Store (key_name , true )
745747 go (func () {
746748 for {
747- tid := self .touch_require (x + rand_offset (), y + rand_offset (), touch_pos_scale )
749+ tid := self .touch_require (x + rand_offset (), y + rand_offset (), true )
748750 time .Sleep (time .Duration (down_time ) * time .Millisecond )
749751 self .touch_release (tid )
750752 time .Sleep (time .Duration (interval_time ) * time .Millisecond )
@@ -768,7 +770,7 @@ func (self *TouchHandler) execute_key_action(start time.Time, key_name string, u
768770 for i := range action .Get ("POS_S" ).MustArray () {
769771 x := int32 (action .Get ("POS_S" ).GetIndex (i ).GetIndex (0 ).MustFloat64 ()* float64 (self .rel_screen_x )) + rand_offset ()
770772 y := int32 (action .Get ("POS_S" ).GetIndex (i ).GetIndex (1 ).MustFloat64 ()* float64 (self .rel_screen_y )) + rand_offset ()
771- tid := self .touch_require (x , y , touch_pos_scale )
773+ tid := self .touch_require (x , y , true )
772774 tid_save = append (tid_save , tid )
773775 time .Sleep (time .Duration (8 ) * time .Millisecond ) // 间隔8ms 是否需要延迟有待验证
774776 }
@@ -794,17 +796,17 @@ func (self *TouchHandler) execute_key_action(start time.Time, key_name string, u
794796 interval_time := action .Get ("INTERVAL" ).GetIndex (0 ).MustInt ()
795797 init_x := int32 (action .Get ("POS_S" ).GetIndex (0 ).GetIndex (0 ).MustFloat64 () * float64 (self .rel_screen_x ))
796798 init_y := int32 (action .Get ("POS_S" ).GetIndex (0 ).GetIndex (1 ).MustFloat64 () * float64 (self .rel_screen_y ))
797- tid := self .touch_require (init_x , init_y , touch_pos_scale )
799+ tid := self .touch_require (init_x , init_y , true )
798800 time .Sleep (time .Duration (interval_time ) * time .Millisecond )
799801 for index := 1 ; index < pos_len - 1 ; index ++ {
800802 x := int32 (action .Get ("POS_S" ).GetIndex (index ).GetIndex (0 ).MustFloat64 ()* float64 (self .rel_screen_x )) + rand_offset ()
801803 y := int32 (action .Get ("POS_S" ).GetIndex (index ).GetIndex (1 ).MustFloat64 ()* float64 (self .rel_screen_y )) + rand_offset ()
802- self .touch_move (tid , x , y , touch_pos_scale )
804+ self .touch_move (tid , x , y , true )
803805 time .Sleep (time .Duration (interval_time ) * time .Millisecond )
804806 }
805807 end_x := int32 (action .Get ("POS_S" ).GetIndex (pos_len - 1 ).GetIndex (0 ).MustFloat64 () * float64 (self .rel_screen_x ))
806808 end_y := int32 (action .Get ("POS_S" ).GetIndex (pos_len - 1 ).GetIndex (1 ).MustFloat64 () * float64 (self .rel_screen_y ))
807- self .touch_move (tid , end_x , end_y , touch_pos_scale )
809+ self .touch_move (tid , end_x , end_y , true )
808810 self .touch_release (tid )
809811 })()
810812 } else if up_down == UP {
@@ -1085,7 +1087,7 @@ func (self *TouchHandler) mix_touch(touch_events chan *event_pack, max_mt_x, max
10851087 if copy_id_statuses [i ] != id_statuses [i ] {
10861088 if id_statuses [i ] { //false -> true 申请
10871089 x , y := translate_xy (pos_s [i ][0 ], pos_s [i ][1 ])
1088- id_2_vid [i ] = self .touch_require (x , y , 0 )
1090+ id_2_vid [i ] = self .touch_require (x , y , false )
10891091 logger .Debugf ("mixTouch\t require\t [%d] translate_xy(%d,%d) => (%d,%d)" , i , pos_s [i ][0 ], pos_s [i ][1 ], x , y )
10901092 } else {
10911093 self .touch_release (id_2_vid [i ])
@@ -1094,7 +1096,7 @@ func (self *TouchHandler) mix_touch(touch_events chan *event_pack, max_mt_x, max
10941096 } else {
10951097 if pos_s [i ][0 ] != copy_pos_s [i ][0 ] || pos_s [i ][1 ] != copy_pos_s [i ][1 ] {
10961098 x , y := translate_xy (pos_s [i ][0 ], pos_s [i ][1 ])
1097- self .touch_move (id_2_vid [i ], x , y , 0 )
1099+ self .touch_move (id_2_vid [i ], x , y , false )
10981100 logger .Debugf ("mixTouch\t move\t [%d] translate_xy(%d,%d) => (%d,%d)" , i , pos_s [i ][0 ], pos_s [i ][1 ], x , y )
10991101 }
11001102 }
0 commit comments