virtual joysticks: MSVC support part 1/2, make driver's .c file be uniquely named
authorDavid Ludwig <dludwig@pobox.com>
Sun, 15 Mar 2020 15:05:36 -0400
changeset 13630a0ab6d4ff5e7
parent 13629 811d194a1f25
child 13631 4ee09b18876b
virtual joysticks: MSVC support part 1/2, make driver's .c file be uniquely named
Xcode-iOS/SDL/SDL.xcodeproj/project.pbxproj
Xcode/SDL/SDL.xcodeproj/project.pbxproj
src/joystick/SDL_joystick.c
src/joystick/virtual/SDL_sysjoystick.c
src/joystick/virtual/SDL_sysjoystick_c.h
src/joystick/virtual/SDL_virtualjoystick.c
src/joystick/virtual/SDL_virtualjoystick_c.h
     1.1 --- a/Xcode-iOS/SDL/SDL.xcodeproj/project.pbxproj	Sun Mar 15 14:40:51 2020 -0400
     1.2 +++ b/Xcode-iOS/SDL/SDL.xcodeproj/project.pbxproj	Sun Mar 15 15:05:36 2020 -0400
     1.3 @@ -359,13 +359,13 @@
     1.4  		63CC93C823849391002A5C54 /* SDL_strtokr.c in Sources */ = {isa = PBXBuildFile; fileRef = 63CC93C623849391002A5C54 /* SDL_strtokr.c */; };
     1.5  		63CC93C923849391002A5C54 /* SDL_strtokr.c in Sources */ = {isa = PBXBuildFile; fileRef = 63CC93C623849391002A5C54 /* SDL_strtokr.c */; };
     1.6  		63CC93CA23849391002A5C54 /* SDL_strtokr.c in Sources */ = {isa = PBXBuildFile; fileRef = 63CC93C623849391002A5C54 /* SDL_strtokr.c */; };
     1.7 -		75BB5C66241EA8C300D75403 /* SDL_sysjoystick.c in Sources */ = {isa = PBXBuildFile; fileRef = 75BB5C64241EA8C300D75403 /* SDL_sysjoystick.c */; };
     1.8 -		75BB5C67241EA8C300D75403 /* SDL_sysjoystick.c in Sources */ = {isa = PBXBuildFile; fileRef = 75BB5C64241EA8C300D75403 /* SDL_sysjoystick.c */; };
     1.9 -		75BB5C68241EA8C300D75403 /* SDL_sysjoystick.c in Sources */ = {isa = PBXBuildFile; fileRef = 75BB5C64241EA8C300D75403 /* SDL_sysjoystick.c */; };
    1.10 -		75BB5C69241EA8C300D75403 /* SDL_sysjoystick.c in Sources */ = {isa = PBXBuildFile; fileRef = 75BB5C64241EA8C300D75403 /* SDL_sysjoystick.c */; };
    1.11 -		75BB5C6A241EA8C300D75403 /* SDL_sysjoystick_c.h in Headers */ = {isa = PBXBuildFile; fileRef = 75BB5C65241EA8C300D75403 /* SDL_sysjoystick_c.h */; };
    1.12 -		75BB5C6B241EA8C300D75403 /* SDL_sysjoystick_c.h in Headers */ = {isa = PBXBuildFile; fileRef = 75BB5C65241EA8C300D75403 /* SDL_sysjoystick_c.h */; };
    1.13 -		75BB5C6C241EA8C300D75403 /* SDL_sysjoystick_c.h in Headers */ = {isa = PBXBuildFile; fileRef = 75BB5C65241EA8C300D75403 /* SDL_sysjoystick_c.h */; };
    1.14 +		75BB5C66241EA8C300D75403 /* SDL_virtualjoystick.c in Sources */ = {isa = PBXBuildFile; fileRef = 75BB5C64241EA8C300D75403 /* SDL_virtualjoystick.c */; };
    1.15 +		75BB5C67241EA8C300D75403 /* SDL_virtualjoystick.c in Sources */ = {isa = PBXBuildFile; fileRef = 75BB5C64241EA8C300D75403 /* SDL_virtualjoystick.c */; };
    1.16 +		75BB5C68241EA8C300D75403 /* SDL_virtualjoystick.c in Sources */ = {isa = PBXBuildFile; fileRef = 75BB5C64241EA8C300D75403 /* SDL_virtualjoystick.c */; };
    1.17 +		75BB5C69241EA8C300D75403 /* SDL_virtualjoystick.c in Sources */ = {isa = PBXBuildFile; fileRef = 75BB5C64241EA8C300D75403 /* SDL_virtualjoystick.c */; };
    1.18 +		75BB5C6A241EA8C300D75403 /* SDL_virtualjoystick_c.h in Headers */ = {isa = PBXBuildFile; fileRef = 75BB5C65241EA8C300D75403 /* SDL_virtualjoystick_c.h */; };
    1.19 +		75BB5C6B241EA8C300D75403 /* SDL_virtualjoystick_c.h in Headers */ = {isa = PBXBuildFile; fileRef = 75BB5C65241EA8C300D75403 /* SDL_virtualjoystick_c.h */; };
    1.20 +		75BB5C6C241EA8C300D75403 /* SDL_virtualjoystick_c.h in Headers */ = {isa = PBXBuildFile; fileRef = 75BB5C65241EA8C300D75403 /* SDL_virtualjoystick_c.h */; };
    1.21  		93CB792313FC5E5200BD3E05 /* SDL_uikitviewcontroller.h in Headers */ = {isa = PBXBuildFile; fileRef = 93CB792213FC5E5200BD3E05 /* SDL_uikitviewcontroller.h */; };
    1.22  		93CB792613FC5F5300BD3E05 /* SDL_uikitviewcontroller.m in Sources */ = {isa = PBXBuildFile; fileRef = 93CB792513FC5F5300BD3E05 /* SDL_uikitviewcontroller.m */; };
    1.23  		A704172E20F7E74800A82227 /* controller_type.h in Headers */ = {isa = PBXBuildFile; fileRef = A704172D20F7E74800A82227 /* controller_type.h */; };
    1.24 @@ -994,8 +994,8 @@
    1.25  		56ED04E0118A8EE200A56AA6 /* SDL_power.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_power.c; sourceTree = "<group>"; };
    1.26  		56ED04E2118A8EFD00A56AA6 /* SDL_syspower.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SDL_syspower.m; sourceTree = "<group>"; };
    1.27  		63CC93C623849391002A5C54 /* SDL_strtokr.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_strtokr.c; sourceTree = "<group>"; };
    1.28 -		75BB5C64241EA8C300D75403 /* SDL_sysjoystick.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_sysjoystick.c; sourceTree = "<group>"; };
    1.29 -		75BB5C65241EA8C300D75403 /* SDL_sysjoystick_c.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_sysjoystick_c.h; sourceTree = "<group>"; };
    1.30 +		75BB5C64241EA8C300D75403 /* SDL_virtualjoystick.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_virtualjoystick.c; sourceTree = "<group>"; };
    1.31 +		75BB5C65241EA8C300D75403 /* SDL_virtualjoystick_c.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_virtualjoystick_c.h; sourceTree = "<group>"; };
    1.32  		93CB792213FC5E5200BD3E05 /* SDL_uikitviewcontroller.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_uikitviewcontroller.h; sourceTree = "<group>"; };
    1.33  		93CB792513FC5F5300BD3E05 /* SDL_uikitviewcontroller.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SDL_uikitviewcontroller.m; sourceTree = "<group>"; };
    1.34  		A704172D20F7E74800A82227 /* controller_type.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = controller_type.h; sourceTree = "<group>"; };
    1.35 @@ -1433,8 +1433,8 @@
    1.36  		75BB5C63241EA8C300D75403 /* virtual */ = {
    1.37  			isa = PBXGroup;
    1.38  			children = (
    1.39 -				75BB5C64241EA8C300D75403 /* SDL_sysjoystick.c */,
    1.40 -				75BB5C65241EA8C300D75403 /* SDL_sysjoystick_c.h */,
    1.41 +				75BB5C64241EA8C300D75403 /* SDL_virtualjoystick.c */,
    1.42 +				75BB5C65241EA8C300D75403 /* SDL_virtualjoystick_c.h */,
    1.43  			);
    1.44  			path = virtual;
    1.45  			sourceTree = "<group>";
    1.46 @@ -2004,7 +2004,7 @@
    1.47  				52ED1DC6222889500061FCE0 /* SDL_pixels.h in Headers */,
    1.48  				52ED1DC7222889500061FCE0 /* SDL_platform.h in Headers */,
    1.49  				52ED1DC8222889500061FCE0 /* SDL_power.h in Headers */,
    1.50 -				75BB5C6B241EA8C300D75403 /* SDL_sysjoystick_c.h in Headers */,
    1.51 +				75BB5C6B241EA8C300D75403 /* SDL_virtualjoystick_c.h in Headers */,
    1.52  				52ED1DC9222889500061FCE0 /* SDL_quit.h in Headers */,
    1.53  				52ED1DCA222889500061FCE0 /* SDL_rect.h in Headers */,
    1.54  				52ED1DCB222889500061FCE0 /* SDL_render.h in Headers */,
    1.55 @@ -2142,7 +2142,7 @@
    1.56  				F3E3C6B42241389A007D243C /* SDL_pixels.h in Headers */,
    1.57  				F3E3C6B52241389A007D243C /* SDL_platform.h in Headers */,
    1.58  				F3E3C6B62241389A007D243C /* SDL_power.h in Headers */,
    1.59 -				75BB5C6C241EA8C300D75403 /* SDL_sysjoystick_c.h in Headers */,
    1.60 +				75BB5C6C241EA8C300D75403 /* SDL_virtualjoystick_c.h in Headers */,
    1.61  				F3E3C6B72241389A007D243C /* SDL_quit.h in Headers */,
    1.62  				F3E3C6B82241389A007D243C /* SDL_rect.h in Headers */,
    1.63  				F3E3C6B92241389A007D243C /* SDL_render.h in Headers */,
    1.64 @@ -2220,7 +2220,7 @@
    1.65  				04BA9D6511EF474A00B60E01 /* SDL_touch_c.h in Headers */,
    1.66  				041B2CF212FA0F680087D585 /* SDL_sysrender.h in Headers */,
    1.67  				04409BA812FA989600FB9AA8 /* SDL_yuv_sw_c.h in Headers */,
    1.68 -				75BB5C6A241EA8C300D75403 /* SDL_sysjoystick_c.h in Headers */,
    1.69 +				75BB5C6A241EA8C300D75403 /* SDL_virtualjoystick_c.h in Headers */,
    1.70  				AA13B3591FB8B46400D9FEE6 /* yuv_rgb.h in Headers */,
    1.71  				04F7807712FB751400FC43C0 /* SDL_blendfillrect.h in Headers */,
    1.72  				04F7807912FB751400FC43C0 /* SDL_blendline.h in Headers */,
    1.73 @@ -2533,7 +2533,7 @@
    1.74  				52ED1DF7222889500061FCE0 /* SDL_dynapi.c in Sources */,
    1.75  				52ED1DF8222889500061FCE0 /* SDL_mouse.c in Sources */,
    1.76  				52ED1DF9222889500061FCE0 /* SDL_quit.c in Sources */,
    1.77 -				75BB5C67241EA8C300D75403 /* SDL_sysjoystick.c in Sources */,
    1.78 +				75BB5C67241EA8C300D75403 /* SDL_virtualjoystick.c in Sources */,
    1.79  				52ED1DFA222889500061FCE0 /* SDL_windowevents.c in Sources */,
    1.80  				52ED1DFB222889500061FCE0 /* SDL_uikitmetalview.m in Sources */,
    1.81  				52ED1DFC222889500061FCE0 /* SDL_rwops.c in Sources */,
    1.82 @@ -2667,7 +2667,7 @@
    1.83  				F3E3C6E52241389A007D243C /* SDL_dynapi.c in Sources */,
    1.84  				F3E3C6E62241389A007D243C /* SDL_mouse.c in Sources */,
    1.85  				F3E3C6E72241389A007D243C /* SDL_quit.c in Sources */,
    1.86 -				75BB5C69241EA8C300D75403 /* SDL_sysjoystick.c in Sources */,
    1.87 +				75BB5C69241EA8C300D75403 /* SDL_virtualjoystick.c in Sources */,
    1.88  				F3E3C6E82241389A007D243C /* SDL_windowevents.c in Sources */,
    1.89  				F3E3C6E92241389A007D243C /* SDL_uikitmetalview.m in Sources */,
    1.90  				F3E3C6EA2241389A007D243C /* SDL_rwops.c in Sources */,
    1.91 @@ -2843,7 +2843,7 @@
    1.92  				FAB5986D1BB5C31600BE72C5 /* SDL_render.c in Sources */,
    1.93  				FAB598711BB5C31600BE72C5 /* SDL_yuv_sw.c in Sources */,
    1.94  				FAB598721BB5C31600BE72C5 /* SDL_getenv.c in Sources */,
    1.95 -				75BB5C68241EA8C300D75403 /* SDL_sysjoystick.c in Sources */,
    1.96 +				75BB5C68241EA8C300D75403 /* SDL_virtualjoystick.c in Sources */,
    1.97  				FAB598731BB5C31600BE72C5 /* SDL_iconv.c in Sources */,
    1.98  				FAB598741BB5C31600BE72C5 /* SDL_malloc.c in Sources */,
    1.99  				FAB598751BB5C31600BE72C5 /* SDL_qsort.c in Sources */,
   1.100 @@ -2925,7 +2925,7 @@
   1.101  				56A6703718565E760007D20F /* SDL_dynapi.c in Sources */,
   1.102  				FD6526730DE8FCDD002AD96B /* SDL_mouse.c in Sources */,
   1.103  				FD6526740DE8FCDD002AD96B /* SDL_quit.c in Sources */,
   1.104 -				75BB5C66241EA8C300D75403 /* SDL_sysjoystick.c in Sources */,
   1.105 +				75BB5C66241EA8C300D75403 /* SDL_virtualjoystick.c in Sources */,
   1.106  				FD6526750DE8FCDD002AD96B /* SDL_windowevents.c in Sources */,
   1.107  				4D7516FB1EE1C28A00820EEA /* SDL_uikitmetalview.m in Sources */,
   1.108  				FD6526760DE8FCDD002AD96B /* SDL_rwops.c in Sources */,
     2.1 --- a/Xcode/SDL/SDL.xcodeproj/project.pbxproj	Sun Mar 15 14:40:51 2020 -0400
     2.2 +++ b/Xcode/SDL/SDL.xcodeproj/project.pbxproj	Sun Mar 15 15:05:36 2020 -0400
     2.3 @@ -21,24 +21,24 @@
     2.4  		56C5237F1D8F4985001F2F30 /* CoreAudio.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A7381E951D8B69D600B177DD /* CoreAudio.framework */; };
     2.5  		56C523811D8F498C001F2F30 /* CoreFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 00D0D08310675DD9004B05EF /* CoreFoundation.framework */; };
     2.6  		5C2EF7011FC9EF10003F5197 /* SDL_egl.h in Headers */ = {isa = PBXBuildFile; fileRef = 5C2EF7001FC9EF0F003F5197 /* SDL_egl.h */; };
     2.7 -		75E0915A241EA924004729E1 /* SDL_sysjoystick.c in Sources */ = {isa = PBXBuildFile; fileRef = 75E09158241EA924004729E1 /* SDL_sysjoystick.c */; };
     2.8 -		75E0915B241EA924004729E1 /* SDL_sysjoystick.c in Sources */ = {isa = PBXBuildFile; fileRef = 75E09158241EA924004729E1 /* SDL_sysjoystick.c */; };
     2.9 -		75E0915C241EA924004729E1 /* SDL_sysjoystick.c in Sources */ = {isa = PBXBuildFile; fileRef = 75E09158241EA924004729E1 /* SDL_sysjoystick.c */; };
    2.10 -		75E0915D241EA924004729E1 /* SDL_sysjoystick.c in Sources */ = {isa = PBXBuildFile; fileRef = 75E09158241EA924004729E1 /* SDL_sysjoystick.c */; };
    2.11 -		75E0915E241EA924004729E1 /* SDL_sysjoystick.c in Sources */ = {isa = PBXBuildFile; fileRef = 75E09158241EA924004729E1 /* SDL_sysjoystick.c */; };
    2.12 -		75E0915F241EA924004729E1 /* SDL_sysjoystick.c in Sources */ = {isa = PBXBuildFile; fileRef = 75E09158241EA924004729E1 /* SDL_sysjoystick.c */; };
    2.13 -		75E09160241EA924004729E1 /* SDL_sysjoystick.c in Sources */ = {isa = PBXBuildFile; fileRef = 75E09158241EA924004729E1 /* SDL_sysjoystick.c */; };
    2.14 -		75E09161241EA924004729E1 /* SDL_sysjoystick.c in Sources */ = {isa = PBXBuildFile; fileRef = 75E09158241EA924004729E1 /* SDL_sysjoystick.c */; };
    2.15 -		75E09162241EA924004729E1 /* SDL_sysjoystick.c in Sources */ = {isa = PBXBuildFile; fileRef = 75E09158241EA924004729E1 /* SDL_sysjoystick.c */; };
    2.16 -		75E09163241EA924004729E1 /* SDL_sysjoystick_c.h in Headers */ = {isa = PBXBuildFile; fileRef = 75E09159241EA924004729E1 /* SDL_sysjoystick_c.h */; };
    2.17 -		75E09164241EA924004729E1 /* SDL_sysjoystick_c.h in Headers */ = {isa = PBXBuildFile; fileRef = 75E09159241EA924004729E1 /* SDL_sysjoystick_c.h */; };
    2.18 -		75E09165241EA924004729E1 /* SDL_sysjoystick_c.h in Headers */ = {isa = PBXBuildFile; fileRef = 75E09159241EA924004729E1 /* SDL_sysjoystick_c.h */; };
    2.19 -		75E09166241EA924004729E1 /* SDL_sysjoystick_c.h in Headers */ = {isa = PBXBuildFile; fileRef = 75E09159241EA924004729E1 /* SDL_sysjoystick_c.h */; };
    2.20 -		75E09167241EA924004729E1 /* SDL_sysjoystick_c.h in Headers */ = {isa = PBXBuildFile; fileRef = 75E09159241EA924004729E1 /* SDL_sysjoystick_c.h */; };
    2.21 -		75E09168241EA924004729E1 /* SDL_sysjoystick_c.h in Headers */ = {isa = PBXBuildFile; fileRef = 75E09159241EA924004729E1 /* SDL_sysjoystick_c.h */; };
    2.22 -		75E09169241EA924004729E1 /* SDL_sysjoystick_c.h in Headers */ = {isa = PBXBuildFile; fileRef = 75E09159241EA924004729E1 /* SDL_sysjoystick_c.h */; };
    2.23 -		75E0916A241EA924004729E1 /* SDL_sysjoystick_c.h in Headers */ = {isa = PBXBuildFile; fileRef = 75E09159241EA924004729E1 /* SDL_sysjoystick_c.h */; };
    2.24 -		75E0916B241EA924004729E1 /* SDL_sysjoystick_c.h in Headers */ = {isa = PBXBuildFile; fileRef = 75E09159241EA924004729E1 /* SDL_sysjoystick_c.h */; };
    2.25 +		75E0915A241EA924004729E1 /* SDL_virtualjoystick.c in Sources */ = {isa = PBXBuildFile; fileRef = 75E09158241EA924004729E1 /* SDL_virtualjoystick.c */; };
    2.26 +		75E0915B241EA924004729E1 /* SDL_virtualjoystick.c in Sources */ = {isa = PBXBuildFile; fileRef = 75E09158241EA924004729E1 /* SDL_virtualjoystick.c */; };
    2.27 +		75E0915C241EA924004729E1 /* SDL_virtualjoystick.c in Sources */ = {isa = PBXBuildFile; fileRef = 75E09158241EA924004729E1 /* SDL_virtualjoystick.c */; };
    2.28 +		75E0915D241EA924004729E1 /* SDL_virtualjoystick.c in Sources */ = {isa = PBXBuildFile; fileRef = 75E09158241EA924004729E1 /* SDL_virtualjoystick.c */; };
    2.29 +		75E0915E241EA924004729E1 /* SDL_virtualjoystick.c in Sources */ = {isa = PBXBuildFile; fileRef = 75E09158241EA924004729E1 /* SDL_virtualjoystick.c */; };
    2.30 +		75E0915F241EA924004729E1 /* SDL_virtualjoystick.c in Sources */ = {isa = PBXBuildFile; fileRef = 75E09158241EA924004729E1 /* SDL_virtualjoystick.c */; };
    2.31 +		75E09160241EA924004729E1 /* SDL_virtualjoystick.c in Sources */ = {isa = PBXBuildFile; fileRef = 75E09158241EA924004729E1 /* SDL_virtualjoystick.c */; };
    2.32 +		75E09161241EA924004729E1 /* SDL_virtualjoystick.c in Sources */ = {isa = PBXBuildFile; fileRef = 75E09158241EA924004729E1 /* SDL_virtualjoystick.c */; };
    2.33 +		75E09162241EA924004729E1 /* SDL_virtualjoystick.c in Sources */ = {isa = PBXBuildFile; fileRef = 75E09158241EA924004729E1 /* SDL_virtualjoystick.c */; };
    2.34 +		75E09163241EA924004729E1 /* SDL_virtualjoystick_c.h in Headers */ = {isa = PBXBuildFile; fileRef = 75E09159241EA924004729E1 /* SDL_virtualjoystick_c.h */; };
    2.35 +		75E09164241EA924004729E1 /* SDL_virtualjoystick_c.h in Headers */ = {isa = PBXBuildFile; fileRef = 75E09159241EA924004729E1 /* SDL_virtualjoystick_c.h */; };
    2.36 +		75E09165241EA924004729E1 /* SDL_virtualjoystick_c.h in Headers */ = {isa = PBXBuildFile; fileRef = 75E09159241EA924004729E1 /* SDL_virtualjoystick_c.h */; };
    2.37 +		75E09166241EA924004729E1 /* SDL_virtualjoystick_c.h in Headers */ = {isa = PBXBuildFile; fileRef = 75E09159241EA924004729E1 /* SDL_virtualjoystick_c.h */; };
    2.38 +		75E09167241EA924004729E1 /* SDL_virtualjoystick_c.h in Headers */ = {isa = PBXBuildFile; fileRef = 75E09159241EA924004729E1 /* SDL_virtualjoystick_c.h */; };
    2.39 +		75E09168241EA924004729E1 /* SDL_virtualjoystick_c.h in Headers */ = {isa = PBXBuildFile; fileRef = 75E09159241EA924004729E1 /* SDL_virtualjoystick_c.h */; };
    2.40 +		75E09169241EA924004729E1 /* SDL_virtualjoystick_c.h in Headers */ = {isa = PBXBuildFile; fileRef = 75E09159241EA924004729E1 /* SDL_virtualjoystick_c.h */; };
    2.41 +		75E0916A241EA924004729E1 /* SDL_virtualjoystick_c.h in Headers */ = {isa = PBXBuildFile; fileRef = 75E09159241EA924004729E1 /* SDL_virtualjoystick_c.h */; };
    2.42 +		75E0916B241EA924004729E1 /* SDL_virtualjoystick_c.h in Headers */ = {isa = PBXBuildFile; fileRef = 75E09159241EA924004729E1 /* SDL_virtualjoystick_c.h */; };
    2.43  		A7381E961D8B69D600B177DD /* CoreAudio.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A7381E951D8B69D600B177DD /* CoreAudio.framework */; };
    2.44  		A7381E971D8B6A0300B177DD /* AudioToolbox.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A7381E931D8B69C300B177DD /* AudioToolbox.framework */; };
    2.45  		A75FCCFD23E25AB700529352 /* SDL_shaders_metal_tvos.h in Headers */ = {isa = PBXBuildFile; fileRef = A7D8A8E323E2514000DCD162 /* SDL_shaders_metal_tvos.h */; };
    2.46 @@ -3991,8 +3991,8 @@
    2.47  		564624371FF821CB0074AC87 /* Metal.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Metal.framework; path = System/Library/Frameworks/Metal.framework; sourceTree = SDKROOT; };
    2.48  		567E2F2017C44C35005F1892 /* SDL_filesystem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_filesystem.h; sourceTree = "<group>"; };
    2.49  		5C2EF7001FC9EF0F003F5197 /* SDL_egl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_egl.h; sourceTree = "<group>"; };
    2.50 -		75E09158241EA924004729E1 /* SDL_sysjoystick.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_sysjoystick.c; sourceTree = "<group>"; };
    2.51 -		75E09159241EA924004729E1 /* SDL_sysjoystick_c.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_sysjoystick_c.h; sourceTree = "<group>"; };
    2.52 +		75E09158241EA924004729E1 /* SDL_virtualjoystick.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_virtualjoystick.c; sourceTree = "<group>"; };
    2.53 +		75E09159241EA924004729E1 /* SDL_virtualjoystick_c.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_virtualjoystick_c.h; sourceTree = "<group>"; };
    2.54  		A7381E931D8B69C300B177DD /* AudioToolbox.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AudioToolbox.framework; path = System/Library/Frameworks/AudioToolbox.framework; sourceTree = SDKROOT; };
    2.55  		A7381E951D8B69D600B177DD /* CoreAudio.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreAudio.framework; path = System/Library/Frameworks/CoreAudio.framework; sourceTree = SDKROOT; };
    2.56  		A75FCEB323E25AB700529352 /* libSDL2.dylib */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.dylib"; includeInIndex = 0; path = libSDL2.dylib; sourceTree = BUILT_PRODUCTS_DIR; };
    2.57 @@ -4837,8 +4837,8 @@
    2.58  		75E09157241EA924004729E1 /* virtual */ = {
    2.59  			isa = PBXGroup;
    2.60  			children = (
    2.61 -				75E09158241EA924004729E1 /* SDL_sysjoystick.c */,
    2.62 -				75E09159241EA924004729E1 /* SDL_sysjoystick_c.h */,
    2.63 +				75E09158241EA924004729E1 /* SDL_virtualjoystick.c */,
    2.64 +				75E09159241EA924004729E1 /* SDL_virtualjoystick_c.h */,
    2.65  			);
    2.66  			path = virtual;
    2.67  			sourceTree = "<group>";
    2.68 @@ -5877,7 +5877,7 @@
    2.69  				A75FCDA923E25AB700529352 /* SDL_render.h in Headers */,
    2.70  				A75FCDAA23E25AB700529352 /* SDL_nullvideo.h in Headers */,
    2.71  				A75FCDAB23E25AB700529352 /* SDL_blit_copy.h in Headers */,
    2.72 -				75E0916A241EA924004729E1 /* SDL_sysjoystick_c.h in Headers */,
    2.73 +				75E0916A241EA924004729E1 /* SDL_virtualjoystick_c.h in Headers */,
    2.74  				A75FCDAC23E25AB700529352 /* SDL_RLEaccel_c.h in Headers */,
    2.75  				A75FCDAD23E25AB700529352 /* eglplatform.h in Headers */,
    2.76  				A75FCDAE23E25AB700529352 /* edid.h in Headers */,
    2.77 @@ -6118,7 +6118,7 @@
    2.78  				A75FCF6223E25AC700529352 /* SDL_render.h in Headers */,
    2.79  				A75FCF6323E25AC700529352 /* SDL_nullvideo.h in Headers */,
    2.80  				A75FCF6423E25AC700529352 /* SDL_blit_copy.h in Headers */,
    2.81 -				75E0916B241EA924004729E1 /* SDL_sysjoystick_c.h in Headers */,
    2.82 +				75E0916B241EA924004729E1 /* SDL_virtualjoystick_c.h in Headers */,
    2.83  				A75FCF6523E25AC700529352 /* SDL_RLEaccel_c.h in Headers */,
    2.84  				A75FCF6623E25AC700529352 /* eglplatform.h in Headers */,
    2.85  				A75FCF6723E25AC700529352 /* edid.h in Headers */,
    2.86 @@ -6383,7 +6383,7 @@
    2.87  				A769B13223E259AE00872273 /* SDL_nullvideo.h in Headers */,
    2.88  				A769B13323E259AE00872273 /* SDL_blit_copy.h in Headers */,
    2.89  				A769B13423E259AE00872273 /* SDL_RLEaccel_c.h in Headers */,
    2.90 -				75E09168241EA924004729E1 /* SDL_sysjoystick_c.h in Headers */,
    2.91 +				75E09168241EA924004729E1 /* SDL_virtualjoystick_c.h in Headers */,
    2.92  				A769B13523E259AE00872273 /* eglplatform.h in Headers */,
    2.93  				A769B13623E259AE00872273 /* edid.h in Headers */,
    2.94  				A769B13723E259AE00872273 /* SDL_revision.h in Headers */,
    2.95 @@ -6588,7 +6588,7 @@
    2.96  				A7D8BA7423E2514400DCD162 /* SDL_shaders_gl.h in Headers */,
    2.97  				A7D8AC4623E2514100DCD162 /* SDL_uikitview.h in Headers */,
    2.98  				A7D88A3D23E2437C00DCD162 /* SDL_opengl.h in Headers */,
    2.99 -				75E09164241EA924004729E1 /* SDL_sysjoystick_c.h in Headers */,
   2.100 +				75E09164241EA924004729E1 /* SDL_virtualjoystick_c.h in Headers */,
   2.101  				A7D8AC0423E2514100DCD162 /* SDL_rect_c.h in Headers */,
   2.102  				A7D8A97C23E2514000DCD162 /* SDL_syssensor.h in Headers */,
   2.103  				A7D88A3E23E2437C00DCD162 /* SDL_opengl_glext.h in Headers */,
   2.104 @@ -6832,7 +6832,7 @@
   2.105  				A7D8AF1423E2514100DCD162 /* SDL_cocoaevents.h in Headers */,
   2.106  				A7D8BA7523E2514400DCD162 /* SDL_shaders_gl.h in Headers */,
   2.107  				A7D8AC4723E2514100DCD162 /* SDL_uikitview.h in Headers */,
   2.108 -				75E09165241EA924004729E1 /* SDL_sysjoystick_c.h in Headers */,
   2.109 +				75E09165241EA924004729E1 /* SDL_virtualjoystick_c.h in Headers */,
   2.110  				A7D88BF623E24BED00DCD162 /* SDL_opengl.h in Headers */,
   2.111  				A7D8AC0523E2514100DCD162 /* SDL_rect_c.h in Headers */,
   2.112  				A7D8A97D23E2514000DCD162 /* SDL_syssensor.h in Headers */,
   2.113 @@ -7112,7 +7112,7 @@
   2.114  				A7D8ABFB23E2514100DCD162 /* SDL_nullvideo.h in Headers */,
   2.115  				A7D8B39C23E2514200DCD162 /* SDL_blit_copy.h in Headers */,
   2.116  				A7D8B3A223E2514200DCD162 /* SDL_RLEaccel_c.h in Headers */,
   2.117 -				75E09167241EA924004729E1 /* SDL_sysjoystick_c.h in Headers */,
   2.118 +				75E09167241EA924004729E1 /* SDL_virtualjoystick_c.h in Headers */,
   2.119  				A7D8B24C23E2514200DCD162 /* eglplatform.h in Headers */,
   2.120  				A7D8B1DA23E2514200DCD162 /* edid.h in Headers */,
   2.121  				A7D88D4423E24D3B00DCD162 /* SDL_revision.h in Headers */,
   2.122 @@ -7291,7 +7291,7 @@
   2.123  				AA7558261595D4D800BBD41B /* SDL_log.h in Headers */,
   2.124  				A7D8BB4B23E2514500DCD162 /* default_cursor.h in Headers */,
   2.125  				A7D8AEB223E2514100DCD162 /* SDL_cocoametalview.h in Headers */,
   2.126 -				75E09163241EA924004729E1 /* SDL_sysjoystick_c.h in Headers */,
   2.127 +				75E09163241EA924004729E1 /* SDL_virtualjoystick_c.h in Headers */,
   2.128  				A7D8B3D423E2514300DCD162 /* yuv_rgb.h in Headers */,
   2.129  				A7D8B1D023E2514200DCD162 /* SDL_x11xinput2.h in Headers */,
   2.130  				A7D8B25423E2514200DCD162 /* vk_icd.h in Headers */,
   2.131 @@ -7433,7 +7433,7 @@
   2.132  				AA7558011595D4D800BBD41B /* SDL_atomic.h in Headers */,
   2.133  				A7D8AC0623E2514100DCD162 /* SDL_rect_c.h in Headers */,
   2.134  				A7D8B1D323E2514200DCD162 /* SDL_x11xinput2.h in Headers */,
   2.135 -				75E09166241EA924004729E1 /* SDL_sysjoystick_c.h in Headers */,
   2.136 +				75E09166241EA924004729E1 /* SDL_virtualjoystick_c.h in Headers */,
   2.137  				A7D8B99E23E2514400DCD162 /* SDL_shaders_metal_osx.h in Headers */,
   2.138  				A7D8B98F23E2514400DCD162 /* SDL_shaders_metal_ios.h in Headers */,
   2.139  				A7D8AB8823E2514100DCD162 /* SDL_offscreenwindow.h in Headers */,
   2.140 @@ -7673,7 +7673,7 @@
   2.141  				A7D8AC0E23E2514100DCD162 /* SDL_shape_internals.h in Headers */,
   2.142  				A7D8BA7E23E2514400DCD162 /* SDL_glfuncs.h in Headers */,
   2.143  				DB313FCB17554B71006C0E22 /* SDL_atomic.h in Headers */,
   2.144 -				75E09169241EA924004729E1 /* SDL_sysjoystick_c.h in Headers */,
   2.145 +				75E09169241EA924004729E1 /* SDL_virtualjoystick_c.h in Headers */,
   2.146  				A7D8AC0823E2514100DCD162 /* SDL_rect_c.h in Headers */,
   2.147  				A7D8B1D523E2514200DCD162 /* SDL_x11xinput2.h in Headers */,
   2.148  				A7D8B9A023E2514400DCD162 /* SDL_shaders_metal_osx.h in Headers */,
   2.149 @@ -8388,7 +8388,7 @@
   2.150  				A75FCE2023E25AB700529352 /* SDL_haptic.c in Sources */,
   2.151  				A75FCE2123E25AB700529352 /* SDL_uikitvulkan.m in Sources */,
   2.152  				A75FCE2223E25AB700529352 /* SDL_x11modes.c in Sources */,
   2.153 -				75E09161241EA924004729E1 /* SDL_sysjoystick.c in Sources */,
   2.154 +				75E09161241EA924004729E1 /* SDL_virtualjoystick.c in Sources */,
   2.155  				A75FCE2323E25AB700529352 /* SDL_cocoametalview.m in Sources */,
   2.156  				A75FCE2423E25AB700529352 /* SDL_audiotypecvt.c in Sources */,
   2.157  				A75FCE2523E25AB700529352 /* SDL_uikitevents.m in Sources */,
   2.158 @@ -8584,7 +8584,7 @@
   2.159  				A75FCFD923E25AC700529352 /* SDL_haptic.c in Sources */,
   2.160  				A75FCFDA23E25AC700529352 /* SDL_uikitvulkan.m in Sources */,
   2.161  				A75FCFDB23E25AC700529352 /* SDL_x11modes.c in Sources */,
   2.162 -				75E09162241EA924004729E1 /* SDL_sysjoystick.c in Sources */,
   2.163 +				75E09162241EA924004729E1 /* SDL_virtualjoystick.c in Sources */,
   2.164  				A75FCFDC23E25AC700529352 /* SDL_cocoametalview.m in Sources */,
   2.165  				A75FCFDD23E25AC700529352 /* SDL_audiotypecvt.c in Sources */,
   2.166  				A75FCFDE23E25AC700529352 /* SDL_uikitevents.m in Sources */,
   2.167 @@ -8863,7 +8863,7 @@
   2.168  				A769B1E523E259AE00872273 /* SDL_RLEaccel.c in Sources */,
   2.169  				A769B1E723E259AE00872273 /* SDL_assert.c in Sources */,
   2.170  				A769B1E823E259AE00872273 /* SDL_bmp.c in Sources */,
   2.171 -				75E0915F241EA924004729E1 /* SDL_sysjoystick.c in Sources */,
   2.172 +				75E0915F241EA924004729E1 /* SDL_virtualjoystick.c in Sources */,
   2.173  				A769B1E923E259AE00872273 /* SDL_uikit_main.c in Sources */,
   2.174  				A769B1EA23E259AE00872273 /* SDL_stdlib.c in Sources */,
   2.175  				A769B1EB23E259AE00872273 /* SDL_dummyaudio.c in Sources */,
   2.176 @@ -8952,7 +8952,7 @@
   2.177  				A7D8B75323E2514300DCD162 /* SDL_sysloadso.c in Sources */,
   2.178  				A7D8B98723E2514400DCD162 /* SDL_render_metal.m in Sources */,
   2.179  				A7D8AE7723E2514100DCD162 /* SDL_clipboard.c in Sources */,
   2.180 -				75E0915B241EA924004729E1 /* SDL_sysjoystick.c in Sources */,
   2.181 +				75E0915B241EA924004729E1 /* SDL_virtualjoystick.c in Sources */,
   2.182  				A7D8AEC523E2514100DCD162 /* SDL_cocoaevents.m in Sources */,
   2.183  				A7D8B1BF23E2514200DCD162 /* SDL_x11messagebox.c in Sources */,
   2.184  				A7D8B86723E2514400DCD162 /* SDL_audiocvt.c in Sources */,
   2.185 @@ -9147,7 +9147,7 @@
   2.186  				A7D8B75423E2514300DCD162 /* SDL_sysloadso.c in Sources */,
   2.187  				A7D8B98823E2514400DCD162 /* SDL_render_metal.m in Sources */,
   2.188  				A7D8AE7823E2514100DCD162 /* SDL_clipboard.c in Sources */,
   2.189 -				75E0915C241EA924004729E1 /* SDL_sysjoystick.c in Sources */,
   2.190 +				75E0915C241EA924004729E1 /* SDL_virtualjoystick.c in Sources */,
   2.191  				A7D8AEC623E2514100DCD162 /* SDL_cocoaevents.m in Sources */,
   2.192  				A7D8B1C023E2514200DCD162 /* SDL_x11messagebox.c in Sources */,
   2.193  				A7D8B86823E2514400DCD162 /* SDL_audiocvt.c in Sources */,
   2.194 @@ -9450,7 +9450,7 @@
   2.195  				A7D8AC3723E2514100DCD162 /* SDL_RLEaccel.c in Sources */,
   2.196  				A7D8BBB523E2514500DCD162 /* SDL_assert.c in Sources */,
   2.197  				A7D8B3DE23E2514300DCD162 /* SDL_bmp.c in Sources */,
   2.198 -				75E0915E241EA924004729E1 /* SDL_sysjoystick.c in Sources */,
   2.199 +				75E0915E241EA924004729E1 /* SDL_virtualjoystick.c in Sources */,
   2.200  				A7D8BC0723E2590800DCD162 /* SDL_uikit_main.c in Sources */,
   2.201  				A7D8B97223E2514400DCD162 /* SDL_stdlib.c in Sources */,
   2.202  				A7D8B79E23E2514400DCD162 /* SDL_dummyaudio.c in Sources */,
   2.203 @@ -9579,7 +9579,7 @@
   2.204  				A7D8BBDD23E2574800DCD162 /* SDL_uikitmodes.m in Sources */,
   2.205  				A7D8BA3723E2514400DCD162 /* SDL_d3dmath.c in Sources */,
   2.206  				A7D8B17623E2514200DCD162 /* SDL_x11mouse.c in Sources */,
   2.207 -				75E0915A241EA924004729E1 /* SDL_sysjoystick.c in Sources */,
   2.208 +				75E0915A241EA924004729E1 /* SDL_virtualjoystick.c in Sources */,
   2.209  				A7D8ABEB23E2514100DCD162 /* SDL_nullvideo.c in Sources */,
   2.210  				A7D8AB6723E2514100DCD162 /* SDL_offscreenevents.c in Sources */,
   2.211  				A7D8ABF123E2514100DCD162 /* SDL_nullevents.c in Sources */,
   2.212 @@ -9841,7 +9841,7 @@
   2.213  				A7D8B97123E2514400DCD162 /* SDL_stdlib.c in Sources */,
   2.214  				A7D8B79D23E2514400DCD162 /* SDL_dummyaudio.c in Sources */,
   2.215  				A7D8B3A723E2514200DCD162 /* SDL_fillrect.c in Sources */,
   2.216 -				75E0915D241EA924004729E1 /* SDL_sysjoystick.c in Sources */,
   2.217 +				75E0915D241EA924004729E1 /* SDL_virtualjoystick.c in Sources */,
   2.218  				A7D8ABE223E2514100DCD162 /* SDL_nullframebuffer.c in Sources */,
   2.219  				A7D8A96C23E2514000DCD162 /* SDL_dummysensor.c in Sources */,
   2.220  				A7D8B95F23E2514400DCD162 /* SDL_string.c in Sources */,
   2.221 @@ -10035,7 +10035,7 @@
   2.222  				A7D8B97323E2514400DCD162 /* SDL_stdlib.c in Sources */,
   2.223  				A7D8B79F23E2514400DCD162 /* SDL_dummyaudio.c in Sources */,
   2.224  				A7D8B3A923E2514200DCD162 /* SDL_fillrect.c in Sources */,
   2.225 -				75E09160241EA924004729E1 /* SDL_sysjoystick.c in Sources */,
   2.226 +				75E09160241EA924004729E1 /* SDL_virtualjoystick.c in Sources */,
   2.227  				A7D8ABE423E2514100DCD162 /* SDL_nullframebuffer.c in Sources */,
   2.228  				A7D8A96E23E2514000DCD162 /* SDL_dummysensor.c in Sources */,
   2.229  				A7D8B96123E2514400DCD162 /* SDL_string.c in Sources */,
     3.1 --- a/src/joystick/SDL_joystick.c	Sun Mar 15 14:40:51 2020 -0400
     3.2 +++ b/src/joystick/SDL_joystick.c	Sun Mar 15 15:05:36 2020 -0400
     3.3 @@ -47,7 +47,7 @@
     3.4  #endif
     3.5  
     3.6  #if SDL_JOYSTICK_VIRTUAL
     3.7 -#include "./virtual/SDL_sysjoystick_c.h"
     3.8 +#include "./virtual/SDL_virtualjoystick_c.h"
     3.9  #endif
    3.10  
    3.11  static SDL_JoystickDriver *SDL_joystick_drivers[] = {
     4.1 --- a/src/joystick/virtual/SDL_sysjoystick.c	Sun Mar 15 14:40:51 2020 -0400
     4.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.3 @@ -1,413 +0,0 @@
     4.4 -/*
     4.5 -  Simple DirectMedia Layer
     4.6 -  Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
     4.7 -
     4.8 -  This software is provided 'as-is', without any express or implied
     4.9 -  warranty.  In no event will the authors be held liable for any damages
    4.10 -  arising from the use of this software.
    4.11 -
    4.12 -  Permission is granted to anyone to use this software for any purpose,
    4.13 -  including commercial applications, and to alter it and redistribute it
    4.14 -  freely, subject to the following restrictions:
    4.15 -
    4.16 -  1. The origin of this software must not be misrepresented; you must not
    4.17 -     claim that you wrote the original software. If you use this software
    4.18 -     in a product, an acknowledgment in the product documentation would be
    4.19 -     appreciated but is not required.
    4.20 -  2. Altered source versions must be plainly marked as such, and must not be
    4.21 -     misrepresented as being the original software.
    4.22 -  3. This notice may not be removed or altered from any source distribution.
    4.23 -*/
    4.24 -#include "../../SDL_internal.h"
    4.25 -
    4.26 -#if defined(SDL_JOYSTICK_VIRTUAL)
    4.27 -
    4.28 -/* This is the virtual implementation of the SDL joystick API */
    4.29 -
    4.30 -#include "SDL_sysjoystick_c.h"
    4.31 -#include "../SDL_sysjoystick.h"
    4.32 -#include "../SDL_joystick_c.h"
    4.33 -
    4.34 -extern SDL_JoystickDriver SDL_VIRTUAL_JoystickDriver;
    4.35 -
    4.36 -static joystick_hwdata * g_VJoys = NULL;
    4.37 -
    4.38 -
    4.39 -static joystick_hwdata *
    4.40 -VIRTUAL_HWDataForIndex(int device_index)
    4.41 -{
    4.42 -    joystick_hwdata *vjoy = g_VJoys;
    4.43 -    while (vjoy) {
    4.44 -        if (device_index == 0)
    4.45 -            break;
    4.46 -        --device_index;
    4.47 -        vjoy = vjoy->next;
    4.48 -    }
    4.49 -    return vjoy;
    4.50 -}
    4.51 -
    4.52 -
    4.53 -static void
    4.54 -VIRTUAL_FreeHWData(joystick_hwdata *hwdata)
    4.55 -{
    4.56 -    joystick_hwdata * cur = g_VJoys;
    4.57 -    joystick_hwdata * prev = NULL;
    4.58 - 
    4.59 -    if (!hwdata) {
    4.60 -        return;
    4.61 -    }
    4.62 -    if (hwdata->axes) {
    4.63 -        SDL_free((void *)hwdata->axes);
    4.64 -        hwdata->axes = NULL;
    4.65 -    }
    4.66 -    if (hwdata->buttons) {
    4.67 -        SDL_free((void *)hwdata->buttons);
    4.68 -        hwdata->buttons = NULL;
    4.69 -    }
    4.70 -    if (hwdata->hats) {
    4.71 -        SDL_free(hwdata->hats);
    4.72 -        hwdata->hats = NULL;
    4.73 -    }
    4.74 -
    4.75 -    /* Remove hwdata from SDL-global list */
    4.76 -    while (cur) {
    4.77 -        if (hwdata == cur) {
    4.78 -            if (prev) {
    4.79 -                prev->next = cur->next;
    4.80 -            } else {
    4.81 -                g_VJoys = cur->next;
    4.82 -            }
    4.83 -            break;
    4.84 -        }
    4.85 -        prev = cur;
    4.86 -        cur = cur->next;
    4.87 -    }
    4.88 -
    4.89 -    SDL_free(hwdata);
    4.90 -}
    4.91 -
    4.92 -
    4.93 -int
    4.94 -SDL_JoystickAttachVirtualInner(SDL_JoystickType type,
    4.95 -                               int naxes,
    4.96 -                               int nbuttons,
    4.97 -                               int nhats)
    4.98 -{
    4.99 -    joystick_hwdata *hwdata = NULL;
   4.100 -    int device_index = -1;
   4.101 -
   4.102 -    hwdata = SDL_calloc(1, sizeof(joystick_hwdata));
   4.103 -    if (!hwdata) {
   4.104 -        VIRTUAL_FreeHWData(hwdata);
   4.105 -        return SDL_OutOfMemory();
   4.106 -    }
   4.107 -
   4.108 -    hwdata->naxes = naxes;
   4.109 -    hwdata->nbuttons = nbuttons;
   4.110 -    hwdata->nhats = nhats;
   4.111 -    hwdata->name = "Virtual Joystick";
   4.112 -
   4.113 -    /* Note that this is a Virtual device and what subtype it is */
   4.114 -    hwdata->guid.data[14] = 'v';
   4.115 -    hwdata->guid.data[15] = (Uint8)type;
   4.116 -
   4.117 -    /* Allocate fields for different control-types */
   4.118 -    if (naxes > 0) {
   4.119 -        hwdata->axes = SDL_calloc(naxes, sizeof(Sint16));
   4.120 -        if (!hwdata->axes) {
   4.121 -            VIRTUAL_FreeHWData(hwdata);
   4.122 -            return SDL_OutOfMemory();
   4.123 -        }
   4.124 -    }
   4.125 -    if (nbuttons > 0) {
   4.126 -        hwdata->buttons = SDL_calloc(nbuttons, sizeof(Uint8));
   4.127 -        if (!hwdata->buttons) {
   4.128 -            VIRTUAL_FreeHWData(hwdata);
   4.129 -            return SDL_OutOfMemory();
   4.130 -        }
   4.131 -    }
   4.132 -    if (nhats > 0) {
   4.133 -        hwdata->hats = SDL_calloc(nhats, sizeof(Uint8));
   4.134 -        if (!hwdata->hats) {
   4.135 -            VIRTUAL_FreeHWData(hwdata);
   4.136 -            return SDL_OutOfMemory();
   4.137 -        }
   4.138 -    }
   4.139 -
   4.140 -    /* Allocate an instance ID for this device */
   4.141 -    hwdata->instance_id = SDL_GetNextJoystickInstanceID();
   4.142 -
   4.143 -    /* Add virtual joystick to SDL-global lists */
   4.144 -    hwdata->next = g_VJoys;
   4.145 -    g_VJoys = hwdata;
   4.146 -    SDL_PrivateJoystickAdded(hwdata->instance_id);
   4.147 -
   4.148 -    /* Return the new virtual-device's index */
   4.149 -    device_index = SDL_JoystickGetDeviceIndexFromInstanceID(hwdata->instance_id);
   4.150 -    return device_index;
   4.151 -}
   4.152 -
   4.153 -
   4.154 -int
   4.155 -SDL_JoystickDetachVirtualInner(int device_index)
   4.156 -{
   4.157 -    SDL_JoystickID instance_id;
   4.158 -    joystick_hwdata *hwdata = VIRTUAL_HWDataForIndex(device_index);
   4.159 -    if (!hwdata) {
   4.160 -        return SDL_SetError("Virtual joystick data not found");
   4.161 -    }
   4.162 -    instance_id = hwdata->instance_id;
   4.163 -    VIRTUAL_FreeHWData(hwdata);
   4.164 -    SDL_PrivateJoystickRemoved(instance_id);
   4.165 -    return 0;
   4.166 -}
   4.167 -
   4.168 -
   4.169 -int
   4.170 -SDL_JoystickSetVirtualAxisInner(SDL_Joystick * joystick, int axis, Sint16 value)
   4.171 -{
   4.172 -    joystick_hwdata *hwdata;
   4.173 -
   4.174 -    SDL_LockJoysticks();
   4.175 -
   4.176 -    if (!joystick || !joystick->hwdata) {
   4.177 -        SDL_UnlockJoysticks();
   4.178 -        return SDL_SetError("Invalid joystick");
   4.179 -    }
   4.180 -
   4.181 -    hwdata = (joystick_hwdata *)joystick->hwdata;
   4.182 -    if (axis < 0 || axis >= hwdata->nbuttons) {
   4.183 -        SDL_UnlockJoysticks();
   4.184 -        return SDL_SetError("Invalid axis index");
   4.185 -    }
   4.186 -
   4.187 -    hwdata->axes[axis] = value;
   4.188 -
   4.189 -    SDL_UnlockJoysticks();
   4.190 -    return 0;
   4.191 -}
   4.192 -
   4.193 -
   4.194 -int
   4.195 -SDL_JoystickSetVirtualButtonInner(SDL_Joystick * joystick, int button, Uint8 value)
   4.196 -{
   4.197 -    joystick_hwdata *hwdata;
   4.198 -
   4.199 -    SDL_LockJoysticks();
   4.200 -
   4.201 -    if (!joystick || !joystick->hwdata) {
   4.202 -        SDL_UnlockJoysticks();
   4.203 -        return SDL_SetError("Invalid joystick");
   4.204 -    }
   4.205 -
   4.206 -    hwdata = (joystick_hwdata *)joystick->hwdata;
   4.207 -    if (button < 0 || button >= hwdata->nbuttons) {
   4.208 -        SDL_UnlockJoysticks();
   4.209 -        return SDL_SetError("Invalid button index");
   4.210 -    }
   4.211 -
   4.212 -    hwdata->buttons[button] = value;
   4.213 -
   4.214 -    SDL_UnlockJoysticks();
   4.215 -    return 0;
   4.216 -}
   4.217 -
   4.218 -
   4.219 -int
   4.220 -SDL_JoystickSetVirtualHatInner(SDL_Joystick * joystick, int hat, Uint8 value)
   4.221 -{
   4.222 -    joystick_hwdata *hwdata;
   4.223 -
   4.224 -    SDL_LockJoysticks();
   4.225 -
   4.226 -    if (!joystick || !joystick->hwdata) {
   4.227 -        SDL_UnlockJoysticks();
   4.228 -        return SDL_SetError("Invalid joystick");
   4.229 -    }
   4.230 -
   4.231 -    hwdata = (joystick_hwdata *)joystick->hwdata;
   4.232 -    if (hat < 0 || hat >= hwdata->nbuttons) {
   4.233 -        SDL_UnlockJoysticks();
   4.234 -        return SDL_SetError("Invalid hat index");
   4.235 -    }
   4.236 -
   4.237 -    hwdata->hats[hat] = value;
   4.238 -
   4.239 -    SDL_UnlockJoysticks();
   4.240 -    return 0;
   4.241 -}
   4.242 -
   4.243 -
   4.244 -static int
   4.245 -VIRTUAL_JoystickInit(void)
   4.246 -{
   4.247 -    return 0;
   4.248 -}
   4.249 -
   4.250 -
   4.251 -static int
   4.252 -VIRTUAL_JoystickGetCount(void)
   4.253 -{
   4.254 -    int count = 0;
   4.255 -    joystick_hwdata *cur = g_VJoys;
   4.256 -    while (cur) {
   4.257 -        ++count;
   4.258 -        cur = cur->next;
   4.259 -    }
   4.260 -    return count;
   4.261 -}
   4.262 -
   4.263 -
   4.264 -static void
   4.265 -VIRTUAL_JoystickDetect(void)
   4.266 -{
   4.267 -}
   4.268 -
   4.269 -
   4.270 -static const char *
   4.271 -VIRTUAL_JoystickGetDeviceName(int device_index)
   4.272 -{
   4.273 -    joystick_hwdata *hwdata = VIRTUAL_HWDataForIndex(device_index);
   4.274 -    if (!hwdata) {
   4.275 -        return NULL;
   4.276 -    }
   4.277 -    return hwdata->name ? hwdata->name : "";
   4.278 -}
   4.279 -
   4.280 -
   4.281 -static int
   4.282 -VIRTUAL_JoystickGetDevicePlayerIndex(int device_index)
   4.283 -{
   4.284 -    return -1;
   4.285 -}
   4.286 -
   4.287 -
   4.288 -static void
   4.289 -VIRTUAL_JoystickSetDevicePlayerIndex(int device_index, int player_index)
   4.290 -{
   4.291 -}
   4.292 -
   4.293 -
   4.294 -static SDL_JoystickGUID
   4.295 -VIRTUAL_JoystickGetDeviceGUID(int device_index)
   4.296 -{
   4.297 -    joystick_hwdata *hwdata = VIRTUAL_HWDataForIndex(device_index);
   4.298 -    if (!hwdata) {
   4.299 -        SDL_JoystickGUID guid;
   4.300 -        SDL_zero(guid);
   4.301 -        return guid;
   4.302 -    }
   4.303 -    return hwdata->guid;
   4.304 -}
   4.305 -
   4.306 -
   4.307 -static SDL_JoystickID
   4.308 -VIRTUAL_JoystickGetDeviceInstanceID(int device_index)
   4.309 -{
   4.310 -    joystick_hwdata *hwdata = VIRTUAL_HWDataForIndex(device_index);
   4.311 -    if (!hwdata) {
   4.312 -        return -1;
   4.313 -    }
   4.314 -    return hwdata->instance_id;
   4.315 -}
   4.316 -
   4.317 -
   4.318 -static int
   4.319 -VIRTUAL_JoystickOpen(SDL_Joystick * joystick, int device_index)
   4.320 -{
   4.321 -    joystick_hwdata *hwdata = VIRTUAL_HWDataForIndex(device_index);
   4.322 -    if (!hwdata) {
   4.323 -        return SDL_SetError("No such device");
   4.324 -    }
   4.325 -    if (hwdata->opened) {
   4.326 -        return SDL_SetError("Joystick already opened");
   4.327 -    }
   4.328 -    joystick->instance_id = hwdata->instance_id;
   4.329 -    joystick->hwdata = hwdata;
   4.330 -    joystick->naxes = hwdata->naxes;
   4.331 -    joystick->nbuttons = hwdata->nbuttons;
   4.332 -    joystick->nhats = hwdata->nhats;
   4.333 -    hwdata->opened = SDL_TRUE;
   4.334 -    return 0;
   4.335 -}
   4.336 -
   4.337 -
   4.338 -static int
   4.339 -VIRTUAL_JoystickRumble(SDL_Joystick * joystick, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble)
   4.340 -{
   4.341 -    return SDL_Unsupported();
   4.342 -}
   4.343 -
   4.344 -
   4.345 -static void
   4.346 -VIRTUAL_JoystickUpdate(SDL_Joystick * joystick)
   4.347 -{
   4.348 -    joystick_hwdata *hwdata;
   4.349 -
   4.350 -    if (!joystick) {
   4.351 -        return;
   4.352 -    }
   4.353 -    if (!joystick->hwdata) {
   4.354 -        return;
   4.355 -    }
   4.356 -
   4.357 -    hwdata = (joystick_hwdata *)joystick->hwdata;
   4.358 -
   4.359 -    for (int i = 0; i < hwdata->naxes; ++i) {
   4.360 -        SDL_PrivateJoystickAxis(joystick, i, hwdata->axes[i]);
   4.361 -    }
   4.362 -    for (int i = 0; i < hwdata->nbuttons; ++i) {
   4.363 -        SDL_PrivateJoystickButton(joystick, i, hwdata->buttons[i]);
   4.364 -    }
   4.365 -    for (int i = 0; i < hwdata->nhats; ++i) {
   4.366 -        SDL_PrivateJoystickHat(joystick, i, hwdata->hats[i]);
   4.367 -    }
   4.368 -}
   4.369 -
   4.370 -
   4.371 -static void
   4.372 -VIRTUAL_JoystickClose(SDL_Joystick * joystick)
   4.373 -{
   4.374 -    joystick_hwdata *hwdata;
   4.375 -
   4.376 -    if (!joystick) {
   4.377 -        return;
   4.378 -    }
   4.379 -    if (!joystick->hwdata) {
   4.380 -        return;
   4.381 -    }
   4.382 -
   4.383 -    hwdata = (joystick_hwdata *)joystick->hwdata;
   4.384 -    hwdata->opened = SDL_FALSE;
   4.385 -}
   4.386 -
   4.387 -
   4.388 -static void
   4.389 -VIRTUAL_JoystickQuit(void)
   4.390 -{
   4.391 -    while (g_VJoys) {
   4.392 -        VIRTUAL_FreeHWData(g_VJoys);
   4.393 -    }
   4.394 -}
   4.395 -
   4.396 -
   4.397 -SDL_JoystickDriver SDL_VIRTUAL_JoystickDriver =
   4.398 -{
   4.399 -    VIRTUAL_JoystickInit,
   4.400 -    VIRTUAL_JoystickGetCount,
   4.401 -    VIRTUAL_JoystickDetect,
   4.402 -    VIRTUAL_JoystickGetDeviceName,
   4.403 -    VIRTUAL_JoystickGetDevicePlayerIndex,
   4.404 -    VIRTUAL_JoystickSetDevicePlayerIndex,
   4.405 -    VIRTUAL_JoystickGetDeviceGUID,
   4.406 -    VIRTUAL_JoystickGetDeviceInstanceID,
   4.407 -    VIRTUAL_JoystickOpen,
   4.408 -    VIRTUAL_JoystickRumble,
   4.409 -    VIRTUAL_JoystickUpdate,
   4.410 -    VIRTUAL_JoystickClose,
   4.411 -    VIRTUAL_JoystickQuit,
   4.412 -};
   4.413 -
   4.414 -#endif /* SDL_JOYSTICK_VIRTUAL || SDL_JOYSTICK_DISABLED */
   4.415 -
   4.416 -/* vi: set ts=4 sw=4 expandtab: */
     5.1 --- a/src/joystick/virtual/SDL_sysjoystick_c.h	Sun Mar 15 14:40:51 2020 -0400
     5.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.3 @@ -1,62 +0,0 @@
     5.4 -/*
     5.5 -  Simple DirectMedia Layer
     5.6 -  Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
     5.7 -
     5.8 -  This software is provided 'as-is', without any express or implied
     5.9 -  warranty.  In no event will the authors be held liable for any damages
    5.10 -  arising from the use of this software.
    5.11 -
    5.12 -  Permission is granted to anyone to use this software for any purpose,
    5.13 -  including commercial applications, and to alter it and redistribute it
    5.14 -  freely, subject to the following restrictions:
    5.15 -
    5.16 -  1. The origin of this software must not be misrepresented; you must not
    5.17 -     claim that you wrote the original software. If you use this software
    5.18 -     in a product, an acknowledgment in the product documentation would be
    5.19 -     appreciated but is not required.
    5.20 -  2. Altered source versions must be plainly marked as such, and must not be
    5.21 -     misrepresented as being the original software.
    5.22 -  3. This notice may not be removed or altered from any source distribution.
    5.23 -*/
    5.24 -#include "../../SDL_internal.h"
    5.25 -
    5.26 -#ifndef SDL_JOYSTICK_VIRTUAL_H
    5.27 -#define SDL_JOYSTICK_VIRTUAL_H
    5.28 -
    5.29 -#if SDL_JOYSTICK_VIRTUAL
    5.30 -
    5.31 -#include "SDL_joystick.h"
    5.32 -
    5.33 -/**
    5.34 - * Data for a virtual, software-only joystick.
    5.35 - */
    5.36 -typedef struct joystick_hwdata
    5.37 -{
    5.38 -    SDL_JoystickType type;
    5.39 -    SDL_bool attached;
    5.40 -    const char *name;
    5.41 -    SDL_JoystickGUID guid;
    5.42 -    int naxes;
    5.43 -    Sint16 *axes;
    5.44 -    int nbuttons;
    5.45 -    Uint8 *buttons;
    5.46 -    int nhats;
    5.47 -    Uint8 *hats;
    5.48 -    SDL_JoystickID instance_id;
    5.49 -    SDL_bool opened;
    5.50 -    struct joystick_hwdata *next;
    5.51 -} joystick_hwdata;
    5.52 -
    5.53 -int SDL_JoystickAttachVirtualInner(SDL_JoystickType type,
    5.54 -                                   int naxes,
    5.55 -                                   int nbuttons,
    5.56 -                                   int nhats);
    5.57 -
    5.58 -int SDL_JoystickDetachVirtualInner(int device_index);
    5.59 -
    5.60 -int SDL_JoystickSetVirtualAxisInner(SDL_Joystick * joystick, int axis, Sint16 value);
    5.61 -int SDL_JoystickSetVirtualButtonInner(SDL_Joystick * joystick, int button, Uint8 value);
    5.62 -int SDL_JoystickSetVirtualHatInner(SDL_Joystick * joystick, int hat, Uint8 value);
    5.63 -
    5.64 -#endif  /* SDL_JOYSTICK_VIRTUAL */
    5.65 -#endif  /* SDL_JOYSTICK_VIRTUAL_H */
     6.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     6.2 +++ b/src/joystick/virtual/SDL_virtualjoystick.c	Sun Mar 15 15:05:36 2020 -0400
     6.3 @@ -0,0 +1,413 @@
     6.4 +/*
     6.5 +  Simple DirectMedia Layer
     6.6 +  Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
     6.7 +
     6.8 +  This software is provided 'as-is', without any express or implied
     6.9 +  warranty.  In no event will the authors be held liable for any damages
    6.10 +  arising from the use of this software.
    6.11 +
    6.12 +  Permission is granted to anyone to use this software for any purpose,
    6.13 +  including commercial applications, and to alter it and redistribute it
    6.14 +  freely, subject to the following restrictions:
    6.15 +
    6.16 +  1. The origin of this software must not be misrepresented; you must not
    6.17 +     claim that you wrote the original software. If you use this software
    6.18 +     in a product, an acknowledgment in the product documentation would be
    6.19 +     appreciated but is not required.
    6.20 +  2. Altered source versions must be plainly marked as such, and must not be
    6.21 +     misrepresented as being the original software.
    6.22 +  3. This notice may not be removed or altered from any source distribution.
    6.23 +*/
    6.24 +#include "../../SDL_internal.h"
    6.25 +
    6.26 +#if defined(SDL_JOYSTICK_VIRTUAL)
    6.27 +
    6.28 +/* This is the virtual implementation of the SDL joystick API */
    6.29 +
    6.30 +#include "SDL_virtualjoystick_c.h"
    6.31 +#include "../SDL_sysjoystick.h"
    6.32 +#include "../SDL_joystick_c.h"
    6.33 +
    6.34 +extern SDL_JoystickDriver SDL_VIRTUAL_JoystickDriver;
    6.35 +
    6.36 +static joystick_hwdata * g_VJoys = NULL;
    6.37 +
    6.38 +
    6.39 +static joystick_hwdata *
    6.40 +VIRTUAL_HWDataForIndex(int device_index)
    6.41 +{
    6.42 +    joystick_hwdata *vjoy = g_VJoys;
    6.43 +    while (vjoy) {
    6.44 +        if (device_index == 0)
    6.45 +            break;
    6.46 +        --device_index;
    6.47 +        vjoy = vjoy->next;
    6.48 +    }
    6.49 +    return vjoy;
    6.50 +}
    6.51 +
    6.52 +
    6.53 +static void
    6.54 +VIRTUAL_FreeHWData(joystick_hwdata *hwdata)
    6.55 +{
    6.56 +    joystick_hwdata * cur = g_VJoys;
    6.57 +    joystick_hwdata * prev = NULL;
    6.58 + 
    6.59 +    if (!hwdata) {
    6.60 +        return;
    6.61 +    }
    6.62 +    if (hwdata->axes) {
    6.63 +        SDL_free((void *)hwdata->axes);
    6.64 +        hwdata->axes = NULL;
    6.65 +    }
    6.66 +    if (hwdata->buttons) {
    6.67 +        SDL_free((void *)hwdata->buttons);
    6.68 +        hwdata->buttons = NULL;
    6.69 +    }
    6.70 +    if (hwdata->hats) {
    6.71 +        SDL_free(hwdata->hats);
    6.72 +        hwdata->hats = NULL;
    6.73 +    }
    6.74 +
    6.75 +    /* Remove hwdata from SDL-global list */
    6.76 +    while (cur) {
    6.77 +        if (hwdata == cur) {
    6.78 +            if (prev) {
    6.79 +                prev->next = cur->next;
    6.80 +            } else {
    6.81 +                g_VJoys = cur->next;
    6.82 +            }
    6.83 +            break;
    6.84 +        }
    6.85 +        prev = cur;
    6.86 +        cur = cur->next;
    6.87 +    }
    6.88 +
    6.89 +    SDL_free(hwdata);
    6.90 +}
    6.91 +
    6.92 +
    6.93 +int
    6.94 +SDL_JoystickAttachVirtualInner(SDL_JoystickType type,
    6.95 +                               int naxes,
    6.96 +                               int nbuttons,
    6.97 +                               int nhats)
    6.98 +{
    6.99 +    joystick_hwdata *hwdata = NULL;
   6.100 +    int device_index = -1;
   6.101 +
   6.102 +    hwdata = SDL_calloc(1, sizeof(joystick_hwdata));
   6.103 +    if (!hwdata) {
   6.104 +        VIRTUAL_FreeHWData(hwdata);
   6.105 +        return SDL_OutOfMemory();
   6.106 +    }
   6.107 +
   6.108 +    hwdata->naxes = naxes;
   6.109 +    hwdata->nbuttons = nbuttons;
   6.110 +    hwdata->nhats = nhats;
   6.111 +    hwdata->name = "Virtual Joystick";
   6.112 +
   6.113 +    /* Note that this is a Virtual device and what subtype it is */
   6.114 +    hwdata->guid.data[14] = 'v';
   6.115 +    hwdata->guid.data[15] = (Uint8)type;
   6.116 +
   6.117 +    /* Allocate fields for different control-types */
   6.118 +    if (naxes > 0) {
   6.119 +        hwdata->axes = SDL_calloc(naxes, sizeof(Sint16));
   6.120 +        if (!hwdata->axes) {
   6.121 +            VIRTUAL_FreeHWData(hwdata);
   6.122 +            return SDL_OutOfMemory();
   6.123 +        }
   6.124 +    }
   6.125 +    if (nbuttons > 0) {
   6.126 +        hwdata->buttons = SDL_calloc(nbuttons, sizeof(Uint8));
   6.127 +        if (!hwdata->buttons) {
   6.128 +            VIRTUAL_FreeHWData(hwdata);
   6.129 +            return SDL_OutOfMemory();
   6.130 +        }
   6.131 +    }
   6.132 +    if (nhats > 0) {
   6.133 +        hwdata->hats = SDL_calloc(nhats, sizeof(Uint8));
   6.134 +        if (!hwdata->hats) {
   6.135 +            VIRTUAL_FreeHWData(hwdata);
   6.136 +            return SDL_OutOfMemory();
   6.137 +        }
   6.138 +    }
   6.139 +
   6.140 +    /* Allocate an instance ID for this device */
   6.141 +    hwdata->instance_id = SDL_GetNextJoystickInstanceID();
   6.142 +
   6.143 +    /* Add virtual joystick to SDL-global lists */
   6.144 +    hwdata->next = g_VJoys;
   6.145 +    g_VJoys = hwdata;
   6.146 +    SDL_PrivateJoystickAdded(hwdata->instance_id);
   6.147 +
   6.148 +    /* Return the new virtual-device's index */
   6.149 +    device_index = SDL_JoystickGetDeviceIndexFromInstanceID(hwdata->instance_id);
   6.150 +    return device_index;
   6.151 +}
   6.152 +
   6.153 +
   6.154 +int
   6.155 +SDL_JoystickDetachVirtualInner(int device_index)
   6.156 +{
   6.157 +    SDL_JoystickID instance_id;
   6.158 +    joystick_hwdata *hwdata = VIRTUAL_HWDataForIndex(device_index);
   6.159 +    if (!hwdata) {
   6.160 +        return SDL_SetError("Virtual joystick data not found");
   6.161 +    }
   6.162 +    instance_id = hwdata->instance_id;
   6.163 +    VIRTUAL_FreeHWData(hwdata);
   6.164 +    SDL_PrivateJoystickRemoved(instance_id);
   6.165 +    return 0;
   6.166 +}
   6.167 +
   6.168 +
   6.169 +int
   6.170 +SDL_JoystickSetVirtualAxisInner(SDL_Joystick * joystick, int axis, Sint16 value)
   6.171 +{
   6.172 +    joystick_hwdata *hwdata;
   6.173 +
   6.174 +    SDL_LockJoysticks();
   6.175 +
   6.176 +    if (!joystick || !joystick->hwdata) {
   6.177 +        SDL_UnlockJoysticks();
   6.178 +        return SDL_SetError("Invalid joystick");
   6.179 +    }
   6.180 +
   6.181 +    hwdata = (joystick_hwdata *)joystick->hwdata;
   6.182 +    if (axis < 0 || axis >= hwdata->nbuttons) {
   6.183 +        SDL_UnlockJoysticks();
   6.184 +        return SDL_SetError("Invalid axis index");
   6.185 +    }
   6.186 +
   6.187 +    hwdata->axes[axis] = value;
   6.188 +
   6.189 +    SDL_UnlockJoysticks();
   6.190 +    return 0;
   6.191 +}
   6.192 +
   6.193 +
   6.194 +int
   6.195 +SDL_JoystickSetVirtualButtonInner(SDL_Joystick * joystick, int button, Uint8 value)
   6.196 +{
   6.197 +    joystick_hwdata *hwdata;
   6.198 +
   6.199 +    SDL_LockJoysticks();
   6.200 +
   6.201 +    if (!joystick || !joystick->hwdata) {
   6.202 +        SDL_UnlockJoysticks();
   6.203 +        return SDL_SetError("Invalid joystick");
   6.204 +    }
   6.205 +
   6.206 +    hwdata = (joystick_hwdata *)joystick->hwdata;
   6.207 +    if (button < 0 || button >= hwdata->nbuttons) {
   6.208 +        SDL_UnlockJoysticks();
   6.209 +        return SDL_SetError("Invalid button index");
   6.210 +    }
   6.211 +
   6.212 +    hwdata->buttons[button] = value;
   6.213 +
   6.214 +    SDL_UnlockJoysticks();
   6.215 +    return 0;
   6.216 +}
   6.217 +
   6.218 +
   6.219 +int
   6.220 +SDL_JoystickSetVirtualHatInner(SDL_Joystick * joystick, int hat, Uint8 value)
   6.221 +{
   6.222 +    joystick_hwdata *hwdata;
   6.223 +
   6.224 +    SDL_LockJoysticks();
   6.225 +
   6.226 +    if (!joystick || !joystick->hwdata) {
   6.227 +        SDL_UnlockJoysticks();
   6.228 +        return SDL_SetError("Invalid joystick");
   6.229 +    }
   6.230 +
   6.231 +    hwdata = (joystick_hwdata *)joystick->hwdata;
   6.232 +    if (hat < 0 || hat >= hwdata->nbuttons) {
   6.233 +        SDL_UnlockJoysticks();
   6.234 +        return SDL_SetError("Invalid hat index");
   6.235 +    }
   6.236 +
   6.237 +    hwdata->hats[hat] = value;
   6.238 +
   6.239 +    SDL_UnlockJoysticks();
   6.240 +    return 0;
   6.241 +}
   6.242 +
   6.243 +
   6.244 +static int
   6.245 +VIRTUAL_JoystickInit(void)
   6.246 +{
   6.247 +    return 0;
   6.248 +}
   6.249 +
   6.250 +
   6.251 +static int
   6.252 +VIRTUAL_JoystickGetCount(void)
   6.253 +{
   6.254 +    int count = 0;
   6.255 +    joystick_hwdata *cur = g_VJoys;
   6.256 +    while (cur) {
   6.257 +        ++count;
   6.258 +        cur = cur->next;
   6.259 +    }
   6.260 +    return count;
   6.261 +}
   6.262 +
   6.263 +
   6.264 +static void
   6.265 +VIRTUAL_JoystickDetect(void)
   6.266 +{
   6.267 +}
   6.268 +
   6.269 +
   6.270 +static const char *
   6.271 +VIRTUAL_JoystickGetDeviceName(int device_index)
   6.272 +{
   6.273 +    joystick_hwdata *hwdata = VIRTUAL_HWDataForIndex(device_index);
   6.274 +    if (!hwdata) {
   6.275 +        return NULL;
   6.276 +    }
   6.277 +    return hwdata->name ? hwdata->name : "";
   6.278 +}
   6.279 +
   6.280 +
   6.281 +static int
   6.282 +VIRTUAL_JoystickGetDevicePlayerIndex(int device_index)
   6.283 +{
   6.284 +    return -1;
   6.285 +}
   6.286 +
   6.287 +
   6.288 +static void
   6.289 +VIRTUAL_JoystickSetDevicePlayerIndex(int device_index, int player_index)
   6.290 +{
   6.291 +}
   6.292 +
   6.293 +
   6.294 +static SDL_JoystickGUID
   6.295 +VIRTUAL_JoystickGetDeviceGUID(int device_index)
   6.296 +{
   6.297 +    joystick_hwdata *hwdata = VIRTUAL_HWDataForIndex(device_index);
   6.298 +    if (!hwdata) {
   6.299 +        SDL_JoystickGUID guid;
   6.300 +        SDL_zero(guid);
   6.301 +        return guid;
   6.302 +    }
   6.303 +    return hwdata->guid;
   6.304 +}
   6.305 +
   6.306 +
   6.307 +static SDL_JoystickID
   6.308 +VIRTUAL_JoystickGetDeviceInstanceID(int device_index)
   6.309 +{
   6.310 +    joystick_hwdata *hwdata = VIRTUAL_HWDataForIndex(device_index);
   6.311 +    if (!hwdata) {
   6.312 +        return -1;
   6.313 +    }
   6.314 +    return hwdata->instance_id;
   6.315 +}
   6.316 +
   6.317 +
   6.318 +static int
   6.319 +VIRTUAL_JoystickOpen(SDL_Joystick * joystick, int device_index)
   6.320 +{
   6.321 +    joystick_hwdata *hwdata = VIRTUAL_HWDataForIndex(device_index);
   6.322 +    if (!hwdata) {
   6.323 +        return SDL_SetError("No such device");
   6.324 +    }
   6.325 +    if (hwdata->opened) {
   6.326 +        return SDL_SetError("Joystick already opened");
   6.327 +    }
   6.328 +    joystick->instance_id = hwdata->instance_id;
   6.329 +    joystick->hwdata = hwdata;
   6.330 +    joystick->naxes = hwdata->naxes;
   6.331 +    joystick->nbuttons = hwdata->nbuttons;
   6.332 +    joystick->nhats = hwdata->nhats;
   6.333 +    hwdata->opened = SDL_TRUE;
   6.334 +    return 0;
   6.335 +}
   6.336 +
   6.337 +
   6.338 +static int
   6.339 +VIRTUAL_JoystickRumble(SDL_Joystick * joystick, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble)
   6.340 +{
   6.341 +    return SDL_Unsupported();
   6.342 +}
   6.343 +
   6.344 +
   6.345 +static void
   6.346 +VIRTUAL_JoystickUpdate(SDL_Joystick * joystick)
   6.347 +{
   6.348 +    joystick_hwdata *hwdata;
   6.349 +
   6.350 +    if (!joystick) {
   6.351 +        return;
   6.352 +    }
   6.353 +    if (!joystick->hwdata) {
   6.354 +        return;
   6.355 +    }
   6.356 +
   6.357 +    hwdata = (joystick_hwdata *)joystick->hwdata;
   6.358 +
   6.359 +    for (int i = 0; i < hwdata->naxes; ++i) {
   6.360 +        SDL_PrivateJoystickAxis(joystick, i, hwdata->axes[i]);
   6.361 +    }
   6.362 +    for (int i = 0; i < hwdata->nbuttons; ++i) {
   6.363 +        SDL_PrivateJoystickButton(joystick, i, hwdata->buttons[i]);
   6.364 +    }
   6.365 +    for (int i = 0; i < hwdata->nhats; ++i) {
   6.366 +        SDL_PrivateJoystickHat(joystick, i, hwdata->hats[i]);
   6.367 +    }
   6.368 +}
   6.369 +
   6.370 +
   6.371 +static void
   6.372 +VIRTUAL_JoystickClose(SDL_Joystick * joystick)
   6.373 +{
   6.374 +    joystick_hwdata *hwdata;
   6.375 +
   6.376 +    if (!joystick) {
   6.377 +        return;
   6.378 +    }
   6.379 +    if (!joystick->hwdata) {
   6.380 +        return;
   6.381 +    }
   6.382 +
   6.383 +    hwdata = (joystick_hwdata *)joystick->hwdata;
   6.384 +    hwdata->opened = SDL_FALSE;
   6.385 +}
   6.386 +
   6.387 +
   6.388 +static void
   6.389 +VIRTUAL_JoystickQuit(void)
   6.390 +{
   6.391 +    while (g_VJoys) {
   6.392 +        VIRTUAL_FreeHWData(g_VJoys);
   6.393 +    }
   6.394 +}
   6.395 +
   6.396 +
   6.397 +SDL_JoystickDriver SDL_VIRTUAL_JoystickDriver =
   6.398 +{
   6.399 +    VIRTUAL_JoystickInit,
   6.400 +    VIRTUAL_JoystickGetCount,
   6.401 +    VIRTUAL_JoystickDetect,
   6.402 +    VIRTUAL_JoystickGetDeviceName,
   6.403 +    VIRTUAL_JoystickGetDevicePlayerIndex,
   6.404 +    VIRTUAL_JoystickSetDevicePlayerIndex,
   6.405 +    VIRTUAL_JoystickGetDeviceGUID,
   6.406 +    VIRTUAL_JoystickGetDeviceInstanceID,
   6.407 +    VIRTUAL_JoystickOpen,
   6.408 +    VIRTUAL_JoystickRumble,
   6.409 +    VIRTUAL_JoystickUpdate,
   6.410 +    VIRTUAL_JoystickClose,
   6.411 +    VIRTUAL_JoystickQuit,
   6.412 +};
   6.413 +
   6.414 +#endif /* SDL_JOYSTICK_VIRTUAL || SDL_JOYSTICK_DISABLED */
   6.415 +
   6.416 +/* vi: set ts=4 sw=4 expandtab: */
     7.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     7.2 +++ b/src/joystick/virtual/SDL_virtualjoystick_c.h	Sun Mar 15 15:05:36 2020 -0400
     7.3 @@ -0,0 +1,62 @@
     7.4 +/*
     7.5 +  Simple DirectMedia Layer
     7.6 +  Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
     7.7 +
     7.8 +  This software is provided 'as-is', without any express or implied
     7.9 +  warranty.  In no event will the authors be held liable for any damages
    7.10 +  arising from the use of this software.
    7.11 +
    7.12 +  Permission is granted to anyone to use this software for any purpose,
    7.13 +  including commercial applications, and to alter it and redistribute it
    7.14 +  freely, subject to the following restrictions:
    7.15 +
    7.16 +  1. The origin of this software must not be misrepresented; you must not
    7.17 +     claim that you wrote the original software. If you use this software
    7.18 +     in a product, an acknowledgment in the product documentation would be
    7.19 +     appreciated but is not required.
    7.20 +  2. Altered source versions must be plainly marked as such, and must not be
    7.21 +     misrepresented as being the original software.
    7.22 +  3. This notice may not be removed or altered from any source distribution.
    7.23 +*/
    7.24 +#include "../../SDL_internal.h"
    7.25 +
    7.26 +#ifndef SDL_VIRTUALJOYSTICK_C_H
    7.27 +#define SDL_VIRTUALJOYSTICK_C_H
    7.28 +
    7.29 +#if SDL_JOYSTICK_VIRTUAL
    7.30 +
    7.31 +#include "SDL_joystick.h"
    7.32 +
    7.33 +/**
    7.34 + * Data for a virtual, software-only joystick.
    7.35 + */
    7.36 +typedef struct joystick_hwdata
    7.37 +{
    7.38 +    SDL_JoystickType type;
    7.39 +    SDL_bool attached;
    7.40 +    const char *name;
    7.41 +    SDL_JoystickGUID guid;
    7.42 +    int naxes;
    7.43 +    Sint16 *axes;
    7.44 +    int nbuttons;
    7.45 +    Uint8 *buttons;
    7.46 +    int nhats;
    7.47 +    Uint8 *hats;
    7.48 +    SDL_JoystickID instance_id;
    7.49 +    SDL_bool opened;
    7.50 +    struct joystick_hwdata *next;
    7.51 +} joystick_hwdata;
    7.52 +
    7.53 +int SDL_JoystickAttachVirtualInner(SDL_JoystickType type,
    7.54 +                                   int naxes,
    7.55 +                                   int nbuttons,
    7.56 +                                   int nhats);
    7.57 +
    7.58 +int SDL_JoystickDetachVirtualInner(int device_index);
    7.59 +
    7.60 +int SDL_JoystickSetVirtualAxisInner(SDL_Joystick * joystick, int axis, Sint16 value);
    7.61 +int SDL_JoystickSetVirtualButtonInner(SDL_Joystick * joystick, int button, Uint8 value);
    7.62 +int SDL_JoystickSetVirtualHatInner(SDL_Joystick * joystick, int hat, Uint8 value);
    7.63 +
    7.64 +#endif  /* SDL_JOYSTICK_VIRTUAL */
    7.65 +#endif  /* SDL_VIRTUALJOYSTICK_C_H */