[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
AW: [Gnash-commit] gnash ChangeLog server/asobj/Key.cpp server/aso...
From: |
Benjamin Wolsey |
Subject: |
AW: [Gnash-commit] gnash ChangeLog server/asobj/Key.cpp server/aso... |
Date: |
Thu, 11 Oct 2007 06:41:03 +0000 (GMT) |
> > + int byte_index = keycode >> 3;
> > + int bit_index = keycode - (byte_index << 3);
> > + uint8_t mask = ~(1 << bit_index);
> > + if ((m_unreleased_keys[byte_index] & mask) !=
> > m_unreleased_keys[byte_index] ) return true; ---------> [1]
> >
> > return false;
> > }
> Is this an attempt for optimization or fixing anything? Any
> assumption for with [1]?
> eg. If there are 2 bits set within the same byte, [1] would always return
> true.
> --zou
It works:
For example, keys A (position 2 in byte) and C (position 4) are pressed.
so: m_unreleased_keys[byte_index] = 10
if bit_index = 2, mask = ~(1 << 2) = 253
10 & 254 = 10 <-- false
10 & 253 = 8 <-- true.
10 & 252 = 10
10 & 201 = 2 <-- true (bit_index 8)
10 & 200 = 10
etc.
But you're right that it's a mess. The complement rubbish can go and a simple
if ((m_unreleased_keys[byte_index] & (1 << bit_index)) != 0 ) will do.
--bwy
__________________________________
Alles was der Gesundheit und Entspannung dient. BE A BETTER MEDIZINMANN!
www.yahoo.de/clever
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- AW: [Gnash-commit] gnash ChangeLog server/asobj/Key.cpp server/aso...,
Benjamin Wolsey <=