[win32] - about joystick - Page 2
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Page 2 of 2 FirstFirst 12
Results 16 to 23 of 23

Thread: [win32] - about joystick

  1. #16
    Join Date
    Dec 2012
    Location
    England
    Posts
    2,361

    Re: [win32] - about joystick

    Code:
    else if (b.dwXpos == 0 && b.dwYpos == 65535)
    What is the type of b.dwYpos? Have you checked this value to see what it actually is?
    All advice is offered in good faith only. You are ultimately responsible for effects of your programs and the integrity of the machines they run on.

  2. #17
    Join Date
    Apr 2009
    Posts
    636

    Re: [win32] - about joystick

    Quote Originally Posted by 2kaud View Post
    Code:
    else if (b.dwXpos == 0 && b.dwYpos == 65535)
    What is the type of b.dwYpos? Have you checked this value to see what it actually is?
    the type is DWORD and that values was found with a VB6 code. but if isn't right, please tell me.
    i use that line for see the joystick directions...
    the MSDN is limited:
    "
    dwXpos Current X-coordinate.
    dwYpos Current Y-coordinate.
    dwZpos Current Z-coordinate.
    dwRpos Current position of the rudder or fourth joystick axis.
    dwUpos Current fifth axis position.
    dwVpos Current sixth axis position."


    like you see.
    unless is the remark section(on bottom of page):
    http://msdn.microsoft.com/en-us/libr...=vs.85%29.aspx
    that tell us the directions const... but i don't understand 100% what says
    Last edited by Cambalinho; August 1st, 2014 at 04:37 PM.

  3. #18
    Join Date
    Dec 2012
    Location
    England
    Posts
    2,361

    Re: [win32] - about joystick

    Use the debugger (or display the values) of dwYpos, dwXpos etc to see what these values actually are - then you know what values to test for.
    All advice is offered in good faith only. You are ultimately responsible for effects of your programs and the integrity of the machines they run on.

  4. #19
    Join Date
    Nov 2000
    Location
    Voronezh, Russia
    Posts
    5,970

    Re: [win32] - about joystick

    Quote Originally Posted by Cambalinho View Post
    sorry, but can i do something like these:
    if(buttons==(JOY_BUTTON1 | JOY_BUTTON2))
    //do something
    ???
    i mean convert the b.dwButtons to buttons
    The code
    Code:
    if (buttons == (BUTTON1 | BUTTON2) )
    effectively tests for exactly the two buttons pressed simultaneously.

    but the code
    Code:
    if (buttons & (BUTTON1 | BUTTON2) )
    tests for any of the two being pressed no matter what other buttons state is.

    Feel the difference.
    Best regards,
    Igor

  5. #20
    Join Date
    Apr 2009
    Posts
    636

    Re: [win32] - about joystick

    thanks to both.. i had tested the dwYpos and dwXpos, but i can't test the others
    maybe because my joystick don't have them. but see what MSDN says:

    dwZpos
    Current Z-coordinate.
    dwRpos Current position of the rudder or fourth joystick axis.

    dwUpos Current fifth axis position.
    dwVpos Current sixth axis position.

    for me, that information don't make sence
    can anyone explain to me what is 'axis', 'rudder' and 'Z'?

  6. #21
    Join Date
    Dec 2012
    Location
    England
    Posts
    2,361

    Re: [win32] - about joystick

    An axis is a physical manifest of an abstract dimension - so the six axis correlate to the six-dimensional space.

    http://en.wikipedia.org/wiki/Six-dimensional_space
    All advice is offered in good faith only. You are ultimately responsible for effects of your programs and the integrity of the machines they run on.

  7. #22
    Join Date
    Apr 2009
    Posts
    636

    Re: [win32] - about joystick

    Quote Originally Posted by 2kaud View Post
    An axis is a physical manifest of an abstract dimension - so the six axis correlate to the six-dimensional space.

    http://en.wikipedia.org/wiki/Six-dimensional_space
    now i found what i was looking for: Joystick Layout
    Name:  joystick.gif
Views: 19
Size:  24.3 KB
    isn't a complete layout.. maybe i can find more about the others
    but i need ask 1 thing from image and what i used from joystick:
    - the Hat(direction keys) and the X, Y coordenates are the same or can be programmed in diferent ways?

  8. #23
    Join Date
    Apr 2009
    Posts
    636

    Re: [win32] - about joystick

    i need more advices:
    1 - how can i change these loop for detect the joystick by ID?
    Code:
    īlse if(wParam==JoystickTimer)
                        {
                            JOYINFOEX  b;
                            b.dwSize=sizeof(JOYINFOEX );
                            b.dwFlags=JOY_RETURNALL;
    
                            //cicle all possible joysticks
                            for (int i=0; i<16; i++)
                            {
                                int direction=0;
                                if(joyGetPosEx(i,&b)!= JOYERR_NOERROR) //if theres any error then continue to next joystick
                                {
                                    if(i==0)
                                        inst->Joystick(-1, -1,-1);
                                    else
                                        inst->Joystick(0, -1,-1);
                                    break;
                                }
    like you see, i use a for loop for all possible joystick ID's. but these loop can be changed?
    what i mean is testing all connected joysticks and detect their ID's.

    2 - imagine that i have using 2 joysticks, in same time, and i wan't do the joystickdown() event\message. how can i save the values, in static way, for not lose all joystick buttons?
    maybe using a vector?(instead the normal array)

    3 - i can get the X and Y axis values. but how can i get the angle values(in degrees)?

Page 2 of 2 FirstFirst 12

Posting Permissions

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


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center