locked
XBox to PC controls conversion help RRS feed

  • Question

  • Hello everybody!

    I have been working on a program for a few days which uses a Data Extension, which allows you to use a XBox controller with a PC, currently I need help on the actual button pushes, as there is nothing like a "GameController.ButtonClicked = <Sub name here>" which is where I got confused, so how would I make it so when you push the buttons on the controller (And while the program is in the background) it then translates to a key on a keyboard?

    Code: RNF195

    And I am still working on the vibration settings just a bit, but I mainly want to focus on when the button is pushed down it then translates into the chosen key.

    Thanks!

    ~Alex


    • Edited by acenomad Thursday, February 16, 2012 3:27 AM
    Thursday, February 16, 2012 3:25 AM

Answers

  • Ohh ... I am really sorry. I must have been a little blind that I didn't see that you clearly wrote that you try to use the Data Extension! I have to confess that I didn't check that out myself so far, so I cannot really help you with that extension.

    But of course: This is the correct forum for it!

    I do not know, if the extension supports the XNA Controller already. But It could be possible to support the XNA Controller through a new extension which is either using managed directx or xna internally.

    There is a CodeProject article which explains how you could access the controller through XNA:
    http://www.codeproject.com/Articles/16983/Using-XNA-to-Access-an-Xbox-360-Joystick

    And a managed Direct X examle can be found here:
    http://blogs.msdn.com/b/pstubbs/archive/2006/02/13/531008.aspx

    If you want to make your own extension to SmallBasic, this thread might help to get a quick start - even if the thread mainly covers the intellisense help: http://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/3b638aab-2950-46f8-9e2a-28307518dd49

    I think it could be a nice idea - if it is not already inside the Data Extension you linked. I would like to give it a try, too, but I simply do not have any controller for my PC so I would be unable to do any tests :(
    (For my projects, I am using the normal controllers of each device e.g. mouse/keyboard on a PC, Controller on XBox and Touchscreen on phone ... but I just did some proove on concepts only so far and have no game so far.)

    So such an extension could be created and if someone is interested in it, I could at least help a little.

    But what I understood, too is the fact that you just want to create a program that runs in the background which is reading the controller input and creates some output. So if you press a button on the controller you want to make the system think, that a key was pressed. This would need another extension so I would simply say, that small basic is not the correct platform for such a program. I would suggest to use at least vb.net/c# but even that can be quite difficult because you have to access the system, too. So maybe C++ would be best to choose.

    I think for something like that, these links could be helpfull:

    keybd_event function:
    http://msdn.microsoft.com/en-us/library/ms646304(VS.85).aspx

    CodeProject: Mouse and Keyboard Library
    http://www.codeproject.com/Articles/28064/Global-Mouse-and-Keyboard-Library

    Codeproject: Using Keybd_event to simulate keyboard events
    http://www.codeproject.com/Articles/7305/Keyboard-Events-Simulation-using-keybd_event-funct

    From the research I did so far, it should be ok to use C# to build such a solution. But you should also be aware, that some games might have some protection so that such solutions will not work. I have no experience with it and just know that some vendors try to make sure that nobody can cheat. So it could be required to even go into the system and go to a driver level (in which case you need c++ and the WDK).

    I hope that I finally understood you correct and that I was able to give you some usefull information.

    With kind regards,

    Konrad

    • Marked as answer by acenomad Friday, February 17, 2012 7:33 PM
    Friday, February 17, 2012 10:22 AM

All replies

  • Hi,

    this forum only covers the Small basic (http://smallbasic.com) product. I would suggest to look for forum where your question is on topic.

    At the moment I cannot suggest a forum because I am not 100% aware what you are trying to do. You are developing a game with the XNA Framework? Then you should have a closer look at http://create.msdn.com where you will find a lot of ressources around the XNA framework includign forums where you can ask your questions.

    With kind regards,

    Konrad

    Thursday, February 16, 2012 12:10 PM
  • I'm sorry I don't think I was very clear, this isn't a game, nor is it using the XNA Framework, The Data Extension that I'm using on Small Baisc comes with an option to plug in your XBox controller and use it in SmallBasic, and on that I was trying to make a program where you choose which buttons on the controller convert to a key on a keyboard, but still be able to use the program in the background (So you could use it in a browser or a another game) , if the small basic fourms don't cover data extensions, then could you suggest a fourm which does?


    • Edited by acenomad Friday, February 17, 2012 3:30 AM
    Friday, February 17, 2012 12:02 AM
  • Ohh ... I am really sorry. I must have been a little blind that I didn't see that you clearly wrote that you try to use the Data Extension! I have to confess that I didn't check that out myself so far, so I cannot really help you with that extension.

    But of course: This is the correct forum for it!

    I do not know, if the extension supports the XNA Controller already. But It could be possible to support the XNA Controller through a new extension which is either using managed directx or xna internally.

    There is a CodeProject article which explains how you could access the controller through XNA:
    http://www.codeproject.com/Articles/16983/Using-XNA-to-Access-an-Xbox-360-Joystick

    And a managed Direct X examle can be found here:
    http://blogs.msdn.com/b/pstubbs/archive/2006/02/13/531008.aspx

    If you want to make your own extension to SmallBasic, this thread might help to get a quick start - even if the thread mainly covers the intellisense help: http://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/3b638aab-2950-46f8-9e2a-28307518dd49

    I think it could be a nice idea - if it is not already inside the Data Extension you linked. I would like to give it a try, too, but I simply do not have any controller for my PC so I would be unable to do any tests :(
    (For my projects, I am using the normal controllers of each device e.g. mouse/keyboard on a PC, Controller on XBox and Touchscreen on phone ... but I just did some proove on concepts only so far and have no game so far.)

    So such an extension could be created and if someone is interested in it, I could at least help a little.

    But what I understood, too is the fact that you just want to create a program that runs in the background which is reading the controller input and creates some output. So if you press a button on the controller you want to make the system think, that a key was pressed. This would need another extension so I would simply say, that small basic is not the correct platform for such a program. I would suggest to use at least vb.net/c# but even that can be quite difficult because you have to access the system, too. So maybe C++ would be best to choose.

    I think for something like that, these links could be helpfull:

    keybd_event function:
    http://msdn.microsoft.com/en-us/library/ms646304(VS.85).aspx

    CodeProject: Mouse and Keyboard Library
    http://www.codeproject.com/Articles/28064/Global-Mouse-and-Keyboard-Library

    Codeproject: Using Keybd_event to simulate keyboard events
    http://www.codeproject.com/Articles/7305/Keyboard-Events-Simulation-using-keybd_event-funct

    From the research I did so far, it should be ok to use C# to build such a solution. But you should also be aware, that some games might have some protection so that such solutions will not work. I have no experience with it and just know that some vendors try to make sure that nobody can cheat. So it could be required to even go into the system and go to a driver level (in which case you need c++ and the WDK).

    I hope that I finally understood you correct and that I was able to give you some usefull information.

    With kind regards,

    Konrad

    • Marked as answer by acenomad Friday, February 17, 2012 7:33 PM
    Friday, February 17, 2012 10:22 AM
  • Ok thank you!

    As I have only being working with Small Basic for a few months, I probably won't start learning any new language untill I get better at Small Basic, but for when I do start on a new language, I'll be sure to keep that in mind, thanks!

    Friday, February 17, 2012 7:31 PM
  • Xbox controller api of DirectX doesn't have OnButtonDown event so I cant provide one.

    Of course I could insert listener thread and simulate OnButtonDown event but that would be just waste of resources.

    GameController was made to be used with while loop in little more advanced programs.

    Samples:

    • GameController Sample 1 : VXF713
    • GameController Sample 2 : DGG883
    • GameController Sample 3 : RZS268


    Saturday, February 25, 2012 4:48 PM
  • Hi,

    It is true that games normaly just run with a main loop and are not event oriented. But why would it be a waste of resources to build something that will create such events? I cannot really follow you in this point. All that is required is a seperate thread that checks the controller state and trigers events on changes. But do not forget a Thread.Sleep so you only do the checks that are required (you do not need to check the controller to often per second).

    If you want to check the status of the controller then it is not a waste of resources to do exactly that :)

    Konrad

    Saturday, February 25, 2012 7:48 PM
  • All that is required is a seperate thread that checks the controller state and trigers events on changes. But do not forget a Thread.Sleep so you only do the checks that are required (you do not need to check the controller to often per second)

    I actually made one version that had functionality like this but in testing I wasn't happy with results (too much delay on input & not so great performance) so I reverted back to original version. But I do still have the code in my "code archive".

    Still it might be good idea after all to have ButtonDown event for those who love to use events.

    Monday, February 27, 2012 1:50 PM