Add on_snoop Lua callback
[lsnes.git] / window.hpp
blobe593c1ab72ee2f1f8c108b4352151fe1bc2c13b7
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_internal;
17 class window;
19 /**
20 * \brief Handle to the graphics system.
22 * This is a handle to graphics system. Note that creating multiple contexts produces undefined results.
24 class window
26 public:
27 window();
28 ~window();
30 /**
31 * \brief Add messages to message queue.
33 * Adds a messages to mesage queue to be shown.
35 * \param msg The messages to add (split by '\n').
36 * \throws std::bad_alloc Not enough memory.
38 void message(const std::string& msg) throw(std::bad_alloc);
40 /**
41 * \brief Get output stream printing into message queue.
43 * \return The output stream.
44 * \throws std::bad_alloc Not enough memory.
46 std::ostream& out() throw(std::bad_alloc);
48 /**
49 * \brief Display a modal message.
51 * Displays a modal message, not returning until the message is acknowledged. Keybindings are not available, but
52 * should quit be generated somehow, modal message will be closed and command callback triggered.
54 * \param msg The message to show.
55 * \param confirm If true, ask for Ok/cancel type input.
56 * \return If confirm is true, true if ok was chosen, false if cancel was chosen. Otherwise always false.
57 * \throws std::bad_alloc Not enough memory.
59 bool modal_message(const std::string& msg, bool confirm = false) throw(std::bad_alloc);
61 /**
62 * \brief Signal that the emulator state is too screwed up to continue.
64 * Displays fatal error message, quitting after the user acks it.
66 void fatal_error() throw();
68 /**
69 * \brief Bind a key.
71 * \param mod Set of modifiers.
72 * \param modmask Modifier mask (set of modifiers).
73 * \param keyname Name of key or pseudo-key.
74 * \param command Command to run.
75 * \throws std::bad_alloc Not enough memory.
76 * \throws std::runtime_error Invalid key or modifier name, or conflict.
78 void bind(std::string mod, std::string modmask, std::string keyname, std::string command)
79 throw(std::bad_alloc, std::runtime_error);
81 /**
82 * \brief Unbind a key.
84 * \param mod Set of modifiers.
85 * \param modmask Modifier mask (set of modifiers).
86 * \param keyname Name of key or pseudo-key.
87 * \throws std::bad_alloc Not enough memory.
88 * \throws std::runtime_error Invalid key or modifier name, or not bound.
90 void unbind(std::string mod, std::string modmask, std::string keyname) throw(std::bad_alloc,
91 std::runtime_error);
93 /**
94 * \brief Dump bindings into this window.
96 * \throws std::bad_alloc Not enough memory.
98 //Dump bindings.
99 void dumpbindings() throw(std::bad_alloc);
102 * \brief Process inputs, calling command handler if needed.
104 * Processes inputs. If in non-modal mode (normal mode without pause), this returns quickly. Otherwise it waits
105 * for modal mode to exit.
107 * \throws std::bad_alloc Not enough memory.
109 void poll_inputs() throw(std::bad_alloc);
112 * \brief Get emulator status area
114 * \return Emulator status area.
116 std::map<std::string, std::string>& get_emustatus() throw();
119 * \brief Notify that the screen has been updated.
121 * \param full Do full refresh.
123 void notify_screen_update(bool full = false) throw();
126 * \brief Set the screen to use as main surface.
128 * \param scr The screen to use.
130 void set_main_surface(screen& scr) throw();
133 * \brief Enable/Disable pause mode.
135 * \param enable Enable pause if true, disable otherwise.
137 void paused(bool enable) throw();
140 * \brief Wait specified number of milliseconds (polling for input).
142 * \param msec Number of ms to wait.
143 * \throws std::bad_alloc Not enough memory.
145 void wait_msec(uint64_t msec) throw(std::bad_alloc);
148 * \brief Enable or disable sound.
150 * \param enable Enable sounds if true, otherwise disable sounds.
152 void sound_enable(bool enable) throw();
155 * \brief Input audio sample (at 32040.5Hz).
157 * \param left Left sample.
158 * \param right Right sample.
160 void play_audio_sample(uint16_t left, uint16_t right) throw();
163 * \brief Cancel pending wait, making it return now.
165 void cancel_wait() throw();
168 * \brief Set window compensation parameters.
170 void set_window_compensation(uint32_t xoffset, uint32_t yoffset, uint32_t hscl, uint32_t vscl);
171 private:
172 window_internal* i;
173 window(const window&);
174 window& operator==(const window&);
178 * \brief Get number of msec since some undetermined epoch.
180 * \return The number of milliseconds.
182 uint64_t get_ticks_msec() throw();
185 #endif