21d9377822
* MacOSX with input events and mfb_set_viewport * Windows with input events and mfb_set_viewport * Minor changes in macosx and windows * X11 with input and mfb_set_viewport * Minor changes on X11 * Fix bug in X11 resize event * Fix bug in windows resize * added scale image to X11 * Added stretch_image with & without bilinear interpolation * moved MiniFB_internal.h * Added wayland events * minor changes * unify a bit the window structs * More work on wayland * Added cmake file * minor fix on windows * modified test * Fix on wayland. Unset wayland as default for linux * Use stdbool instead of our own macro eBool Remove prefix e from all enums * Remove _ex sufix in common files * merge X11MiniFB_ex.c into X11MiniFB.c * Merge WaylandMiniFB_ex.c into WaylandMiniFB.c * Add user_data to callbacks * Merge WinMiniFB_ex.c into WinMiniFB.c * Some minor changes on Windows * Fix bug on Wayland * Multiple Windows for MacOS X & Linux * Multiple Windows for Windows Refactor * Refactor * Added mfb_get_key_name * remove some warnings * Events per window working on MacOS & Linux (maybe Windows) * Fix on Windows * Added default key callback on macos & wayland * Unify keyboard_default on all platforms * keyboard_default on all platforms
55 lines
1.6 KiB
C++
Executable File
55 lines
1.6 KiB
C++
Executable File
#include <MiniFB_cpp.h>
|
|
#include <MiniFB_enums.h>
|
|
#include <vector>
|
|
|
|
Stub *
|
|
Stub::GetInstance(struct Window *window) {
|
|
static std::vector<Stub *> s_instances;
|
|
|
|
for(Stub *instance : s_instances) {
|
|
if(instance->m_window == window) {
|
|
return instance;
|
|
}
|
|
}
|
|
|
|
s_instances.push_back(new Stub);
|
|
s_instances.back()->m_window = window;
|
|
|
|
return s_instances.back();
|
|
}
|
|
|
|
void Stub::active_stub(struct Window *window, bool isActive) {
|
|
Stub *stub = Stub::GetInstance(window);
|
|
stub->m_active(window, isActive);
|
|
}
|
|
|
|
void Stub::resize_stub(struct Window *window, int width, int height) {
|
|
Stub *stub = Stub::GetInstance(window);
|
|
stub->m_resize(window, width, height);
|
|
}
|
|
|
|
void Stub::keyboard_stub(struct Window *window, Key key, KeyMod mod, bool isPressed) {
|
|
Stub *stub = Stub::GetInstance(window);
|
|
stub->m_keyboard(window, key, mod, isPressed);
|
|
}
|
|
|
|
void Stub::char_input_stub(struct Window *window, unsigned int code) {
|
|
Stub *stub = Stub::GetInstance(window);
|
|
stub->m_char_input(window, code);
|
|
}
|
|
|
|
void Stub::mouse_btn_stub(struct Window *window, MouseButton button, KeyMod mod, bool isPressed) {
|
|
Stub *stub = Stub::GetInstance(window);
|
|
stub->m_mouse_btn(window, button, mod, isPressed);
|
|
}
|
|
|
|
void Stub::mouse_move_stub(struct Window *window, int x, int y) {
|
|
Stub *stub = Stub::GetInstance(window);
|
|
stub->m_mouse_move(window, x, y);
|
|
}
|
|
|
|
void Stub::scroll_stub(struct Window *window, KeyMod mod, float deltaX, float deltaY) {
|
|
Stub *stub = Stub::GetInstance(window);
|
|
stub->m_scroll(window, mod, deltaX, deltaY);
|
|
}
|