[squeak-dev] for the operation MAP := B bitOr:( M bitShift:3) given
MAP how do I derive B and M?
gettimothy
gettimothy at zoho.com
Wed Feb 12 02:05:30 UTC 2014
To reverse a MorphicEvent into an primitive event I need to unmap the buttons and modifiers.
In a primitive event, the fifth element (buttons) can be 1,2 or 4 and the sixth element (modifiers) 1,2,4 or 8.
HandMorph >> generateMouseEvent combines them into one field as such:
buttons := evtBuf fifth.
modifiers := evtBuf sixth.
buttons := buttons bitOr: (modifiers bitShift: 3).
I need to reverse that "buttons bitOr: (modifiers bitShift: 3)" back into the original values to recreate the primitive event.
Here are the possible values of B(uttons) and M(odifiers) under that operation:
B M MAP
1 bitOr:(1 bitShift:3 ) 9
1 bitOr:(2 bitShift:3 ) 17
1 bitOr:(4 bitShift:3 ) 33
1 bitOr:(8 bitShift:3 ) 65
2 bitOr:(1 bitShift:3 ) 10
2 bitOr:(2 bitShift:3 ) 18
2 bitOr:(4 bitShift:3 ) 34
2 bitOr:(8 bitShift:3 ) 66
4 bitOr:(1 bitShift:3 ) 12
4 bitOr:(2 bitShift:3 ) 20
4 bitOr:(4 bitShift:3 ) 36
4 bitOr:(8 bitShift:3 ) 68
So, given a MAP on the right, I need to derive a B and a M.
I can figure something out, but it will probably be ugly. Hence, this email to the list.
Any bit-fiddlers on the board who know an elegant method?
thx.
tty.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20140211/181ca1b7/attachment.htm
More information about the Squeak-dev
mailing list
|