⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cir93xx.cpp

📁 EP9315开发板的Wince6.0的BSP包文件
💻 CPP
字号:
/**********************************************************************
#                                                                      
# Filename: CIR9315A.cpp
#                                                                      
# Description:
#
# THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
# ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
# PARTICULAR PURPOSE.
#
# Use of this source code is subject to the terms of the Cirrus end-user
# license agreement (EULA) under which you licensed this SOFTWARE PRODUCT.
# If you did not accept the terms of the EULA, you are not authorized to 
# use this source code. For a copy of the EULA, please see the 
# EULA.RTF on your install media.
#
# Copyright(c) Cirrus Logic Corporation 2005, All Rights Reserved                       
#                                                                      
#**********************************************************************/
#include <windows.h>
#include <Pkfuncs.h>
#include <nkintr.h>

typedef int (__cdecl *PFN_tprintf)(const TCHAR*, ...);
PFN_tprintf  v_pfn_tprintf;
HMODULE v_hCoreDLL;
BOOL v_fDebugOut=FALSE;


void CIRIntProc(void);

int OutputMessage (TCHAR *pFormat, ...) {

   #define MAX_BUFFER_SIZE 256
    
   va_list ArgList;
   TCHAR Buffer[MAX_BUFFER_SIZE];
   int      RetVal;
   HRESULT  hr;

   va_start (ArgList, pFormat);

   hr = StringCchVPrintf(
            Buffer,
            _countof(Buffer),
            pFormat,
            ArgList);

   if (hr != S_OK)
      return 0x00;

   RetVal = wcslen(Buffer);
   
   if (!v_fDebugOut) {
      if (v_pfn_tprintf == NULL) {
         // Since not all configs contain the wprintf function we'll
         // try to find it.  If it's not there we'll default to using
         // OutputDebugString.
         v_hCoreDLL = LoadLibrary(TEXT("coredll.dll"));
         if (v_hCoreDLL) {
#ifdef UNICODE
            v_pfn_tprintf = (PFN_tprintf)GetProcAddress(v_hCoreDLL, TEXT("wprintf"));
#else 
            v_pfn_tprintf = (PFN_tprintf)GetProcAddress(v_hCoreDLL, TEXT("printf"));
#endif
         }

      }
      if (v_pfn_tprintf != NULL) {
         (v_pfn_tprintf) (TEXT("%s"), Buffer);
      }
      else {
         // Couldn't find the entry point, revert to OutputDebugString()
         v_fDebugOut = TRUE;
      }
   }
   if (v_fDebugOut) {
      OutputDebugString(Buffer);
   }
   return RetVal; 
}


int _tmain(int argc, TCHAR **argv ) 
{
	if( argc >1 ){

		if( argv[1][0] =='/' && ( argv[1][1] =='d' ||argv[1][1] =='D') ){

			v_fDebugOut=TRUE;
		}
	}


	OutputMessage(L"Support Sony TV remote only\r\n");
	OutputMessage(L"All keys except 0~9 are treated as unknown keys\r\n");
	OutputMessage(L"press key \'0\' to exit\r\n");
	
	CIRIntProc();

	return 0;
}


void CIRIntProc(void)
{
	unsigned short keyName[20];
	unsigned long nameLen;
	HANDLE hDevice;

	hDevice=CreateFile(  L"CIR1:",
			  GENERIC_READ, 
			  0, 
			  NULL, 
			  OPEN_EXISTING,
			  0, 
			  NULL
			);

	if( hDevice ==INVALID_HANDLE_VALUE ){

		OutputMessage((L"Can't find CIR device, stop\r\n"));
		return;
	}

	while(1)
	{
		if( ReadFile(hDevice,keyName, sizeof(keyName), &nameLen,  NULL ) ){
			OutputMessage(TEXT("key %s\r\n"), keyName);

			if( '0' == keyName[0] )
				break;
		}
	}
	OutputMessage((L"game over\r\n"));
	return;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -