File tree 1 file changed +13
-0
lines changed
Samples/Toolkit/Common/MouseInput 1 file changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -101,8 +101,21 @@ protected override void Draw(GameTime gameTime)
101
101
sb . AppendFormat ( "Right button : {0}\n " , mouseState . Right ) ;
102
102
sb . AppendFormat ( "XButton1 : {0}\n " , mouseState . XButton1 ) ;
103
103
sb . AppendFormat ( "XButton2 : {0}\n " , mouseState . XButton2 ) ;
104
+
105
+ // the mouse coordinates are in range [0; 1] relative to window.
106
+ // any coordinates outside of the game window or control are clamped to this range
107
+ // on Windows 8 platform it may not get to the values exactly 0 or 1 because of "active corners" feature of the OS.
104
108
sb . AppendFormat ( "X : {0}\n " , mouseState . X ) ;
105
109
sb . AppendFormat ( "Y : {0}\n " , mouseState . Y ) ;
110
+
111
+ // compute mouse position in screen coordinates
112
+ var backbuffer = GraphicsDevice . BackBuffer ;
113
+ var screenWidth = backbuffer . Width ;
114
+ var screenHeight = backbuffer . Height ;
115
+
116
+ sb . AppendFormat ( "Screen X : {0}\n " , mouseState . X * screenWidth ) ;
117
+ sb . AppendFormat ( "Screen Y : {0}\n " , mouseState . Y * screenHeight ) ;
118
+
106
119
sb . AppendFormat ( "Wheel : {0}\n " , mouseState . WheelDelta ) ;
107
120
108
121
// Render the text
You can’t perform that action at this time.
0 commit comments