コード例 #1
0
 def test_SDL_GameControllerAddMapping(self):
     newmap = (b"030000005e0400002700000006010000,Microsoft SideWinder,"
               b"platform:Mac OS X,a:b0,b:b1,x:b2,y:b3,dpup:-a1,dpdown:+a1,"
               b"dpleft:-a0,dpright:+a0,lefttrigger:b4,righttrigger:b5")
     if sdl2.dll.version >= 2006:
         n1 = gamecontroller.SDL_GameControllerNumMappings()
         ret = gamecontroller.SDL_GameControllerAddMapping(newmap)
         assert ret != -1
         n2 = gamecontroller.SDL_GameControllerNumMappings()
         assert n2 == n1 + 1
     else:
         # NumMappings not available before 2.0.6
         ret = gamecontroller.SDL_GameControllerAddMapping(newmap)
         assert ret != -1
コード例 #2
0
 def test_SDL_GameControllerMappingForIndex(self):
     newmap = (b"030000005e0400002700000006010000,Microsoft SideWinder,"
               b"platform:Mac OS X,a:b0,b:b1,x:b2,y:b3,dpup:-a1,dpdown:+a1,"
               b"dpleft:-a0,dpright:+a0,lefttrigger:b4,righttrigger:b5")
     ret = gamecontroller.SDL_GameControllerAddMapping(newmap)
     assert ret != 0
     num = gamecontroller.SDL_GameControllerNumMappings()
     retmap = gamecontroller.SDL_GameControllerMappingForIndex(num - 1)
     assert newmap == retmap
コード例 #3
0
 def test_SDL_GameControllerMappingForGUID(self):
     newmap = (b"030000005e0400002700000006010000,Microsoft SideWinder,"
               b"platform:Mac OS X,a:b0,b:b1,x:b2,y:b3,dpup:-a1,dpdown:+a1,"
               b"dpleft:-a0,dpright:+a0,lefttrigger:b4,righttrigger:b5")
     ret = gamecontroller.SDL_GameControllerAddMapping(newmap)
     assert ret != 0
     # Get GUID for new mapping
     guid_str = newmap.split(b",")[0]
     guid = joystick.SDL_JoystickGetGUIDFromString(guid_str)
     # Get mapping for GUID
     retmap = gamecontroller.SDL_GameControllerMappingForGUID(guid)
     assert retmap == newmap