1 /*---------------------------------------------------------------------------*
2   Project:  TwlSDK - screenshot test - Ext
3   File:     ext_keycontrol.h
4 
5   Copyright 2003-2008 Nintendo. All rights reserved.
6 
7   These coded instructions, statements, and computer programs contain
8   proprietary information of Nintendo of America Inc. and/or Nintendo
9   Company Ltd., and are protected by Federal copyright law. They may
10   not be disclosed to third parties or copied or duplicated in any form,
11   in whole or in part, without the prior written consent of Nintendo.
12 
13   $Date:: 2008-09-18#$
14   $Rev: 8573 $
15   $Author: okubata_ryoma $
16  *---------------------------------------------------------------------------*/
17 
18 #include <nitro/types.h>
19 #include <nitro/ext.h>
20 
21 
22 /*---------------------------------------------------------------------------*
23   Name:         EXT_AutoKeys
24 
25   Description:  Key input
26 
27   Arguments:    mode: Current display mode
28 
29   Returns:      Type of current capture mode.
30                 (See GXCaptureMode for more detail.)
31  *---------------------------------------------------------------------------*/
EXT_AutoKeys(const EXTKeys * sequence,u16 * cont,u16 * trig)32 void EXT_AutoKeys(const EXTKeys *sequence, u16 *cont, u16 *trig)
33 {
34     // Key sequence counter
35     static u16 absolute_cnt = 0;
36     static u16 last_key = 0;
37     u16     cnt;
38 
39     cnt = absolute_cnt;
40     while (cnt >= sequence->count)
41     {
42         // If there is a sequence with a count value of 0, regard it as the end
43         if (sequence->count == 0)
44         {
45             return;
46         }
47         cnt -= sequence->count;
48         sequence++;
49     }
50 
51     *cont |= sequence->key;
52     *trig = (u16)(~last_key & *cont);
53     last_key = *cont;
54     absolute_cnt++;
55 }
56