View Single Post
  #29   Spotlight this post!  
Unread 17-02-2004, 00:06
deltacoder1020's Avatar
deltacoder1020 deltacoder1020 is offline
Computer Guy
AKA: Dav
#1020 (The Indiana Prank Monkeys)
Team Role: Programmer
 
Join Date: Jan 2004
Location: Muncie, Indiana
Posts: 340
deltacoder1020 has a spectacular aura aboutdeltacoder1020 has a spectacular aura about
Send a message via AIM to deltacoder1020
Re: Programming joysticks

Code:
if( (p1_wheel & 0xC0) == 0xC0 )
"&" is the "bitwise AND" operator. that means that it looks at individual bits of a value, and does an AND operation. AND is defined as follows: true if both inputs are true, otherwise false. a logic table:

0, 0 = 0
1, 0 = 0
0, 1 = 0
1, 1 = 1

so as you can see, it will only return 1's in the places where both numbers have ones. thus, it will only return all of the bits of one value if the same bits are 1's in the other value. the if statement essentially checks to see that all of the bits that are 1 in 0xC0 are also 1 in p1_wheel. replace 0xC0 with whatever "bitmask" (set of bits) you want to test as being 1.
__________________
Team 1020, the Indiana Prank Monkeys (www.team1020.org)