[win32] - how use joystick?

This is a discussion on [win32] - how use joystick? within the Windows Programming forums, part of the Platform Specific Boards category; i understand how can i activate the joystick: Code: joySetCapture(inst->hWnd(),JOYSTICKID1,100,true); joySetCapture(inst->hWnd(),JOYSTICKID2,100,true); but i see 1 problem: i must activate for ...

  1. #1
    Registered User
    Join Date
    Aug 2013
    Posts
    138

    [win32] - how use joystick?

    i understand how can i activate the joystick:
    Code:
    joySetCapture(inst->hWnd(),JOYSTICKID1,100,true);
                        joySetCapture(inst->hWnd(),JOYSTICKID2,100,true);
    but i see 1 problem: i must activate for all connected joysticks, but how can i get the number of connected joysticks?
    and then i must release the joystick(when i don't need it):
    Code:
    joyReleaseCapture(JOYSTICKID1);
                        joyReleaseCapture(JOYSTICKID2);
    i activate the joystick, when the form is created, but i think that isn't the right way to do, because the user can connect the joystick when want's.
    please anyone tell me something.

  2. #2
    Registered User
    Join Date
    Aug 2013
    Posts
    138
    using a timer, i put the joystick more complete

    please see the image
    Name:  joystick.gif
Views: 38
Size:  24.3 KB

    now i need ask:
    1 - how can i get the Z in circle way(for getting in degrees from 0 to 360)?
    2 - if the Analog button is in red, how can i detect the Hat buttons?

  3. #3
    Registered User
    Join Date
    Aug 2013
    Posts
    138
    the Hat is the POV. but heres another information:
    1 - if the Analog button is red, the POV\Hat and X,Y Axis are diferent;
    2 - if the Analog button is turn of, the POV\HAT and X,Y Axis are the same buttons... but the results are in X and Y Axis;
    3 - if the X,Y,Z center is 32767, the POV is activated and the Analog is red. else the X,Y,Z center is 32511.

    i continue with 1 question: how can i get the circle angle from Z and X,Y Axis?

  4. #4
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,596
    Your post appears to be using a library of some sorts. For peripheral devices in Windows you can use raw input. Follow the link below to learn more.

    Raw Input (Windows)

    Once you get a grasp on the concepts then you can wrap it into your own library or at least understand more of what is going on with the API you are currently using.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Raw input from a HID joystick
    By Cynic in forum Networking/Device Communication
    Replies: 0
    Last Post: 05-10-2012, 09:19 AM
  2. joystick program
    By Titanium in forum C++ Programming
    Replies: 2
    Last Post: 05-18-2008, 11:19 AM
  3. Getting joystick movements.
    By Queatrix in forum C++ Programming
    Replies: 1
    Last Post: 01-04-2006, 01:58 PM
  4. Joystick
    By merlin371 in forum C++ Programming
    Replies: 2
    Last Post: 09-02-2003, 07:15 PM
  5. I'm looking for a Joystick controller
    By Raideen in forum Windows Programming
    Replies: 0
    Last Post: 06-24-2003, 10:36 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21