I've been attempting to re-implement SmartPad support into CEmu for a presentation I'll be doing soon. However, I do not understand the format that keypad.cpp uses to map computer keys to calculator keys.

I'm particularly having trouble with the defined macros. I don't know what their names stand for and figuring out the correct arguments for each has been tricky. I'm not sure any of the existing macros will work since I need to check if multiple modifiers are pressed. For example: ctrl+win+alt+shift+F11

After a lot of trial and error I've commented my findings
//This applies the final code to key conversion. It's called by all the following macros
#define HK(code, nativeCode, nativeMask, modifier, mask) { Qt::Key_##code, nativeCode, nativeMask, Qt::modifier##Modifier, Qt::mask##Modifier, QStringLiteral(#code) }

//The main key seems to work if there are 0 or more modifiers.
#define NRM(code) HK(code, 0, 0, No, No)

//only used twice and only in Wabbit controls, don't understand what 'nativeCode' or 'nativeMask' are.
#define NAT(code, nativeCode, nativeMask) HK(code, nativeCode, nativeMask, No, No)

/* code: The main key that was pressed
 * modifier: When added but mask is set to 'No', it seems to prevent the main key from working at all.
 *           When added and mask is set to the same modifier, the main key now only works if the modifier is held.
 * mask: the MOD function will ignore the main key if the 'mask' modifier is pressed.
#define MOD(code, modifier, mask) HK(code, 0, 0, modifier, mask)

My questions are:
What do the macro names mean, and how do I apply multiple modifiers?
You'll want a bunch of these combined with | in both Modifier positions, which is not supported by any of the current macros. NoRMal ignores modifiers, NATive supports distinguishing what would otherwise be identical keys like left and right shift, and MODifiers supports checking a single modifier for being pressed (Shift, Shift) or not being pressed (No, Shift). If you are still confused, consider that [5] may be typed with or without shift depending on the layout, but [a] vs [A] can only be distingushed by checking shift.
Thank you Jacobly!

I made several of my own macros and made a pull request.
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 1
» All times are UTC - 5 Hours
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum