14 #error TnbCeBluetoothAvrcpWatcher.h is only supported on Windows CE platforms.
28typedef struct _AvrcpMsg {
134 m_inner.pListener = NULL;
143 m_inner.pListener = P;
153 return m_inner.msgQueue.IsStarted();
163 LPCTSTR lpszAvrcpQueueName = _T(
"Avrcp10MsgQ");
165 m_inner.msgQueue.SetListener(&m_inner);
166 MSGQUEUEOPTIONS opt = { 0 };
167 opt.dwFlags = MSGQUEUE_ALLOW_BROKEN;
168 opt.dwMaxMessages = 20;
169 opt.cbMaxMessage = 100;
170 opt.bReadAccess = TRUE;
171 if ( m_inner.msgQueue.Start(lpszAvrcpQueueName, opt, _T(
"AVRCP Watch")) )
175 DWORD r = ::GetLastError();
189 return m_inner.msgQueue.Stop();
198 return m_inner.msgQueue.ReferThreadStatus();
209 CStr s = _T(
"unknown");
210 if ( code == PassThru_t )
213 #define _x_(SS) case SS##_t: s = _T(#SS); break;
217 _x_(Up); _x_(Down); _x_(Left); _x_(Right);
218 _x_(RightUp); _x_(RightDown); _x_(LeftUp); _x_(LeftDown);
219 _x_(RootMenu); _x_(SetupMenu);
223 _x_(ChannelUp); _x_(ChannelDown);
225 _x_(SoundSel); _x_(InputSel);
228 _x_(PageUp); _x_(PageDown);
230 _x_(VolUp); _x_(VolDown); _x_(Mute);
231 _x_(Play); _x_(
Stop); _x_(Pause); _x_(Record);
232 _x_(Rewind); _x_(FastFwd);
234 _x_(Forward); _x_(Backward);
240 s += ((
id & 0x80) == 0) ? _T(
" Down") : _T(
" Up");
256 virtual void OnMsgQueueWatcherEvent(
const AvrcpMsg& data,
size_t length,
bool isAlert)
258 if ( pListener != NULL )
260 pListener->OnBluetoothAvrcpEvent(data.OpCode, data.OpId);
282#define AVRCP_MSG_SZ TEXT("Avrcp10MsgQ")
285int AvrcpMsgProcess (
void* p)
287 static int avrcp_tick;
288 bool_t PlayState = 0;
291 int Param = PLAYER_PLAY;
292 node* Player = Context()->Player;
293 MSGQUEUEOPTIONS mqOptions;
294 memset (&mqOptions, 0,
sizeof(mqOptions));
295 mqOptions.dwFlags = MSGQUEUE_ALLOW_BROKEN;
296 mqOptions.dwSize =
sizeof(mqOptions);
297 mqOptions.dwMaxMessages = 2;
298 mqOptions.cbMaxMessage = 100;
299 mqOptions.bReadAccess = TRUE;
300 hMsgQ = CreateMsgQueue(AVRCP_MSG_SZ, &mqOptions);
308 DWORD dwWait = WaitForSingleObject (hMsgQ, INFINITE);
309 NodeRegLoadValue(AVRCP_ID,AVRCP_ENABLE,&bAvrcp,
sizeof(
int),TYPE_INT);
314 if (WAIT_OBJECT_0 == dwWait)
318 DWORD dwBytesRead = 0;
319 BOOL fRet = ReadMsgQueue (hMsgQ, &btAvrcp,
sizeof(AvrcpMsg), &dwBytesRead, 10, &dwFlags);
322 if(hAvrcpConfMode==1)
328 intConfAvrcpMsg=btAvrcp.OpId;
340 if(btAvrcp.OpId==GetAvrcpCmd(AVRCP_PLAY))
343 if(Player->Get(Player,Param,&PlayState,
sizeof(PlayState))==ERR_NONE)
345 PlayState = !PlayState;
349 PlayState = 1 - PlayState;
351 Player->Set(Player,Param,&PlayState,
sizeof(PlayState));
353 else if(btAvrcp.OpId==GetAvrcpCmd(AVRCP_PAUSE))
356 if(Player->Get(Player,Param,&PlayState,
sizeof(PlayState))==ERR_NONE)
358 PlayState = !PlayState;
362 PlayState = 1 - PlayState;
364 Player->Set(Player,Param,&PlayState,
sizeof(PlayState));
366 else if(btAvrcp.OpId==GetAvrcpCmd(AVRCP_STOP))
369 Player->Set(Player,Param,NULL,1);
371 Percent.Den = TRACKMAX;
372 Player->Set(Player,PLAYER_PERCENT,&Percent,
sizeof(Percent));
374 else if(btAvrcp.OpId==GetAvrcpCmd(AVRCP_PREV))
377 Player->Set(Player,Param,NULL,0);
379 else if(btAvrcp.OpId==GetAvrcpCmd(AVRCP_NEXT))
382 Player->Set(Player,Param,NULL,0);
384 else if(btAvrcp.OpId==GetAvrcpCmd(AVRCP_BACKWARD))
386 Param=PLAYER_MOVEBACK;
387 Player->Set(Player,Param,NULL,0);
389 else if(btAvrcp.OpId==GetAvrcpCmd(AVRCP_FORWARD))
391 Param=PLAYER_MOVEFFWD;
392 Player->Set(Player,Param,NULL,0);
394 if(GetAvrcpCmd(AVRCP_OFFSCREEN))
396 if(GetAvrcpCmd(AVRCP_LOCK_KEYPAD)) keybd_event(0x85,0,0,0);
397 SetSystemPowerState( NULL, POWER_STATE_IDLE, POWER_FORCE);
407 CloseMsgQueue(hMsgQ);
CThreadStatus & ReferThreadStatus(void)
[参照] 監視スレッド状態参照.
void SetListener(IListener *P)
[設定] リスナー設定.
CBluetoothAvrcpWatcher(void)
コンストラクタ
bool IsStarted(void) const
[確認] 監視確認.
bool Start(void)
[設定] 監視スタート.
static CStr ToString(DWORD code, DWORD id)
[変換] 文字列化.
bool Stop(void)
[設定] 監視ストップ.
Bluetooth(CE) AVRCP 監視のリスナー.
virtual void OnBluetoothAvrcpEvent(DWORD code, DWORD id)=0
[通知] イベント通知.
virtual ~IListener(void)
デストラクタ