SoftButton callback to Managed C++ problem

Post questions, comments and feedback to our 3Dconnexion Windows Development Team.

Moderator: Moderators

Post Reply
fsteinmann
Posts: 2
Joined: Fri Sep 23, 2011 7:46 am

SoftButton callback to Managed C++ problem

Post by fsteinmann »

I’m trying to create a managed wrapper around the Logitech GamePanel SDK. I’ve been able get the Configuration and Notify callback functions to work, however, I can’t get the soft button callback to work. I can’t figure out what I’m doing wrong, the connection strategy is the same as for notification and configuration, but I don’t see the button callback triggering when the application runs.

I should also note that the C++ project compiles to a DLL, which is then used by a parent C# DLL which connects to the SpacePilot Pro using HID. This C# DLL is then referenced by the application layer.

Any help would be appreciated.

Code: Select all

LogitechLCD_Applet::LogitechLCD_Applet(System::String^ AppletName, bool AutoStart, AppletCapabilities Capabilities, bool Configurable)
	{
	DWORD res=ERROR_SUCCESS;	//assume success (also set if refCount>0)
	void* tPntr;
	if(LogitechLCD_Applet::refCount==0)
		{
		res = lgLcdInit();
		}
	if(ERROR_SUCCESS == res)
		{
		//keep the context around
		myCTX=new lgLcdConnectContextEx();
	    memset(myCTX, 0, sizeof(lgLcdConnectContextEx));
		tPntr=Marshal::StringToHGlobalUni(AppletName).ToPointer();
		myCTX->appFriendlyName=(LPCWSTR)tPntr;
		myCTX->dwAppletCapabilitiesSupported=(DWORD)Capabilities;
		myCTX->isAutostartable=AutoStart;
		myCTX->isPersistent=TRUE;
		
		System::Delegate^ d;
		if(Configurable)
			{
			//setup configuration callback hooks
			myCTX->onConfigure.configContext=0;	//no need for context, we are going to raise an event into the context space
			//create a function delegate pointing back to this instance
			d=gcnew PaR::LogitechLCD_Applet::dlgt_OnConfigCB(this,&PaR::LogitechLCD_Applet::OnConfigCB);
			this->gcConfig=GCHandle::Alloc(d);	//lock this in place since this delegate disapears once the method exits
			myCTX->onConfigure.configCallback=(lgLcdOnConfigureCB)Marshal::GetFunctionPointerForDelegate(d).ToPointer();
			}

		//setup notification callback hooks
		myCTX->onNotify.notifyContext=0;	//no need for context, we are going to raise an event into the context space
		//create a function delegate pointing back to this instance
		d=gcnew PaR::LogitechLCD_Applet::dlgt_OnNotifyCB(this,&PaR::LogitechLCD_Applet::OnNotificationCB);
		this->gcNotify=GCHandle::Alloc(d);	//lock this in place since this delegate disapears once the method exits
		myCTX->onNotify.notificationCallback=(lgLcdOnNotificationCB)Marshal::GetFunctionPointerForDelegate(d).ToPointer();

		this->openCTX=new lgLcdOpenByTypeContext();
		memset(openCTX,0,sizeof(lgLcdOpenByTypeContext));
		//setup button callback hooks
		openCTX->onSoftbuttonsChanged.softbuttonsChangedContext=this->openCTX;
		d=gcnew PaR::LogitechLCD_Applet::dlgt_OnSoftButtonCB(this,&PaR::LogitechLCD_Applet::OnSoftButtonCB);
		this->gcSoftButton=GCHandle::Alloc(d);
		openCTX->onSoftbuttonsChanged.softbuttonsChangedCallback=(lgLcdOnSoftButtonsCB)Marshal::GetFunctionPointerForDelegate(d).ToPointer();
		res=lgLcdConnectEx(myCTX);
		if(res != ERROR_SUCCESS)
			{
			this->!LogitechLCD_Applet();	//free up my memory
			throw res;
			}
		else
			{
			//attempt to open a connection to a device
			openCTX->connection=myCTX->connection;
			openCTX->device=LGLCD_INVALID_DEVICE;
			openCTX->deviceType=(int)myCTX->dwAppletCapabilitiesSupported;

			//try to open the context
			DWORD res=lgLcdOpenByType(openCTX);
			lgLcdSetAsLCDForegroundApp(openCTX->device,LGLCD_LCD_FOREGROUND_APP_NO);

			LogitechLCD_Applet::refCount++;	//bump the ref count
			}
		}
	}
jwick
Moderator
Moderator
Posts: 3455
Joined: Wed Dec 20, 2006 2:25 pm
Location: USA
Contact:

Post by jwick »

We only redistribute the Logitech GamePanel SDK. We don't have much experience with it.

The best place to find out more about it would be the Logitech forums.
Post Reply