Thread: I am trying to detect a XBOX 360 controller in a port but all i get is a lot of error

  1. #1
    Registered User
    Join Date
    Oct 2013
    Posts
    33

    I am trying to detect a XBOX 360 controller in a port but all i get is a lot of error

    Hello I am trying to write a program that uses a controller to emulate key presses and mouse clicks and movements. I thought that this would be a cool program so that I could add in XBOX 360 controller support to games that have none.
    Here is my entire code(note how I have just gotten started on this progect)
    Code:
    #include <stdio.h>
    #include <Xinput.h>
    #define FALSE 0
    #define TRUE 0
    void main()
    {
     puts("Welcome to Key Mapper \n");
     puts("Program by: Jeremy Red\n");
     puts("Information:\n");
     if (ControllerExists() > FALSE);
     {
      puts("Controller Found");
     }
     puts("Program is used to map keys to a controller input\n");
     puts("Select type in an option:\n\n");
     puts("\t 1. <L>oad a program\n");
     puts("\t 2. <S>tart a new program\n");
     puts("\t 3. <E>dit an existing program\n");
     puts("\t 4. <R>un current program\n");
     puts("\t 5. <Q>uit preogram\n");
    }
    BYTE ControllerExists()
    {
     for (BYTE i = 0; i < 4; i++)
     {
      XINPUT_STATE state;
      ZeroMemory(&state, sizeof(XINPUT_STATE));
      if (XInputGetState(0, &state) == TRUE)
      {
       printf("Controller was found in port %i\n", i);
       return i + 1;
      }
     }
     puts("Error no controller was found on any port");
     return 0;
    }
    When I compile this code I get the following 11 errors.

    Error 1 error C1189: #error : "No Target Architecture" c:\program files (x86)\windows kits\8.1\include\um\winnt.h 145 1 Joystick Key Mapper

    2 IntelliSense: #error directive: "No Target Architecture" c:\Program Files (x86)\Windows Kits\8.1\Include\um\winnt.h 145 2 Joystick Key Mapper

    3 IntelliSense: identifier "PCONTEXT" is undefined c:\Program Files (x86)\Windows Kits\8.1\Include\um\winnt.h 9017 5 Joystick Key Mapper

    4 IntelliSense: identifier "PCONTEXT" is undefined c:\Program Files (x86)\Windows Kits\8.1\Include\um\winnt.h 16918 11 Joystick Key Mapper

    5 IntelliSense: identifier "PSLIST_HEADER" is undefined c:\Program Files (x86)\Windows Kits\8.1\Include\um\winnt.h 17529 11 Joystick Key Mapper

    6 IntelliSense: identifier "SLIST_HEADER" is undefined c:\Program Files (x86)\Windows Kits\8.1\Include\um\winnt.h 17537 16 Joystick Key Mapper

    7 IntelliSense: identifier "PSLIST_HEADER" is undefined c:\Program Files (x86)\Windows Kits\8.1\Include\um\winnt.h 17544 13 Joystick Key Mapper

    8 IntelliSense: identifier "PSLIST_HEADER" is undefined c:\Program Files (x86)\Windows Kits\8.1\Include\um\winnt.h 17551 13 Joystick Key Mapper

    9 IntelliSense: identifier "PSLIST_HEADER" is undefined c:\Program Files (x86)\Windows Kits\8.1\Include\um\winnt.h 17559 13 Joystick Key Mapper

    10 IntelliSense: identifier "PSLIST_HEADER" is undefined c:\Program Files (x86)\Windows Kits\8.1\Include\um\winnt.h 17569 13 Joystick Key Mapper

    11 IntelliSense: identifier "PSLIST_HEADER" is undefined c:\Program Files (x86)\Windows Kits\8.1\Include\um\winnt.h 17576 10 Joystick Key Mapper

    If you know what these errors mean and how I can fix them please say so. Thank you for taking the time to read this

    JustinWeq,

  2. #2
    Unregistered User Yarin's Avatar
    Join Date
    Jul 2007
    Posts
    2,158
    Quote Originally Posted by Justinweq View Post
    Code:
    #include <stdio.h>
    #include <Xinput.h>
    #define FALSE 0
    #define TRUE 0
    Include <windows.h>?

    Also, don't define TRUE and FALSE like that, include <stdbool.h> instead.

  3. #3
    Registered User
    Join Date
    Oct 2013
    Posts
    33
    I tried including windows.h and it just add 14 more compile errors. Any other suggestions anyone?

  4. #4
    Registered User ledow's Avatar
    Join Date
    Dec 2011
    Posts
    435
    Fix your compile errors before you continue? Maybe even post them so we can see?

    - Compiler warnings are like "Bridge Out Ahead" warnings. DON'T just ignore them.
    - A compiler error is something SO stupid that the compiler genuinely can't carry on with its job. A compiler warning is the compiler saying "Well, that's bloody stupid but if you WANT to ignore me..." and carrying on.
    - The best debugging tool in the world is a bunch of printf()'s for everything important around the bits you think might be wrong.

  5. #5
    Registered User
    Join Date
    Oct 2013
    Posts
    33
    Good idea here is all of my errors.

    Error 1 error C1189: #error : "No Target Architecture" c:\program files (x86)\windows kits\8.1\include\um\winnt.h 145 1 Joystick Key Mapper

    2 IntelliSense: #error directive: "No Target Architecture" c:\Program Files (x86)\Windows Kits\8.1\Include\um\winnt.h 145 2 Joystick Key Mapper

    3 IntelliSense: identifier "PCONTEXT" is undefined c:\Program Files (x86)\Windows Kits\8.1\Include\um\winnt.h 9017 5 Joystick Key Mapper

    4 IntelliSense: identifier "PCONTEXT" is undefined c:\Program Files (x86)\Windows Kits\8.1\Include\um\winnt.h 16918 11 Joystick Key Mapper

    5 IntelliSense: identifier "PSLIST_HEADER" is undefined c:\Program Files (x86)\Windows Kits\8.1\Include\um\winnt.h 17529 11 Joystick Key Mapper

    6 IntelliSense: identifier "SLIST_HEADER" is undefined c:\Program Files (x86)\Windows Kits\8.1\Include\um\winnt.h 17537 16 Joystick Key Mapper

    7 IntelliSense: identifier "PSLIST_HEADER" is undefined c:\Program Files (x86)\Windows Kits\8.1\Include\um\winnt.h 17544 13 Joystick Key Mapper

    8 IntelliSense: identifier "PSLIST_HEADER" is undefined c:\Program Files (x86)\Windows Kits\8.1\Include\um\winnt.h 17551 13 Joystick Key Mapper

    9 IntelliSense: identifier "PSLIST_HEADER" is undefined c:\Program Files (x86)\Windows Kits\8.1\Include\um\winnt.h 17559 13 Joystick Key Mapper

    10 IntelliSense: identifier "PSLIST_HEADER" is undefined c:\Program Files (x86)\Windows Kits\8.1\Include\um\winnt.h 17569 13 Joystick Key Mapper

    11 IntelliSense: identifier "PSLIST_HEADER" is undefined c:\Program Files (x86)\Windows Kits\8.1\Include\um\winnt.h 17576 10 Joystick Key Mapper

    12 IntelliSense: identifier "PSLIST_HEADER" is undefined c:\Program Files (x86)\Windows Kits\8.1\Include\um\interlockedapi.h 51 11 Joystick Key Mapper

    13 IntelliSense: identifier "PSLIST_HEADER" is undefined c:\Program Files (x86)\Windows Kits\8.1\Include\um\interlockedapi.h 59 13 Joystick Key Mapper

    14 IntelliSense: identifier "PCONTEXT" is undefined c:\Program Files (x86)\Windows Kits\8.1\Include\um\WinBase.h 8619 13 Joystick Key Mapper

    15 IntelliSense: identifier "PCONTEXT" is undefined c:\Program Files (x86)\Windows Kits\8.1\Include\um\WinBase.h 8621 10 Joystick Key Mapper

    16 IntelliSense: identifier "PCONTEXT" is undefined c:\Program Files (x86)\Windows Kits\8.1\Include\um\WinBase.h 8637 11 Joystick Key Mapper

    17 IntelliSense: identifier "PCONTEXT" is undefined c:\Program Files (x86)\Windows Kits\8.1\Include\um\WinBase.h 8660 10 Joystick Key Mapper

    18 IntelliSense: identifier "PCONTEXT" is undefined c:\Program Files (x86)\Windows Kits\8.1\Include\um\WinBase.h 8669 10 Joystick Key Mapper

    19 IntelliSense: identifier "PCONTEXT" is undefined c:\Program Files (x86)\Windows Kits\8.1\Include\um\WinBase.h 8685 13 Joystick Key Mapper

    20 IntelliSense: identifier "PSLIST_HEADER" is undefined c:\Program Files (x86)\Windows Kits\8.1\Include\um\interlockedapi.h 51 11 Joystick Key Mapper

    21 IntelliSense: identifier "PSLIST_HEADER" is undefined c:\Program Files (x86)\Windows Kits\8.1\Include\um\interlockedapi.h 59 13 Joystick Key Mapper

    22 IntelliSense: identifier "PSLIST_HEADER" is undefined c:\Program Files (x86)\Windows Kits\8.1\Include\um\interlockedapi.h 67 13 Joystick Key Mapper

    23 IntelliSense: identifier "PSLIST_HEADER" is undefined c:\Program Files (x86)\Windows Kits\8.1\Include\um\interlockedapi.h 81 13 Joystick Key Mapper

    24 IntelliSense: identifier "PSLIST_HEADER" is undefined c:\Program Files (x86)\Windows Kits\8.1\Include\um\interlockedapi.h 94 13 Joystick Key Mapper

    25 IntelliSense: identifier "PSLIST_HEADER" is undefined c:\Program Files (x86)\Windows Kits\8.1\Include\um\interlockedapi.h 102 10 Joystick Key Mapper

  6. #6
    Registered User
    Join Date
    Oct 2013
    Posts
    33
    Anyone have any ideas?

  7. #7
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    > Error 1 error C1189: #error : "No Target Architecture" c:\program files (x86)\windows kits\8.1\include\um\winnt.h 145 1 Joystick Key Mapper
    > 2 IntelliSense: #error directive: "No Target Architecture" c:\Program Files (x86)\Windows Kits\8.1\Include\um\winnt.h 145 2 Joystick Key Mapper
    The first thing you need to do is look in this file at around line 145

    It's going to be something like
    Code:
    #ifdef XBOX
    // some stuff
    #else
    #error "No Target Architecture"
    #endif
    You need to set up the project pre-conditions so this particular header file can declare the appropriate things properly.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  8. #8
    Registered User
    Join Date
    Jun 2011
    Posts
    4,513
    Minor note:

    Code:
    #define FALSE 0
    #define TRUE 0
    Something is wrong there.

  9. #9
    Unregistered User Yarin's Avatar
    Join Date
    Jul 2007
    Posts
    2,158
    Quote Originally Posted by Matticus View Post
    Minor note:

    Code:
    #define FALSE 0
    #define TRUE 0
    Something is wrong there.
    Exactly it should be
    Code:
    #define FALSE 1
    #define TRUE 0

  10. #10
    Registered User
    Join Date
    Oct 2013
    Posts
    33
    Quote Originally Posted by Salem View Post
    > Error 1 error C1189: #error : "No Target Architecture" c:\program files (x86)\windows kits\8.1\include\um\winnt.h 145 1 Joystick Key Mapper
    > 2 IntelliSense: #error directive: "No Target Architecture" c:\Program Files (x86)\Windows Kits\8.1\Include\um\winnt.h 145 2 Joystick Key Mapper
    The first thing you need to do is look in this file at around line 145

    It's going to be something like
    Code:
    #ifdef XBOX
    // some stuff
    #else
    #error "No Target Architecture"
    #endif
    You need to set up the project pre-conditions so this particular header file can declare the appropriate things properly.
    My winnt.h looks different at line 45 it looks like this.
    Code:
    #if defined(_AMD64_) || defined(_X86_)
    #define PROBE_ALIGNMENT(_s) TYPE_ALIGNMENT(DWORD)
    #elif defined(_IA64_) || defined(_ARM_)
    #define PROBE_ALIGNMENT(_s) (TYPE_ALIGNMENT(_s) > TYPE_ALIGNMENT(DWORD) ? TYPE_ALIGNMENT(_s) : TYPE_ALIGNMENT(DWORD))
    #elif !defined(RC_INVOKED)
    #error
        "No Target Architecture"
    #endif
    
    #if defined(_WIN64)
    #define PROBE_ALIGNMENT32(_s) TYPE_ALIGNMENT(DWORD)
    #endif
    Also what do you mean by "pre-conditions" I am new to this API and I have no idea what you mean by this if you could explain in detail or give an example it would be great.
    Last edited by Salem; 12-30-2013 at 11:34 PM. Reason: fix dog-food of a code post

  11. #11
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    > #if defined(_AMD64_) || defined(_X86_)
    > #define PROBE_ALIGNMENT(_s) TYPE_ALIGNMENT(DWORD)
    > #elif defined(_IA64_) || defined(_ARM_)
    You need to define one of these as a predefined pre-processor symbol in the project settings.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  12. #12
    Registered User
    Join Date
    Oct 2013
    Posts
    33
    Quote Originally Posted by Salem View Post
    > #if defined(_AMD64_) || defined(_X86_)
    > #define PROBE_ALIGNMENT(_s) TYPE_ALIGNMENT(DWORD)
    > #elif defined(_IA64_) || defined(_ARM_)
    You need to define one of these as a predefined pre-processor symbol in the project settings.
    How would I get to the project settings in visual studio 2013? and which one of these should I choose? if its computer specific I have an ASUS G750-JX Laptop with the following specs.
    Ram: 16 GB DDR3
    HDD: 1 TB 7200 RPM
    SDD: 256 Raid 0
    8X multi DVD ROM
    Graphics: NVidia GTX 770M
    Processor: Fourth Gen Intel i7 4700-MQ
    4 USB 3.0 Ports with one being thunderbolt which is supposed to be twice as fast as 3.0.
    Not sure if all of this information was necessary but if it could help I might as well write it down.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. how to detect the hardware(Serial Port) using visual studio?
    By ArunS in forum Networking/Device Communication
    Replies: 5
    Last Post: 03-08-2012, 08:18 AM
  2. Getting an XBox controller for my PC
    By Mario F. in forum General Discussions
    Replies: 5
    Last Post: 12-14-2010, 09:58 PM
  3. Detect if port is being blocked by my host?
    By Yarin in forum Tech Board
    Replies: 2
    Last Post: 10-21-2009, 05:49 PM
  4. Parallel Port to USB controller and outb()
    By coletek in forum Linux Programming
    Replies: 1
    Last Post: 06-05-2009, 06:57 AM
  5. Parallel Port! Detect incoming current, posible?
    By hyaku_ in forum Networking/Device Communication
    Replies: 2
    Last Post: 01-11-2005, 02:42 AM