Recent

Author Topic: Communicating with a video game controller.  (Read 3799 times)

OC DelGuy

  • Full Member
  • ***
  • Posts: 195
Communicating with a video game controller.
« on: December 26, 2024, 04:12:02 am »
How does one communicate with a video game controller?

Hello and Merry Christmas to everyone!


I got a cool little controller for Christmas.  It works real nice with the games I have installed on my computer.

Having said that, I now want to write a program that communicates with it.  Not sure if I'm going to write anything that actually uses the controller, just yet, but I really just want to make stuff happen on the screen as I push the buttons and move the joysticks around.  Is there a package that I need to download?  It uses DirectX, if that's pertinent information, to answering my question.

Also, is there a way to write a program (I mean, I'm sure there is...) that allows the buttons and joysticks to emulate (is that the right word?) keys on the computer?
For example, maybe by using the the "four button cross" button on the left to do the same thing as pushing the four arrow keys on the keyboard.  And making the four buttons on the right side (a, b, x and y) do things like, if I press one button, it's the same as if I pressed a key or a series of keys on the keyboard.  Stuff like that.

I know it's kind of vague, but I really don't know what I want to do with this at the moment, except for knowing that I can put a dot on the screen and I can move it around with the joystick.  I'm sorry if this doesn't make sense.  But I just want to learn how to use a game controller in a program and not necessarily in a game.
I'm going to post this now as it seems I'm just rambling on and on.
Free Pascal Lazarus Version #: 2.2.4
Date: 24 SEP 2022
FPC Version: 3.2.2
Revision: Lazarus_2_2_4
x86_64-win64-win32/win64

Fibonacci

  • Hero Member
  • *****
  • Posts: 663
  • Internal Error Hunter

OC DelGuy

  • Full Member
  • ***
  • Posts: 195
Re: Communicating with a video game controller.
« Reply #2 on: December 29, 2024, 07:45:50 am »
Thanks! I'll give this a try.  Do you know if it comes with docs on how it's used?
Free Pascal Lazarus Version #: 2.2.4
Date: 24 SEP 2022
FPC Version: 3.2.2
Revision: Lazarus_2_2_4
x86_64-win64-win32/win64

Fibonacci

  • Hero Member
  • *****
  • Posts: 663
  • Internal Error Hunter

Seenkao

  • Hero Member
  • *****
  • Posts: 676
    • New ZenGL.
Re: Communicating with a video game controller.
« Reply #4 on: December 29, 2024, 09:42:29 am »
Попробуйте 3-ю демку в ZenGL и проверьте как работает ваш контроллер.
Функциональность джойстиков и контроллеров во многом совпадает и они стараются взаимозаменять друг друга по возможности.

По поводу эмулирования кнопок клавиатуры, то да, вы можете это сделать, но вам нужно будет самому реализовать эту функциональность. Самая приближенная функциональность, это когда у вас виртуальная клавиатура, а вы выбираете на ней нужную вам клавишу и нажимаете (обычно это делают мышкой, а не джойстиком).

----------------------------------------
Google translate:
Try the 3rd demo in ZenGL and check how your controller works.
The functionality of joysticks and controllers is largely the same and they try to replace each other whenever possible.

Regarding emulating keyboard buttons, yes, you can do it, but you will need to implement this functionality yourself. The closest functionality is when you have a virtual keyboard, and you select the key you need on it and press it (usually this is done with a mouse, not a joystick).
Rus: Стремлюсь к созданию минимальных и достаточно быстрых приложений.

Eng: I strive to create applications that are minimal and reasonably fast.
Working on ZenGL

lainz

  • Hero Member
  • *****
  • Posts: 4695
  • Web, Desktop & Android developer
    • https://lainz.github.io/
Re: Communicating with a video game controller.
« Reply #5 on: December 29, 2024, 06:16:12 pm »
Mouse and key input package has the keyboard functionality you're looking for.

To use joystick check 5dpo (Sdpo) package.

 

TinyPortal © 2005-2018