Commits

Ivan Vučica committed 4d7957f

Functioning use of vmulti under Win32; axis 0 and 1 (x, y) of joystick moves

Comments (0)

Files changed (3)

HIDPadDesktop.xcodeproj/project.pbxproj

 /* Begin PBXBuildFile section */
 		1DDD58160DA1D0A300B32029 /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 1DDD58140DA1D0A300B32029 /* MainMenu.xib */; };
 		256AC3DA0F4B6AC300CF3369 /* HIDPadDesktopAppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 256AC3D90F4B6AC300CF3369 /* HIDPadDesktopAppDelegate.m */; };
+		7FAB866212BE9B7A00B421CF /* client.c in Sources */ = {isa = PBXBuildFile; fileRef = 7FAB866112BE9B7A00B421CF /* client.c */; };
 		7FEFA4A512B5436A00AC4A10 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 089C165CFE840E0CC02AAC07 /* InfoPlist.strings */; };
 		7FEFA4A612B5436A00AC4A10 /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 1DDD58140DA1D0A300B32029 /* MainMenu.xib */; };
 		7FEFA4A812B5436A00AC4A10 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 29B97316FDCFA39411CA2CEA /* main.m */; settings = {ATTRIBUTES = (); }; };
 		29B97316FDCFA39411CA2CEA /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
 		29B97324FDCFA39411CA2CEA /* AppKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AppKit.framework; path = /System/Library/Frameworks/AppKit.framework; sourceTree = "<absolute>"; };
 		29B97325FDCFA39411CA2CEA /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = /System/Library/Frameworks/Foundation.framework; sourceTree = "<absolute>"; };
+		7FAB865F12BE9B6900B421CF /* vmulticlient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = vmulticlient.h; path = vmulti/inc/vmulticlient.h; sourceTree = "<group>"; };
+		7FAB866012BE9B6900B421CF /* vmulticommon.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = vmulticommon.h; path = vmulti/inc/vmulticommon.h; sourceTree = "<group>"; };
+		7FAB866112BE9B7A00B421CF /* client.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = client.c; path = vmulti/client/client.c; sourceTree = "<group>"; };
 		7FEFA4AF12B5436A00AC4A10 /* HIDPadDesktopWin32.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = HIDPadDesktopWin32.app; sourceTree = BUILT_PRODUCTS_DIR; };
 		7FEFA4B112B5436A00AC4A10 /* HIDPadDesktopWin32-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "HIDPadDesktopWin32-Info.plist"; sourceTree = "<group>"; };
 		8D1107310486CEB800E47090 /* HIDPadDesktop-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "HIDPadDesktop-Info.plist"; sourceTree = "<group>"; };
 		29B97314FDCFA39411CA2CEA /* HIDPadDesktop */ = {
 			isa = PBXGroup;
 			children = (
+				7FAB865D12BE9B4100B421CF /* vmulti */,
 				080E96DDFE201D6D7F000001 /* Classes */,
 				29B97315FDCFA39411CA2CEA /* Other Sources */,
 				29B97317FDCFA39411CA2CEA /* Resources */,
 			name = Frameworks;
 			sourceTree = "<group>";
 		};
+		7FAB865D12BE9B4100B421CF /* vmulti */ = {
+			isa = PBXGroup;
+			children = (
+				7FAB866112BE9B7A00B421CF /* client.c */,
+				7FAB865F12BE9B6900B421CF /* vmulticlient.h */,
+				7FAB866012BE9B6900B421CF /* vmulticommon.h */,
+			);
+			name = vmulti;
+			sourceTree = "<group>";
+		};
 /* End PBXGroup section */
 
 /* Begin PBXNativeTarget section */
 			files = (
 				7FEFA4A812B5436A00AC4A10 /* main.m in Sources */,
 				7FEFA4A912B5436A00AC4A10 /* HIDPadDesktopAppDelegate.m in Sources */,
+				7FAB866212BE9B7A00B421CF /* client.c in Sources */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
 				GCC_PRECOMPILE_PREFIX_HEADER = NO;
 				GCC_PREFIX_HEADER = "";
 				GCC_VERSION = org.cocotron.1.0.windows.i386.gcc.4.3.1;
-				HEADER_SEARCH_PATHS = "/Developer/Cocotron/1.0/Windows/i386/gcc-4.3.1/include";
+				HEADER_SEARCH_PATHS = (
+					"/Developer/Cocotron/1.0/Windows/i386/gcc-4.3.1/include",
+					"/Developer/Cocotron/1.0/Windows/i386/gcc-4.3.1/i386-mingw32msvc/include/ddk",
+				);
 				INFOPLIST_FILE = "HIDPadDesktopWin32-Info.plist";
 				INSTALL_PATH = "$(HOME)/Applications";
 				OTHER_LDFLAGS = (
+					"-lhid",
+					"-lsetupapi",
+					"-lcomdlg32",
 					"-framework",
 					Foundation,
 					"-framework",
 				);
 				PRODUCT_NAME = HIDPadDesktopWin32;
 				SDKROOT = "";
+				USER_HEADER_SEARCH_PATHS = "$(inherited) $(PROJECT_DIR)/vmulti/inc";
 			};
 			name = Debug;
 		};
 				GCC_PRECOMPILE_PREFIX_HEADER = NO;
 				GCC_PREFIX_HEADER = "";
 				GCC_VERSION = org.cocotron.1.0.windows.i386.gcc.4.3.1;
-				HEADER_SEARCH_PATHS = "/Developer/Cocotron/1.0/Windows/i386/gcc-4.3.1/include";
+				HEADER_SEARCH_PATHS = (
+					"/Developer/Cocotron/1.0/Windows/i386/gcc-4.3.1/include",
+					"/Developer/Cocotron/1.0/Windows/i386/gcc-4.3.1/i386-mingw32msvc/include/ddk",
+				);
 				INFOPLIST_FILE = "HIDPadDesktopWin32-Info.plist";
 				INSTALL_PATH = "$(HOME)/Applications";
 				OTHER_LDFLAGS = (
+					"-lhid",
+					"-lsetupapi",
+					"-lcomdlg32",
 					"-framework",
 					Foundation,
 					"-framework",
 				);
 				PRODUCT_NAME = HIDPadDesktopWin32;
 				SDKROOT = "";
+				USER_HEADER_SEARCH_PATHS = "$(inherited) $(PROJECT_DIR)/vmulti/inc";
 			};
 			name = Release;
 		};

HIDPadDesktopAppDelegate.h

 #import <Cocoa/Cocoa.h>
 #import <TargetConditionals.h>
 
+#if TARGET_OS_WIN32
+#import <windows.h>
+#import "vmulticlient.h"
+#import "vmulticommon.h"
+#endif
+
+
 @interface HIDPadDesktopAppDelegate : NSObject 
 #if !TARGET_OS_WIN32 
 <NSApplicationDelegate, NSNetServiceBrowserDelegate, NSNetServiceDelegate, NSTableViewDelegate, NSStreamDelegate, NSTableViewDataSource>
 	//////////////////
 	
 	NSButton *btn;
+	
+	///////////
+	#if TARGET_OS_WIN32
+	pvmulti_client vmulti;
+	#endif
 }
 
 @property (assign) IBOutlet NSWindow *window;

HIDPadDesktopAppDelegate.m

 	
 	//NSNetService*dummy=[[NSNetService alloc] initWithDomain:@"" type:@"_http._tcp" name:@"" port:80];
 	//[dummy publish];
+	#if TARGET_OS_WIN32
+		if(vmulti = vmulti_alloc())
+		{
+			if(vmulti_connect(vmulti))
+			{
+			}
+			else
+			{
+				vmulti_free(vmulti);
+				vmulti = NULL;
+			}	
+		}
+		
+		#endif
+	
 	
 	
 	data = [[NSMutableData alloc] init];
 	
 }
 
+-(void)dealloc
+{
+	[super dealloc];
+	// FIXME dealloc other objects
+	
+	#if TARGET_OS_WIN32
+	if(vmulti)
+	{
+		vmulti_disconnect(vmulti);
+		vmulti_free(vmulti);
+	}
+	#endif
+}
+
 #pragma mark -
 #pragma mark Net service browser
 
 -(void)netServiceDidResolveAddress:(NSNetService *)service
 {
 	
-	NSLog(@"Host: %@", [service hostName]);
+	NSLog(@"Host: %@ Port: %d", [service hostName], [service port]);
 	[service getInputStream:&inputStream outputStream:&outputStream];
 	
 	inputStream.delegate = self;
 	}
 	NSLog(@"New pos: %g %g", frame.origin.x, frame.origin.y);
 	[btn setFrame:frame];
+	
+	#if TARGET_OS_WIN32
+	if (vmulti) {
+		static float axis_cache[128] = {0};
+		axis_cache[index] = value;
+		vmulti_update_joystick(vmulti, 0, axis_cache[0]*127, axis_cache[1]*127, 0);
+	}
+	#endif
 }
 @synthesize btn;