oblitum / Interception

The Interception API aims to build a portable programming interface that allows one to intercept and control a range of input devices.
http://oblita.com/interception
1.35k stars 269 forks source link

Ctrl+Alt+Del (numpad Del) not intercepted #16

Open r1me opened 8 years ago

r1me commented 8 years ago

In cadstop example, a combination of Ctrl+Alt+Delete is intercepted, but if Delete key from numpad is used - it still goes through the filter (not intercepted).

Scan codes and state for Delete and Del (numpad) keys:

Delete

Constant definition of Delete key in cadstop code looks like this:

InterceptionKeyStroke del_down = {scancode::del , INTERCEPTION_KEY_DOWN | INTERCEPTION_KEY_E0, 0};
InterceptionKeyStroke del_up = {scancode::del , INTERCEPTION_KEY_UP | INTERCEPTION_KEY_E0 , 0};

And then key that was pressed by user is compared, by checking keystroke code and state to be exactly the same as in constant:

return first.code == second.code && first.state == second.state;

in this case only Delete (not numpad version) key, will be considered as del_down or del_up.

Possible solutions for this issue

I believe second solution should be the right one. Key state enumeration should begin from 1, not 0. Zero should be used as "no/invalid/unknown/no action" state, so bitmask operations can be performed on valid key states.

For mouse buttons state enumeration begins from 1 which is technically more correct.

Keep up the good work.

oblitum commented 8 years ago

Hi, thanks for the further clarification!

I think first option is the correct, besides being easier to understand.

The key setup is the way it's is on purpose, also internally, Windows works this way and the reasons are: