Hi everyone.
Has anyone succeeded in being able to issue a key on both a switch press and its release? I have tried a few ways but been unsuccessful. A clue to get me in the correct direction would be appreciated.
Thanks,
Ross
HIDKeys: issue key on both press and release

 Posts: 15
 Joined: Sun Oct 28, 2012 1:41 pm

 Posts: 15
 Joined: Sun Oct 28, 2012 1:41 pm
Re: HIDKeys: issue key on both press and release
Hi, I just downloaded HIDkeys, got it working on a USBasp stick (with fewer keys), and came up with this modification to generate distinct key events when you release the button. So you get 117 when pressed, 1834 when released (in the keyReport array). So when I pressed a certain button, it types an A, and then when I release that button, it types an R.
Code: Select all
// main.c:68
#define NUM_KEYS 17*2
// main.c:266
if(lastKey != key && !keyDidChange){
if (lastKey && lastKey <= NUM_KEYS/2)
lastKey += NUM_KEYS/2;
else
lastKey = key;
keyDidChange = 1;
}
// main.c:200
static const uchar keyReport[NUM_KEYS + 1][2] PROGMEM = {
/* none */ {0, 0}, /* no key pressed */
/* 1 */ {MOD_SHIFT_LEFT, KEY_A},
/* 2 */ {MOD_SHIFT_LEFT, KEY_B},
/* 3 */ {MOD_SHIFT_LEFT, KEY_C},
/* 4 */ {MOD_SHIFT_LEFT, KEY_D},
/* 5 */ {MOD_SHIFT_LEFT, KEY_E},
/* 6 */ {MOD_SHIFT_LEFT, KEY_F},
/* 7 */ {MOD_SHIFT_LEFT, KEY_G},
/* 8 */ {MOD_SHIFT_LEFT, KEY_H},
/* 9 */ {MOD_SHIFT_LEFT, KEY_I},
/* 10 */ {MOD_SHIFT_LEFT, KEY_J},
/* 11 */ {MOD_SHIFT_LEFT, KEY_K},
/* 12 */ {MOD_SHIFT_LEFT, KEY_L},
/* 13 */ {MOD_SHIFT_LEFT, KEY_M},
/* 14 */ {MOD_SHIFT_LEFT, KEY_N},
/* 15 */ {MOD_SHIFT_LEFT, KEY_O},
/* 16 */ {MOD_SHIFT_LEFT, KEY_P},
/* 17 */ {MOD_SHIFT_LEFT, KEY_Q},
/* 18 */ {MOD_SHIFT_LEFT, KEY_R}, // 134 release gives these
/* 19 */ {MOD_SHIFT_LEFT, KEY_S},
/* 20 */ {MOD_SHIFT_LEFT, KEY_T},
/* 21 */ {MOD_SHIFT_LEFT, KEY_U},
/* 22 */ {MOD_SHIFT_LEFT, KEY_V},
/* 23 */ {MOD_SHIFT_LEFT, KEY_W},
/* 24 */ {MOD_SHIFT_LEFT, KEY_X},
/* 25 */ {MOD_SHIFT_LEFT, KEY_Y},
/* 26 */ {MOD_SHIFT_LEFT, KEY_Z},
/* 27 */ {MOD_SHIFT_LEFT, KEY_1},
/* 28 */ {MOD_SHIFT_LEFT, KEY_2},
/* 29 */ {MOD_SHIFT_LEFT, KEY_3},
/* 30 */ {MOD_SHIFT_LEFT, KEY_4},
/* 31 */ {MOD_SHIFT_LEFT, KEY_5},
/* 32 */ {MOD_SHIFT_LEFT, KEY_6},
/* 33 */ {MOD_SHIFT_LEFT, KEY_7},
/* 34 */ {MOD_SHIFT_LEFT, KEY_8},
};

 Posts: 15
 Joined: Sun Oct 28, 2012 1:41 pm
Re: HIDKeys: issue key on both press and release
Many, many thanks.
I will test it after my granddaughters (5 and 3) go home tomorrow. At the moment that are using 120% of our time and energies.
Cheers,
Ross
I will test it after my granddaughters (5 and 3) go home tomorrow. At the moment that are using 120% of our time and energies.
Cheers,
Ross

 Posts: 15
 Joined: Sun Oct 28, 2012 1:41 pm
Re: HIDKeys: issue key on both press and release
Hi Blarrg.
Granddaughters have gone back to their parents and I have just tested your code... successfully. Thanks.
Now I need to understand it and extend it so that multiple keys can be pressed and released without interfering with each other. Another day... another quest.
Cheers,
Ross (who has been answering to "Pops" for the last 48 hours )
Granddaughters have gone back to their parents and I have just tested your code... successfully. Thanks.
Now I need to understand it and extend it so that multiple keys can be pressed and released without interfering with each other. Another day... another quest.
Cheers,
Ross (who has been answering to "Pops" for the last 48 hours )
Re: HIDKeys: issue key on both press and release
This equals 88 bits. In the hypothical worst case all data is FF, which is practictally impossible. In that case 14 bits are "stuffed", resulting in a total maximum critical packet lengths of 102 bits or 84 without CRC.
_______________________
Unlike scam 820421 exam and itil wikipedia training program, our best Stanford University and IBM online training courses provide you quick success in first try of LPI
_______________________
Unlike scam 820421 exam and itil wikipedia training program, our best Stanford University and IBM online training courses provide you quick success in first try of LPI