pygame-ce icon indicating copy to clipboard operation
pygame-ce copied to clipboard

SDL2: game controller (711)

Open GalacticEmperor1 opened this issue 2 years ago • 1 comments
trafficstars

Issue №711 opened by illume at 2019-01-03 11:11:52

Various SDL_GameController functions need to be implemented in _sdl2. https://wiki.libsdl.org/CategoryGameController

  • [x] an example script
  • [ ] examples/eventlist.py
  • [x] Tests for controller are needed
  • [ ] CONTROLLER_* consts look a bit long, shorter names are needed I think?
  • [x] Better interface for controller mapping in pygame (ask @husano896 what this is about)
  • [ ] docs (API docs, but also a migration guide for people used to the old joystick API).

Comments

# # husano896 commented at 2019-05-14 15:08:04

Better interface for controller mapping in pygame (ask @husano896 what this is about)

https://wiki.libsdl.org/SDL_GameControllerAddMapping

At this moment, mapping uses a really long string as SDL2 like

"341a3608000000000000504944564944,Afterglow PS3 Controller,a:b1,b:b2,y:b3,x:b0,start:b9,guide:b12,back:b8,dpup:h0.1,dpleft:h0.8,dpdown:h0.4,dpright:h0.2,leftshoulder:b4,rightshoulder:b5,leftstick:b10,rightstick:b11,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:b6,righttrigger:b7"

What I think is:

since we can easily get guid and controller name, add mapping should use a easier parameter like

mapping = {
 "a" : "b1",
 "b" : "b2",
 "y" :  "b3",
 "x" : "b0"
 #  etc...
}
controller.add_mapping(mapping)

and so as get_mapping.

mapping = controller.get_mapping() #  return a dict

GalacticEmperor1 avatar Feb 12 '23 09:02 GalacticEmperor1