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
Changes from 5 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
16 changes: 15 additions & 1 deletion caster/asynch/mouse/legion.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,19 @@ 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")
dpi_map = {96: 1.0, 120: 1.25, 144: 1.5, 192: 2.0}

LOGPIXELSX = 88
dc = windll.user32.GetDC(0)
horizontal_dpi = windll.gdi32.GetDeviceCaps(
dc, LOGPIXELSX) # Horizontal DPI determines the DPI scaling value
windll.user32.ReleaseDC(0, dc)
dpi_scaling = dpi_map[horizontal_dpi]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was just thinking about ways I could test this and that made me wonder if there is any software that could fake it on my current hardware. In order to keep the simulated resolution high enough to be usable it wouldn't necessarily scale at the same rates horizontally and vertically. It could also have weird DPI values.

What if a piece of hardware doesn't have square pixels? Also, wouldn't it be easier/faster to just divide the given DPI value by 96.0?


try:
opts, args = getopt.getopt(argv, "ht:a:d:m:",
["tirg=", "dimensions=", "autoquit="])
Expand All @@ -228,7 +241,8 @@ 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))
dimensions = Dimensions(
int(r.dx*dpi_scaling), int(r.dy*dpi_scaling), 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