Recent

Author Topic: Getting input from usb steering wheel  (Read 1260 times)

mciv

  • New member
  • *
  • Posts: 8
Getting input from usb steering wheel
« on: November 16, 2020, 06:20:04 pm »
Hi

Does anyone here have experience with getting input from usb steering wheels (like Logitech Momo Racing in attachment, or G27 etc)?

jamie

  • Hero Member
  • *****
  • Posts: 4039
Re: Getting input from usb steering wheel
« Reply #1 on: November 16, 2020, 11:37:32 pm »
it more than likely works as a joy stick interface.

the mmsystem unit has joy stick functions in it..

here is a link that gives you a little help

http://sheepdogguides.com/dt4i.htm



http://mc-computing.com/Languages/Joysticks.htm


That one is the same but looks more complete.

P.s.
  you may have issues with window messaging. I don't think Lazarus allows those ranges of numbers but if not, I have a simple unit that makes it easy to add messages to the form.

The only true wisdom is knowing you know nothing

MarkMLl

  • Hero Member
  • *****
  • Posts: 1760
Re: Getting input from usb steering wheel
« Reply #2 on: November 17, 2020, 06:34:03 pm »
Does anyone here have experience with getting input from usb steering wheels (like Logitech Momo Racing in attachment, or G27 etc)?

Perhaps. But you aren't going to get anything like a useful answer if you don't tell us what OS etc.

MarkMLl
Turbo Pascal v1 on CCP/M-86, multitasking with LAN and graphics in 128Kb.
Pet hate: people who boast about the size and sophistication of their computer.

Mr.Madguy

  • Hero Member
  • *****
  • Posts: 609
Re: Getting input from usb steering wheel
« Reply #3 on: November 17, 2020, 08:41:43 pm »
You can also try DirectInput

As I know, almost all USB input devices are treated as "standard". I.e. they just have X axises and Y buttons. Axises can have some range of values and buttons can be either pressed or released.
DynamicData 3.0 is released!
Since now development is frozen - only optimization passes will be made at some point.
Lack of multiple inheritance turns it into abomination.

mciv

  • New member
  • *
  • Posts: 8
Re: Getting input from usb steering wheel
« Reply #4 on: November 19, 2020, 02:51:57 am »
Thanks guys, I will look into this stuff. Its Windows 7

MarkMLl

  • Hero Member
  • *****
  • Posts: 1760
Re: Getting input from usb steering wheel
« Reply #5 on: November 19, 2020, 11:59:10 am »
Thanks guys, I will look into this stuff. Its Windows 7

Don't think I can help directly with that. I've done a fair amount of hacking on a G600 mouse on Linux, and my experience it that the various extra buttons were heavily oriented towards being programmed (using a private API, reverse-engineered by various people) as keyboard events.

I'd expect a steering wheel to be similar, but contrary to what Jamie says you are likely to find that there are event codes for this style of device rather than it appearing as a joystick.

MarkMLl
Turbo Pascal v1 on CCP/M-86, multitasking with LAN and graphics in 128Kb.
Pet hate: people who boast about the size and sophistication of their computer.

PascalDragon

  • Hero Member
  • *****
  • Posts: 2595
  • Compiler Developer
Re: Getting input from usb steering wheel
« Reply #6 on: November 19, 2020, 01:01:02 pm »
I'd expect a steering wheel to be similar, but contrary to what Jamie says you are likely to find that there are event codes for this style of device rather than it appearing as a joystick.

Both joysticks and steering wheels are HID devices and steering wheels use normal axis fields that joysticks use as well.

MarkMLl

  • Hero Member
  • *****
  • Posts: 1760
Re: Getting input from usb steering wheel
« Reply #7 on: November 19, 2020, 02:08:53 pm »
I'd expect a steering wheel to be similar, but contrary to what Jamie says you are likely to find that there are event codes for this style of device rather than it appearing as a joystick.

Both joysticks and steering wheels are HID devices and steering wheels use normal axis fields that joysticks use as well.

Not a safe assumption at the event level on Linux:

Code: [Select]
#define ABS_X                   0x00
#define ABS_Y                   0x01
#define ABS_Z                   0x02
#define ABS_RX                  0x03
#define ABS_RY                  0x04
#define ABS_RZ                  0x05
#define ABS_THROTTLE            0x06
#define ABS_RUDDER              0x07
#define ABS_WHEEL               0x08

etc.

MarkMLl
Turbo Pascal v1 on CCP/M-86, multitasking with LAN and graphics in 128Kb.
Pet hate: people who boast about the size and sophistication of their computer.

mciv

  • New member
  • *
  • Posts: 8
Re: Getting input from usb steering wheel
« Reply #8 on: November 22, 2020, 11:49:43 pm »
it more than likely works as a joy stick interface.

the mmsystem unit has joy stick functions in it..

here is a link that gives you a little help

http://sheepdogguides.com/dt4i.htm



http://mc-computing.com/Languages/Joysticks.htm


That one is the same but looks more complete.

P.s.
  you may have issues with window messaging. I don't think Lazarus allows those ranges of numbers but if not, I have a simple unit that makes it easy to add messages to the form.

This one worked with Momo Racing right away, except I cannot capture brake pedal.
 
I've looked here

Lazarus\fpc\3.2.0\source\packages\winunits-base\src\mmsystem.pp

and here

http://www.delphigroups.info/2/78/19929.html

and it turns out that wXpos is steering wheel position (0 being max left, 65535 being max right, so centered wheel is 32767,5 (while decimal point gets lost in reading anyway). wZpos is acceleration pedal (65535 is not touched, 0 is pressed to the floor). wButtons capture buttons as well. But I cannot capture brake (wYpos reads nothing), if anybody has any idea I will appreciate.

Here is a simple code in which you can control scrollbar with steering wheel (TTimer.Interval is set to 1 (milisecond))

Code: Pascal  [Select][+][-]
  1. uses
  2.     mmSystem;
  3.  
  4. type
  5.     TForm1 = class(TForm)
  6.     Edit1: TEdit;
  7.     ScrollBar1: TScrollBar;
  8.     Timer1: TTimer;
  9.     procedure Timer1Timer(Sender: TObject);
  10.  
  11. var
  12.   myjoy: tjoyinfo;
  13.  
  14. procedure TForm1.Timer1Timer(Sender: TObject);
  15. begin
  16.   joygetpos(joystickid1,@myjoy);
  17.   Edit1.Text:=IntToStr(myjoy.wxpos);
  18.   ScrollBar1.Position:=round(myjoy.wxpos/655.35);
  19. end;
  20.  

jamie

  • Hero Member
  • *****
  • Posts: 4039
Re: Getting input from usb steering wheel
« Reply #9 on: November 23, 2020, 01:12:29 am »
multiple devices

use a different device number …
The only true wisdom is knowing you know nothing

mciv

  • New member
  • *
  • Posts: 8
Re: Getting input from usb steering wheel
« Reply #10 on: November 23, 2020, 01:43:26 am »
multiple devices

use a different device number …

Doesn't work, it's part of one unit.

jamie

  • Hero Member
  • *****
  • Posts: 4039
Re: Getting input from usb steering wheel
« Reply #11 on: November 23, 2020, 01:57:50 am »
I understand that....

that does not mean it will not show as multiple devices!!!!!!!

Please test the device count.

There are many USB devices that will generate multiple devices when plugged in.
The only true wisdom is knowing you know nothing

mciv

  • New member
  • *
  • Posts: 8
Re: Getting input from usb steering wheel
« Reply #12 on: November 23, 2020, 08:13:09 am »
I understand that....

that does not mean it will not show as multiple devices!!!!!!!

Please test the device count.

There are many USB devices that will generate multiple devices when plugged in.

How should I do that? joyGetNumDevs shows 16 but I can select only joystickid1 or joystickid2 As I said I am new to this, maybe give some code example instead "!!!!!!!!!!ing"

MarkMLl

  • Hero Member
  • *****
  • Posts: 1760
Re: Getting input from usb steering wheel
« Reply #13 on: November 23, 2020, 09:05:58 am »
I understand that....

that does not mean it will not show as multiple devices!!!!!!!

Please test the device count.

There are many USB devices that will generate multiple devices when plugged in.

How should I do that? joyGetNumDevs shows 16 but I can select only joystickid1 or joystickid2 As I said I am new to this, maybe give some code example instead "!!!!!!!!!!ing"

Unlike some people I am very resistant to guessing, and that's particularly the case here since I don't have one of those and don't run Windows. However my experience of various devices on Linux is that they can be a mix of "the obvious" plus something extra like a keyboard, with some of the buttons simulating keypresses as determined by the dominant game of the genre and sometimes being programmable using a proprietary interface.

MarkMLl
Turbo Pascal v1 on CCP/M-86, multitasking with LAN and graphics in 128Kb.
Pet hate: people who boast about the size and sophistication of their computer.

mciv

  • New member
  • *
  • Posts: 8
Re: Getting input from usb steering wheel
« Reply #14 on: November 25, 2020, 02:57:05 am »
Does anybody have an idea how to detect if device is plugged to pc? It turns out joyGetNumDev shows 16 all the time, regardless if usb cable is in or not (I guess it accesses driver capabilities instead some physical state)

 

TinyPortal © 2005-2018