Re-wrote Port::Print() to be variadic.
[rpn.git] / src / wii / port.h
blob7370375ae6cd597ae621e4dcdc738daa4a7f4209
1 /*******************************************************************************
2 * Reverse Polish Notation calculator. *
3 * Copyright (c) 2007-2008, Samuel Fredrickson <kinghajj@gmail.com> *
4 * All rights reserved. *
5 * *
6 * Redistribution and use in source and binary forms, with or without *
7 * modification, are permitted provided that the following conditions are met: *
8 * * Redistributions of source code must retain the above copyright *
9 * notice, this list of conditions and the following disclaimer. *
10 * * Redistributions in binary form must reproduce the above copyright *
11 * notice, this list of conditions and the following disclaimer in the *
12 * documentation and/or other materials provided with the distribution. *
13 * *
14 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER ``AS IS'' AND ANY EXPRESS *
15 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED *
16 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE *
17 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY *
18 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES *
19 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR *
20 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER *
21 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT *
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY *
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH *
24 * DAMAGE. *
25 ******************************************************************************/
27 /*******************************************************************************
28 * port.h - specialized ports for the wii version. *
29 ******************************************************************************/
31 #ifndef DOXYGEN_SKIP
32 #ifndef _CONSOLE_PORT_H_
33 #define _CONSOLE_PORT_H_
35 extern "C" {
36 #include <gccore.h>
37 #include <wiiuse/wpad.h>
38 #include <fat.h>
41 #include <string>
43 namespace RPN
46 const int BUFFER_SIZE = 64;
48 struct InputBuffer
50 int pos;
51 char buf[BUFFER_SIZE];
54 class Port
56 static void InitPads()
58 // Initialise the attached controllers.
59 WPAD_Init();
60 // Allow the WPAD to use the accelerator ? (needed for libosk)
61 WPAD_SetDataFormat(WPAD_CHAN_0, WPAD_FMT_BTNS_ACC_IR);
64 static void InitConsole();
66 public:
68 static bool CanRun()
70 return true;
73 static std::string GetLine();
75 static void Post()
79 static void Print(const char* str, ...)
81 va_list args;
83 va_start(args, str);
84 vprintf(str, args);
85 va_end(args);
88 static void Setup()
90 InitConsole();
91 InitPads();
96 #endif
97 #endif