struct PlatformDisplayPrivate: public sigc::trackable
{
- AInputQueue *input_queue = 0;
+ AInputQueue *input_queue = nullptr;
std::list<Window::Event> events;
Mutex event_mutex;
- WindowHandle native_window = 0;
+ WindowHandle native_window = nullptr;
Mutex window_mutex;
void push_event(AndroidEventType);
case WINDOW_DESTROYED:
signal_lost_focus.emit();
priv->signal_window_lost.emit();
- priv->window = 0;
+ priv->window = nullptr;
display.remove_window(*this);
display.add_window(*this);
break;
struct PlatformEvent
{
AndroidEventType type;
- AInputEvent *aevent = 0;
+ AInputEvent *aevent = nullptr;
};
} // namespace Graphics
struct GLContext::Private
{
- ContextHandle context = 0;
+ ContextHandle context = nullptr;
};
void GLContext::platform_init(const GLOptions &opts)
Display::Display(const string &):
priv(new Private)
{
- static ErrorDialog err_dlg(0);
+ static ErrorDialog err_dlg(nullptr);
priv->display = create_display();
}
{
priv->windows.erase(wnd.get_private().window);
if(&wnd==focus_window)
- focus_window = 0;
+ focus_window = nullptr;
}
const VideoMode &Display::get_desktop_mode() const
const VideoMode *Display::find_mode(const VideoMode &mode, float rate_tolerance) const
{
- const VideoMode *closest = 0;
+ const VideoMode *closest = nullptr;
float rate_diff = 0.0f;
float target_rate = mode.rate;
void Display::window_lost_focus()
{
- focus_window = 0;
+ focus_window = nullptr;
}
void Display::tick()
private:
std::list<Monitor> monitors;
- Monitor *primary_monitor = 0;
+ Monitor *primary_monitor = nullptr;
std::list<VideoMode> modes;
- Private *priv = 0;
- ErrorDialog *err_dialog = 0;
- Window *focus_window = 0;
+ Private *priv = nullptr;
+ ErrorDialog *err_dialog = nullptr;
+ Window *focus_window = nullptr;
public:
Display(const std::string &disp_name = std::string());
struct Display::Private: PlatformDisplayPrivate
{
- DisplayHandle display = 0;
+ DisplayHandle display = nullptr;
std::map<WindowHandle, Window *> windows;
};
if(egl_display==EGL_NO_DISPLAY)
throw runtime_error("no egl display");
- if(!eglInitialize(egl_display, 0, 0))
+ if(!eglInitialize(egl_display, nullptr, nullptr))
throw runtime_error("could not initialize egl");
vector<int> attribs;
eglGetConfigAttrib(priv->display, config, EGL_NATIVE_VISUAL_ID, &format);
ANativeWindow_setBuffersGeometry(native_window, 0, 0, format);
- priv->surface = eglCreateWindowSurface(priv->display, config, native_window, 0);
+ priv->surface = eglCreateWindowSurface(priv->display, config, native_window, nullptr);
eglBindAPI(EGL_OPENGL_ES_API);
int context_attribs[] = { EGL_CONTEXT_CLIENT_VERSION, 2, EGL_NONE };
- priv->context = eglCreateContext(priv->display, config, 0, context_attribs);
+ priv->context = eglCreateContext(priv->display, config, nullptr, context_attribs);
eglMakeCurrent(priv->display, priv->surface, priv->surface, priv->context);
class ErrorDialog: public Debug::ErrorReporter
{
private:
- Display *display = 0;
+ Display *display = nullptr;
public:
ErrorDialog(Display *d): display(d) { }
Display &display;
Window &window;
- Private *priv = 0;
+ Private *priv = nullptr;
public:
GLContext(Window &wnd, const GLOptions &opts = GLOptions());
struct GLContext::Private
{
- ContextHandle context = 0;
+ ContextHandle context = nullptr;
// We need to create a window with the chosen visual
WindowHandle subwnd = None;
GLXWindow glxwnd = None;
priv->subwnd = XCreateWindow(dpy, window.get_private().window, 0, 0, window.get_width(), window.get_height(), 0, vi->depth, InputOutput, vi->visual, CWColormap, &attr);
XMapWindow(dpy, priv->subwnd);
- priv->glxwnd = glXCreateWindow(dpy, fb_configs[0], priv->subwnd, 0);
+ priv->glxwnd = glXCreateWindow(dpy, fb_configs[0], priv->subwnd, nullptr);
if(opts.forward_compatible || opts.gl_version_major!=GLOptions::DEFAULT_VERSION)
{
unsigned gl_version_minor = opts.gl_version_minor;
if(opts.gl_version_major==GLOptions::LATEST_VERSION)
{
- ContextHandle probe_context = glXCreateNewContext(dpy, fb_configs[0], GLX_RGBA_TYPE, 0, true);
+ ContextHandle probe_context = glXCreateNewContext(dpy, fb_configs[0], GLX_RGBA_TYPE, nullptr, true);
glXMakeContextCurrent(dpy, priv->glxwnd, priv->glxwnd, probe_context);
const char *gl_ver_ptr = reinterpret_cast<const char *>(glGetString(GL_VERSION));
gl_version_major = lexical_cast<unsigned>(parts[0]);
gl_version_minor = lexical_cast<unsigned>(parts[1]);
- glXMakeContextCurrent(dpy, 0, 0, 0);
+ glXMakeContextCurrent(dpy, None, None, nullptr);
glXDestroyContext(dpy, probe_context);
}
const GLubyte *name = reinterpret_cast<const GLubyte *>("glXCreateContextAttribsARB");
PFNGLXCREATECONTEXTATTRIBSARBPROC glXCreateContextAttribs = reinterpret_cast<PFNGLXCREATECONTEXTATTRIBSARBPROC>(glXGetProcAddressARB(name));
- priv->context = glXCreateContextAttribs(dpy, fb_configs[0], 0, true, &ctx_attribs[0]);
+ priv->context = glXCreateContextAttribs(dpy, fb_configs[0], nullptr, true, &ctx_attribs[0]);
}
else
- priv->context = glXCreateNewContext(dpy, fb_configs[0], GLX_RGBA_TYPE, 0, true);
+ priv->context = glXCreateNewContext(dpy, fb_configs[0], GLX_RGBA_TYPE, nullptr, true);
XFree(vi);
XFree(fb_configs);
priv = new Private;
priv->glxwnd = 0;
- priv->context = glXCreateContext(dpy, vi, 0, true);
+ priv->context = glXCreateContext(dpy, vi, nullptr, true);
XSetWindowAttributes attr;
attr.colormap = XCreateColormap(dpy, DefaultRootWindow(dpy), vi->visual, AllocNone);
if(priv->glxwnd)
{
- glXMakeContextCurrent(dpy, 0, 0, 0);
+ glXMakeContextCurrent(dpy, None, None, nullptr);
glXDestroyWindow(dpy, priv->glxwnd);
}
else
- glXMakeCurrent(dpy, 0, 0);
+ glXMakeCurrent(dpy, None, nullptr);
glXDestroyContext(dpy, priv->context);
XDestroyWindow(dpy, priv->subwnd);
width(other.width),
height(other.height),
stride(other.stride),
- owned_pixels(other.pixels ? new char[stride*height] : 0),
+ owned_pixels(other.pixels ? new char[stride*height] : nullptr),
pixels(owned_pixels)
{
if(pixels)
Image::Data &Image::Data::operator=(const Data &other)
{
delete[] owned_pixels;
- pixels = owned_pixels = 0;
+ pixels = owned_pixels = nullptr;
fmt = other.fmt;
width = other.width;
unsigned width = 0;
unsigned height = 0;
unsigned stride = 0;
- char *owned_pixels = 0;
- char *pixels = 0;
+ char *owned_pixels = nullptr;
+ char *pixels = nullptr;
Data() = default;
Data(const Data &);
string signature(registry.loaders.back()->get_signature_size(), 0);
unsigned sig_len = io.read(&signature[0], signature.size());
- ImageLoader *loader = 0;
+ ImageLoader *loader = nullptr;
for(auto i=registry.loaders.begin(); (!loader && i!=registry.loaders.end()); ++i)
if((*i)->detect(signature))
loader = (*i)->create(io);
};
private:
- IO::Base *source = 0;
+ IO::Base *source = nullptr;
State state = INITIAL;
protected:
private:
struct Private;
- Private *priv = 0;
+ Private *priv = nullptr;
public:
JpegLoader(IO::Seekable &);
{
struct Settings
{
- const VideoMode *mode = 0;
+ const VideoMode *mode = nullptr;
VideoRotation rotation = ROTATE_NORMAL;
int x = 0;
int y = 0;
std::list<const VideoMode *> video_modes;
Settings desktop_settings;
Settings current_settings;
- const Monitor *next_left = 0;
- const Monitor *next_right = 0;
+ const Monitor *next_left = nullptr;
+ const Monitor *next_right = nullptr;
};
} // namespace Graphics
struct PngLoader::Private
{
string message;
- png_struct *png = 0;
- png_info *info = 0;
+ png_struct *png = nullptr;
+ png_info *info = nullptr;
int interlace = PNG_INTERLACE_NONE;
};
PngLoader::PngLoader(IO::Base &io, unsigned sig_bytes):
priv(new Private)
{
- priv->png = png_create_read_struct(PNG_LIBPNG_VER_STRING, &priv->message, error, 0);
+ priv->png = png_create_read_struct(PNG_LIBPNG_VER_STRING, &priv->message, error, nullptr);
priv->info = png_create_info_struct(priv->png);
// These probably won't give any errors
PngLoader::~PngLoader()
{
- png_destroy_read_struct(&priv->png, &priv->info, 0);
+ png_destroy_read_struct(&priv->png, &priv->info, nullptr);
delete priv;
}
png_uint_32 height;
int depth;
int color;
- png_get_IHDR(priv->png, priv->info, &width, &height, &depth, &color, &priv->interlace, 0, 0);
+ png_get_IHDR(priv->png, priv->info, &width, &height, &depth, &color, &priv->interlace, nullptr, nullptr);
unsigned nchans = png_get_channels(priv->png, priv->info);
if(depth!=8)
void PngLoader::load_pixels_(Image::Data &data)
{
- png_byte **rows = 0;
+ png_byte **rows = nullptr;
if(setjmp(png_jmpbuf(priv->png)))
{
rows[y] = reinterpret_cast<png_byte *>(data.pixels+data.stride*(data.height-1-y));
for(unsigned i=0; i<n_passes; ++i)
- png_read_rows(priv->png, rows, 0, data.height);
+ png_read_rows(priv->png, rows, nullptr, data.height);
delete[] rows;
- rows = 0;
}
else
{
for(unsigned y=0; y<data.height; ++y)
- png_read_row(priv->png, reinterpret_cast<png_byte *>(data.pixels+data.stride*(data.height-1-y)), 0);
+ png_read_row(priv->png, reinterpret_cast<png_byte *>(data.pixels+data.stride*(data.height-1-y)), nullptr);
}
- png_read_end(priv->png, 0);
+ png_read_end(priv->png, nullptr);
}
} // namespace Graphics
private:
struct Private;
- Private *priv = 0;
+ Private *priv = nullptr;
public:
PngLoader(IO::Base &, unsigned = 0);
private:
struct Private;
- Private *priv = 0;
+ Private *priv = nullptr;
public:
QuartzLoader(IO::Seekable &);
struct VideoMode
{
unsigned index = 0;
- const Monitor *monitor = 0;
+ const Monitor *monitor = nullptr;
unsigned width = 0;
unsigned height = 0;
float rate = 0.0f;
instance_create_info.enabledExtensionCount = extensions.size();
instance_create_info.ppEnabledExtensionNames = extensions.data();
- VkResult result = f.vkCreateInstance(&instance_create_info, 0, &priv->instance);
+ VkResult result = f.vkCreateInstance(&instance_create_info, nullptr, &priv->instance);
if(result!=VK_SUCCESS)
throw vulkan_error(result, "vkCreateInstance");
debug_report_create_info.pfnCallback = &Private::debug_report_func;
debug_report_create_info.pUserData = this;
- result = f.vkCreateDebugReportCallback(priv->instance, &debug_report_create_info, 0, &priv->debug_report_callback);
+ result = f.vkCreateDebugReportCallback(priv->instance, &debug_report_create_info, nullptr, &priv->debug_report_callback);
if(result!=VK_SUCCESS)
throw vulkan_error(result, "vkCreateDebugReportCallback");
}
surface_create_info.dpy = display.get_private().display;
surface_create_info.window = window.get_private().window;
- result = f.vkCreateXlibSurface(priv->instance, &surface_create_info, 0, &priv->surface);
+ result = f.vkCreateXlibSurface(priv->instance, &surface_create_info, nullptr, &priv->surface);
if(result!=VK_SUCCESS)
throw vulkan_error(result, "vkCreateXlibSurface");
unsigned n_phys_devices = 0;
- result = f.vkEnumeratePhysicalDevices(priv->instance, &n_phys_devices, 0);
+ result = f.vkEnumeratePhysicalDevices(priv->instance, &n_phys_devices, nullptr);
if(result!=VK_SUCCESS)
throw vulkan_error(result, "vkEnumeratePhysicalDevices");
else if(!n_phys_devices)
VkPhysicalDevice phys_device = phys_devices[i];
unsigned n_queue_families = 0;
- f.vkGetPhysicalDeviceQueueFamilyProperties(phys_device, &n_queue_families, 0);
+ f.vkGetPhysicalDeviceQueueFamilyProperties(phys_device, &n_queue_families, nullptr);
vector<VkQueueFamilyProperties> queue_family_props(n_queue_families);
f.vkGetPhysicalDeviceQueueFamilyProperties(phys_device, &n_queue_families, queue_family_props.data());
device_create_info.ppEnabledExtensionNames = extensions.data();
device_create_info.pEnabledFeatures = &features;
- result = f.vkCreateDevice(priv->physical_device, &device_create_info, 0, &priv->device);
+ result = f.vkCreateDevice(priv->physical_device, &device_create_info, nullptr, &priv->device);
if(result!=VK_SUCCESS)
throw vulkan_error(result, "vkCreateDevice");
catch(...)
{
if(priv->device)
- f.vkDestroyDevice(priv->device, 0);
+ f.vkDestroyDevice(priv->device, nullptr);
if(priv->surface)
- f.vkDestroySurface(priv->instance, priv->surface, 0);
+ f.vkDestroySurface(priv->instance, priv->surface, nullptr);
if(priv->debug_report_callback)
- f.vkDestroyDebugReportCallback(priv->instance, priv->debug_report_callback, 0);
+ f.vkDestroyDebugReportCallback(priv->instance, priv->debug_report_callback, nullptr);
if(priv->instance)
- f.vkDestroyInstance(priv->instance, 0);
+ f.vkDestroyInstance(priv->instance, nullptr);
delete priv;
throw;
}
VulkanContext::~VulkanContext()
{
const VulkanFunctions &f = priv->functions;
- f.vkDestroyDevice(priv->device, 0);
- f.vkDestroySurface(priv->instance, priv->surface, 0);
+ f.vkDestroyDevice(priv->device, nullptr);
+ f.vkDestroySurface(priv->instance, priv->surface, nullptr);
if(priv->debug_report_callback)
- f.vkDestroyDebugReportCallback(priv->instance, priv->debug_report_callback, 0);
- f.vkDestroyInstance(priv->instance, 0);
+ f.vkDestroyDebugReportCallback(priv->instance, priv->debug_report_callback, nullptr);
+ f.vkDestroyInstance(priv->instance, nullptr);
delete priv;
}
struct VulkanFunctions
{
- PFN_vkCreateInstance vkCreateInstance = 0;
- PFN_vkDestroyInstance vkDestroyInstance = 0;
- PFN_vkEnumeratePhysicalDevices vkEnumeratePhysicalDevices = 0;
- PFN_vkGetPhysicalDeviceQueueFamilyProperties vkGetPhysicalDeviceQueueFamilyProperties = 0;
- PFN_vkGetPhysicalDeviceSurfaceSupportKHR vkGetPhysicalDeviceSurfaceSupport = 0;
- PFN_vkCreateDevice vkCreateDevice = 0;
- PFN_vkDestroyDevice vkDestroyDevice = 0;
- PFN_vkGetDeviceQueue vkGetDeviceQueue = 0;
- PFN_vkCreateXlibSurfaceKHR vkCreateXlibSurface = 0;
- PFN_vkDestroySurfaceKHR vkDestroySurface = 0;
- PFN_vkCreateDebugReportCallbackEXT vkCreateDebugReportCallback = 0;
- PFN_vkDestroyDebugReportCallbackEXT vkDestroyDebugReportCallback = 0;
+ PFN_vkCreateInstance vkCreateInstance = nullptr;
+ PFN_vkDestroyInstance vkDestroyInstance = nullptr;
+ PFN_vkEnumeratePhysicalDevices vkEnumeratePhysicalDevices = nullptr;
+ PFN_vkGetPhysicalDeviceQueueFamilyProperties vkGetPhysicalDeviceQueueFamilyProperties = nullptr;
+ PFN_vkGetPhysicalDeviceSurfaceSupportKHR vkGetPhysicalDeviceSurfaceSupport = nullptr;
+ PFN_vkCreateDevice vkCreateDevice = nullptr;
+ PFN_vkDestroyDevice vkDestroyDevice = nullptr;
+ PFN_vkGetDeviceQueue vkGetDeviceQueue = nullptr;
+ PFN_vkCreateXlibSurfaceKHR vkCreateXlibSurface = nullptr;
+ PFN_vkDestroySurfaceKHR vkDestroySurface = nullptr;
+ PFN_vkCreateDebugReportCallbackEXT vkCreateDebugReportCallback = nullptr;
+ PFN_vkDestroyDebugReportCallbackEXT vkDestroyDebugReportCallback = nullptr;
};
struct VulkanContext::Private
{
VulkanFunctions functions;
- VkInstance instance = 0;
- VkPhysicalDevice physical_device = 0;
- VkDevice device = 0;
+ VkInstance instance = nullptr;
+ VkPhysicalDevice physical_device = nullptr;
+ VkDevice device = nullptr;
unsigned graphics_queue_family = 0;
- VkQueue graphics_queue = 0;
- VkSurfaceKHR surface = 0;
- VkDebugReportCallbackEXT debug_report_callback = 0;
+ VkQueue graphics_queue = nullptr;
+ VkSurfaceKHR surface = nullptr;
+ VkDebugReportCallbackEXT debug_report_callback = nullptr;
static VkBool32 debug_report_func(VkDebugReportFlagsEXT, VkDebugReportObjectTypeEXT, uint64_t, size_t, int32_t, const char *, const char *, void *);
};
Display &display;
Window &window;
- Private *priv = 0;
+ Private *priv = nullptr;
public:
VulkanContext(Window &, const VulkanOptions & = VulkanOptions());
struct GLContext::Private
{
- ContextHandle context = 0;
+ ContextHandle context = nullptr;
};
if(!priv->context)
throw unsupported_gl_mode(opts);
- wglMakeCurrent(0, 0);
+ wglMakeCurrent(nullptr, nullptr);
wglDeleteContext(fake_context);
}
else
GLContext::~GLContext()
{
- wglMakeCurrent(0, 0);
+ wglMakeCurrent(nullptr, nullptr);
wglDeleteContext(priv->context);
delete priv;
unsigned width = 640;
unsigned height = 480;
bool fullscreen = false;
- const Monitor *fullscreen_monitor = 0;
+ const Monitor *fullscreen_monitor = nullptr;
bool fullscreen_exclusive = true;
bool resizable = false;
};
bool touch_input = false;
bool resizing = false;
bool moving = false;
- Private *priv = 0;
+ Private *priv = nullptr;
public:
Window(Display &, unsigned w, unsigned h, bool fs = false);
Display::Display(const string &):
priv(new Private)
{
- static ErrorDialog err_dlg(0);
+ static ErrorDialog err_dlg(nullptr);
for(unsigned i=0;; ++i)
{
DISPLAY_DEVICE adapter_dev;
adapter_dev.cb = sizeof(adapter_dev);
- if(!EnumDisplayDevices(0, i, &adapter_dev, 0))
+ if(!EnumDisplayDevices(nullptr, i, &adapter_dev, 0))
break;
if(adapter_dev.StateFlags&DISPLAY_DEVICE_MIRRORING_DRIVER)
bool Display::process_events()
{
MSG msg;
- if(PeekMessage(&msg, 0, 0, 0, PM_REMOVE))
+ if(PeekMessage(&msg, nullptr, 0, 0, PM_REMOVE))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
wndcl.cbClsExtra = 0;
wndcl.cbWndExtra = sizeof(Window *);
wndcl.hInstance = reinterpret_cast<HINSTANCE>(Application::get_data());
- wndcl.hIcon = 0;
- wndcl.hCursor = LoadCursor(0, IDC_ARROW);
- wndcl.hbrBackground = 0;
- wndcl.lpszMenuName = 0;
+ wndcl.hIcon = nullptr;
+ wndcl.hCursor = LoadCursor(nullptr, IDC_ARROW);
+ wndcl.hbrBackground = nullptr;
+ wndcl.lpszMenuName = nullptr;
wndcl.lpszClassName = "mspgui";
- wndcl.hIconSm = 0;
+ wndcl.hIconSm = nullptr;
if(!RegisterClassEx(&wndcl))
throw system_error("RegisterClassEx");
}
if(options.fullscreen)
- SetWindowPos(priv->window, 0, 0, 0, rect.right-rect.left, rect.bottom-rect.top, SWP_NOZORDER);
+ SetWindowPos(priv->window, nullptr, 0, 0, rect.right-rect.left, rect.bottom-rect.top, SWP_NOZORDER);
else if(options.user_position)
- SetWindowPos(priv->window, 0, options.x, options.y, rect.right-rect.left, rect.bottom-rect.top, SWP_NOZORDER);
+ SetWindowPos(priv->window, nullptr, options.x, options.y, rect.right-rect.left, rect.bottom-rect.top, SWP_NOZORDER);
else
- SetWindowPos(priv->window, 0, 0, 0, rect.right-rect.left, rect.bottom-rect.top, SWP_NOMOVE|SWP_NOZORDER);
+ SetWindowPos(priv->window, nullptr, 0, 0, rect.right-rect.left, rect.bottom-rect.top, SWP_NOMOVE|SWP_NOZORDER);
}
void Window::show_cursor(bool s)
{
priv->cursor_visible = s;
if(priv->cursor_in_client_area && !s)
- SetCursor(NULL);
+ SetCursor(nullptr);
}
void Window::warp_pointer(int, int)
case WM_SETCURSOR:
priv->cursor_in_client_area = (LOWORD(evnt.lparam)==HTCLIENT);
if(priv->cursor_in_client_area && !priv->cursor_visible)
- SetCursor(NULL);
+ SetCursor(nullptr);
else
return false;
break;
priv(new Private)
{
if(disp_name.empty())
- priv->display = XOpenDisplay(0);
+ priv->display = XOpenDisplay(nullptr);
else
priv->display = XOpenDisplay(disp_name.c_str());
if(!priv->display)
for(int i=0; i<res->noutput; ++i)
{
XRROutputInfo *output = XRRGetOutputInfo(priv->display, res, res->outputs[i]);
- XRRCrtcInfo *crtc = (output->crtc ? XRRGetCrtcInfo(priv->display, res, output->crtc) : 0);
+ XRRCrtcInfo *crtc = (output->crtc ? XRRGetCrtcInfo(priv->display, res, output->crtc) : nullptr);
monitors.push_back(Monitor());
Monitor &monitor = monitors.back();
int prop_format;
unsigned long length;
unsigned long overflow;
- unsigned char *edid = 0;
+ unsigned char *edid = nullptr;
XRRGetOutputProperty(priv->display, res->outputs[i], edid_prop, 0, 32, false, false, XA_INTEGER, &prop_type, &prop_format, &length, &overflow, &edid);
if(prop_type==XA_INTEGER && prop_format==8)
{
XRRFreeScreenResources(res);
monitors.sort(monitor_x_compare);
- Monitor *prev_enabled = 0;
+ Monitor *prev_enabled = nullptr;
for(Monitor &m: monitors)
if(m.desktop_settings.mode)
{
// Check if the output already has a CRTC and find a free one if it doesn't
RRCrtc crtc = output_info->crtc;
- XRRCrtcInfo *crtc_info = 0;
+ XRRCrtcInfo *crtc_info = nullptr;
if(crtc)
crtc_info = XRRGetCrtcInfo(priv->display, res, crtc);
else
{
XRROutputInfo *o = XRRGetOutputInfo(priv->display, res, priv->monitors[m.index]);
if(o->crtc)
- XRRSetCrtcConfig(priv->display, res, o->crtc, CurrentTime, 0, 0, 0, RR_Rotate_0, 0, 0);
+ XRRSetCrtcConfig(priv->display, res, o->crtc, CurrentTime, 0, 0, 0, RR_Rotate_0, nullptr, 0);
XRRFreeOutputInfo(o);
- m.current_settings.mode = 0;
+ m.current_settings.mode = nullptr;
m.current_settings.rotation = ROTATE_NORMAL;
m.current_settings.x = 0;
m.current_settings.y = 0;
int screen = DefaultScreen(dpy);
Pixmap pm = XCreatePixmap(dpy, priv->window, 1, 1, 1);
- GC gc = XCreateGC(dpy, pm, 0, 0);
+ GC gc = XCreateGC(dpy, pm, 0, nullptr);
XSetFunction(dpy, gc, GXclear);
XDrawPoint(dpy, pm, gc, 0, 0);
XFreeGC(dpy, gc);
else if(!d.name.empty())
resolved_devs.push_back(dev.find_subdevice(d.name));
else
- resolved_devs.push_back(0);
+ resolved_devs.push_back(nullptr);
}
return resolved_devs;
}
for(const Binding &b: bindings)
{
Control *ctrl = control_scheme.find(b.control);
- Device *bdev = (b.device<resolved_devs.size() ? resolved_devs[b.device] : 0);
+ Device *bdev = (b.device<resolved_devs.size() ? resolved_devs[b.device] : nullptr);
if(ctrl && bdev)
{
ctrl->set_source(*bdev, b.type, b.index);
void Control::cancel_capture()
{
notify_callbacks();
- capture_dev = 0;
+ capture_dev = nullptr;
connect_signals();
}
src.index = i;
notify_callbacks();
- capture_dev = 0;
+ capture_dev = nullptr;
connect_signals();
signal_capture_complete.emit();
}
src.index = i;
notify_callbacks();
- capture_dev = 0;
+ capture_dev = nullptr;
connect_signals();
signal_capture_complete.emit();
}
*/
struct ControlSource
{
- Device *dev = 0;
+ Device *dev = nullptr;
ControlSrcType type = NO_SOURCE;
unsigned index = 0;
protected:
ControlSource src;
- Device *capture_dev = 0;
- BinaryControl *activator = 0;
+ Device *capture_dev = nullptr;
+ BinaryControl *activator = nullptr;
float origin = 0.0f;
bool rising_edge = false;
bool falling_edge = false;
Device *Device::find_subdevice(const string &n)
{
- return (n==name ? this : 0);
+ return (n==name ? this : nullptr);
}
Device *Device::find_subdevice(DeviceType t, unsigned i)
{
- return (t==type && i==0 ? this : 0);
+ return (t==type && i==0 ? this : nullptr);
}
bool Device::get_button_state(unsigned btn) const
private:
struct Private;
- Private *priv = 0;
- IO::EventDispatcher *event_disp = 0;
+ Private *priv = nullptr;
+ IO::EventDispatcher *event_disp = nullptr;
static bool detect_done;
static unsigned n_detected_controllers;
return dev;
--n;
}
- return 0;
+ return nullptr;
}
Device *Hub::find_subdevice(const string &n)
for(Device *d: devices)
if(Device *dev = d->find_subdevice(n))
return dev;
- return 0;
+ return nullptr;
}
string Hub::get_button_name(unsigned btn) const
struct GameController::Private
{
- JsDevice *dev = 0;
+ JsDevice *dev = nullptr;
static std::vector<std::string> detected_controllers;
};
SmoothControl::~SmoothControl()
{
- pair(0);
+ pair(nullptr);
}
void SmoothControl::set_dead_zone(float d)
if(paired_ctrl)
{
SmoothControl *old_pair = paired_ctrl;
- paired_ctrl = 0;
- old_pair->pair(0);
+ paired_ctrl = nullptr;
+ old_pair->pair(nullptr);
}
paired_ctrl = ctrl;
private:
float value = 0.0f;
- SmoothControl *paired_ctrl = 0;
+ SmoothControl *paired_ctrl = nullptr;
float dead_zone = 0.1f;
float threshold = 0.9f;
GameController::~GameController()
{
- use_event_dispatcher(0);
+ use_event_dispatcher(nullptr);
delete priv;
}
else if(priv->event_pipe)
{
GameControllerTimerThread::remove_slot(*priv->timer_slot);
- priv->timer_slot = 0;
+ priv->timer_slot = nullptr;
delete priv->event_pipe;
- priv->event_pipe = 0;
+ priv->event_pipe = nullptr;
}
}
}
-GameControllerTimerThread *GameControllerTimerThread::thread = 0;
+GameControllerTimerThread *GameControllerTimerThread::thread = nullptr;
GameControllerTimerThread::GameControllerTimerThread():
Thread("GameController")
{
thread->timer.add(Time::zero);
delete thread;
- thread = 0;
+ thread = nullptr;
}
}
{
unsigned index = 0;
unsigned last_packet_number = 0;
- IO::Pipe *event_pipe = 0;
- Time::Timer::Slot *timer_slot = 0;
+ IO::Pipe *event_pipe = nullptr;
+ Time::Timer::Slot *timer_slot = nullptr;
static std::vector<unsigned> detected_controllers;
if(event.xevent.type==KeyPress)
{
char ch;
- if(XLookupString(const_cast<XKeyEvent *>(&event.xevent.xkey), &ch, 1, 0, 0))
+ if(XLookupString(const_cast<XKeyEvent *>(&event.xevent.xkey), &ch, 1, nullptr, nullptr))
// XLookupString always returns Latin-1
signal_character.emit(static_cast<unsigned char>(ch));
}