aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/multiple
diff options
context:
space:
mode:
authorinmarket <andrewh@inmarket.com.au>2014-09-26 17:29:31 +1000
committerinmarket <andrewh@inmarket.com.au>2014-09-26 17:29:31 +1000
commit1298e3d6358f65c677fca8125ee7947501592b39 (patch)
tree9b613ef5be1ce20e6f6956158df4ced6ccbbc360 /drivers/multiple
parent67fdb1e0b8faa6e97bd4ed9343805530ca9b0c6f (diff)
downloaduGFX-1298e3d6358f65c677fca8125ee7947501592b39.tar.gz
uGFX-1298e3d6358f65c677fca8125ee7947501592b39.tar.bz2
uGFX-1298e3d6358f65c677fca8125ee7947501592b39.zip
First version X newmouse driver
Diffstat (limited to 'drivers/multiple')
-rw-r--r--drivers/multiple/X/gdisp_lld_X.c132
1 files changed, 87 insertions, 45 deletions
diff --git a/drivers/multiple/X/gdisp_lld_X.c b/drivers/multiple/X/gdisp_lld_X.c
index 00b2748b..0462d0d6 100644
--- a/drivers/multiple/X/gdisp_lld_X.c
+++ b/drivers/multiple/X/gdisp_lld_X.c
@@ -10,10 +10,10 @@
#if GFX_USE_GDISP
#define GDISP_DRIVER_VMT GDISPVMT_X11
-#include "drivers/multiple/X/gdisp_lld_config.h"
+#include "gdisp_lld_config.h"
#include "src/gdisp/driver.h"
-#ifndef GDISP_FORCE_24BIT
+#ifndef GDISP_FORCE_24BIT
#define GDISP_FORCE_24BIT FALSE
#endif
@@ -27,8 +27,45 @@
#define GDISP_FLG_READY (GDISP_FLG_DRIVER<<0)
#if GINPUT_NEED_MOUSE
- /* Include mouse support code */
+ // Include mouse support code
+ #define GMOUSE_DRIVER_VMT GMOUSEVMT_X11
#include "src/ginput/driver_mouse.h"
+
+ // Forward definitions
+ static bool_t XMouseInit(GMouse *m, unsigned driverinstance);
+ static void XMouseRead(GMouse *m, GMouseReading *prd);
+
+ const GMouseVMT const GMOUSE_DRIVER_VMT[1] = {{
+ {
+ GDRIVER_TYPE_MOUSE,
+ GMOUSE_VFLG_NOPOLL|GMOUSE_VFLG_DYNAMICONLY,
+ // Extra flags for testing only
+ //GMOUSE_VFLG_TOUCH|GMOUSE_VFLG_SELFROTATION|GMOUSE_VFLG_DEFAULTFINGER
+ //GMOUSE_VFLG_CALIBRATE|GMOUSE_VFLG_CAL_EXTREMES|GMOUSE_VFLG_CAL_TEST|GMOUSE_VFLG_CAL_LOADFREE
+ //GMOUSE_VFLG_ONLY_DOWN|GMOUSE_VFLG_POORUPDOWN
+ sizeof(GMouse),
+ _gmouseInitDriver, _gmousePostInitDriver, _gmouseDeInitDriver
+ },
+ 1, // z_max
+ 0, // z_min
+ 1, // z_touchon
+ 0, // z_touchoff
+ { // pen_jitter
+ 0, // calibrate
+ 0, // click
+ 0 // move
+ },
+ { // finger_jitter
+ 0, // calibrate
+ 2, // click
+ 2 // move
+ },
+ XMouseInit, // init
+ 0, // deinit
+ XMouseRead, // get
+ 0, // calsave
+ 0 // calload
+ }};
#endif
#include <X11/Xlib.h>
@@ -44,15 +81,16 @@ static XEvent evt;
static Colormap cmap;
static XVisualInfo vis;
static XContext cxt;
-#if GINPUT_NEED_MOUSE
- static coord_t mousex, mousey;
- static uint16_t mousebuttons;
-#endif
typedef struct xPriv {
Pixmap pix;
GC gc;
Window win;
+ #if GINPUT_NEED_MOUSE
+ coord_t mousex, mousey;
+ uint16_t buttons;
+ GMouse * mouse;
+ #endif
} xPriv;
static void ProcessEvent(GDisplay *g, xPriv *priv) {
@@ -68,42 +106,36 @@ static void ProcessEvent(GDisplay *g, xPriv *priv) {
case Expose:
XCopyArea(dis, priv->pix, evt.xexpose.window, priv->gc,
evt.xexpose.x, evt.xexpose.y,
- evt.xexpose.width, evt.xexpose.height,
+ evt.xexpose.width, evt.xexpose.height,
evt.xexpose.x, evt.xexpose.y);
break;
#if GINPUT_NEED_MOUSE
case ButtonPress:
- mousex = evt.xbutton.x;
- mousey = evt.xbutton.y;
+ priv->mousex = evt.xbutton.x;
+ priv->mousey = evt.xbutton.y;
switch(evt.xbutton.button){
- case 1: mousebuttons |= GINPUT_MOUSE_BTN_LEFT; break;
- case 2: mousebuttons |= GINPUT_MOUSE_BTN_MIDDLE; break;
- case 3: mousebuttons |= GINPUT_MOUSE_BTN_RIGHT; break;
- case 4: mousebuttons |= GINPUT_MOUSE_BTN_4; break;
+ case 1: priv->buttons |= GINPUT_MOUSE_BTN_LEFT; break;
+ case 2: priv->buttons |= GINPUT_MOUSE_BTN_MIDDLE; break;
+ case 3: priv->buttons |= GINPUT_MOUSE_BTN_RIGHT; break;
+ case 4: priv->buttons |= GINPUT_MOUSE_BTN_4; break;
}
- #if GINPUT_MOUSE_POLL_PERIOD == TIME_INFINITE
- ginputMouseWakeup();
- #endif
+ _gmouseWakeup(priv->mouse);
break;
case ButtonRelease:
- mousex = evt.xbutton.x;
- mousey = evt.xbutton.y;
+ priv->mousex = evt.xbutton.x;
+ priv->mousey = evt.xbutton.y;
switch(evt.xbutton.button){
- case 1: mousebuttons &= ~GINPUT_MOUSE_BTN_LEFT; break;
- case 2: mousebuttons &= ~GINPUT_MOUSE_BTN_MIDDLE; break;
- case 3: mousebuttons &= ~GINPUT_MOUSE_BTN_RIGHT; break;
- case 4: mousebuttons &= ~GINPUT_MOUSE_BTN_4; break;
+ case 1: priv->buttons &= ~GINPUT_MOUSE_BTN_LEFT; break;
+ case 2: priv->buttons &= ~GINPUT_MOUSE_BTN_MIDDLE; break;
+ case 3: priv->buttons &= ~GINPUT_MOUSE_BTN_RIGHT; break;
+ case 4: priv->buttons &= ~GINPUT_MOUSE_BTN_4; break;
}
- #if GINPUT_MOUSE_POLL_PERIOD == TIME_INFINITE
- ginputMouseWakeup();
- #endif
+ _gmouseWakeup(priv->mouse);
break;
case MotionNotify:
- mousex = evt.xmotion.x;
- mousey = evt.xmotion.y;
- #if GINPUT_MOUSE_POLL_PERIOD == TIME_INFINITE
- ginputMouseWakeup();
- #endif
+ priv->mousex = evt.xmotion.x;
+ priv->mousey = evt.xmotion.y;
+ _gmouseWakeup(priv->mouse);
break;
#endif
}
@@ -125,7 +157,7 @@ static DECLARE_THREAD_FUNCTION(ThreadX, arg) {
}
return 0;
}
-
+
static int FatalXIOError(Display *d) {
(void) d;
@@ -187,13 +219,13 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) {
xa.colormap = cmap;
xa.border_pixel = 0xFFFFFF;
xa.background_pixel = 0x000000;
-
+
priv->win = XCreateWindow(dis, RootWindow(dis, scr), 16, 16,
GDISP_SCREEN_WIDTH, GDISP_SCREEN_HEIGHT,
0, vis.depth, InputOutput, vis.visual,
CWBackPixel|CWColormap|CWBorderPixel, &xa);
XSync(dis, TRUE);
-
+
XSaveContext(dis, priv->win, cxt, (XPointer)g);
{
@@ -205,7 +237,7 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) {
XSetWMIconName(dis, priv->win, &WindowTitle);
XSync(dis, TRUE);
}
-
+
pSH = XAllocSizeHints();
pSH->flags = PSize | PMinSize | PMaxSize;
pSH->min_width = pSH->max_width = pSH->base_width = GDISP_SCREEN_WIDTH;
@@ -213,7 +245,7 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) {
XSetWMNormalHints(dis, priv->win, pSH);
XFree(pSH);
XSync(dis, TRUE);
-
+
priv->pix = XCreatePixmap(dis, priv->win,
GDISP_SCREEN_WIDTH, GDISP_SCREEN_HEIGHT, vis.depth);
XSync(dis, TRUE);
@@ -236,6 +268,12 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) {
g->g.Contrast = 50;
g->g.Width = GDISP_SCREEN_WIDTH;
g->g.Height = GDISP_SCREEN_HEIGHT;
+
+ // Create the associated mouse
+ #if GINPUT_NEED_MOUSE
+ priv->mouse = (GMouse *)gdriverRegister((const GDriverVMT const *)GMOUSE_DRIVER_VMT, g);
+ #endif
+
return TRUE;
}
@@ -312,16 +350,20 @@ LLDSPEC void gdisp_lld_draw_pixel(GDisplay *g)
#endif
#if GINPUT_NEED_MOUSE
-
- void ginput_lld_mouse_init(void) {}
-
- void ginput_lld_mouse_get_reading(MouseReading *pt) {
- pt->x = mousex;
- pt->y = mousey;
- pt->z = (mousebuttons & GINPUT_MOUSE_BTN_LEFT) ? 100 : 0;
- pt->buttons = mousebuttons;
+ static bool_t XMouseInit(GMouse *m, unsigned driverinstance) {
+ (void) m;
+ (void) driverinstance;
+ return TRUE;
+ }
+ static void XMouseRead(GMouse *m, GMouseReading *pt) {
+ xPriv * priv;
+
+ priv = m->display->priv;
+ pt->x = priv->mousex;
+ pt->y = priv->mousey;
+ pt->z = (priv->buttons & GINPUT_MOUSE_BTN_LEFT) ? 1 : 0;
+ pt->buttons = priv->buttons;
}
-
#endif /* GINPUT_NEED_MOUSE */
#endif /* GFX_USE_GDISP */