How to add multiple control methods into a game using Windows Forms?

samhobbs 41 Reputation points
2021-12-10T13:19:47.05+00:00

I am currently working on a game which uses Windows Forms in VB, and by default, you navigate the game using the mouse (and also a keyboard if you really want to). The game features a paddle at the bottom of the screen which is user-controlled, and it involves moving the mouse left or right to get the paddle to move left or right as well. However, I have recently thought about adding additional control methods to the game, such as a controller. For example, I have thought about adding an Xbox One controller as a control method, and then binding the buttons to the different parts of the game (A to press a button, left stick to move the paddle and/or navigate through menus), D-Pad as optional control method, 3 line button to pause etc.) to make the game a bit better. I could also try making the game keyboard controlled, and moving the paddle using the left/right arrow keys or A/D keys.

Is there an easy way of adding different control methods such as an Xbox One controller?

VB
VB
An object-oriented programming language developed by Microsoft that is implemented on the .NET Framework. Previously known as Visual Basic .NET.
2,492 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Castorix31 80,801 Reputation points
    2021-12-10T14:08:34.14+00:00

    You can use Raw Input

    (I had posted a test sample in this thread Manage more mice using VB.net
    that you can improve from MS samples in C++ (with HID_USAGE_GENERIC_GAMEPAD or HID_USAGE_GENERIC_JOYSTICK , HID_USAGE_GENERIC_MULTI_AXIS_CONTROLLER, ...)

    There is also XInput Game Controller APIs (not tested atm)

    0 comments No comments