Permalink
Browse files

Added default controls (one full-screen touchscreen control) to avoid…

… errors

with no controls at all if the XML file is missing.
  • Loading branch information...
jnicholl committed Nov 7, 2011
1 parent 35e5e0a commit e4d1023f18bb187740b78a3e95fb8c3157772aa6
Showing with 23 additions and 0 deletions.
  1. +1 −0 inc/touchcontroloverlay_priv.h
  2. +5 −0 public/touchcontroloverlay.h
  3. +17 −0 src/touchcontroloverlay.cpp
@@ -49,6 +49,7 @@ class TCOContext
Control *controlAt(int pos[]) const;
int loadControls(const char *filename);
+ int loadDefaultControls();
void drawControls(screen_buffer_t buffer);
HandleKeyFunc handleKeyFunc() const { return m_handleKeyFunc; }
@@ -84,6 +84,11 @@ int tco_initialize(tco_context_t *context, screen_context_t screenContext, struc
*/
int tco_loadcontrols(tco_context_t context, const char* filename);
+/**
+ * Load default controls as a fallback.
+ */
+int tco_loadcontrols_default(tco_context_t context);
+
/**
* Show configuration window
* NOTE: the window MUST have a window group set already.
@@ -49,6 +49,12 @@ EXTERNAL_API int tco_loadcontrols(tco_context_t context, const char* filename)
return ctx->loadControls(filename);
}
+EXTERNAL_API int tco_loadcontrols_default(tco_context_t context)
+{
+ TCOContext *ctx = static_cast<TCOContext *>(context);
+ return ctx->loadDefaultControls();
+}
+
EXTERNAL_API int tco_swipedown(tco_context_t context, screen_window_t window)
{
TCOContext *ctx = static_cast<TCOContext *>(context);
@@ -108,6 +114,17 @@ int TCOContext::showConfig(screen_window_t window)
return TCO_SUCCESS;
}
+int TCOContext::loadDefaultControls()
+{
+ // Create a single 1024x600 touch screen.
+ Control *control = new Control(m_screenContext,
+ Control::TOUCHSCREEN, 0, 0, 1024, 600,
+ new TouchScreenEventDispatcher(m_handleTouchScreenFunc), 0);
+ control->fill();
+ m_controls.push_back(control);
+ return TCO_SUCCESS;
+}
+
int TCOContext::loadControls(const char *filename)
{
struct TrackedXML

0 comments on commit e4d1023

Please sign in to comment.