Skip to content

Commit 41c7ca3

Browse files
committed
fix default config file in executable
1 parent 9b6b16e commit 41c7ca3

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

midi2vjoy.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
#
2121

2222
from inspect import trace
23-
from os import path
23+
import os
2424
import sys
2525
import time
2626
import traceback
@@ -249,7 +249,7 @@ def joystick_run():
249249
arch = 'x64'
250250
else:
251251
arch = 'x86'
252-
dll_path = path.join(installpath, arch, 'vJoyInterface.dll')
252+
dll_path = os.path.join(installpath, arch, 'vJoyInterface.dll')
253253
vjoy = ctypes.WinDLL(dll_path)
254254
verbose("VJoy version", vjoy.GetvJoyVersion())
255255

@@ -411,16 +411,22 @@ def main():
411411

412412
pygame.midi.init()
413413

414+
if getattr(sys, 'frozen', False):
415+
application_path = os.path.dirname(sys.executable)
416+
elif __file__:
417+
application_path = os.path.dirname(__file__)
418+
verbose("Application path:", application_path)
419+
414420
if options.help:
415421
help_page()
416422
elif options.config_help:
417423
help_config()
418424
elif options.test:
419425
midi_test()
420-
elif options.conf and path.exists(options.conf):
426+
elif options.conf and os.path.exists(options.conf):
421427
joystick_run()
422-
elif path.exists(path.join(sys.path[0], "mapping.conf")):
423-
options.conf = path.join(sys.path[0], "mapping.conf")
428+
elif os.path.exists(os.path.join(application_path, "mapping.conf")):
429+
options.conf = os.path.join(application_path, "mapping.conf")
424430
joystick_run()
425431
else:
426432
help_page()

0 commit comments

Comments
 (0)