Add support for the windows DPI scaling.
This commit is contained in:
@@ -40,6 +40,16 @@ namespace OpenRA.Platforms.Default
|
||||
| ((raw & (int)SDL.SDL_Keymod.KMOD_SHIFT) != 0 ? Modifiers.Shift : 0);
|
||||
}
|
||||
|
||||
int2 EventPosition(Sdl2GraphicsDevice device, int x, int y)
|
||||
{
|
||||
// On Windows and Linux (X11) events are given in surface coordinates
|
||||
// These must be scaled to our effective window coordinates
|
||||
if (Platform.CurrentPlatform != PlatformType.OSX && device.WindowSize != device.SurfaceSize)
|
||||
return new int2((int)(x / device.WindowScale), (int)(y / device.WindowScale));
|
||||
|
||||
return new int2(x, y);
|
||||
}
|
||||
|
||||
public void PumpInput(Sdl2GraphicsDevice device, IInputHandler inputHandler)
|
||||
{
|
||||
var mods = MakeModifiers((int)SDL.SDL_GetModState());
|
||||
@@ -88,8 +98,7 @@ namespace OpenRA.Platforms.Default
|
||||
var button = MakeButton(e.button.button);
|
||||
lastButtonBits |= button;
|
||||
|
||||
var pos = new int2(e.button.x, e.button.y);
|
||||
|
||||
var pos = EventPosition(device, e.button.x, e.button.y);
|
||||
inputHandler.OnMouseInput(new MouseInput(
|
||||
MouseInputEvent.Down, button, scrollDelta, pos, mods,
|
||||
MultiTapDetection.DetectFromMouse(e.button.button, pos)));
|
||||
@@ -108,7 +117,7 @@ namespace OpenRA.Platforms.Default
|
||||
var button = MakeButton(e.button.button);
|
||||
lastButtonBits &= ~button;
|
||||
|
||||
var pos = new int2(e.button.x, e.button.y);
|
||||
var pos = EventPosition(device, e.button.x, e.button.y);
|
||||
inputHandler.OnMouseInput(new MouseInput(
|
||||
MouseInputEvent.Up, button, scrollDelta, pos, mods,
|
||||
MultiTapDetection.InfoFromMouse(e.button.button)));
|
||||
@@ -118,9 +127,10 @@ namespace OpenRA.Platforms.Default
|
||||
|
||||
case SDL.SDL_EventType.SDL_MOUSEMOTION:
|
||||
{
|
||||
var pos = EventPosition(device, e.motion.x, e.motion.y);
|
||||
pendingMotion = new MouseInput(
|
||||
MouseInputEvent.Move, lastButtonBits, scrollDelta,
|
||||
new int2(e.motion.x, e.motion.y), mods, 0);
|
||||
pos, mods, 0);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user