📄 ircommand.h
字号:
#ifndef _IR_COMMAND_H_
#define _IR_COMMAND_H_
#include "hid_commands.h"
/////////////////////////////////////////////
//Definitions of key codes.
/////////////////////////////////////////////
#define KEYBOARD_KEY 0x100
#define VOLUME_KEY 0x200
#define CHANNEL_KEY 0x400
#define PVR_KEY 0x800
//The first byte defines the key type. The second is the HID usage code for keyboard keys
// or the consumer bit flag for consumer keys.
#define KEYBOARD_0 (KEYBOARD_KEY | 0x27)
#define KEYBOARD_1 (KEYBOARD_KEY | 0x1E)
#define KEYBOARD_2 (KEYBOARD_KEY | 0x1F)
#define KEYBOARD_3 (KEYBOARD_KEY | 0x20)
#define KEYBOARD_4 (KEYBOARD_KEY | 0x21)
#define KEYBOARD_5 (KEYBOARD_KEY | 0x22)
#define KEYBOARD_6 (KEYBOARD_KEY | 0x23)
#define KEYBOARD_7 (KEYBOARD_KEY | 0x24)
#define KEYBOARD_8 (KEYBOARD_KEY | 0x25)
#define KEYBOARD_9 (KEYBOARD_KEY | 0x26)
#define KEYBOARD_UP (KEYBOARD_KEY | 0x52)
#define KEYBOARD_DOWN (KEYBOARD_KEY | 0x51)
#define KEYBOARD_LEFT (KEYBOARD_KEY | 0x50)
#define KEYBOARD_RIGHT (KEYBOARD_KEY | 0x4F)
#define KEYBOARD_ENTER (KEYBOARD_KEY | 0x28)
#define KEYBOARD_BACK (KEYBOARD_KEY | 0x2A)
#define VOLUME_UP (VOLUME_KEY | CONSUMER_FLAG_VOLUME_UP)
#define VOLUME_DOWN (VOLUME_KEY | CONSUMER_FLAG_VOLUME_DOWN)
#define VOLUME_MUTE (VOLUME_KEY | CONSUMER_FLAG_VOLUME_MUTE)
#define CHANNEL_UP (CHANNEL_KEY | CONSUMER_FLAG_CHANNEL_UP)
#define CHANNEL_DOWN (CHANNEL_KEY | CONSUMER_FLAG_CHANNEL_DOWN)
#define PVR_PLAY (PVR_KEY | CONSUMER_FLAG_PVR_PLAY)
#define PVR_RECORD (PVR_KEY | CONSUMER_FLAG_PVR_RECORD)
#define PVR_PAUSE (PVR_KEY | CONSUMER_FLAG_PVR_PAUSE)
#define PVR_STOP (PVR_KEY | CONSUMER_FLAG_PVR_STOP)
////////////////////////////////////////////////////////////////
//class IR_Command
////////////////////////////////////////////////////////////////
class IR_Command
{
typedef struct _KEY_INFO
{
BYTE command_code;
DWORD key_code;
}KEY_INFO, *PKEY_INFO;
typedef struct _KEY_TABLE
{
BYTE num_key_codes;
PKEY_INFO p_key_codes;
}KEY_TABLE, *PKEY_TABLE;
public:
IR_Command(BYTE command_table_index);
VOID initialize(ULONG command);
BOOLEAN isKeyboardKey();
BOOLEAN isAutoRepeatKey();
PVOID getReport();
ULONG getReportSize();
protected:
VOID fillConsumerUsageReport();
VOID fillKeyboardUsageReport();
private:
DWORD _key_code;
union _REPORT{
KEYBOARD_USAGE_PAGE_REPORT keyboard_report;
CONSUMER_USAGE_PAGE_REPORT consumer_report;
}_report;
static const KEY_INFO _s_rc5_table[];
static const KEY_INFO _s_cust_table[];
static const KEY_INFO _s_small_remote_table[];
static const KEY_TABLE _s_key_tables[];
UCHAR _table_index;
};
///////////////////////////////////////////////
//inline implementations
///////////////////////////////////////////////
inline PVOID IR_Command::getReport()
{
return &_report;
}
inline ULONG IR_Command::getReportSize()
{
if(isKeyboardKey())
{
return sizeof(KEYBOARD_USAGE_PAGE_REPORT);
}
else
{
return sizeof(CONSUMER_USAGE_PAGE_REPORT);
}
}
inline BOOLEAN IR_Command::isKeyboardKey()
{
return ((_key_code & KEYBOARD_KEY) != 0);
}
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -