//--------------------INI---------------- Widget::Widget(BtPCModul * btmodul_,NXTclass ** nxtclass_,int max_device_,Qserver *qserver_, QWidget *parent) : QWidget(parent), ui(new Ui::Widget) { qserver=qserver_; max_device=max_device_; // MAX_DEVICE=; nxtclass=nxtclass_; btmodul=btmodul_; RobActNom=1; ui->setupUi(this); //RemControl timer = new QTimer(this); connect(timer, SIGNAL(timeout()), this, SLOT(RC_send())); for(int i=0; i<256; i++) keys[i]=0; key_shift=0; connect(btmodul,SIGNAL(NewDevice()),this,SLOT(SearchingNewDevice())); connect(qserver,SIGNAL(NewChange()),this,SLOT(NewChange())); ui->GB_search->setHidden(1); ui->GB_search->setGeometry(0,0,300,200); this->setGeometry(300,300,300,200); ui->GB_remote->setHidden(1); ui->GB_remote->setGeometry(0,0,300,200); refresh(); }
virtual HRESULT STDMETHODCALLTYPE OnDeviceAdded(LPCWSTR pwstrDeviceId) { MFDebug_Log(2, MFStr("WASAPI: Device added: %S", pwstrDeviceId)); char temp[128]; MFString_CopyUTF16ToUTF8(temp, pwstrDeviceId); MFDevice *pDev = MFDevice_GetDeviceById(temp); if(!pDev) pDev = NewDevice(pwstrDeviceId); return S_OK; }
virtual HRESULT STDMETHODCALLTYPE OnDefaultDeviceChanged(EDataFlow flow, ERole role, LPCWSTR pwstrDefaultDeviceId) { MFDebug_Log(2, MFStr("WASAPI: Default device changed: %S", pwstrDefaultDeviceId)); char temp[128]; MFString_CopyUTF16ToUTF8(temp, pwstrDefaultDeviceId); MFDevice *pDev = MFDevice_GetDeviceById(temp); if(!pDev) pDev = NewDevice(pwstrDefaultDeviceId); if(pDev) MFDevice_SetDefaultDevice(gDt[flow], gDef[role], pDev); return S_OK; }
virtual HRESULT STDMETHODCALLTYPE OnDeviceRemoved(LPCWSTR pwstrDeviceId) { MFDebug_Log(2, MFStr("WASAPI: Device removed: %S", pwstrDeviceId)); char temp[128]; MFString_CopyUTF16ToUTF8(temp, pwstrDeviceId); MFDevice *pDev = MFDevice_GetDeviceById(temp); if(!pDev) pDev = NewDevice(pwstrDeviceId); if(pDev) UpdateState(pDev, DEVICE_STATE_UNPLUGGED); return S_OK; }
virtual HRESULT STDMETHODCALLTYPE OnDeviceStateChanged(LPCWSTR pwstrDeviceId, DWORD dwNewState) { MFDebug_Log(2, MFStr("WASAPI: State changed: %d (%S)", dwNewState, pwstrDeviceId)); char temp[128]; MFString_CopyUTF16ToUTF8(temp, pwstrDeviceId); MFDevice *pDev = MFDevice_GetDeviceById(temp); if(!pDev) pDev = NewDevice(pwstrDeviceId); if(pDev) UpdateState(pDev, dwNewState); return S_OK; }
KSGDeviceNode* KSGDeviceManager::NewDevice( int did, KSGDeviceNode *parent, const std::string& phyid, NormalDeviceType devtype) { KSGDevice* dev = FindDeviceType(devtype); if(!dev) { throw DevTypeNotExists(); } return NewDevice(did,parent,phyid,dev); }
int PASCAL WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR cmdLine, int nCmdShow ) #endif { Main::hInstance = hInstance; Main::hPrevInstance = hPrevInstance; Main::nCmdShow = nCmdShow; if ( ! Main::hPrevInstance ) { MainWindow::Register(); } Palette palette; palette.Shade16(); Device *dev = NewDevice(WinX, WinY, &palette); MainApp app(*dev); return Main::MessageLoop(app); }
int main() #endif { #ifndef LINUX #ifndef SDL SetCurrentDirectory("C:\\Mes documents\\Mes Programmes\\All Platform Projects\\Data"); //SetCurrentDirectory("D:\\YOB\\Perso\\3d\\All Platform Projects\\Data"); Main::hInstance = hInstance; Main::hPrevInstance = hPrevInstance; Main::nCmdShow = nCmdShow; if ( ! Main::hPrevInstance ) { MainWindow::Register(); } #endif #endif Palette palette; palette.Shade16(); Device * dev = NewDevice(WinX, WinY, &palette); MainApp app(*dev, palette); return app.Launch(); }
/* ************************************************************************* * MiniportInitialize ************************************************************************* * * * Initializes the network interface card. * * * */ NDIS_STATUS MiniportInitialize ( PNDIS_STATUS OpenErrorStatus, PUINT SelectedMediumIndex, PNDIS_MEDIUM MediumArray, UINT MediumArraySize, NDIS_HANDLE NdisAdapterHandle, NDIS_HANDLE WrapperConfigurationContext ) { UINT mediumIndex; IrDevice *thisDev = NULL; NDIS_STATUS retStat, result = NDIS_STATUS_SUCCESS; DBGOUT(("MiniportInitialize()")); /* * Search the passed-in array of supported media for the IrDA medium. */ for (mediumIndex = 0; mediumIndex < MediumArraySize; mediumIndex++){ if (MediumArray[mediumIndex] == NdisMediumIrda){ break; } } if (mediumIndex < MediumArraySize){ *SelectedMediumIndex = mediumIndex; } else { /* * Didn't see the IrDA medium */ DBGERR(("Didn't see the IRDA medium in MiniportInitialize")); result = NDIS_STATUS_UNSUPPORTED_MEDIA; goto _initDone; } /* * Allocate a new device object to represent this connection. */ thisDev = NewDevice(); if (!thisDev){ return NDIS_STATUS_NOT_ACCEPTED; } /* * Allocate resources for this connection. */ if (!OpenDevice(thisDev)){ DBGERR(("OpenDevice failed")); result = NDIS_STATUS_FAILURE; goto _initDone; } /* * Read the system registry to get parameters like COM port number, etc. */ if (!Configure(thisDev, WrapperConfigurationContext)){ result = NDIS_STATUS_FAILURE; goto _initDone; } /* * This call will associate our adapter handle with the wrapper's * adapter handle. The wrapper will then always use our handle * when calling us. We use a pointer to the device object as the context. */ NdisMSetAttributes ( NdisAdapterHandle, (NDIS_HANDLE)thisDev, FALSE, NdisInterfaceInternal ); /* * Tell NDIS about the range of IO space that we'll be using. */ retStat = NdisMRegisterIoPortRange( (PVOID)thisDev->mappedPortRange, NdisAdapterHandle, thisDev->portInfo.ioBase, 8); if (retStat != NDIS_STATUS_SUCCESS){ DBGERR(("NdisMRegisterIoPortRange failed")); result = NDIS_STATUS_FAILURE; goto _initDone; } /* * Record the NDIS wrapper's handle for this adapter, which we use * when we call up to the wrapper. * (This miniport's adapter handle is just thisDev, the pointer to the device object.). */ DBGOUT(("NDIS handle: %xh <-> IRMINI handle: %xh", (UINT)NdisAdapterHandle, (UINT)thisDev)); thisDev->ndisAdapterHandle = NdisAdapterHandle; /* * Open COMM communication channel. * This will let the dongle driver update its capabilities from their default values. */ if (!DoOpen(thisDev)){ DBGERR(("DoOpen failed")); result = NDIS_STATUS_FAILURE; goto _initDone; } /* * Register an interrupt with NDIS. */ retStat = NdisMRegisterInterrupt( (PNDIS_MINIPORT_INTERRUPT)&thisDev->interruptObj, NdisAdapterHandle, thisDev->portInfo.irq, thisDev->portInfo.irq, TRUE, // want ISR TRUE, // MUST share interrupts NdisInterruptLevelSensitive ); if (retStat != NDIS_STATUS_SUCCESS){ DBGERR(("NdisMRegisterInterrupt failed")); result = NDIS_STATUS_FAILURE; goto _initDone; } _initDone: if (result == NDIS_STATUS_SUCCESS){ /* * Add this device object to the beginning of our global list. */ thisDev->next = firstIrDevice; firstIrDevice = thisDev; DBGOUT(("MiniportInitialize succeeded")); } else { if (thisDev){ FreeDevice(thisDev); } DBGOUT(("MiniportInitialize failed")); } return result; }
void BtPCModul ::Find_Device(int time) { //m_device_id=0; BLUETOOTH_DEVICE_INFO m_device_info= {sizeof(BLUETOOTH_DEVICE_INFO),0,}; ZeroMemory(&m_device_info, sizeof(BLUETOOTH_DEVICE_INFO)); m_device_info.dwSize = sizeof(BLUETOOTH_DEVICE_INFO); BLUETOOTH_DEVICE_SEARCH_PARAMS m_search_params = { sizeof(BLUETOOTH_DEVICE_SEARCH_PARAMS), 1, 1, 1, 1, 1, time, NULL }; m_search_params.hRadio = m_radio; HBLUETOOTH_DEVICE_FIND m_bt_dev = BluetoothFindFirstDevice(&m_search_params, &m_device_info); printf("Start searching..."); if(m_bt_dev != NULL) printf("\nBluetoothFindFirstDevice() is working!\n"); else { printf("\nBluetoothFindFirstDevice() failed with error code %d\n", GetLastError()); return; } do { //SaveAddr[m_device_id]=m_device_info.Address; // Well, the found device information can be used for further socket // operation such as creating a socket, bind, listen, connect, send, receive etc.. // If no more device, exit the loop //if(!BluetoothFindNextDevice(m_bt_dev, &m_device_info)) char newaddr[18]; ba2str(m_device_info.Address,newaddr); bool bnew=true; for (int i=0; i<m_device_id; i++) { if (!memcmp(newaddr,BTaddr[i],18)) { bnew=false; } } if (bnew) { wprintf(L"\n\tDevice %d:\r\n", m_device_id); wprintf(L" \tInstance Name: %s\r\n", m_device_info.szName); wprintf(L" \tAddress: %02X:%02X:%02X:%02X:%02X:%02X\r\n", m_device_info.Address.rgBytes[5],m_device_info.Address.rgBytes[4], m_device_info.Address.rgBytes[3], m_device_info.Address.rgBytes[2],m_device_info.Address.rgBytes[1], m_device_info.Address.rgBytes[0]); wprintf(L" \tClass: 0x%08x\r\n", m_device_info.ulClassofDevice); wprintf(L" \tConnected: %s\r\n", m_device_info.fConnected ? L"true" : L"false"); wprintf(L" \tAuthenticated: %s\r\n", m_device_info.fAuthenticated ? L"true" : L"false"); wprintf(L" \tRemembered: %s\r\n", m_device_info.fRemembered ? L"true" : L"false"); memcpy(BTaddr[m_device_id],newaddr,18); //ba2str(m_device_info.Address,BTaddr[m_device_id]); for(int j=0; j<BLUETOOTH_MAX_SIZE_NAME; j++) SaveName[m_device_id][j]=m_device_info.szName[j]; m_device_id++; emit NewDevice(); } } while((BluetoothFindNextDevice(m_bt_dev, &m_device_info))); if(BluetoothFindDeviceClose(m_bt_dev)) printf("\nBluetoothFindDeviceClose(m_bt_dev) is OK!\n"); else printf("\nBluetoothFindDeviceClose(m_bt_dev) failed with error code %d\n", GetLastError()); }