History

add normalized mouse pos

nshaheed committed 3 years ago

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

Unified · Split

src/core/util_hid.cpp+20−2
@@ -6041,6 +6041,10 @@ void Mouse_init() · 6040 unmodified lines
60416041 EM_poplog();
60426042 }
60436043
6044+//-----------------------------------------------------------------------------
6045+// name: Mouse_poll()
6046+// desc: Populate mouse polling HID message for windows
6047+//-----------------------------------------------------------------------------
60446048 void Mouse_poll()
60456049 {
60466050 if( !mice )
@@ -6076,14 +6080,28 @@ void Mouse_poll() · 29 unmodified lines
60766080 msg.idata[0] = state.lX;
60776081 msg.idata[1] = state.lY;
60786082
6083+ // 1.5.0.0 (nshaheed) add support for absolute and normalized mouse pos
6084+ // Acquire cursor position (in pixels)
60796085 POINT point;
60806086 if (GetCursorPos(&point)) {
60816087 msg.idata[2] = point.x;
60826088 msg.idata[3] = point.y;
6083− cout << point.x << "," << point.y << "\n";
60846089 }
60856090
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);
60876105 }
60886106
60896107 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