Should I begin compiling notes about functions and add them as doxygen comments in the Prizm SDK header, allowing function documentation to be available?
Yes
 88%  [ 8 ]
No
 11%  [ 1 ]
Total Votes : 9

I actually use this setup:


Code:
static const unsigned short* keyboard_register = (unsigned short*)0xA44B0000;

int main(void) {

...

unsigned short*lastkey = malloc(sizeof(unsigned short)*8);
   unsigned short*holdkey = malloc(sizeof(unsigned short)*8);
   int llastkey = KEY_PRGM_NONE;
   int lholdkey = KEY_PRGM_NONE;
   void keyupdate(void) {
      memcpy(holdkey, lastkey, sizeof(unsigned short)*8);
      lholdkey = llastkey;
      memcpy(lastkey, keyboard_register, sizeof(unsigned short)*8);
      llastkey = PRGM_GetKey();
   }
   int keydownlast(int basic_keycode) {
      int row, col, word, bit;
      row = basic_keycode%10;
      col = basic_keycode/10-1;
      word = row>>1;
      bit = col + 8*(row&1);
      return (0 != (lastkey[word] & 1<<bit));
   }
   int keydownhold(int basic_keycode) {
      int row, col, word, bit;
      row = basic_keycode%10;
      col = basic_keycode/10-1;
      word = row>>1;
      bit = col + 8*(row&1);
      return (0 != (holdkey[word] & 1<<bit));
   }
   void keymenu(void) {
      int key = KEY_PRGM_MENU;
      GetKey(&key);
      Bdisp_EnableColor(1);
      DrawFrame(COLOR_BLACK);
   }
 ...
 _Bool running = true;
 while(running) {
    keyupdate();
    ...
   
   // check if shift key is held:
   if(keydownlast(KEY_PRGM_SHIFT)) { ...}
   /// check if shift key was just pressed:
   if(keydownlast(KEY_PRGM_SHIFT) && !keydownhold(KEY_PRGM_HOLD)) { ...}
   // check if shift key was just released:
   if(!keydownlast(KEY_PRGM_SHIFT) && keydownhold(KEY_PRGM_HOLD)) { ...}

    ...
 }


As you can see, it's a lot more code, and more code to see if values are met. But it's by far the fastest routine (doesn't even go through the OS at all), allows for multiple keypresses to be checked at a time, allows for detection of psuedo-ONKEYUP/ONKEYDOWN events, etc.

EDIT: based on PierottLL's original routine, I added the pseudo-event checking and some other things.
I see that PRGM_GetKey returns a row/col in that array. Does it use the same values as GetKeyWait_OS?
AHelper wrote:
I see that PRGM_GetKey returns a row/col in that array. Does it use the same values as GetKeyWait_OS?
It does not. Actually, when I went to write Tetrizm, I was a bit confused where I had found those row/column equates in the first place; I'll take a look at the FX-9860 documentation for C, because I believe that's where it was.
PRGM_GetKey
Code:
/** Returns the encoded row and col of a pressed key
 *
 * This is nonblocking
 * This does not handle {MENU}
 *
 * This will return an encoded row/col as such:
 *   (col)(row-1)
 * F1 is (7,10) (col,row).  PRGM_GetKey returns 79
 * AC/ON is (1,1). PRGM_GetKey returns 10
 *
 * @returns col in the tens place, row-1 in the ones place of a decimal number.
 */


I have done testing on this and confirmed on all keys.
Well, I have been slowly testing functions and adding doxygen comments and making wiki pages. If you know anything about a function, even if it isn't complete or correct, add it and include the {{Preliminary}} template so it can be documented further. Very Happy
  
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 2 of 2
» 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

 

Advertisement