Skip to content

Commit 6446754

Browse files
author
ahao
committed
通用鼠标支持
1 parent 0a2c371 commit 6446754

40 files changed

+10477
-145
lines changed

controller/ApexMacroConfigController.py

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ class MacroMode(Enum):
2222

2323
LGS = "LGS"
2424
GHUB = "GHUB"
25+
GHUB2 = "GHUB-通用鼠标"
2526

2627
class MacroConfigController():
2728

@@ -56,7 +57,6 @@ def init_ui_data(self) -> None:
5657

5758
for macroMode in MacroMode:
5859
self.view.driversoft.addItem(macroMode.value, userData=macroMode)
59-
self.driver_changed()
6060

6161
for aimMode in AimMode:
6262
self.view.modes.addItem(aimMode.value, userData=aimMode)
@@ -95,6 +95,8 @@ def init_ui_with_config(self):
9595
keyBindings = []
9696
for key in self.config["keybinds"]:
9797
modifiers = key.split("+")[0].split(",")
98+
if len(modifiers) == 1 and modifiers[0] == "":
99+
modifiers = []
98100
mouseBtn = key.split("+")[-1]
99101
try:
100102
scriptFunc = self.macroFunctions[self.config["keybinds"][key]]
@@ -121,7 +123,10 @@ def save_config(self):
121123

122124
keyBinding_data = self.tablemodel.data.copy()
123125
keyBinding_data.append(KeyBinding(1,self.macroFunctions["leftbutton"]))
124-
keyBinding_data.append(KeyBinding(2,self.macroFunctions["rightbutton"]))
126+
rightkey = 2
127+
if self.view.driversoft.currentData() == MacroMode.GHUB2:
128+
rightkey = 3
129+
keyBinding_data.append(KeyBinding(rightkey,self.macroFunctions["rightbutton"]))
125130

126131
## render config.lua
127132
result = ""
@@ -195,13 +200,6 @@ def save_config(self):
195200

196201
Settings().save_config_to_json()
197202

198-
def load_configs(self,configpath):
199-
config = None
200-
with open(configpath, "r") as f:
201-
config = json.load(f)
202-
if config:
203-
self.config = config
204-
205203
def load_functions(self, script_file_path: str) -> str:
206204
with open(script_file_path, "r") as f:
207205
scripts = json.load(f)
@@ -245,6 +243,16 @@ def download_driverscript(self):
245243
tempfile.tempdir.replace("\\", "/")+"/config.lua")
246244
with open(save_path, "w") as f:
247245
f.write(result)
246+
elif self.view.driversoft.currentData() == MacroMode.GHUB2:
247+
try:
248+
mainscript = self.macroFunctions["script"]
249+
except:
250+
traceback.print_exc()
251+
return
252+
result = mainscript.openContent.format(
253+
tempfile.tempdir.replace("\\", "/")+"/config.lua")
254+
with open(save_path, "w") as f:
255+
f.write(result)
248256

249257
def mode_changed(self):
250258
self.config["adsmode"] = self.view.modes.currentData().value
@@ -304,6 +312,8 @@ def driver_changed(self):
304312
self.macroFunctions = self.parse_functions_to_model(self.load_functions(Settings().resource_dir+"lgsscripts.json"))
305313
if macro == MacroMode.GHUB:
306314
self.macroFunctions = self.parse_functions_to_model(self.load_functions(Settings().resource_dir+"ghubscripts.json"))
315+
if macro == MacroMode.GHUB2:
316+
self.macroFunctions = self.parse_functions_to_model(self.load_functions(Settings().resource_dir+"ghub2scripts.json"))
307317
self.load_macro_functions()
308318

309319
def load_macro_functions(self):
@@ -352,6 +362,8 @@ def save_macro_script(self,func:MacroFunction,openContent: str,closeContent:str,
352362
save_file = Settings().resource_dir+"lgsscripts.json"
353363
elif self.view.driversoft.currentData() == MacroMode.GHUB:
354364
save_file = Settings().resource_dir+"ghubscripts.json"
365+
elif self.view.driversoft.currentData() == MacroMode.GHUB2:
366+
save_file = Settings().resource_dir+"ghub2scripts.json"
355367

356368
with open(save_file,"w") as file:
357369
json.dump(result, file, indent=4)

controller/ApexRecognizer.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ def check_resolution(self):
4949
point = self.boxs[k]
5050
newpoint = [point[0]+monitor["left"],point[1]+monitor["top"]]
5151
self.boxs[k] = newpoint
52+
self.boxs[k].extend(point[2:])
5253
self.resize_rate = float(height/1080)
5354
except FileNotFoundError as e:
5455
raise FileNotFoundError("不支持的分辨率{}x{}".format(width,height))
@@ -84,8 +85,10 @@ def isweapon_icon(self, cvimg):
8485
return round(np.sum(cvimg)/6311250*100)>=8
8586

8687
def recognize(self):
87-
icon_scale = 180/45
88-
icon_height = round(45 * self.resize_rate)
88+
icon_width = self.boxs["weapon1"][2]
89+
icon_height = self.boxs["weapon1"][3]
90+
icon_scale = icon_width/icon_height
91+
icon_height = round(icon_height * self.resize_rate)
8992
icon_width = round(icon_height * icon_scale)
9093

9194
box1 = (self.boxs["weapon1"][0],
@@ -119,8 +122,10 @@ def recognize(self):
119122
self.qt_comunicate.update.emit(d) if self.qt_comunicate else None
120123

121124
def screenshot(self):
122-
icon_scale = 180/45
123-
icon_height = round(45 * self.resize_rate)
125+
icon_width = self.boxs["weapon1"][2]
126+
icon_height = self.boxs["weapon1"][3]
127+
icon_scale = icon_width/icon_height
128+
icon_height = round(icon_height * self.resize_rate)
124129
icon_width = round(icon_height * icon_scale)
125130

126131
box1 = (self.boxs["weapon1"][0],

controller/ApexWeaponConfigController.py

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ def load_datas(self):
6767
self.datas = {
6868
"loading": 0,
6969
"dq": ["true"],
70-
"dqrate": 2,
70+
"dqrate": [2],
7171
"debug": ["false"],
7272
"weapons": {}
7373
}
@@ -78,7 +78,7 @@ def load_datas(self):
7878
is_weapon_data = True
7979
# global sensitive
8080
for k in self.datas.keys():
81-
if f.find(k)>=0:
81+
if f.find(k+"=")>=0:
8282
leftquote = f.split("=")[-1].find("{")
8383
rightquote = f.split("=")[-1].find("}")
8484
self.datas[k] = f.split("=")[-1][leftquote+1:rightquote].split(",")
@@ -135,6 +135,8 @@ def generate_config(self):
135135
def block_ui_event(self,block:bool):
136136
for widget in [self.view.loading,
137137
self.view.dq,
138+
self.view.debug,
139+
self.view.dqrate,
138140
self.view.speed,
139141
self.view.yrate,
140142
self.view.xrate,
@@ -199,11 +201,13 @@ def cal_data_result(self):
199201
movex = (offsetx) * xrate
200202
movey = (base + offsety) * yrate
201203

202-
countx = countx + movex
203-
county = county + movey
204+
# countx = countx + movex
205+
# county = county + movey
204206

205-
countdatax.append("{:.2f}".format(countx))
206-
countdatay.append("{:.2f}".format(county))
207+
# countdatax.append("{:.2f}".format(countx))
208+
# countdatay.append("{:.2f}".format(county))
209+
countdatax.append("{:.2f}".format(movex))
210+
countdatay.append("{:.2f}".format(movey))
207211
# self.view.weapon_data_result.append(f"{{{i},{movey},0}}")
208212

209213
countdatax = str(countdatax).replace("[","{").replace("]","}")
@@ -259,8 +263,11 @@ def fill_ui_data(self):
259263

260264
def delteweapon(self):
261265
weapon_name = self.view.weapons.currentText()
262-
del self.datas["weapons"][weapon_name]
263-
self.fill_ui_data()
266+
try:
267+
del self.datas["weapons"][weapon_name]
268+
self.fill_ui_data()
269+
except:
270+
pass
264271

265272
def apply(self):
266273
result = ""

controller/PubgMacroConfigController.py

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ class MacroMode(Enum):
2121

2222
LGS = "LGS"
2323
GHUB = "GHUB"
24+
GHUB2 = "GHUB-通用鼠标"
2425

2526
class MacroConfigController():
2627

@@ -55,8 +56,8 @@ def init_ui_data(self) -> None:
5556

5657
for macroMode in MacroMode:
5758
self.view.driversoft.addItem(macroMode.value, userData=macroMode)
58-
self.view.driversoft.setCurrentIndex( self.view.driversoft.findData(MacroMode(self.config["driver"])) )
59-
self.driver_changed()
59+
# self.view.driversoft.setCurrentIndex( self.view.driversoft.findData(MacroMode(self.config["driver"])) )
60+
# self.driver_changed()
6061

6162
for aimMode in AimMode:
6263
self.view.modes.addItem(aimMode.value, userData=aimMode)
@@ -111,6 +112,8 @@ def init_ui_with_config(self):
111112
keyBindings = []
112113
for key in self.config["keybinds"]:
113114
modifiers = key.split("+")[0].split(",")
115+
if len(modifiers) == 1 and modifiers[0] == "":
116+
modifiers = []
114117
mouseBtn = key.split("+")[-1]
115118
try:
116119
scriptFunc = self.macroFunctions[self.config["keybinds"][key]]
@@ -141,7 +144,10 @@ def save_config(self):
141144

142145
keyBinding_data = self.tablemodel.data.copy()
143146
keyBinding_data.append(KeyBinding(1,self.macroFunctions["leftbutton"]))
144-
keyBinding_data.append(KeyBinding(2,self.macroFunctions["rightbutton"]))
147+
rightkey = 2
148+
if self.view.driversoft.currentData() == MacroMode.GHUB2:
149+
rightkey = 3
150+
keyBinding_data.append(KeyBinding(rightkey,self.macroFunctions["rightbutton"]))
145151

146152
if self.config["adsmode"] == AimMode.HOLD_MOUSE_BTN_2.value:
147153
keyBinding_data.append(KeyBinding(self.config["aimbutton"],self.macroFunctions["aimbutton"]))
@@ -278,6 +284,16 @@ def download_driverscript(self):
278284
tempfile.tempdir.replace("\\", "/")+"/config.lua")
279285
with open(save_path, "w") as f:
280286
f.write(result)
287+
elif self.view.driversoft.currentData() == MacroMode.GHUB2:
288+
try:
289+
mainscript = self.macroFunctions["script"]
290+
except:
291+
print("配置文件损坏")
292+
return
293+
result = mainscript.openContent.format(
294+
tempfile.tempdir.replace("\\", "/")+"/config.lua")
295+
with open(save_path, "w") as f:
296+
f.write(result)
281297

282298
def mode_changed(self):
283299
self.view.toggle_aimMode_display(False) if self.view.modes.currentData() == AimMode.CLICK_MOUSE_BTN_2 else self.view.toggle_aimMode_display(True)
@@ -356,6 +372,8 @@ def driver_changed(self):
356372
self.macroFunctions = self.parse_functions_to_model(self.load_functions(Settings().resource_dir+"lgsscripts.json"))
357373
if macro == MacroMode.GHUB:
358374
self.macroFunctions = self.parse_functions_to_model(self.load_functions(Settings().resource_dir+"ghubscripts.json"))
375+
if macro == MacroMode.GHUB2:
376+
self.macroFunctions = self.parse_functions_to_model(self.load_functions(Settings().resource_dir+"ghub2scripts.json"))
359377
self.load_macro_functions()
360378

361379
def load_macro_functions(self):
@@ -404,6 +422,8 @@ def save_macro_script(self,func:MacroFunction,openContent: str,closeContent:str,
404422
save_file = Settings().resource_dir+"lgsscripts.json"
405423
elif self.view.driversoft.currentData() == MacroMode.GHUB:
406424
save_file = Settings().resource_dir+"ghubscripts.json"
425+
elif self.view.driversoft.currentData() == MacroMode.GHUB2:
426+
save_file = Settings().resource_dir+"ghub2scripts.json"
407427

408428
with open(save_file,"w") as file:
409429
json.dump(result, file, indent=4)

controller/PubgWeaponConfigController.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -226,11 +226,13 @@ def cal_data_result(self):
226226
movex = round(offsetx * rate )
227227
movey = round((base + offsety) * rate )
228228

229-
countx = countx + movex
230-
county = county + movey
229+
# countx = countx + movex
230+
# county = county + movey
231231

232-
countdatax.append(countx)
233-
countdatay.append(county)
232+
# countdatax.append(countx)
233+
# countdatay.append(county)
234+
countdatax.append(movex)
235+
countdatay.append(movey)
234236
# self.view.weapon_data_result.append(f"{{{i},{movey},0}}")
235237

236238
countdatax = str(countdatax).replace("[","{").replace("]","}")

resource/APEX/config.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
{
22
"macro_config": {
3-
"driver": "LGS",
3+
"driver": "GHUB-\u901a\u7528\u9f20\u6807",
44
"adsmode": "HOLD",
55
"keybinds": {
6-
"lctrl,lshift,lalt+5": "reloadconfig"
6+
"+2": "reloadconfig"
77
}
88
},
99
"pose": {

0 commit comments

Comments
 (0)