Skip to content

Commit

Permalink
fix #35
Browse files Browse the repository at this point in the history
  • Loading branch information
mgth committed Dec 11, 2017
1 parent 1f44042 commit 104bcd2
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 14 deletions.
2 changes: 1 addition & 1 deletion LittleBigMouse/Daemon/Geo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public static Line fromSegment(Segment s)
private readonly double _origine;
public double OrigineY => double.IsPositiveInfinity(Coef) ? 0 : _origine;

public double OrigineX => double.IsPositiveInfinity(Coef) ? _origine : (0 - _origine)/Coef;
public double OrigineX => (double.IsPositiveInfinity(Coef) || Coef==0) ? _origine : (0 - _origine)/Coef;

public Point Origine => new Point(OrigineX, OrigineY);

Expand Down
27 changes: 16 additions & 11 deletions LittleBigMouse/Daemon/MouseEngine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -216,24 +216,29 @@ private void OnMouseMoveExt(object sender, MouseEventExtArgs e)
Side side = seg.IntersectSide(oldScreen.InMm.Bounds);


foreach (Screen screen in Config.AllScreens.Where(s => !Equals(s, oldScreen)))
if (Config.AllowCornerCrossing)
{
if (Config.AllowCornerCrossing)
foreach (var screen in Config.AllBut(oldScreen))
{
foreach ( Point p in seg.Line.Intersect(screen.InMm.Bounds) )
foreach (Point p in seg.Line.Intersect(screen.InMm.Bounds))
{
Segment travel = new Segment(oldpInMm, p);
var travel = new Segment(oldpInMm, p);
if (!travel.Rect.Contains(pInMm)) continue;
if (travel.Size > dist) continue;

dist = travel.Size;
pOut = screen.InPixel.GetPoint(screen.InMm, p);// (new PhysicalPoint(Config, screen, p.X, p.Y)).Pixel.Inside;
pOut = screen.InPixel.GetPoint(screen.InMm,
p); // (new PhysicalPoint(Config, screen, p.X, p.Y)).Pixel.Inside;
pOut = screen.InPixel.Inside(pOut);
screenOut = screen;
}
}
else
}
else
{
foreach (var screen in Config.AllBut(oldScreen))
{
Vector offset = new Vector(0,0);
Vector offset = new Vector(0, 0);

switch (side)
{
Expand Down Expand Up @@ -264,17 +269,17 @@ private void OnMouseMoveExt(object sender, MouseEventExtArgs e)
if (offset.Length > 0 && offset.Length < dist)
{
Point shiftedPoint = pInMm + offset;

if (Equals(Config.ScreenFromMmPosition(shiftedPoint), screen))
{
dist = offset.Length;
pOut = screen.InPixel.GetPoint(screen.InMm,shiftedPoint);
pOut = screen.InPixel.GetPoint(screen.InMm, shiftedPoint);
pOut = screen.InPixel.Inside(pOut);
screenOut = screen;
screenOut = screen;
}
else
{

}
}
}
Expand Down
4 changes: 2 additions & 2 deletions LittleBigMouse/ScreenConfig/ScreenSize.cs
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,8 @@ public double OutsideY

public Point Inside(Point p)
{
var x = p.X < X ? X : p.X > Bounds.Right ? Bounds.Right : p.X;
var y = p.Y < Y ? Y : p.Y > Bounds.Bottom ? Bounds.Bottom : p.Y;
var x = p.X < X ? X : (p.X > Bounds.Right - 1) ? (Bounds.Right - 1) : p.X;
var y = p.Y < Y ? Y : (p.Y > Bounds.Bottom - 1) ? (Bounds.Bottom - 1) : p.Y;

return new Point(x,y);
}
Expand Down

0 comments on commit 104bcd2

Please sign in to comment.