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

📄 hid_keyboard_aux.c

📁 根據bluelab3.5.2實例hid-keyboard做出應用
💻 C
字号:
/****************************************************************************
Copyright (C) Cambridge Silicon Radio Ltd. 2005-2006
Part of BlueLab 3.5.2-release

FILE NAME
    hid_keyboard_aux.c        
DESCRIPTION
    This file contains the aux key functions.
NOTES

*/

/****************************************************************************
    Header files
*/
#include "hid_keyboard.h"
#include "hid_keyboard_sm.h"
#include "hid_keyboard_aux.h"

/*************************************************************************
NAME    
    appSendAuxKeyReport
DESCRIPTION
    Sends an aux key input report.
RETURNS
    void     
*/
void appSendAuxKeyReport(appTaskData *theApp)
{
	uint8 data[2];

	MAIN_PRINT(("appSendAuxKeyReport\n"));

	/* Disconnect HID tranform from interrupt sink */
   	StreamDisconnect(StreamHidSource(), theApp->interrupt_sink);

	/* Initialise input report */
	data[0] = 0x02;
	data[1] = theApp->aux_keys_state;

	/* Send input report */
	HidInterruptReport(theApp->hid, hid_report_input, 2, data);

	/* Connect HID transform in interrupt sink */
    StreamConnect(StreamHidSource(), theApp->interrupt_sink);
}

/*************************************************************************
NAME    
    appHandleDataAux
DESCRIPTION
    Handles aux key data on interrupt channel passed down by firmware.
RETURNS
    void     
*/
void appHandleDataAux(appTaskData *theApp, Source source)
{
    int size;
       
    /* Loop, pulling packets from source */
    while ((size = SourceBoundary(source)) != 0)
    {
		const uint8 *ptr = SourceMap(source);
              
		MAIN_PRINT(("appHandleAuxData %x\n", ptr[0]));
	
		/* Store state of aux keys (Bits 0, 1 & 2) */
		theApp->aux_keys_state = ptr[0] & 0x07;

		/* Check if in report mode */
		if (theApp->keyboard_protocol == hid_protocol_report)
		{
			/* Check we are connected */
			if (appGetState(theApp) == appCabledConnected)
				appSendAuxKeyReport(theApp);
		}

		/* We don't have a connect button, so we simulate it by looking for the
		   three aux buttons being held down */
		/*pioExternal(&theApp->pioState, 0x01, (theApp->aux_keys_state == 0x07) ? 0x01 : 0);*/
        
		/* Discard the packet */
		SourceDrop(source, size);
    } 
}

⌨️ 快捷键说明

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