Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Explain keypad number conversions in jni_ConvertToJavaLocation(...) #445

Open
spxl opened this issue Jun 27, 2023 · 0 comments
Open

Explain keypad number conversions in jni_ConvertToJavaLocation(...) #445

spxl opened this issue Jun 27, 2023 · 0 comments

Comments

@spxl
Copy link

spxl commented Jun 27, 2023

// FIXME Should this fall though? comments are highly suspicious. It seems that there should not be a fall-through in these places.

Please describe the logic of the subtractions made for numpad keys 1 to 9

eg
*nativeKeyCode -= ((VC_KP_1 - VC_1) - (VC_KP_4 - VC_4) ); // 0x4D - 0x46

Why are these not all just like the code for keypad 0?

case VC_KP_0:
*nativeKeyCode = VC_0;
*javaKeyLocation = com_github_kwhat_jnativehook_keyboard_NativeKeyEvent_LOCATION_NUMPAD;
break;
case VC_KP_1:
case VC_KP_2:
case VC_KP_3:
*nativeKeyCode -= ((VC_KP_1 - VC_1) - (VC_KP_4 - VC_4) ); // 0x4D - 0x46
// FIXME Should this fall though?
/* fall-thru */
case VC_KP_4:
case VC_KP_5:
case VC_KP_6:
*nativeKeyCode -= ((VC_KP_4 - VC_4) - (VC_KP_7 - VC_7) ); // 0x46 - 0x3F
// FIXME Should this fall though?
/* fall-thru */
case VC_KP_7:
case VC_KP_8:
case VC_KP_9:
*nativeKeyCode -= (VC_KP_7 - VC_7); // 0x3F
*javaKeyLocation = com_github_kwhat_jnativehook_keyboard_NativeKeyEvent_LOCATION_NUMPAD;
break;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant