1 /*---------------------------------------------------------------------------*
2   Project:	Caf� KBD RPL
3   File: 	kpr.h
4 
5   Copyright (C) 2013 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 
14 #ifndef __KPR_H__
15 #define __KPR_H__
16 
17 #ifdef __cplusplus
18 extern "C" {
19 #endif
20 
21 // KPR_FLUSH_AKP_CHAR is the character used to finish an Alt+keypad sequence.
22 // KPR_FLUSH_ALL_CHAR will "flush" all unprocessed characters in a queue.
23 
24 #define KPR_FLUSH_AKP_CHAR 0x0000
25 #define KPR_FLUSH_ALL_CHAR 0xffff
26 
27 typedef enum _KPRMode
28 {
29     KPR_MODE_NONE               = 0x00,
30     KPR_MODE_ALT_KEYPAD         = 0x01,
31     KPR_MODE_DEADKEY            = 0x02,
32     KPR_MODE_JP_ROMAJI_HIRAGANA = 0x04, // this and the next
33     KPR_MODE_JP_ROMAJI_KATAKANA = 0x08  // are mutually exclusive
34 } KPRMode;
35 
36 // Note: 5 characters is the longest queue length necessary.
37 // Do not make this bigger; KPR is not a general-purpose queue.
38 #define KPR_MAX_QUEUE_LEN  5
39 
40 typedef struct _KPRQueue
41 {
42     wchar_t  text[ KPR_MAX_QUEUE_LEN ];
43     KPRMode mode;
44     u8       oCount; // number of characters available for output
45     u8       iCount; // number of characters that are input
46     u32      altVal; // for building up Alt-keypad value
47 } KPRQueue;
48 
49 void    KPRInitRegionUS ( void );
50 void    KPRInitRegionJP ( void );
51 void    KPRInitRegionEU ( void );
52 
53 void    KPRInitQueue    ( KPRQueue *queue );
54 void    KPRClearQueue   ( KPRQueue *queue );
55 void    KPRSetMode      ( KPRQueue *queue, KPRMode mode );
56 KPRMode KPRGetMode      ( KPRQueue *queue );
57 u8      KPRPutChar      ( KPRQueue *queue, wchar_t inChar );
58 wchar_t KPRGetChar      ( KPRQueue *queue );
59 wchar_t KPRRemoveChar   ( KPRQueue *queue );
60 u8      KPRLookAhead    ( KPRQueue *queue, wchar_t *string, u32 maxSize );
61 
62 #ifdef __cplusplus
63 }
64 #endif
65 
66 #endif // __KPR_H__
67