1 #ifndef _window__hpp__included__
2 #define _window__hpp__included__
10 #define WINSTATE_NORMAL 0
11 #define WINSTATE_COMMAND 1
12 #define WINSTATE_MODAL 2
13 #define WINSTATE_IDENTIFY 3
18 * Some backnotifications.
23 virtual ~window_callback() throw();
25 * Called when user tries to close the window.
27 virtual void on_close() throw();
29 * Called when user clicks on the screen.
31 virtual void on_click(int32_t x
, int32_t y
, uint32_t buttonmask
) throw();
33 * Do try to close the window.
35 static void do_close() throw();
37 * Do click on the screen.
39 static void do_click(int32_t x
, int32_t y
, uint32_t buttonmask
) throw();
41 * Set the callback handler.
43 static void set_callback_handler(window_callback
& cb
) throw();
47 * Sound/Graphics init/quit functions. Sound init is called after graphics init, and vice versa for quit.
57 * This is a handle to graphics system. Note that creating multiple contexts produces undefined results.
65 * Initialize the graphics system.
70 * Shut down the graphics system.
75 * Adds a messages to mesage queue to be shown.
77 * parameter msg: The messages to add (split by '\n').
78 * throws std::bad_alloc: Not enough memory.
80 static void message(const std::string
& msg
) throw(std::bad_alloc
);
83 * Get output stream printing into message queue.
85 * Note that lines printed there should be terminated by '\n'.
87 * returns: The output stream.
88 * throws std::bad_alloc: Not enough memory.
90 static std::ostream
& out() throw(std::bad_alloc
);
93 * Displays a modal message, not returning until the message is acknowledged. Keybindings are not available, but
94 * should quit be generated somehow, modal message will be closed and command callback triggered.
96 * parameter msg: The message to show.
97 * parameter confirm: If true, ask for Ok/cancel type input.
98 * returns: If confirm is true, true if ok was chosen, false if cancel was chosen. Otherwise always false.
99 * throws std::bad_alloc: Not enough memory.
101 static bool modal_message(const std::string
& msg
, bool confirm
= false) throw(std::bad_alloc
);
104 * Displays fatal error message, quitting after the user acks it.
106 static void fatal_error() throw();
109 * Processes inputs. If in non-modal mode (normal mode without pause), this returns quickly. Otherwise it waits
110 * for modal mode to exit. Also needs to call poll_joysticks().
112 * throws std::bad_alloc: Not enough memory.
114 static void poll_inputs() throw(std::bad_alloc
);
117 * Get emulator status area
119 * returns: Emulator status area.
121 static std::map
<std::string
, std::string
>& get_emustatus() throw();
124 * Notify that the screen has been updated.
126 * parameter full: Do full refresh if true.
128 static void notify_screen_update(bool full
= false) throw();
131 * Set the screen to use as main surface.
133 * parameter scr: The screen to use.
135 static void set_main_surface(screen
& scr
) throw();
138 * Enable/Disable pause mode.
140 * parameter enable: Enable pause if true, disable otherwise.
142 static void paused(bool enable
) throw();
145 * Wait specified number of microseconds (polling for input).
147 * parameter usec: Number of us to wait.
148 * throws std::bad_alloc: Not enough memory.
150 static void wait_usec(uint64_t usec
) throw(std::bad_alloc
);
153 * Cancel pending wait_usec, making it return now.
155 static void cancel_wait() throw();
158 * Enable or disable sound.
160 * parameter enable: Enable sounds if true, otherwise disable sounds.
162 static void sound_enable(bool enable
) throw();
165 * Input audio sample (at 32040.5Hz).
167 * parameter left: Left sample.
168 * parameter right: Right sample.
170 static void play_audio_sample(uint16_t left
, uint16_t right
) throw();
173 * Set window main screen compensation parameters. This is used for mouse click reporting.
175 * parameter xoffset: X coordinate of origin.
176 * parameter yoffset: Y coordinate of origin.
177 * parameter hscl: Horizontal scaling factor.
178 * parameter vscl: Vertical scaling factor.
180 static void set_window_compensation(uint32_t xoffset
, uint32_t yoffset
, uint32_t hscl
, uint32_t vscl
);
183 * Set sound sampling rate.
185 * parameter rate_n: Numerator of sampling rate.
186 * parameter rate_d: Denomerator of sampling rate.
188 static void set_sound_rate(uint32_t rate_n
, uint32_t rate_d
);
191 * Has the sound system been successfully initialized?
193 static bool sound_initialized();
198 static void set_sound_device(const std::string
& dev
);
201 * Get current sound device.
203 static std::string
get_current_sound_device();
206 * Get available sound devices.
208 static std::map
<std::string
, std::string
> get_sound_devices();
210 window(const window
&);
211 window
& operator==(const window
&);
214 void poll_joysticks();
216 extern const char* sound_plugin_name
;
217 extern const char* graphics_plugin_name
;
218 extern const char* joystick_plugin_name
;