On 23 September 2015 at 17:44, Programmingkid <programmingk...@gmail.com> wrote: > > On Sep 23, 2015, at 8:34 PM, Peter Maydell wrote:
>>> + */ >>> +- (void) raiseAllKeys >>> +{ >>> + int index; >>> + const int max_index = 220; /* This is the highest value key */ >> >> No, you need to use ARRAY_SIZE. > > I did use it, it didn't work. The command key would still stay down. > This is because the command key has a value of 220. The keymap > array size is only 126. I know it is confusing. I was thinking of using > cocoa_keycode_to_qemu() to translate the index to the qemu (pc xt) > values, but that would be expensive in terms of cpu usage. We don't care about the keymap array size. ARRAY_SIZE(modifiers_state) is 256. If you're iterating through an array, as we are here, then the correct upper bound is always ARRAY_SIZE(array). >> >>> + >>> + for (index = 0; index <= max_index; index++) { >>> + if (modifiers_state[index]) { >>> + modifiers_state[index] = 0; >>> + qemu_input_event_send_key_number(dcl->con, index, false); >>> + } >>> + } -- PMM