winapi - Convert events from a USB human interface device using C++ -
i have usb hid touchpad collects input. default, when press on touchpad generates carriage return (enter) , when try use mouse enters dragging state.
what want convert carriage return mouse click event , dragging state cursor move without initial clicking part.
i found raw input alternative. however, don't know how convert mouse click , cursor move.
here code responsible mouse 'reading':
lresult callback mouseproc (int ncode, wparam wparam, lparam lparam) { mousehookstruct * pmousestruct = (mousehookstruct *)lparam; if (pmousestruct != null) { if(wparam == wm_lbuttondown) { cout<<"clicked"<<endl; } printf("mouse position x = %d mouse position y = %d\n", pmousestruct->pt.x,pmousestruct->pt.y); stringstream sx, sy; sx << (int) pmousestruct->pt.x << endl; sy << (int) pmousestruct->pt.y << endl; } return callnexthookex(hmousehook, ncode, wparam, lparam); }
then keyboard part:
lresult callback lowlevelkeyboardproc(int ncode, wparam wparam, lparam lparam) { if (ncode < 0) return callnexthookex(null, ncode, wparam, lparam); tagkbdllhookstruct *str = (tagkbdllhookstruct *)lparam; cout<<str->vkcode<<endl; return callnexthookex(null, ncode, wparam, lparam); }
then logging part:
dword winapi mylogger(lpvoid lpparm) { hinstance hinstance = getmodulehandle(null); hmousehook = setwindowshookex( wh_mouse_ll, mouseproc, hinstance, null ); hkeyhook = setwindowshookex( wh_keyboard_ll, lowlevelkeyboardproc, hinstance, null ); msg message; while (getmessage(&message,null,0,0)) { translatemessage( &message ); dispatchmessage( &message ); } unhookwindowshookex(hmousehook); return 0; }
note: don't know if relevant, want use hid play in chromium instance on windows system.
when register hook wh_mouse_ll, possible values of wparam are: wm_lbuttondown, wm_lbuttonup, wm_mousemove, wm_mousewheel, wm_mousehwheel, wm_rbuttondown, or wm_rbuttonup.
i'm expecting once wm_lbuttondown issued, a corresponding wm_lbuttonup has issued prevent cursor entering dragging state.
i don't have device test try call below prevent entering dragging state.
callnexthookex(hmousehook, ncode, wm_lbuttonup, lparam);
or use mouse_event
mouseeventf_leftup inject release of left button.
i don't think raw input alternative idea. see measure of last resort.
Comments
Post a Comment