Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 [tutorial] joysticks/joypads (finally)
Index -> Programming, Turing -> Turing Tutorials
Goto page Previous  1, 2
View previous topic Printable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
BigBear




PostPosted: Tue Mar 17, 2009 11:26 pm   Post subject: Re: RE:[tutorial] joysticks/joypads (finally)

Tony @ Mon Mar 16, 2009 11:28 pm wrote:
You have an array that represents the input state, very similar to the one you would have from Input.KeyDown. If you want a particular button, just check the corresponding index directly.

(that is, you don't normally loop over every keyboard key, looking if letter 'Q' was pressed)


So could write a program using Input.KeyDown then use something like this

Turing:

Input.KeyDown (key)
for i : 1 .. 31
    if joy (1).button (i) then
        if i = 1 then
            key = ('1')
        elsif i = 2 then
            key = ('2')
        elsif i = 3 then
            key = ('3')
        elsif i = 4 then
            key = ('4')
        elsif i = 5 then
            key = ('5')
        end if
    end if
end for
Sponsor
Sponsor
Sponsor
sponsor
Tony




PostPosted: Tue Mar 17, 2009 11:35 pm   Post subject: RE:[tutorial] joysticks/joypads (finally)

No, that doesn't even make sense. If you are looking for a specific button #5
code:

if joy (1).button (5) then
   put "win"
end
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
BigBear




PostPosted: Wed Mar 18, 2009 12:07 am   Post subject: RE:[tutorial] joysticks/joypads (finally)

OK but with this
Turing:
if joy (2).button (1) then
        keys := ('1')
    elsif joy (2).button (2) then
        keys := ('2')
    elsif joy (2).button (3) then
        keys := ('3')
    elsif joy (2).button (4) then
        keys := ('4')
    elsif joy (2).button (5) then
        keys := ('5')
    end if


I am getting

Assigned value is the wrong type
Nick




PostPosted: Wed Mar 18, 2009 6:59 pm   Post subject: Re: RE:[tutorial] joysticks/joypads (finally)

BigBear @ Mon Mar 16, 2009 11:44 pm wrote:
What is with the 3.. 3 +31


that's for Text.Locate

BigBear wrote:
I am getting

Assigned value is the wrong type


that's because you're mixing keys with button, look at Tony's post a second time
BigBear




PostPosted: Wed Mar 18, 2009 8:34 pm   Post subject: RE:[tutorial] joysticks/joypads (finally)

I wanted to know if you could easily use joystick buttons to seem like keys were being pressed.

I wanted to do this so I could take this Guitar Hero Game found here

http://compsci.ca/v3/viewtopic.php?t=15739&highlight=guitar+hero

And just add the joystick information and that check for buttons to be keys.

But I guess I will have make one that I (1) understand and (2) uses joystick buttons.
The_Bean




PostPosted: Wed Mar 18, 2009 9:27 pm   Post subject: Re: [tutorial] joysticks/joypads (finally)

You should be able to do it the way you want to, you're just mixing up what the 'keys' variable is.

The variable keys is defined as an array char of boolean
If you break it up, you get :an array with an element for every char of the keyboard as a boolean value
So if you push a key down, then that char in the array will become true.
What you need to do is make the program think that the keyboard key is pushed down when it's actually on the controller.
to change the boolean value of an individual char use:
Turing:

keys(chr(46)):=true %for the number 1 on the keyboard
Display posts from previous:   
   Index -> Programming, Turing -> Turing Tutorials
View previous topic Tell A FriendPrintable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 2 of 2  [ 21 Posts ]
Goto page Previous  1, 2
Jump to:   


Style:  
Search: