Fix binding to multi-button keygroup
[lsnes.git] / window.hpp
blob795b50ffd40239ce413effbf19fca33963e33690
1 #ifndef _window__hpp__included__
2 #define _window__hpp__included__
4 #include "SDL.h"
5 #include "render.hpp"
6 #include <string>
7 #include <map>
8 #include <list>
9 #include <stdexcept>
11 #define WINSTATE_NORMAL 0
12 #define WINSTATE_COMMAND 1
13 #define WINSTATE_MODAL 2
14 #define WINSTATE_IDENTIFY 3
16 class window;
18 /**
19 * This is a handle to graphics system. Note that creating multiple contexts produces undefined results.
21 class window
23 public:
24 window() throw() {}
26 /**
27 * Initialize the graphics system.
29 static void init();
31 /**
32 * Shut down the graphics system.
34 static void quit();
36 /**
37 * Adds a messages to mesage queue to be shown.
39 * parameter msg: The messages to add (split by '\n').
40 * throws std::bad_alloc: Not enough memory.
42 static void message(const std::string& msg) throw(std::bad_alloc);
44 /**
45 * Get output stream printing into message queue.
47 * Note that lines printed there should be terminated by '\n'.
49 * returns: The output stream.
50 * throws std::bad_alloc: Not enough memory.
52 static std::ostream& out() throw(std::bad_alloc);
54 /**
55 * Displays a modal message, not returning until the message is acknowledged. Keybindings are not available, but
56 * should quit be generated somehow, modal message will be closed and command callback triggered.
58 * parameter msg: The message to show.
59 * parameter confirm: If true, ask for Ok/cancel type input.
60 * returns: If confirm is true, true if ok was chosen, false if cancel was chosen. Otherwise always false.
61 * throws std::bad_alloc: Not enough memory.
63 static bool modal_message(const std::string& msg, bool confirm = false) throw(std::bad_alloc);
65 /**
66 * Displays fatal error message, quitting after the user acks it.
68 static void fatal_error() throw();
70 /**
71 * Processes inputs. If in non-modal mode (normal mode without pause), this returns quickly. Otherwise it waits
72 * for modal mode to exit.
74 * throws std::bad_alloc: Not enough memory.
76 static void poll_inputs() throw(std::bad_alloc);
78 /**
79 * Get emulator status area
81 * returns: Emulator status area.
83 static std::map<std::string, std::string>& get_emustatus() throw();
85 /**
86 * Notify that the screen has been updated.
88 * parameter full: Do full refresh if true.
90 static void notify_screen_update(bool full = false) throw();
92 /**
93 * Set the screen to use as main surface.
95 * parameter scr: The screen to use.
97 static void set_main_surface(screen& scr) throw();
99 /**
100 * Enable/Disable pause mode.
102 * parameter enable: Enable pause if true, disable otherwise.
104 static void paused(bool enable) throw();
107 * Wait specified number of milliseconds (polling for input).
109 * parameter msec: Number of ms to wait.
110 * throws std::bad_alloc: Not enough memory.
112 static void wait_msec(uint64_t msec) throw(std::bad_alloc);
115 * Cancel pending wait_msec, making it return now.
117 static void cancel_wait() throw();
120 * Enable or disable sound.
122 * parameter enable: Enable sounds if true, otherwise disable sounds.
124 static void sound_enable(bool enable) throw();
127 * Input audio sample (at 32040.5Hz).
129 * parameter left: Left sample.
130 * parameter right: Right sample.
132 static void play_audio_sample(uint16_t left, uint16_t right) throw();
135 * Set window main screen compensation parameters. This is used for mouse click reporting.
137 * parameter xoffset: X coordinate of origin.
138 * parameter yoffset: Y coordinate of origin.
139 * parameter hscl: Horizontal scaling factor.
140 * parameter vscl: Vertical scaling factor.
142 static void set_window_compensation(uint32_t xoffset, uint32_t yoffset, uint32_t hscl, uint32_t vscl);
143 private:
144 window(const window&);
145 window& operator==(const window&);
149 * Get number of msec since some undetermined epoch.
151 * returns: The number of milliseconds.
153 uint64_t get_ticks_msec() throw();
155 #endif