History

add normalized mouse pos

nshaheed committed 3 years ago

Commit dfa77d21 parent b24ff0e1 file · +20 −2Browse files

Showing the changes to src/core/util_hid.cpp (1 of 1 file). Show all

Unified · Split

src/core/util_hid.cpp+20−2
@@ -6041,6 +6041,10 @@ void Mouse_init() · 6040 unmodified lines
6041 EM_poplog();6041 EM_poplog();
6042}6042}
6043 6043
6044//-----------------------------------------------------------------------------
6045// name: Mouse_poll()
6046// desc: Populate mouse polling HID message for windows
6047//-----------------------------------------------------------------------------
6044void Mouse_poll()6048void Mouse_poll()
6045{6049{
6046 if( !mice )6050 if( !mice )
@@ -6076,14 +6080,28 @@ void Mouse_poll() · 29 unmodified lines
6076 msg.idata[0] = state.lX;6080 msg.idata[0] = state.lX;
6077 msg.idata[1] = state.lY;6081 msg.idata[1] = state.lY;
6078 6082
6083 // 1.5.0.0 (nshaheed) add support for absolute and normalized mouse pos
6084 // Acquire cursor position (in pixels)
6079 POINT point;6085 POINT point;
6080 if (GetCursorPos(&point)) {6086 if (GetCursorPos(&point)) {
6081 msg.idata[2] = point.x;6087 msg.idata[2] = point.x;
6082 msg.idata[3] = point.y;6088 msg.idata[3] = point.y;
6083 cout << point.x << "," << point.y << "\n";
6084 }6089 }
6085 6090
6086 HidInManager::push_message( msg );6091 // Get primary monitor handle
6092 const POINT ptZero = { 0, 0 };
6093 HMONITOR hMonitor = MonitorFromPoint(ptZero, MONITOR_DEFAULTTOPRIMARY);
6094
6095 MONITORINFO info;
6096 info.cbSize = sizeof(info);
6097
6098 // Populate scaledCursorX and scaledCursorY
6099 if (GetMonitorInfo(hMonitor, (LPMONITORINFO)&info)) {
6100 msg.fdata[0] = ((t_CKFLOAT) (point.x - info.rcMonitor.left)) / (info.rcMonitor.right - 1);
6101 msg.fdata[1] = ((t_CKFLOAT) (point.y - info.rcMonitor.top)) / (info.rcMonitor.bottom - 1);
6102 }
6103
6104 HidInManager::push_message(msg);
6087 }6105 }
6088 6106
6089 if( state.lZ != 0 )6107 if( state.lZ != 0 )

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t