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

Legion DPI fix #223

Merged
merged 22 commits into from
May 1, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
e6bea33
fixed wrong placement of squares when using different DPI scaling value
BazookaMusic Apr 1, 2018
10dce2c
error checking for dpi settings retrieval
BazookaMusic Apr 1, 2018
387b0e0
Added stricter foreground enforcement
BazookaMusic Apr 1, 2018
1359888
removed in stricter foreground enforcement
BazookaMusic Apr 1, 2018
0529b08
fixed error message
BazookaMusic Apr 1, 2018
5479779
simpler way to calculate scaling
BazookaMusic Apr 1, 2018
53cd974
Fixed typo
BazookaMusic Apr 2, 2018
4c01444
also scale coordinates of the monitor
BazookaMusic Apr 3, 2018
953983a
also scale coordinates of the monitor
BazookaMusic Apr 3, 2018
13345f7
Merge branch 'Legion_fix' of https://github.com/gerrish/caster into L…
BazookaMusic Apr 3, 2018
fbcd112
changed the way monitor rectangles are retrieved to eliminate the nee…
BazookaMusic Apr 3, 2018
a697272
changed the way monitor rectangles are retrieved to eliminate the nee…
BazookaMusic Apr 3, 2018
9d9f1ec
removed useless code
BazookaMusic Apr 3, 2018
4d06b30
fixed height calculation
BazookaMusic Apr 4, 2018
9698b37
fixed conflicts
BazookaMusic Apr 4, 2018
7eb1b36
fixed conflicts
BazookaMusic Apr 4, 2018
a7cda84
voice recognition added garbage to comment,fixed
BazookaMusic Apr 4, 2018
9568e48
maximum square width is now relative, depends on resolution
BazookaMusic Apr 5, 2018
79cc762
move the vertical partitions to settings
BazookaMusic Apr 7, 2018
5522202
reverted to dragonfly dependent code, works with danesprite dragonfly
BazookaMusic Apr 11, 2018
aa5295d
changed documentation to include DaneSprite fork
BazookaMusic May 1, 2018
0ce0449
Added Dane sprite fork installation in the documentation. Also, updat…
BazookaMusic May 1, 2018
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
25 changes: 17 additions & 8 deletions caster/asynch/mouse/legion.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@
import sys
import threading
from ctypes import *

from dragonfly import monitors

#from dragonfly import monitors

try: # Style C -- may be imported into Caster, or externally
BASE_PATH = os.path.realpath(__file__).split("\\caster")[0].replace("\\", "/")
if BASE_PATH not in sys.path:
Expand All @@ -16,14 +17,15 @@
from caster.lib import gdi, settings, utilities

try:
from PIL import ImageGrab, ImageFilter
from PIL import ImageGrab, ImageFilter, Image
except ImportError:
utilities.availability_message("Legion", "PIL")
'''
Roughly determines the size of each rectangle (give or take a few pixels).
Anything less than 60 starts to feel cluttered. 30 is the bare minimum before three digit numbers no longer fit.
The screen will be divided into vertical columns of equal width.
The width of each Legion box cannot exceed the width of the column.
This way relative partitioning is achieved since larger resolutions
will be partitioned into columns of larger width.
'''
MAX_WIDTH = 60


class Rectangle:
Expand All @@ -38,7 +40,8 @@ def __init__(self, grid_size=None, tirg=None, auto_quit=False):
self.setup_xmlrpc_server()
TkTransparent.__init__(self, settings.LEGION_TITLE, grid_size)
self.attributes("-alpha", 0.7)

self.max_rectangle_width = int(
grid_size.width/settings.SETTINGS["miscellaneous"]["legion_vertical_columns"])
self.tirg_positions = {}
if tirg is not None:
self.process_rectangles(tirg)
Expand Down Expand Up @@ -92,7 +95,7 @@ def split_rectangles(self):
# Split larger rectangles into smaller ones to allow greater precision.
rectangles_to_split = []
for rect in self.tirg_rectangles: # Collect all the rectangles that are too large.
if rect.x2 - rect.x1 >= MAX_WIDTH:
if rect.x2 - rect.x1 >= self.max_rectangle_width:
rectangles_to_split.append(rect)
self.tirg_rectangles = [
x for x in self.tirg_rectangles if x not in rectangles_to_split
Expand All @@ -103,7 +106,7 @@ def perform_split(self, rectangles_to_split):
# Helper class for splitting larger rectangles to smaller ones.
for rect in rectangles_to_split:
width = rect.x2 - rect.x1
pieces = width/MAX_WIDTH
pieces = width/self.max_rectangle_width
new_width = width/pieces
for i in range(0, pieces):
r = Rectangle()
Expand Down Expand Up @@ -205,6 +208,11 @@ def main(argv):
monitor = 1
dimensions = None
auto_quit = False

error_code = windll.shcore.SetProcessDpiAwareness(2) #enable 1-1 pixel mapping
if error_code == -2147024891:
raise OSError("Failed to set app awareness")

try:
opts, args = getopt.getopt(argv, "ht:a:d:m:",
["tirg=", "dimensions=", "autoquit="])
Expand All @@ -229,6 +237,7 @@ def main(argv):
if dimensions is None:
r = monitors[int(monitor) - 1].rectangle
dimensions = Dimensions(int(r.dx), int(r.dy), int(r.x), int(r.y))

lg = LegionGrid(grid_size=dimensions, tirg=tirg, auto_quit=auto_quit)
except Exception:
utilities.simple_log(True)
Expand Down
20 changes: 14 additions & 6 deletions caster/bin/inno/dragonfly_upgrade.bat
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,26 @@ cd temp_dragonfly



git clone https://github.com/t4ngo/dragonfly.git
git clone --recursive https://github.com/Danesprite/dragonfly.git
cd dragonfly
python setup.py install

echo ------------------------------------------
echo Dragonfly Upgrade Complete
echo ------------------------------------------

git submodule foreach python setup.py install


echo ------------------------------------------
echo Dragonfly Submodules installed
echo ------------------------------------------

python -m pip install .[sphinx]

cd dragonfly\dragonfly
xcopy /Y/E/Q * C:\Python27\Lib\site-packages\dragonfly

cd C:\
rmdir /S/Q temp_dragonfly

echo ------------------------------------------
echo Dragonfly Upgrade Complete
echo ------------------------------------------

pause
4 changes: 3 additions & 1 deletion caster/doc/Installation.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
# Installation

- [Dragonfly](https://github.com/Danesprite/dragonfly)
Follow the instructions in the readme to install danesprite's dragonfly fork. Alternatively, install caster using the YouTube video below and run `(Caster_installation_path)/bin/dragonfly_upgrade.bat` before restarting your voice recognition engine.

## YouTube Videos

- [Dragonfly](https://www.youtube.com/watch?v=iNAsV4pcnEA)
- [Caster](https://www.youtube.com/watch?v=wjSwB4cpMDI)

## Addendums
Expand Down
1 change: 1 addition & 0 deletions caster/lib/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ def _find_natspeak():
"integer_remap_crash_fix": False,
"print_rdescripts": False,
"history_playback_delay_secs": 1.0,
"legion_vertical_columns": 30,
},
"pronunciations": {
"c++": "C plus plus",
Expand Down