Ejemplo n.º 1
0
//--------------------------------------------------------------------------------------
// Entry point to the program. Initializes everything and goes into a message processing 
// loop. Idle time is used to render the scene.
//--------------------------------------------------------------------------------------
int WINAPI wWinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int nCmdShow )
{
    UNREFERENCED_PARAMETER( hPrevInstance );
    UNREFERENCED_PARAMETER( lpCmdLine );

    if( FAILED( InitWindow( hInstance, nCmdShow ) ) )
        return 0;

    if( FAILED( InitDevice() ) )
    {
        CleanupDevice();
        return 0;
    }

    // Main message loop
    MSG msg = {0};
    while( WM_QUIT != msg.message )
    {
        if( PeekMessage( &msg, NULL, 0, 0, PM_REMOVE ) )
        {
            TranslateMessage( &msg );
            DispatchMessage( &msg );
        }
        else
        {
            Render();
        }
    }

    CleanupDevice();

    return ( int )msg.wParam;
}
	DirectX9Renderer::DirectX9Renderer(HWND	a_hWindow, D3DPRESENT_PARAMETERS d3dpp)
	{
		m_pD3D = NULL;
		m_pd3dDevice = NULL;
		m_hWindow = a_hWindow;
		InitDevice(d3dpp);
	}
Ejemplo n.º 3
0
gs_device::gs_device(gs_init_data *data)
	: curRenderTarget      (NULL),
	  curZStencilBuffer    (NULL),
	  curRenderSide        (0),
	  curIndexBuffer       (NULL),
	  curVertexBuffer      (NULL),
	  curVertexShader      (NULL),
	  curPixelShader       (NULL),
	  curSwapChain         (&defaultSwap),
	  zstencilStateChanged (true),
	  rasterStateChanged   (true),
	  blendStateChanged    (true),
	  curDepthStencilState (NULL),
	  curRasterState       (NULL),
	  curBlendState        (NULL),
	  curToplogy           (D3D11_PRIMITIVE_TOPOLOGY_UNDEFINED)
{
	ComPtr<IDXGIAdapter1> adapter;

	matrix4_identity(&curProjMatrix);
	matrix4_identity(&curViewMatrix);
	matrix4_identity(&curViewProjMatrix);

	memset(&viewport, 0, sizeof(viewport));

	for (size_t i = 0; i < GS_MAX_TEXTURES; i++) {
		curTextures[i] = NULL;
		curSamplers[i] = NULL;
	}

	InitFactory(data->adapter, adapter.Assign());
	InitDevice(data, adapter);
	device_set_render_target(this, NULL, NULL);
}
Ejemplo n.º 4
0
HRESULT DxWidget::Init(TestQt* mainWin)
{
	HRESULT hrResult = E_FAIL;
	HRESULT hrRetCode = E_FAIL;

	m_pd3dDevice = NULL;
	m_pSwapChain = NULL;
	m_pRenderTargetView = NULL;
	m_pTechnique = NULL;
	m_pVertexLayout = NULL;
	m_pVertexBuffer = NULL;
	m_pEffect = NULL;
	m_pMainWin = mainWin;
	KE_PROCESS_ERROR(m_pMainWin);

	hrRetCode = InitDevice();
	KE_COM_PROCESS_ERROR(hrRetCode);

	QTimer *timer = new QTimer(this);
	KE_PROCESS_ERROR(timer);
	connect(timer, SIGNAL(timeout()), this, SLOT(update()));
	timer->start(20);

	hrResult = S_OK;
Exit0:
	return hrResult;
}
Ejemplo n.º 5
0
int MUCamSource::OnDevice( MM::PropertyBase* pProp, MM::ActionType eAct )
{
#ifdef _LOG_OUT_
    OutputDebugString("OnDevice");
#endif
    if (eAct == MM::AfterSet)
    {
        string strName;
        pProp->Get(strName);
        
        vector<string>::const_iterator begin = DevicesVec_.begin();
        vector<string>::const_iterator end = DevicesVec_.end();
        vector<string>::const_iterator it = find(begin, end, strName);
        vector<string>::difference_type idx = distance(begin, it);
        if (it != end && idx != currentCam_)
        {
            StopSequenceAcquisition();
            if (!OpenCamera(hCameras_[idx])) return DEVICE_ERR;
            currentCam_ = idx;// MIDP_GetCurCameraIndex();
            InitDevice();
        }
    }
    else if (eAct == MM::BeforeGet)
    {
        if(currentCam_ >= 0 && currentCam_ < cameraCnt_)
        {
            string strName = DevicesVec_[currentCam_];
            pProp->Set(strName.c_str());
        }
    }
    
    return DEVICE_OK;
}
Ejemplo n.º 6
0
PleoraVideo::PleoraVideo(Params& p): size_bytes(0), lPvSystem(0), lDevice(0), lStream(0), lDeviceParams(0), lStart(0), lStop(0),
    lTemperatureCelcius(0), getTemp(false), lStreamParams(0), validGrabbedBuffers(0)
{
    std::string sn;
    std::string mn;
    int index = 0;
    size_t buffer_count = PleoraVideo::DEFAULT_BUFFER_COUNT;
    Params device_params;

    for(Params::ParamMap::iterator it = p.params.begin(); it != p.params.end(); it++) {
        if(it->first == "model"){
            mn = it->second;
        } else if(it->first == "sn"){
            sn = it->second;
        } else if(it->first == "idx"){
            index = p.Get<int>("idx", 0);
        } else if(it->first == "buffers"){
            buffer_count = p.Get<size_t>("buffers", PleoraVideo::DEFAULT_BUFFER_COUNT);
        } else {
            device_params.Set(it->first, it->second);
        }
    }

    InitDevice(mn.empty() ? 0 : mn.c_str(), sn.empty() ? 0 : sn.c_str(), index);
    SetDeviceParams(device_params);
    InitStream();

    InitPangoStreams();
    InitBuffers(buffer_count);

    Start();
}
Ejemplo n.º 7
0
/**
 * Intializes the hardware.
 * Typically we access and initialize hardware at this point.
 * Device properties are typically created here as well.
 * Required by the MM::Device API.
 */
int MUCamSource::Initialize()
{
    if (!LoadFunctions())
        return DEVICE_ERR;
    if (initialized_)
        return DEVICE_OK;

    // set property list
    // -----------------
    FindMoticCameras();
    if(cameraCnt_ == 0)
    {
        return ERR_NO_CAMERAS_FOUND;
    }

    currentCam_ = 0;//MIDP_GetCurCameraIndex();
    int ret;
    CPropertyAction* pAct;
    if (!OpenCamera(hCameras_[currentCam_])) return DEVICE_ERR;
    char sName[Camera_Name_Len];
    GetMotiCamNAME(hCameras_[currentCam_], sName);
    //memcpy(sName, GetMotiCamNAME(hCameras_[currentCam_]), Camera_Name_Len);
    pAct = new CPropertyAction(this, &MUCamSource::OnDevice);
    ret = CreateProperty(g_Keyword_Cameras, sName, MM::String, true, pAct);
    ret = SetAllowedValues(g_Keyword_Cameras, DevicesVec_);
    assert(ret == DEVICE_OK);
    
    ret = InitDevice();
    if(ret == DEVICE_OK)
    {
        initialized_ = true;
    }

    return ret;
}
  //----------------------------------------------------------------------------
  bool MediaFoundationVideoDevice::SetupDevice(unsigned int streamIndex, unsigned int formatIndex)
  {  
    if(this->IsSetup)
    {
      LOG_ERROR("MediaFoundationVideoDevice::SetupDevice failed: device " << this->DeviceIndex << " is already set up");
      return false;
    }

    HRESULT hr = InitDevice();
    if(FAILED(hr))
    {
      LOG_ERROR("MediaFoundationVideoDevice::SetupDevice failed: device " << this->DeviceIndex << " interface IMFMediaSource cannot be retrieved");
      return false;
    }

    this->Width = this->CurrentFormats[streamIndex][formatIndex].width; 
    this->Height = this->CurrentFormats[streamIndex][formatIndex].height;
    this->FrameRate = this->CurrentFormats[streamIndex][formatIndex].MF_MT_FRAME_RATE;
    hr = SetDeviceFormat(this->Source, (DWORD)streamIndex, (DWORD) formatIndex);
    this->IsSetup = (SUCCEEDED(hr));
    if(this->IsSetup)
    {
      LOG_DEBUG("MediaFoundationVideoDevice::SetupDevice: device " << this->DeviceIndex << " device is setup");
    }
    this->PreviousParameters = GetParameters();
    this->ActiveType = formatIndex;
    return this->IsSetup;
  }
Ejemplo n.º 9
0
static status_t
device_open(const char* name, uint32 /*flags*/, void** cookie)
{
	status_t status = B_OK;

	TRACE("device_open() - name: %s\n", name);

	// Find the device name in the list of devices.

	int32 i = 0;
	while (gDeviceNames[i] != NULL && (strcmp(name, gDeviceNames[i]) != 0))
		i++;

	if (gDeviceNames[i] == NULL)
		return B_BAD_VALUE;		// device name not found in list of devices

	DeviceInfo& di = gDeviceInfo[i];

	gLock.Acquire();	// make sure no one else has write access to common data

	if (di.openCount == 0)
		status = InitDevice(di);

	gLock.Release();

	if (status == B_OK) {
		di.openCount++;		// mark device open
		*cookie = &di;		// send cookie to opener
	}

	TRACE("device_open() returning 0x%lx,  open count: %ld\n", status,
		di.openCount);
	return status;
}
Ejemplo n.º 10
0
bool DX11::CreateWindow()
{
  static LPCWSTR AMJU_WINDOW_CLASS_NAME = L"MY_WINDOWS_CLASS";

  // Register class
  WNDCLASSEX wcex;
  wcex.cbSize = sizeof( WNDCLASSEX );
  wcex.style = CS_HREDRAW | CS_VREDRAW;
  wcex.lpfnWndProc = MyDefaultWndProc; // TODO you should supply your own
  wcex.cbClsExtra = 0;
  wcex.cbWndExtra = 0;
  wcex.hInstance = g_hInst; 
  wcex.hIcon = 0; 
  wcex.hCursor = LoadCursor( NULL, IDC_ARROW );
  wcex.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH); 
  wcex.lpszMenuName = NULL;
  wcex.lpszClassName = AMJU_WINDOW_CLASS_NAME; 
  wcex.hIconSm = 0; 
  if( !RegisterClassEx( &wcex ) )
      return false; 

  HWND hWnd = CreateWindowEx(
    NULL, 
    AMJU_WINDOW_CLASS_NAME, 
    L"DX Boiler", // TODO you should supply a window title
    WS_OVERLAPPEDWINDOW | WS_VISIBLE,		
    100, 
    100, 
    640, // TODO you should supply width 
    480, // ..and height 
    NULL, 
    NULL, 
    g_hInst, 
    NULL);
 
  if (!hWnd)
  {
    return false; 
  }

  ShowWindow(hWnd, SW_SHOW);
  UpdateWindow(hWnd);
  g_hWnd = hWnd;

  if (!m_input.Init(&g_hWnd))
  {
	  return false;
  }
 

  if (InitDevice() != S_OK)
  {
    return false;
  }

  return true;
}
void CComponentInputKeyboard::Init(CInputDevice* pcDevice, CComponentInput* pcComponentInput)
{
	CInputVirtualDevice*		pcVirtual;

	pcVirtual = pcDevice->CreateDefaultVirtualDeviceFromThis("Text Editor Input");
	InitDevice(pcVirtual, pcDevice, pcComponentInput);
	InitKeyboard(pcComponentInput->GetInput());
	pcVirtual->Enable();
}
Ejemplo n.º 12
0
bool COSSAudioSource::Init(void)
{
  bool rc = InitAudio(true);

  if (!rc) {
    return false;
  }

  if (!InitDevice()) {
    return false;
  }
  rc = SetAudioSrc(
                   PCMAUDIOFRAME,
                   m_channelsConfigured,
                   m_pConfig->GetIntegerValue(CONFIG_AUDIO_SAMPLE_RATE));

  if (!rc) {
    return false;
  }

  // for live capture we can match the source to the destination
  m_audioSrcSamplesPerFrame = m_audioDstSamplesPerFrame;
  m_pcmFrameSize = 
    m_audioSrcSamplesPerFrame * m_audioSrcChannels * sizeof(u_int16_t);

  if (m_audioOssMaxBufferSize > 0) {
    size_t array_size;
    m_audioOssMaxBufferFrames = m_audioOssMaxBufferSize / m_pcmFrameSize;
    if (m_audioOssMaxBufferFrames == 0) {
      m_audioOssMaxBufferFrames = 1;
    }
    array_size = m_audioOssMaxBufferFrames * sizeof(*m_timestampOverflowArray);
    m_timestampOverflowArray = (Timestamp *)Malloc(array_size);
    memset(m_timestampOverflowArray, 0, array_size);
  }
    
  m_pcmFrameBuffer = (u_int8_t*)malloc(m_pcmFrameSize);
  if (!m_pcmFrameBuffer) {
    goto init_failure;
  }

  // maximum number of passes in ProcessAudio, approx 1 sec.
  m_maxPasses = m_audioSrcSampleRate / m_audioSrcSamplesPerFrame;

  return true;

 init_failure:
  debug_message("audio initialization failed");

  free(m_pcmFrameBuffer);
  m_pcmFrameBuffer = NULL;

  close(m_audioDevice);
  m_audioDevice = -1;
  return false;
}
Ejemplo n.º 13
0
void main() {
     InitDevice();
     
     while(1){
         GetLuminosity();
         GetTemperatureHumidity();
         Uart1_Write_Text(&packet[0]);
         Delay_ms(20000); //20sec
     }
}
Ejemplo n.º 14
0
//--------------------------------------------------------------------------------------
// WinMain
//--------------------------------------------------------------------------------------
int WINAPI wWinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int nCmdShow )
{
	// デバッグ ヒープ マネージャによるメモリ割り当ての追跡方法を設定
	_CrtSetDbgFlag( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF );

	//Oculus Riftの初期化
	if (InitOculusRift() == 1)
	{
		CleanupDevice();
		return 1;
	}

	//ウィンドウの作成
	if(!InitWindow( hInstance, nCmdShow ) )
	{
		CleanupDevice();
		return 1;
	}

	//DirectXの初期化
	if(FAILED(InitDevice()))
	{
		CleanupDevice();
		return 1;
	}

	// Oculusで使用するDirectXのオブジェクトを作成する
	if (FAILED(InitOculusRiftObjects(3U, HMD)))
	{
		CleanupDevice();
		return 1;
	}

	//メッセージループのメイン
	MSG msg = {0};
	while( WM_QUIT != msg.message )
	{
		if( PeekMessage( &msg, NULL, 0, 0, PM_REMOVE ) )
		{
			TranslateMessage( &msg );
			DispatchMessage( &msg );
		}
		else
		{
			//ここにメインループを書く
			Render();
		}
	}

	//終了処理
	CleanupDevice();

	return (int) msg.wParam;
}
Ejemplo n.º 15
0
int main(int argc, char *argv[])
{
	assert(argc == 2);
	char * outFileName = argv[1];
	FILE *outFile = fopen(outFileName, "w");
	
	
	int dtFlyPinitStatus = InitDevice(userIntHandler);
	assert(dtFlyPinitStatus == 0);	
	int status;
/*	
	uint32_t regData[1];
	uint32_t regAddress = 513;
	
	// Read, write, then read again register 0
	// ReadWriteConfigRegs(direction, registerNumber, registerDataBuffer, numberOfRegisters)
	status = ReadWriteConfigRegs(READ, regAddress, regData, 1);
	printf("Read status is %d, value is %08lx\n", status, regData[0]);

	regData[0] = 0x12345678;
	status = ReadWriteConfigRegs(WRITE, regAddress, regData, 1);
	printf("Write status is %d\n", status);

	status = ReadWriteConfigRegs(READ, regAddress, regData, 1);
	printf("Read status is %d, value is %08lx\n", status, regData[0]);

	*/
	
	/*
	 * Read and dump to file
	 */ 
	SBufferInit buffer;
	unsigned bufferIndex = 0;
	AllocateBuffer(bufferIndex, &buffer);
	
	for(int nReads = 0; nReads < 10; nReads += 1) {
		status = ReceiveDMAbyBufIndex(DMA1, bufferIndex, 1);
		if(status > 0) {
			uint64_t *wordBuffer = (uint64_t *)buffer.UserAddr;
			int nWords = status / sizeof(uint64_t);
			
			for(int i = 0; i < nWords; i++) {
				fprintf(outFile, "%016llx\n", wordBuffer[i]);
			}
		}
	}	
	ReleaseBuffer(bufferIndex);	
	
	
	
	ReleaseDevice();
	fclose(outFile);
	return 0;
}
Ejemplo n.º 16
0
/* It's the main function for the program, what more do you need to know? */
int main() {
    int16_t  Degrees = 0;
    uint8_t  SregSave;
    //int16_t  Correction = 0;

    Degrees = Degrees; //Because it's a warning otherwise, and I don't think I can get rid of it
    DataReady = FALSE;

    /* Setup the ATmega328p */
    InitDevice();

    /* Enable interrupts */
    sei();

    /* Wait till we get data */
    while(!DataReady);

    /* Main loop */
    while(TRUE) {
        /* If there is pending data, process it */
        if(DataReady) {
            SregSave = SREG; /* Preserve the status register */
            /* We want the data retrevial completely performed without interruptions */
            cli();
            //Hand off to a function

            Degrees = ProcessData();

            DataReady = FALSE;

            /* Restore the status register */
            SREG = SregSave;
        }

        //Currently not used, add in later once supplies are received
        /* Check to see if the calibration circuit is active, and if so, adjust
         * change the mode to calibration mode
         */
        //if(bit_is_clear(PORTD, PD4)) {
        /* Check to so see if there is a low signal from the calibration circuit */
        //Correction = Calibrate(Correction, Degrees);
        //} else {
        /* If we aren't calibrating, display the direction and such */
        LcdWriteString(HeadingString(Degrees), LCD_LINE_ONE);
        //}
        //Degrees += Correction;

        //LcdWriteString(("Degrees: %d", Degrees), LCD_LINE_TWO); //TODO fix this!
    }
    /* If this is ever called, I don't even know anymore */
    return 0;
}
Ejemplo n.º 17
0
bool CALSAAudioSource::Init(void)
{
  bool rc = InitAudio(true);

  if (!rc) {
    return false;
  }

  if (!InitDevice()) {
    return false;
  }

  //#error we will have to remove this below - the sample rate will be
  rc = SetAudioSrc(
                   PCMAUDIOFRAME,
                   m_channelsConfigured,
                   m_pConfig->GetIntegerValue(CONFIG_AUDIO_SAMPLE_RATE));

  if (!rc) {
    return false;
  }

  // for live capture we can match the source to the destination
  //  m_audioSrcSamplesPerFrame = m_audioDstSamplesPerFrame;
  // gets set 
  m_pcmFrameSize = m_audioSrcSamplesPerFrame * m_audioSrcChannels * sizeof(u_int16_t);

  if (m_audioMaxBufferSize > 0) {
    size_t array_size;
    m_audioMaxBufferFrames = m_audioMaxBufferSize / m_pcmFrameSize;
    if (m_audioMaxBufferFrames == 0) {
      m_audioMaxBufferFrames = 1;
    }
    array_size = m_audioMaxBufferFrames * sizeof(*m_timestampOverflowArray);
    m_timestampOverflowArray = (Timestamp *)Malloc(array_size);
    memset(m_timestampOverflowArray, 0, array_size);
  }
    
  // maximum number of passes in ProcessAudio, approx 1 sec.
  m_maxPasses = m_audioSrcSampleRate / m_audioSrcSamplesPerFrame;

  return true;

#if 0
 init_failure:
  debug_message("audio initialization failed");

  snd_pcm_close(m_pcmHandle);
  m_pcmHandle = -1;
  return false;
#endif
}
Ejemplo n.º 18
0
void OnResetDevice(void)
{
	D3DPRESENT_PARAMETERS &d3dpp = d3d::GetGlobleD3DPP();
	if(FAILED(Device->Reset(&d3dpp)))
	{
		return;
	}

	/*
	m_sprite->OnResetDevice();
	m_font->OnResetDevice();
	*/
	InitDevice();
}
Ejemplo n.º 19
0
/*********************************************************************
*
*                            Main Function 
*
*********************************************************************/
void main(void)
{    
    InitDevice();
    
    while(1)
    {
         // Transmit message
         ECAN_Transmit();
         // Toggle LED
         Heartbeat();
         // Delay for one millisecond 
         Delay(ONE_MS);
    }
}
Ejemplo n.º 20
0
HX_RESULT CHXAudioDevice::CheckFormat(const HXAudioFormat* pFormat)
{
    HX_RESULT res = HXR_FAIL;

    //Symbian only supports 16-bit PCM.
    if (pFormat->uBitsPerSample == 16 &&
        HXR_OK == OpenDevice() &&
        HXR_OK == InitDevice(pFormat))
    {
        res = HXR_OK;
    }

    return res;
}
Ejemplo n.º 21
0
BOOL CMidiChCtrlDlg::OnInitDialog()
{
	CDialogEx::OnInitDialog();

	::SetWindowLong(cmbBank.GetSafeHwnd(), GWL_USERDATA, -1);
	::SetWindowLong(cmbProg.GetSafeHwnd(), GWL_USERDATA, -1);
	// TODO: ここに初期化を追加してください
	if (theCh != 0) {
		InitDevice();
	}

	hTimer = SetTimer(0, 10, 0);
	return TRUE;  // return TRUE unless you set the focus to a control
	// 例外 : OCX プロパティ ページは必ず FALSE を返します。
}
        void PulseAudioPCMOutputDriver::SetActiveDevice(const DeviceInfo& deviceInfo, const CapabilityInfo& capabilityInfo)
        {
            m_activeDevice = deviceInfo;
            m_selectedCaps.channels = static_cast<uint8_t>(capabilityInfo.channels);
            m_selectedCaps.rate = static_cast<uint32_t>(capabilityInfo.sampleRate);
            m_selectedCaps.format = PA_SAMPLE_S16LE;

            if(m_driver)
            {
                pa_simple_free(m_driver);
                m_driver = nullptr;
            }

            InitDevice();
        }
Ejemplo n.º 23
0
NTSTATUS NTAPI
DriverEntry(PDRIVER_OBJECT DriverObject,
	    PUNICODE_STRING RegistryPath)
/*
 * FUNCTION:  Called by the system to initialize the driver
 * ARGUMENTS:
 *            DriverObject = object describing this driver
 *            RegistryPath = path to our configuration entries
 * RETURNS:   Success or failure
 */
{
//  PDEVICE_EXTENSION DeviceExtension;
//  PDEVICE_OBJECT DeviceObject;
//  DEVICE_INSTANCE Instance;
  // Doesn't support multiple instances (yet ...)
  NTSTATUS Status;

  DPRINT("Sound Blaster Device Driver 0.0.2\n");

//    Instance.DriverObject = DriverObject;
    // previous instance = NULL...

//    DeviceExtension->RegistryPath = RegistryPath;

  DriverObject->Flags = 0;
  DriverObject->MajorFunction[IRP_MJ_CREATE] = BlasterCreate;
  DriverObject->MajorFunction[IRP_MJ_CLOSE] = BlasterClose;
  DriverObject->MajorFunction[IRP_MJ_CLEANUP] = BlasterCleanup;
  DriverObject->MajorFunction[IRP_MJ_DEVICE_CONTROL] = BlasterDeviceControl;
  DriverObject->MajorFunction[IRP_MJ_WRITE] = BlasterWrite;
  DriverObject->DriverUnload = BlasterUnload;

    // Major hack to just get this damn thing working:
    Status = InitDevice(RegistryPath->Buffer, DriverObject);    // ????

//    DPRINT("Enumerating devices at %wZ\n", RegistryPath);

//    Status = EnumDeviceKeys(RegistryPath, PARMS_SUBKEY, InitDevice, (PVOID)&DeviceObject); // &Instance;

    // check error

  /* set up device extension */
//  DeviceExtension = DeviceObject->DeviceExtension;
//  DeviceExtension->BeepOn = FALSE;

//  return(STATUS_SUCCESS);
    return(Status);
}
Ejemplo n.º 24
0
BOOLEAN BASE_init(void)
{
  devInit();
  rwibase_handlers = CreateHandlerList(BASE_NUMBER_EVENTS);
  if(InitDevice()) {
    InitBase();
    BASE_Halt();
    //    BASE_TranslateVelocity(init_trans_speed);
    //    BASE_RotateVelocity(init_rot_speed);
    BASE_reset();
    BASE_EnableStopWhenBump();
    return TRUE;
  }
  else
    return FALSE;
}
	DirectX9Renderer::DirectX9Renderer(HWND	a_hWindow)
	{
		m_pD3D = NULL;
		m_pd3dDevice = NULL;
		m_hWindow = a_hWindow;

		D3DPRESENT_PARAMETERS d3dpp;
		ZeroMemory( &d3dpp, sizeof( d3dpp ) );
		d3dpp.Windowed = TRUE;
		d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
		d3dpp.BackBufferFormat = D3DFMT_UNKNOWN;
		d3dpp.EnableAutoDepthStencil = TRUE;
		d3dpp.AutoDepthStencilFormat = D3DFMT_D24S8;

		InitDevice(d3dpp);
	}
Ejemplo n.º 26
0
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
	// Set current directory to module directory
	wchar_t imagePath[MAX_PATH];
	GetModuleFileName(NULL, imagePath, MAX_PATH);
	size_t pathLen = wcslen(imagePath);
	wchar_t* pathEnd = imagePath + pathLen - 1;
	while (pathEnd >= imagePath && (*pathEnd != L'\\' && *pathEnd != L'/'))
		--pathEnd;

	if (pathEnd >= imagePath)
		*pathEnd++ = 0;

	SetCurrentDirectory(imagePath);
	
	InitWindow(hInstance, nCmdShow);

	InitDevice();
	
	InitFlash();

	ShowWindow(hWnd, nCmdShow);


	while(true) {
		MSG msg;
		if(PeekMessage(&msg, NULL, 0, 0, PM_REMOVE) != 0) {
			if(msg.message == WM_QUIT)
				break;
			else {
				TranslateMessage(&msg);
				DispatchMessage(&msg);
			}
		}
		else 
		{
			DrawFrame();
		}
	}

	DeinitFlash();
	DeinitDevice();

// 	UnregisterClass(wc.lpszClassName, hInstance);

	return 0;
}
Ejemplo n.º 27
0
//*****************************************************************************
//Name        : EVT_Handler
//Author      : None
//Description : Event handle for XMS system
//Input       : esrParam - parameter
//Output      : None
//Return      : 1 - Success 
//              0 - Failure
//*****************************************************************************
DJ_Void EVT_Handler(DJ_U32 esrParam)
{
	Acs_Dev_List_Head_t* pAcsDevList = NULL;
	Acs_Evt_t*			 pAcsEvt = NULL;
	
	pAcsEvt = (Acs_Evt_t *)esrParam;
	
	switch(pAcsEvt->m_s32EventType)
	{
	case XMS_EVT_QUERY_DEVICE:
		if (!g_StartWorkFlag)
		{				
			pAcsDevList = (Acs_Dev_List_Head_t *)FetchEventData(pAcsEvt);
			switch (pAcsDevList->m_s32DeviceMain)
			{
			case XMS_DEVMAIN_INTERFACE_CH:		
				AddDeviceRes(pAcsDevList);
				break;
			}
		}
		break;

	case XMS_EVT_QUERY_DEVICE_END:
		if (!g_StartWorkFlag)
		{	
			pdlg->m_BtnStart.EnableWindow();
			InitDevice();
		}
		break;
	
	case XMS_EVT_OPEN_DEVICE:
		Ack_OpenDevice(pAcsEvt);
		break;

	case XMS_EVT_SIGMON:
		if (g_StartWorkFlag)
		{
		Ack_SigMon(pAcsEvt);
		}
		break;

	default:
		break;
	}
	
	return;
}
Ejemplo n.º 28
0
int WINAPI wWinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int nCmdShow )
{
    UNREFERENCED_PARAMETER( hPrevInstance );
    UNREFERENCED_PARAMETER( lpCmdLine );

#ifdef _WIN64
#   define MSBUILD_OPTION "/m /p:Configuration=Release;Platform=x64"
#   define BUILD_TARGET "x64\\Release"
#else // _WIN64
#   define MSBUILD_OPTION "/m /p:Configuration=Release;Platform=Win32"
#   define BUILD_TARGET "Release"
#endif // _WIN64

    tbb::task_scheduler_init::automatic;
    //tbb::task_scheduler_init init(1); // for debug

    if( FAILED( InitWindow( hInstance, nCmdShow ) ) )
        return 0;

    if( FAILED( InitDevice() ) )
    {
        CleanupDevice();
        return 0;
    }
    InitializeCollisions();

    // Main message loop
    MSG msg = {0};
    while( WM_QUIT != msg.message )
    {
        if( PeekMessage( &msg, NULL, 0, 0, PM_REMOVE ) )
        {
            TranslateMessage( &msg );
            DispatchMessage( &msg );
        }
        else
        {
            Render();
        }
    }

    CleanupDevice();

    return ( int )msg.wParam;
}
Ejemplo n.º 29
0
Archivo: main.c Proyecto: Shmuma/radio
void main (void)
{
    int cnt = 0;

    InitDevice ();
    Delay10KTCYx (250);
    InitializeUSB ();
    InitLCD ();

    /* UCONbits.USBEN = 0; */
    /* UCFGbits.UTRDIS = 0; */
    /* UCFGbits.UPUEN = 1; */
    /* UCFGbits.FSEN = 1; */
    USBDeviceAttach ();

    while (1) {
        WriteLCDChar (UCONbits.USBEN ? '0' : '1');
        WriteLCDChar (UCFGbits.FSEN  ? '0' : '1');
        WriteLCDChar (UCFGbits.UTRDIS ? '0' : '1');
        WriteLCDChar (UCFGbits.UPUEN ? '0' : '1');
        WriteLCDChar ('0' + UCFGbits.PPB);
        WriteLCDChar ('-');
        WriteLCDChar ('0' + USTATbits.ENDP);
        WriteLCDChar ('0' + USTATbits.DIR);
        WriteLCDChar ('0' + USTATbits.PPBI);
        WriteLCDChar ('-');
        putNumber (USBDeviceState);
        WriteLCDChar ('-');
        putNumber (cnt++);
//        if (USBDeviceState == DETACHED_STATE)
//            USBDeviceAttach ();
        Delay10KTCYx (1000);
        LCDHome ();
        Delay10KTCYx (10);
    }
//        if (USBDeviceState < CONFIGURED_STATE)
//            continue;

//        bitset (PORTB, E_PORT);
//        Delay10TCYx (10);
//        ClearLCD ();
//        bitclr (PORTB, E_PORT);
//        Delay10TCYx (10);
//    }
}
        bool PulseAudioPCMOutputDriver::WriteBufferToDevice(const unsigned char* buffer, size_t size)
        {
            InitDevice();

            if(m_driver)
            {
                int error(-1);
                if(pa_simple_write(m_driver, buffer, size, &error) < 0)
                {
                    AWS_LOGSTREAM_ERROR(CLASS_NAME, " error writing buffer to output device " << pa_strerror(error));
                    return false;
                }

                return true;
            }

            return false;
        }