/*-------------------------------------------------------
 * 赤外線テレビリモコンの仕様表へのアクセス関数
 *-------------------------------------------------------*/
#include <xc.h>
#include <stdint.h>
#include "mcr.h"
#include "ir-frame.h"
#include "keysym.h"
#include "rc.h"

/* リモコン仕様番号 */
rcs_id_t rcs_id = 0;

/*-------------------------------------------------------
 * フレームからキーシンボルへ変換
 *-------------------------------------------------------*/
enum keysym_e rc_keysym(volatile uint8_t *buff)
{
  const struct keysyms_s *kst = rcspec[rcs_id]->keysyms;
  uint8_t k = 0;
  for (k = 0; kst[k].keysym != KEYSYM_NULL; k++) {
    if ((kst[k].b0 == buff[0]) &&
        (kst[k].b1 == buff[1]) &&
        (kst[k].b2 == buff[2]) &&
        (kst[k].b3 == buff[3])) {
      return kst[k].keysym; /* 登録あり */
    }
  }
  return KEYSYM_NULL; /* 登録なし */
}
