forums.ps2dev.org Forum Index forums.ps2dev.org
Homebrew PS2, PSP & PS3 Development Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

How to detect diagonal on the directional pad..

 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Lua Player Development
View previous topic :: View next topic  
Author Message
fattymc03



Joined: 11 Feb 2006
Posts: 18

PostPosted: Sat Feb 11, 2006 12:26 am    Post subject: How to detect diagonal on the directional pad.. Reply with quote

How can I detect the pressing of a diagonal on the directional pad. Like pressing up and right at the same time.
Back to top
View user's profile Send private message
MikeHaggar



Joined: 18 Jul 2005
Posts: 116

PostPosted: Sat Feb 11, 2006 12:46 am    Post subject: Reply with quote

Here for 'hardcoded':

Code:

if pad:up() and pad:right() then
....
elseif pad:up() and pad:left() then
....
elseif pad:up() then
....
elseif pad:left() then
....
end


Make sure the diagonals are before the 'normal' ones.



You can prolly use this if you use it for some kind of value changes, like y=y+1 and x=x+1 etc.:

Code:

if pad:up() then
....
end

if pad:right() then
....
end

if pad:left() then
....
end



Last edited by MikeHaggar on Sat Feb 11, 2006 7:36 am; edited 1 time in total
Back to top
View user's profile Send private message
fattymc03



Joined: 11 Feb 2006
Posts: 18

PostPosted: Sat Feb 11, 2006 2:09 am    Post subject: Reply with quote

thanks for the quick response i appreciate it. that works, but its not that fluid. its like it moves in the direction of the first detected button. you have to press them both at exactly the same time to get it to move correctly, but it is not that fluid. are there any other solutions?
Back to top
View user's profile Send private message
fattymc03



Joined: 11 Feb 2006
Posts: 18

PostPosted: Sat Feb 11, 2006 2:13 am    Post subject: Reply with quote

opps, sorry about the above post. i didnt realize i had a return statement in the wrong place. it works correctly now. i was wondering if you could explain the buttonmasks and when is the correct time to use them. thanks again.
Back to top
View user's profile Send private message
KawaGeo



Joined: 27 Aug 2005
Posts: 191
Location: Calif Mountains

PostPosted: Sat Feb 11, 2006 2:49 am    Post subject: Reply with quote

Suggest a timer to allow the user to press two buttons before testing them.
_________________
Geo Massar
Retired Engineer
Back to top
View user's profile Send private message Send e-mail
CaseyB



Joined: 23 Jan 2006
Posts: 15

PostPosted: Sat Feb 11, 2006 3:04 am    Post subject: Reply with quote

If you do it the second way suggested by MikeHaggar, i.e.,

MikeHaggar wrote:

You can prolly use this if you use it for some kind of value changes, like y=y+1 and x=x+1 etc.:

Code:

if pad:up() then
....
end

if pad:right() then
....
end

if pad:left() then
....
end



It should work perfectly without having to introduce the complexity of a timer or worrying about what order to call the checks in.
Back to top
View user's profile Send private message
fattymc03



Joined: 11 Feb 2006
Posts: 18

PostPosted: Sat Feb 11, 2006 4:46 am    Post subject: Reply with quote

mike haggars way worked fine.. thanks guys
Back to top
View user's profile Send private message
MikeHaggar



Joined: 18 Jul 2005
Posts: 116

PostPosted: Sat Feb 11, 2006 7:35 am    Post subject: Reply with quote

fattymc03 wrote:
i was wondering if you could explain the buttonmasks and when is the correct time to use them. thanks again.


hm... what do you mean?
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Lua Player Development All times are GMT + 10 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group