1 #define _WIN32_WINNT 0x0601
3 #include <msp/graphics/window_private.h>
4 #include "touchscreen.h"
11 void Touchscreen::input_event(const Graphics::Window::Event &event)
13 if(event.msg==WM_TOUCHMOVE)
15 HTOUCHINPUT handle = reinterpret_cast<HTOUCHINPUT>(event.lparam);
16 unsigned n_points = LOWORD(event.wparam);
17 /* If I ever invent a legitimate use case for more touch points than an
18 average human has fingers, I'll come up with something else here. */
19 TOUCHINPUT touch_buffer[10];
20 if(!GetTouchInputInfo(handle, 10, touch_buffer, sizeof(TOUCHINPUT)))
23 for(unsigned i=0; i<n_points; ++i)
25 const TOUCHINPUT &point = touch_buffer[i];
27 POINT screen_pt = { point.x/100, point.y/100 };
28 POINT client_pt = screen_pt;
29 ScreenToClient(window.get_private().window, &client_pt);
30 float x = (point.x/100.0f-screen_pt.x+client_pt.x)*2.0f/window.get_width()-1.0f;
31 float y = 1.0f-(point.y/100.0f-screen_pt.y+client_pt.y)*2.0f/window.get_height();
33 touch_move(point.dwID, x, y);
34 if(point.dwFlags&TOUCHEVENTF_DOWN)
35 touch_down(point.dwID);
36 else if(point.dwFlags&TOUCHEVENTF_UP)
40 CloseTouchInputHandle(handle);