Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge 2.0 branch to clean up old branch #74

Merged
merged 6 commits into from
Nov 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 30 additions & 14 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,21 +1,37 @@
__pycache__/
src/__pycache__
src/adaptors/__pycache__/
src/functions/__pycache__/
# Files
/logs/*.log
diagrams/*.svg
diagrams/*.pdf
.coverage
.DS_Store
*.ui
*.bat
debug.txt

# Tests
tests/__pycache__
tests/*/__pycache__/
*.code-workspace
.vscode/

# Folders
*__pycache__/

# Folders
*__pycache__/
/build/
/dist/
/logs/*.log
.env
temp/
diagrams/*.svg
diagrams/*.pdf
/notebooks
/logs/*

# IDE
*.code-workspace
.vscode/

# Development
play*.py
tests/__pycache__/*.pyc
*.ui
*.bat
.coverage
.DS_Store
venv/
0.12.0.dev0

venv/
0.12.0.dev0
32 changes: 23 additions & 9 deletions build.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,44 @@
from cx_Freeze import setup, Executable
import joystick_diagrams.version as ver

VER = ver.VERSION
VER = ver.get_current_version()
HERE = pathlib.Path(__file__).parent.resolve()
BASE = None
TARGET_NAME: str = "joystick_diagrams"
LONG_DESC = (HERE / "readme.md").read_text(encoding="utf-8")

try:
from cx_Freeze.hooks import get_qt_plugins_paths
except ImportError:
include_files = []
else:
# Inclusion of extra plugins (new in cx_Freeze 6.8b2)
# cx_Freeze imports automatically the following plugins depending of the
# use of some modules:
# imageformats - QtGui
# platforms - QtGui
# mediaservice - QtMultimedia
# printsupport - QtPrintSupport
#
# So, "platforms" is used here for demonstration purposes.
include_files = get_qt_plugins_paths("PyQt5", "QtGui")

if sys.platform == "win32":
BASE = "Win32GUI"
TARGET_NAME = "joystick_diagrams.exe"

extra_includes = ["./images", "./templates", "./config.cfg", "./readme.md"]
include_files.extend(extra_includes)

build_options = {
"include_files": [
"./images",
"./templates",
"./config.cfg",
"./readme.md",
],
"excludes": ["tkinter", "test", "http", "email", "distutils", "ssl", "asyncio", "concurrent"],
"include_files": include_files,
"excludes": ["tkinter", "test", "http", "email", "distutils", "ssl", "asyncio", "concurrent", "pyqt5"],
"optimize": 2,
}

setup(
name="Joystick Diagrams",
version=ver,
version=VER,
description="Automatically create diagrams for your throttles, joysticks and custom HID devices",
long_description=LONG_DESC,
long_description_content_type="text/markdown",
Expand Down
1,456 changes: 981 additions & 475 deletions poetry.lock

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ description = ""
authors = ["Robert Cox"]

[tool.poetry.dependencies]
python = "^3.7"
python = "^3.11"
PyQt5 = "^5.15.6"
ply = "^3.11"

Expand All @@ -17,7 +17,8 @@ black = "^21.10b0"
pre-commit = "^2.15.0"
coveralls = "^3.3.0"
pylint = "^2.11.1"
cx-Freeze = "^6.8.1"
cx-Freeze = "^6.8.0"
ipykernel = "^6.5.0"

[tool.poetry.scripts]
build-exe = "build:setup"
Expand Down
20 changes: 11 additions & 9 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,21 @@

![Joystick Diagrams](https://joystick-diagrams.com/img/main-hero.png)

# ANNOUNCEMENT
This project is set to close at the end of 2022, please see - https://www.reddit.com/r/hotas/comments/xufar0/joystick_diagrams_project_closing/
# Official Website
http://joystick-diagrams.com/

Please use the website for documentation and information

## FORKS
If you are maintaining a fork, get in touch so I can add here to guide others to your repository.
# Bugs
This project is still early days, if you encounter any issues please raise a bug ticket or reach out on Discord.


## Official Website
http://joystick-diagrams.com/ - Please use the website for documentation and information
# Support / Beer fund

## Discord
If you have any issues/questions, pop along to discord - https://discord.gg/JC5QFMB

## Development Notes
TBC
## Beer
I plan to expand this out and continue on this journey. If you like the tool, maybe buy me a beer.
[Donate via Paypal](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=WLLDYGQM5Z39W&source=url)


47 changes: 28 additions & 19 deletions src/joystick_diagrams/adaptors/dcs_world.py
Original file line number Diff line number Diff line change
@@ -1,26 +1,28 @@
"""DCS World Lua Config Parser for use with Joystick Diagrams"""
from ast import Str
import os
import re
from pathlib import Path
import logging
from shutil import ExecError
from ply import lex, yacc
import joystick_diagrams.adaptors.dcs_world_lex # pylint: disable=unused-import
import joystick_diagrams.adaptors.dcs_world_parse # pylint: disable=unused-import
import joystick_diagrams.adaptors.joystick_diagram_interface as jdi

_logger = logging.getLogger(__name__)

EASY_MODES = "_easy"

class DCSWorldParser(jdi.JDinterface):
def __init__(self, path, easy_modes=True):
jdi.JDinterface.__init__(self)
self.path = path
self.remove_easy_modes = easy_modes
self.__easy_mode = "_easy"
self.__easy_mode = EASY_MODES
self.base_directory = self.__validate_base_directory()
self.valid_profiles = self.__validate_profiles()
self.joystick_listing = {}
self.file = None
self.profiles_to_process = None
self.profile_devices = None
self.fq_path = None
Expand Down Expand Up @@ -80,21 +82,23 @@ def convert_button_format(self, button) -> str:
"""Convert DCS Buttons to match expected "BUTTON_X" format"""
split = button.split("_")

if len(split) == 2:
if split[1][0:3] == "BTN":
return split[1].replace("BTN", "BUTTON_")
elif split[1].isalpha():
return "AXIS_{}".format(split[1])
elif split[1][0:6] == "SLIDER":
return "AXIS_SLIDER_{}".format(split[1][6:])
else:
return split[1]
match len(split):

elif len(split) == 4:
return "{button}_{pov}_{dir}".format(button=split[1].replace("BTN", "POV"), pov=split[2][3], dir=split[3])
case 2:
if len(split) == 2:
if split[1][0:3] == "BTN":
return split[1].replace("BTN", "BUTTON_")
elif split[1].isalpha():
return "AXIS_{}".format(split[1])
elif split[1][0:6] == "SLIDER":
return "AXIS_SLIDER_{}".format(split[1][6:])
else:
return split[1]
## Add default case / better handling
case 4:
return "{button}_{pov}_{dir}".format(button=split[1].replace("BTN", "POV"), pov=split[2][3], dir=split[3])

def process_profiles(self, profile_list=None) -> dict:

if isinstance(profile_list, list) and len(profile_list) > 0:
self.profiles_to_process = profile_list
else:
Expand All @@ -108,7 +112,6 @@ def process_profiles(self, profile_list=None) -> dict:
for item in self.profile_devices:
self.joystick_listing.update({item[:-48]: item})
for joystick_device, joystick_file in self.joystick_listing.items():

if os.path.isdir(os.path.join(self.fq_path, joystick_file)):
print("Skipping as Folder")
else:
Expand All @@ -123,13 +126,19 @@ def process_profiles(self, profile_list=None) -> dict:
)
)
else:
dictionary_2 = self.parse_file()
parsed_config = self.parse_config(self.file) ##Better handling - decompose

button_map = self.create_joystick_map(dictionary_2)
button_map = self.create_joystick_map(parsed_config)

self.update_joystick_dictionary(joystick_device, profile, False, button_map)
return self.joystick_dictionary

def parse_config(self, file: Str):
try:
return self.parse_file(file)
except Exception as error:
_logger.error(error)

def create_joystick_map(self, data) -> dict:
write_val = False
button_array = {}
Expand Down Expand Up @@ -159,7 +168,7 @@ def create_joystick_map(self, data) -> dict:
write_val = False
return button_array

def parse_file(self) -> dict:
def parse_file(self, file: Str) -> dict:
# pylint: disable=unused-variable
tokens = (
"LCURLY",
Expand Down Expand Up @@ -262,7 +271,7 @@ def p_error(t): # pylint: disable=invalid-name

# Parse the data
try:
data = parser.parse(self.file)
data = parser.parse(file)
except Exception as error:
_logger.error(error)
raise
Expand Down
4 changes: 2 additions & 2 deletions src/joystick_diagrams/classes/export.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,12 @@ def export_config(self, progress_bar=None) -> list:
print(f"Saving: {joystick}")
self.save_template(joystick, mode, completed_template)
if isinstance(progress_bar, QtWidgets.QProgressBar):
progress_bar.setValue(progress_bar.value() + (progress_increment / progress_increment_modes))
progress_bar.setValue(int(progress_bar.value() + (progress_increment / progress_increment_modes)))
else:
self.error_bucket.append(f"No Template file found for: {joystick}")

if isinstance(progress_bar, QtWidgets.QProgressBar):
progress_bar.setValue(progress_bar.value() + progress_increment)
progress_bar.setValue(int(progress_bar.value() + progress_increment))

if isinstance(progress_bar, QtWidgets.QProgressBar):
progress_bar.setValue(100)
Expand Down
Loading
Loading