aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoel Bodenmann <joel@seriouslyembedded.com>2015-08-12 17:32:38 +0200
committerJoel Bodenmann <joel@seriouslyembedded.com>2015-08-12 17:32:38 +0200
commit16d213d4ed14add60e286246ad6dc563761b9689 (patch)
treed68cca3afab7ead565fcfd652474b356b2413b63
parentcf06739b4ee44bcbfac8ae99e605a4ec4e832c8b (diff)
downloaduGFX-16d213d4ed14add60e286246ad6dc563761b9689.tar.gz
uGFX-16d213d4ed14add60e286246ad6dc563761b9689.tar.bz2
uGFX-16d213d4ed14add60e286246ad6dc563761b9689.zip
Passing keyboard events to widgets (not finished yet)
-rw-r--r--src/gwin/gwin_button.c5
-rw-r--r--src/gwin/gwin_checkbox.c5
-rw-r--r--src/gwin/gwin_class.h5
-rw-r--r--src/gwin/gwin_container.c5
-rw-r--r--src/gwin/gwin_frame.c5
-rw-r--r--src/gwin/gwin_keyboard.c5
-rw-r--r--src/gwin/gwin_label.c5
-rw-r--r--src/gwin/gwin_list.c5
-rw-r--r--src/gwin/gwin_progressbar.c5
-rw-r--r--src/gwin/gwin_radio.c5
-rw-r--r--src/gwin/gwin_slider.c5
-rw-r--r--src/gwin/gwin_tabset.c5
-rw-r--r--src/gwin/gwin_widget.c21
13 files changed, 81 insertions, 0 deletions
diff --git a/src/gwin/gwin_button.c b/src/gwin/gwin_button.c
index 4066884c..8a178b72 100644
--- a/src/gwin/gwin_button.c
+++ b/src/gwin/gwin_button.c
@@ -95,6 +95,11 @@ static const gwidgetVMT buttonVMT = {
0, // Process mouse move events (NOT USED)
},
#endif
+ #if GINPUT_NEED_KEYBOARD
+ {
+ 0 // Process keyboard events
+ },
+ #endif
#if GINPUT_NEED_TOGGLE
{
1, // 1 toggle role
diff --git a/src/gwin/gwin_checkbox.c b/src/gwin/gwin_checkbox.c
index 11e08804..83d5bc38 100644
--- a/src/gwin/gwin_checkbox.c
+++ b/src/gwin/gwin_checkbox.c
@@ -91,6 +91,11 @@ static const gwidgetVMT checkboxVMT = {
0, // Process mouse move events (NOT USED)
},
#endif
+ #if GINPUT_NEED_KEYBOARD
+ {
+ 0 // Process keyboard events
+ },
+ #endif
#if GINPUT_NEED_TOGGLE
{
1, // 1 toggle role
diff --git a/src/gwin/gwin_class.h b/src/gwin/gwin_class.h
index 01b6e596..45467597 100644
--- a/src/gwin/gwin_class.h
+++ b/src/gwin/gwin_class.h
@@ -96,6 +96,11 @@ typedef struct gwinVMT {
void (*MouseMove) (GWidgetObject *gw, coord_t x, coord_t y); // @< Process mouse move events (optional)
};
#endif
+ #if GINPUT_NEED_KEYBOARD
+ struct {
+ void (*KeyboardEvent) (GWidgetObject *gw, GEventKeyboard *pke); // @< Process keyboard events (optional)
+ };
+ #endif
#if GINPUT_NEED_TOGGLE
struct {
uint16_t toggleroles; // @< The roles supported for toggles (0->toggleroles-1)
diff --git a/src/gwin/gwin_container.c b/src/gwin/gwin_container.c
index b84c96ae..172b6ae8 100644
--- a/src/gwin/gwin_container.c
+++ b/src/gwin/gwin_container.c
@@ -110,6 +110,11 @@ static const gcontainerVMT containerVMT = {
0, 0, 0, // No mouse
},
#endif
+ #if GINPUT_NEED_KEYBOARD
+ {
+ 0 // Process keyboard events
+ },
+ #endif
#if GINPUT_NEED_TOGGLE
{
0, 0, 0, 0, 0, // No toggles
diff --git a/src/gwin/gwin_frame.c b/src/gwin/gwin_frame.c
index b29c4ffc..f8787dcb 100644
--- a/src/gwin/gwin_frame.c
+++ b/src/gwin/gwin_frame.c
@@ -178,6 +178,11 @@ static const gcontainerVMT frameVMT = {
0, // Process mouse move events
},
#endif
+ #if GINPUT_NEED_KEYBOARD
+ {
+ 0 // Process keyboard events
+ },
+ #endif
#if GINPUT_NEED_TOGGLE
{
0, // 1 toggle role
diff --git a/src/gwin/gwin_keyboard.c b/src/gwin/gwin_keyboard.c
index e9f5f860..c27580de 100644
--- a/src/gwin/gwin_keyboard.c
+++ b/src/gwin/gwin_keyboard.c
@@ -313,6 +313,11 @@ static const gwidgetVMT keyboardVMT = {
KeyMouseMove, // Process mouse move events
},
#endif
+ #if GINPUT_NEED_KEYBOARD
+ {
+ 0 // Process keyboard events
+ },
+ #endif
#if GINPUT_NEED_TOGGLE
{
0, // No toggle roles
diff --git a/src/gwin/gwin_label.c b/src/gwin/gwin_label.c
index 4e4d799b..38d9b601 100644
--- a/src/gwin/gwin_label.c
+++ b/src/gwin/gwin_label.c
@@ -58,6 +58,11 @@ static const gwidgetVMT labelVMT = {
0, // Process mouse move events (NOT USED)
},
#endif
+ #if GINPUT_NEED_KEYBOARD
+ {
+ 0 // Process keyboard key down events
+ },
+ #endif
#if GINPUT_NEED_TOGGLE
{
0, // No toggle role
diff --git a/src/gwin/gwin_list.c b/src/gwin/gwin_list.c
index 7ca300a9..3ea6286c 100644
--- a/src/gwin/gwin_list.c
+++ b/src/gwin/gwin_list.c
@@ -279,6 +279,11 @@ static const gwidgetVMT listVMT = {
ListMouseMove,
},
#endif
+ #if GINPUT_NEED_KEYBOARD
+ {
+ 0 // Process keyboard events
+ },
+ #endif
#if GINPUT_NEED_TOGGLE
{
2, // two toggle roles
diff --git a/src/gwin/gwin_progressbar.c b/src/gwin/gwin_progressbar.c
index e275b9e4..3843949a 100644
--- a/src/gwin/gwin_progressbar.c
+++ b/src/gwin/gwin_progressbar.c
@@ -51,6 +51,11 @@ static const gwidgetVMT progressbarVMT = {
0, // Process mouse move events
},
#endif
+ #if GINPUT_NEED_KEYBOARD
+ {
+ 0 // Process keyboard events
+ },
+ #endif
#if GINPUT_NEED_TOGGLE
{
0, // 1 toggle role
diff --git a/src/gwin/gwin_radio.c b/src/gwin/gwin_radio.c
index c7d5cf5c..fcdb242b 100644
--- a/src/gwin/gwin_radio.c
+++ b/src/gwin/gwin_radio.c
@@ -92,6 +92,11 @@ static const gwidgetVMT radioVMT = {
0, // Process mouse move events (NOT USED)
},
#endif
+ #if GINPUT_NEED_KEYBOARD
+ {
+ 0 // Process keyboard events
+ },
+ #endif
#if GINPUT_NEED_TOGGLE
{
1, // 1 toggle role
diff --git a/src/gwin/gwin_slider.c b/src/gwin/gwin_slider.c
index c29d5996..218f4f6b 100644
--- a/src/gwin/gwin_slider.c
+++ b/src/gwin/gwin_slider.c
@@ -250,6 +250,11 @@ static const gwidgetVMT sliderVMT = {
SliderMouseMove, // Process mouse move events
},
#endif
+ #if GINPUT_NEED_KEYBOARD
+ {
+ 0 // Process keyboard events
+ },
+ #endif
#if GINPUT_NEED_TOGGLE
{
2, // 1 toggle role
diff --git a/src/gwin/gwin_tabset.c b/src/gwin/gwin_tabset.c
index f1bcd374..f8731f8f 100644
--- a/src/gwin/gwin_tabset.c
+++ b/src/gwin/gwin_tabset.c
@@ -77,6 +77,11 @@ static const gcontainerVMT tabpageVMT = {
0, // Process mouse move events
},
#endif
+ #if GINPUT_NEED_KEYBOARD
+ {
+ 0 // Process keyboard events
+ },
+ #endif
#if GINPUT_NEED_TOGGLE
{
0, // 1 toggle role
diff --git a/src/gwin/gwin_widget.c b/src/gwin/gwin_widget.c
index bfc5a48f..666987ac 100644
--- a/src/gwin/gwin_widget.c
+++ b/src/gwin/gwin_widget.c
@@ -88,6 +88,7 @@ static const GWidgetStyle * defaultStyle = &BlackWidgetStyle;
/* Process an event */
static void gwidgetEvent(void *param, GEvent *pe) {
#define pme ((GEventMouse *)pe)
+ #define pke ((GEventKeyboard *)pe)
#define pte ((GEventToggle *)pe)
#define pde ((GEventDial *)pe)
@@ -142,6 +143,22 @@ static void gwidgetEvent(void *param, GEvent *pe) {
break;
#endif
+ #if GFX_USE_GINPUT && GINPUT_NEED_KEYBOARD
+ case GEVENT_KEYBOARD:
+ // Cycle through all windows
+ for (gh = gwinGetNextWindow(0); gh; gh = gwinGetNextWindow(gh)) {
+
+ // Check whether the widget is enabled and visible
+ if ((gh->flags & (GWIN_FLG_WIDGET|GWIN_FLG_SYSENABLED|GWIN_FLG_SYSVISIBLE)) != (GWIN_FLG_WIDGET|GWIN_FLG_SYSENABLED|GWIN_FLG_SYSVISIBLE)) {
+ continue;
+ }
+
+ // Pass the information
+ wvmt->KeyboardEvent(gw, pke);
+ }
+ break;
+ #endif
+
#if GFX_USE_GINPUT && GINPUT_NEED_TOGGLE
case GEVENT_TOGGLE:
// Cycle through all windows
@@ -235,6 +252,10 @@ void _gwidgetInit(void)
geventListenerInit(&gl);
geventRegisterCallback(&gl, gwidgetEvent, 0);
geventAttachSource(&gl, ginputGetMouse(GMOUSE_ALL_INSTANCES), GLISTEN_MOUSEMETA|GLISTEN_MOUSEDOWNMOVES);
+
+ #if GINPUT_NEED_KEYBOARD
+ geventAttachSource(&gl, ginputGetKeyboard(GKEYBOARD_ALL_INSTANCES), 0);
+ #endif
}
void _gwidgetDeinit(void)