laamaa / m8c

Cross-platform M8 tracker headless client
Other
382 stars 81 forks source link

FR: Supporting non button sdl keys? #25

Closed peterswimm closed 2 years ago

peterswimm commented 2 years ago

I have an 8bitdo controller, with the following mappings

Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,leftstick:b8,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b9,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Mac OS X,"

How do I map the h0.8 etc ones? It doesn't seem to support them in the ini. If I map the directions to a regular button it seems to work as intended.

laamaa commented 2 years ago

Doesn't work currently, the code in input.c checks only for SDL_JOYBUTTONDOWN and JOYBUTTONUP events. It shouldn't be too hard to add axis support as well though, especially since now things work with the ini file

peterswimm commented 2 years ago

Ah that would be great, it seems all my controllers do the axis method for their dpads! Ill change this to a feature request.

laamaa commented 2 years ago

I tried to hack some kind of support for analog axis (#27), wasn't as simple as I first thought but it works now at least with my Xbox One Gamepad. Could you please try pulling the most recent code and try if it works for you?

peterswimm commented 2 years ago

It works for me on the Xbox one controller but not the 8bitdo above. Tagging @JeffAlyanak

laamaa commented 2 years ago

I rewrote most of the gamepad stuff since analog stuff was hard to add on top of the previous SDL events-based system. Analog axis events didn't seem work that reliably at least on my system. Now all buttons and axis are checked on every cycle in a simple system.

I also added the possibility to map all buttons to analog axis (so that xbone triggers etc. work for start/sel and so on), the mappings are in config.ini.

Could you please try pulling the latest source and check if all pads work normally now? I tested briefly with a knockoff USB PS3 pad and XBOne pad and both seemed to be fine now, with digital and analog.

laamaa commented 2 years ago

I think this works ok, I'll close the issue for now