Forum: PS2 Homebrew/Dev & Emu Scene - Topics relating to homebrew PS2 development and emulation. Stay current and up to date on the latest homebrew releases from the best devs on the scene.


The above video goes away if you are a member and logged in, so log in now!




 
Would you like to get all the new info from
PSX-Scene in your email each day?




Want to learn more about the team keeping you up to date with the latest scene news?

Read about them now!

Check out our Developer bios, too!

 


User Tag List

Thread: Controller Pad
  

Results 1 to 2 of 2
  1. #1 Question Controller Pad 
    jcarelek is offline Registered User
    Join Date
    Jul 2010
    Posts
    5
    Downloads
    0
    Uploads
    0
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Likes Given
    0
    Likes Received
    0
    I was reading over the example pad.c program that came with the ps2sdk provided by ps2dev.org. I confused at the part where it is reading the actual button values. Why can't you just do a comparison such as if(buttons.btns == PAD_LEFT). Why is it first being exclusive OR'ed with 0xffff and then bit ANDed with the old value of btns? Why should it even matter what the previous value of btns is? Thanks for clearing this up?
    Reply With Quote  

  2. #2  
    jcarelek is offline Registered User
    Join Date
    Jul 2010
    Posts
    5
    Downloads
    0
    Uploads
    0
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Likes Given
    0
    Likes Received
    0
    Nevermind. I looked at the code some more and I got was going on. It looks like that bit-wise AND is just so the code doesn't print a million times if you hold down a button. Also the value is XOR'd with all 1's because btns contains a single zero in a particular bit position whereas the values such as PAD_LEFT have a 1 in a particular bit position.
    Reply With Quote  

Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •