Merge pull request #63 from inmarket/master

GINPUT Dial. Simplify input -> GWIN widget assignment
ugfx_release_2.6
Tectu 2013-04-07 02:59:42 -07:00
commit 1d24b6977d
18 changed files with 864 additions and 344 deletions

View File

@ -201,28 +201,24 @@ StepCalibrate:
gwinSetButtonText(ghNext, "Next", FALSE); gwinSetButtonText(ghNext, "Next", FALSE);
gsNext = gwinGetButtonSource(ghNext); gsNext = gwinGetButtonSource(ghNext);
geventAttachSource(&gl, gsNext, 0); geventAttachSource(&gl, gsNext, 0);
gwinAttachButtonMouseSource(ghNext, gs); gwinAttachButtonMouse(ghNext, 0);
ghPrev = gwinCreateButton(&gPrev, swidth-100, 0, 50, 20, font, GBTN_NORMAL); ghPrev = gwinCreateButton(&gPrev, swidth-100, 0, 50, 20, font, GBTN_NORMAL);
gwinSetButtonText(ghPrev, "Back", FALSE); gwinSetButtonText(ghPrev, "Back", FALSE);
gsPrev = gwinGetButtonSource(ghPrev); gsPrev = gwinGetButtonSource(ghPrev);
geventAttachSource(&gl, gsPrev, 0); geventAttachSource(&gl, gsPrev, 0);
gwinAttachButtonMouseSource(ghPrev, gs); gwinAttachButtonMouse(ghPrev, 0);
#if 0 #if 0
{ {
GSourceHandle gsButton1, gsButton2;
// Attach a couple of hardware toggle buttons to our Next and Back buttons as well. // Attach a couple of hardware toggle buttons to our Next and Back buttons as well.
// We can always use the mouse to trigger the buttons if you don't want to use hardware toggles. // We can always use the mouse to trigger the buttons if you don't want to use hardware toggles.
// This code depends on your hardware. Turn it on only if you have // This code depends on your hardware. Turn it on only if you have
// defined a board definition for your toggle driver. Then change // defined a board definition for your toggle driver. Then change
// the next two lines to be correct for your hardware. The values // the next two lines to be correct for your hardware. The values
// below are correct for the Win32 toggle driver. // below are correct for the Win32 toggle driver.
gsButton1 = ginputGetToggle(GINPUT_TOGGLE_MOMENTARY1); gwinAttachButtonToggle(ghNext, GINPUT_TOGGLE_MOMENTARY1);
gsButton2 = ginputGetToggle(GINPUT_TOGGLE_MOMENTARY2); gwinAttachButtonToggle(ghPrev, GINPUT_TOGGLE_MOMENTARY2);
gwinAttachButtonToggleSource(ghNext, gsButton2);
gwinAttachButtonToggleSource(ghPrev, gsButton1);
} }
#endif #endif
} }

View File

@ -53,5 +53,6 @@
/* Features for the GINPUT sub-system. */ /* Features for the GINPUT sub-system. */
#define GINPUT_NEED_MOUSE TRUE #define GINPUT_NEED_MOUSE TRUE
#define GINPUT_NEED_DIAL TRUE
#endif /* _GFXCONF_H */ #endif /* _GFXCONF_H */

View File

@ -31,7 +31,7 @@ int main(void) {
coord_t swidth, sheight; coord_t swidth, sheight;
GHandle ghSliderH, ghSliderV, ghConsole; GHandle ghSliderH, ghSliderV, ghConsole;
font_t fui2; font_t fui2;
GSourceHandle gsMouse; GEvent * pe;
GEventGWinSlider * pSliderEvent; GEventGWinSlider * pSliderEvent;
BaseSequentialStream *consout; BaseSequentialStream *consout;
@ -58,10 +58,15 @@ int main(void) {
gwinSetColor(ghConsole, White); gwinSetColor(ghConsole, White);
gwinSetBgColor(ghConsole, Blue); gwinSetBgColor(ghConsole, Blue);
// Assign the mouse to the sliders. // Assign the mouse and dials to the sliders.
gsMouse = ginputGetMouse(0); #if GINPUT_NEED_MOUSE
gwinAttachSliderMouseSource(ghSliderH, gsMouse); gwinAttachSliderMouse(ghSliderH, 0);
gwinAttachSliderMouseSource(ghSliderV, gsMouse); gwinAttachSliderMouse(ghSliderV, 0);
#endif
#if GINPUT_NEED_DIAL
gwinAttachSliderDial(ghSliderV, 0);
gwinAttachSliderDial(ghSliderH, 1);
#endif
// We want to listen for slider events // We want to listen for slider events
geventListenerInit(&gl); geventListenerInit(&gl);
@ -75,14 +80,14 @@ int main(void) {
while(1) { while(1) {
// Get an Event // Get an Event
// - we can assume it is a slider event as that is all we are listening for pe = geventEventWait(&gl, TIME_INFINITE);
pSliderEvent = (GEventGWinSlider *)geventEventWait(&gl, TIME_INFINITE);
// Double check that assumption switch(pe->type) {
if (pSliderEvent->type != GEVENT_GWIN_SLIDER) case GEVENT_GWIN_SLIDER:
continue; pSliderEvent = (GEventGWinSlider *)pe;
chprintf(consout, "%c=%d\n", pSliderEvent->slider == ghSliderH ? 'H' : 'V', pSliderEvent->position);
chprintf(consout, "%c=%d\n", pSliderEvent->slider == ghSliderH ? 'H' : 'V', pSliderEvent->position); break;
}
} }
return 0; return 0;

View File

@ -0,0 +1,6 @@
This demo supports input from both a mouse/touch and/or a dial input.
If your platform does not support one or the other, turn it off in
gfxconf.h
Note that you will need to include the drivers into your project
makefile for whichever inputs you decide to use.

View File

@ -0,0 +1,5 @@
# List the required driver.
GFXSRC += $(GFXLIB)/drivers/ginput/dial/GADC/ginput_lld_dial.c
# Required include directories
GFXINC += $(GFXLIB)/drivers/ginput/dial/GADC

View File

@ -0,0 +1,101 @@
/*
ChibiOS/GFX - Copyright (C) 2012, 2013
Joel Bodenmann aka Tectu <joel@unormal.org>
This file is part of ChibiOS/GFX.
ChibiOS/GFX is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
ChibiOS/GFX is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* @file drivers/ginput/dial/GADC/ginput_lld_dial.c
* @brief GINPUT Dial low level driver source for GADC hardware.
*
* @defgroup Dial Dial
* @ingroup GINPUT
* @{
*/
#include "ch.h"
#include "hal.h"
#include "gfx.h"
#if GFX_USE_GINPUT && GINPUT_NEED_DIAL
#include "ginput/lld/dial.h"
#if GINPUT_DIAL_NUM_PORTS >= 5
#error "GINPUT: Dial - GADC driver currently only supports 4 devices"
#endif
static adcsample_t samplebuf[GINPUT_DIAL_NUM_PORTS];
#if GINPUT_DIAL_CYCLE_POLL
static uint16_t cycle;
#endif
static void GADCCallback(adcsample_t *buffer, void *param) {
((DialCallbackFn)param)(buffer-samplebuf, buffer[0]);
}
void ginput_lld_dial_init(void) {
#if GINPUT_DIAL_CYCLE_POLL
cycle = 0;
#endif
}
void ginput_lld_dial_poll(DialCallbackFn fn) {
#if GINPUT_DIAL_CYCLE_POLL
switch(cycle++) {
#if GINPUT_DIAL_NUM_PORTS >= 1
case 0:
gadcLowSpeedStart(GINPUT_DIAL_DEVICE0, samplebuf+0, GADCCallback, (void *)fn);
break;
#endif
#if GINPUT_DIAL_NUM_PORTS >= 2
case 1:
gadcLowSpeedStart(GINPUT_DIAL_DEVICE1, samplebuf+1, GADCCallback, (void *)fn);
break;
#endif
#if GINPUT_DIAL_NUM_PORTS >= 3
case 2:
gadcLowSpeedStart(GINPUT_DIAL_DEVICE2, samplebuf+2, GADCCallback, (void *)fn);
break;
#endif
#if GINPUT_DIAL_NUM_PORTS >= 4
case 3:
gadcLowSpeedStart(GINPUT_DIAL_DEVICE3, samplebuf+3, GADCCallback, (void *)fn);
break;
#endif
}
if (cycle >= GINPUT_DIAL_NUM_PORTS)
cycle = 0;
#else
#if GINPUT_DIAL_NUM_PORTS >= 1
gadcLowSpeedStart(GINPUT_DIAL_DEVICE0, samplebuf+0, GADCCallback, (void *)fn);
#endif
#if GINPUT_DIAL_NUM_PORTS >= 2
gadcLowSpeedStart(GINPUT_DIAL_DEVICE1, samplebuf+1, GADCCallback, (void *)fn);
#endif
#if GINPUT_DIAL_NUM_PORTS >= 3
gadcLowSpeedStart(GINPUT_DIAL_DEVICE2, samplebuf+2, GADCCallback, (void *)fn);
#endif
#if GINPUT_DIAL_NUM_PORTS >= 4
gadcLowSpeedStart(GINPUT_DIAL_DEVICE3, samplebuf+3, GADCCallback, (void *)fn);
#endif
#endif
}
#endif /* GFX_USE_GINPUT && GINPUT_NEED_DIAL */
/** @} */

View File

@ -0,0 +1,48 @@
/*
ChibiOS/GFX - Copyright (C) 2012, 2013
Joel Bodenmann aka Tectu <joel@unormal.org>
This file is part of ChibiOS/GFX.
ChibiOS/GFX is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
ChibiOS/GFX is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* @file drivers/ginput/dial/GADC/ginput_lld_dial_board_olimexsam7ex256.h
* @brief GINPUT Dial Driver config file.
*
* @defgroup Dial Dial
* @ingroup GINPUT
* @{
*/
#ifndef _GINPUT_LLD_DIAL_BOARD_OLIMEXSAM7EX256_H
#define _GINPUT_LLD_DIAL_BOARD_OLIMEXSAM7EX256_H
#if GFX_USE_GINPUT && GINPUT_NEED_DIAL
/*===========================================================================*/
/* Analogue devices on this board */
/*===========================================================================*/
#define GINPUT_DIAL_NUM_PORTS 1
#define GINPUT_DIAL_DEVICE0 GADC_PHYSDEV_DIAL
#define GINPUT_DIAL_POLL_PERIOD 200
#define GINPUT_DIAL_CYCLE_POLL FALSE
#endif /* GFX_USE_GINPUT && GINPUT_NEED_DIAL */
#endif /* _GINPUT_LLD_DIAL_BOARD_OLIMEXSAM7EX256_H */
/** @} */

View File

@ -0,0 +1,50 @@
/*
ChibiOS/GFX - Copyright (C) 2012, 2013
Joel Bodenmann aka Tectu <joel@unormal.org>
This file is part of ChibiOS/GFX.
ChibiOS/GFX is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
ChibiOS/GFX is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* @file drivers/ginput/dial/GADC/ginput_lld_dial_config.h
* @brief GINPUT Dial Driver configuration header.
*
* @defgroup Dial Dial
* @ingroup GINPUT
* @{
*/
#ifndef _GINPUT_LLD_DIAL_CONFIG_H
#define _GINPUT_LLD_DIAL_CONFIG_H
#if GFX_USE_GINPUT && GINPUT_NEED_DIAL
#define GINPUT_DIAL_MAX_VALUE ((1<<GADC_BITS_PER_SAMPLE)-1)
#if GINPUT_TOGGLE_USE_CUSTOM_BOARD
/* Include the user supplied board definitions */
#include "ginput_lld_dial_board.h"
#elif defined(BOARD_OLIMEX_SAM7_EX256)
#include "ginput_lld_dial_board_olimexsam7ex256.h"
#else
/* Include the user supplied board definitions */
#include "ginput_lld_dial_board.h"
#endif
#endif /* GFX_USE_GDISP && GINPUT_NEED_DIAL */
#endif /* _GINPUT_LLD_DIAL_CONFIG_H */
/** @} */

View File

@ -0,0 +1,16 @@
To use this driver:
1. Add in your halconf.h:
a) #define GFX_USE_GINPUT TRUE
#define GINPUT_NEED_DIAL TRUE
#define GINPUT_NEED_GADC TRUE
d) If you are not using a known board then create a ginput_lld_toggle_board.h file
and ensure it is on your include path.
Use the ginput_lld_dial_board_example.h file as a basis.
Currently known boards are:
Olimex SAM7-EX256
2. To your makefile add the following lines:
include $(GFXLIB)/drivers/ginput/dial/GADC/ginput_lld.mk
include $(GFXLIB)/drivers/gadc/yourGADCdriver/gadc_lld.mk

View File

@ -1,123 +1,122 @@
/* /*
ChibiOS/GFX - Copyright (C) 2012, 2013 ChibiOS/GFX - Copyright (C) 2012, 2013
Joel Bodenmann aka Tectu <joel@unormal.org> Joel Bodenmann aka Tectu <joel@unormal.org>
This file is part of ChibiOS/GFX. This file is part of ChibiOS/GFX.
ChibiOS/GFX is free software; you can redistribute it and/or modify ChibiOS/GFX is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or the Free Software Foundation; either version 3 of the License, or
(at your option) any later version. (at your option) any later version.
ChibiOS/GFX is distributed in the hope that it will be useful, ChibiOS/GFX is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
/** /**
* @file include/ginput/dial.h * @file include/ginput/dial.h
* @brief GINPUT GFX User Input subsystem header file. * @brief GINPUT GFX User Input subsystem header file.
* *
* @defgroup Dial Dial * @defgroup Dial Dial
* @ingroup GINPUT * @ingroup GINPUT
* *
* @details A dial provides a powerful way to navigate through menus * @details A dial provides a powerful way to navigate through menus
* on a display. * on a display.
* *
* @pre GFX_USE_GINPUT must be set to TRUE in your gfxconf.h * @pre GFX_USE_GINPUT must be set to TRUE in your gfxconf.h
* @pre GINPUT_NEED_DIAL must be set to TRUE in your gfxconf.h * @pre GINPUT_NEED_DIAL must be set to TRUE in your gfxconf.h
* *
* @{ * @{
*/ */
#ifndef _GINPUT_DIAL_H #ifndef _GINPUT_DIAL_H
#define _GINPUT_DIAL_H #define _GINPUT_DIAL_H
#if GINPUT_NEED_DIAL || defined(__DOXYGEN__) #if GINPUT_NEED_DIAL || defined(__DOXYGEN__)
/*===========================================================================*/ /*===========================================================================*/
/* Type definitions */ /* Type definitions */
/*===========================================================================*/ /*===========================================================================*/
// Event types for various ginput sources // Event types for various ginput sources
#define GEVENT_DIAL (GEVENT_GINPUT_FIRST+4) #define GEVENT_DIAL (GEVENT_GINPUT_FIRST+4)
typedef struct GEventDial_t { typedef struct GEventDial_t {
GEventType type; // The type of this event (GEVENT_DIAL) GEventType type; // The type of this event (GEVENT_DIAL)
uint16_t instance; // The dial instance uint16_t instance; // The dial instance
uint16_t value; // The dial value uint16_t value; // The dial value
} GEventDial; } GEventDial;
/*===========================================================================*/ /*===========================================================================*/
/* External declarations. */ /* External declarations. */
/*===========================================================================*/ /*===========================================================================*/
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
/** /**
* @brief Create a dial input instance * @brief Create a dial input instance
* *
* @param[in] instance The ID of the dial input instance (from 0 to 9999) * @param[in] instance The ID of the dial input instance (from 0 to 9999)
* *
* @return The soure handle of the created dial instance * @return The soure handle of the created dial instance
*/ */
GSourceHandle ginputGetDial(uint16_t instance); GSourceHandle ginputGetDial(uint16_t instance);
/** /**
* @brief Reset the value back to the hardware default * @brief Reset the value back to the hardware default
* *
* @param[in] instance The ID of the dial input instance * @param[in] instance The ID of the dial input instance
*/ */
void ginputResetDialRange(uint16_t instance); void ginputResetDialRange(uint16_t instance);
/** /**
* @brief Get the maximum value * @brief Get the maximum value
* @details The readings are scaled to be 0 ... max-1. * @details The readings are scaled to be 0 ... max.
* 0 means over the full uint16_t range. *
* * @param[in] instance The ID of the dial input instance
* @param[in] instance The ID of the dial input instance *
* * @return The maximum value
* @return The maximum value */
*/ uint16_t ginputGetDialRange(uint16_t instance);
uint16_t ginputGetDialRange(uint16_t instance);
/**
/** * @brief Set the maximum value
* @brief Set the maximum value * @details The readings are scaled to be 0 ... max.
* @note This shouldn't be set higher that the hardwares possible maximum value *
* * @param[in] instance The ID of the dial input instance
* @param[in] instance The ID of the dial input instance * @param[in] max The maximum value to be set
* @param[in] max The maximum value to be set */
*/ void ginputSetDialRange(uint16_t instance, uint16_t max);
void ginputSetDialRange(uint16_t instance, uint16_t max);
/**
/** * @brief Set the level change required before a dial even is generated (threshold)
* @brief Set the level change required before a dial even is generated (threshold) * @note This is done after range scaling
* @note This is done after range scaling *
* * @param[in] instance The ID of the dial input instance
* @param[in] instance The ID of the dial input instance * @param[in] diff The amount of level changes
* @param[in] diff The amount of level changes */
*/ void ginputSetDialSensitivity(uint16_t instance, uint16_t diff);
void ginputSetDialSensitivity(uint16_t instance, uint16_t diff);
/**
/** * @brief Get the current dial status
* @brief Get the current dial status *
* * @param[in] instance The ID of the dial input instance
* @param[in] instance The ID of the dial input instance * @param[in] pdial The dial event struct
* @param[in] pdial The dial event struct *
* * @return Returns FALSE on an error (eg invalid instance)
* @return Returns FALSE on an error (eg invalid instance) */
*/ bool_t ginputGetDialStatus(uint16_t instance, GEventDial *pdial);
bool_t ginputGetDialStatus(uint16_t instance, GEventDial *pdial);
#ifdef __cplusplus
#ifdef __cplusplus }
} #endif
#endif
#endif /* GINPUT_NEED_DIAL */
#endif /* GINPUT_NEED_DIAL */
#endif /* _GINPUT_DIAL_H */
#endif /* _GINPUT_DIAL_H */ /** @} */
/** @} */

View File

@ -0,0 +1,57 @@
/*
ChibiOS/GFX - Copyright (C) 2012, 2013
Joel Bodenmann aka Tectu <joel@unormal.org>
This file is part of ChibiOS/GFX.
ChibiOS/GFX is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
ChibiOS/GFX is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* @file include/ginput/lld/dial.h
* @brief GINPUT header file for dial drivers.
*
* @defgroup Dial Dial
* @ingroup GINPUT
* @{
*/
#ifndef _LLD_GINPUT_DIAL_H
#define _LLD_GINPUT_DIAL_H
#if GINPUT_NEED_DIAL || defined(__DOXYGEN__)
#include "ginput_lld_dial_config.h"
typedef void (*DialCallbackFn)(uint16_t instance, uint16_t rawvalue);
/*===========================================================================*/
/* External declarations. */
/*===========================================================================*/
#ifdef __cplusplus
extern "C" {
#endif
void ginput_lld_dial_init(void);
void ginput_lld_dial_poll(DialCallbackFn fn);
#ifdef __cplusplus
}
#endif
#endif /* GFX_USE_GINPUT && GINPUT_NEED_TOGGLE */
#endif /* _LLD_GINPUT_TOGGLE_H */
/** @} */

View File

@ -1,121 +1,181 @@
/* /*
ChibiOS/GFX - Copyright (C) 2012, 2013 ChibiOS/GFX - Copyright (C) 2012, 2013
Joel Bodenmann aka Tectu <joel@unormal.org> Joel Bodenmann aka Tectu <joel@unormal.org>
This file is part of ChibiOS/GFX. This file is part of ChibiOS/GFX.
ChibiOS/GFX is free software; you can redistribute it and/or modify ChibiOS/GFX is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or the Free Software Foundation; either version 3 of the License, or
(at your option) any later version. (at your option) any later version.
ChibiOS/GFX is distributed in the hope that it will be useful, ChibiOS/GFX is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
/** /**
* @file include/ginput/lld/mouse.h * @file include/ginput/lld/mouse.h
* @brief GINPUT LLD header file for mouse/touch drivers. * @brief GINPUT LLD header file for mouse/touch drivers.
* *
* @defgroup Mouse Mouse * @defgroup Mouse Mouse
* @ingroup GINPUT * @ingroup GINPUT
* @{ * @{
*/ */
#ifndef _LLD_GINPUT_MOUSE_H #ifndef _LLD_GINPUT_MOUSE_H
#define _LLD_GINPUT_MOUSE_H #define _LLD_GINPUT_MOUSE_H
#if GINPUT_NEED_MOUSE || defined(__DOXYGEN__) #if GINPUT_NEED_MOUSE || defined(__DOXYGEN__)
#include "ginput_lld_mouse_config.h" #include "ginput_lld_mouse_config.h"
// GEVENT_MOUSE or GEVENT_TOUCH - What type of device is this. // GEVENT_MOUSE or GEVENT_TOUCH - What type of device is this.
#ifndef GINPUT_MOUSE_EVENT_TYPE #ifndef GINPUT_MOUSE_EVENT_TYPE
#define GINPUT_MOUSE_EVENT_TYPE GEVENT_MOUSE #define GINPUT_MOUSE_EVENT_TYPE GEVENT_MOUSE
#endif #endif
// TRUE/FALSE - Does the mouse/touch driver require calibration? // TRUE/FALSE - Does the mouse/touch driver require calibration?
#ifndef GINPUT_MOUSE_NEED_CALIBRATION #ifndef GINPUT_MOUSE_NEED_CALIBRATION
#define GINPUT_MOUSE_NEED_CALIBRATION FALSE #define GINPUT_MOUSE_NEED_CALIBRATION FALSE
#endif #endif
// TRUE/FALSE - Can the mouse/touch driver itself save calibration data? // TRUE/FALSE - Can the mouse/touch driver itself save calibration data?
#ifndef GINPUT_MOUSE_LLD_CALIBRATION_LOADSAVE #ifndef GINPUT_MOUSE_LLD_CALIBRATION_LOADSAVE
#define GINPUT_MOUSE_LLD_CALIBRATION_LOADSAVE FALSE #define GINPUT_MOUSE_LLD_CALIBRATION_LOADSAVE FALSE
#endif #endif
// n or -1 - n means to test calibration result (+/- pixels), -1 means not to. // n or -1 - n means to test calibration result (+/- pixels), -1 means not to.
#ifndef GINPUT_MOUSE_MAX_CALIBRATION_ERROR #ifndef GINPUT_MOUSE_MAX_CALIBRATION_ERROR
#define GINPUT_MOUSE_MAX_CALIBRATION_ERROR -1 #define GINPUT_MOUSE_MAX_CALIBRATION_ERROR -1
#endif #endif
// n - How many times to read (and average) per poll // n - How many times to read (and average) per poll
#ifndef GINPUT_MOUSE_READ_CYCLES #ifndef GINPUT_MOUSE_READ_CYCLES
#define GINPUT_MOUSE_READ_CYCLES 1 #define GINPUT_MOUSE_READ_CYCLES 1
#endif #endif
// n - Millisecs between poll's // n - Millisecs between poll's
#ifndef GINPUT_MOUSE_POLL_PERIOD #ifndef GINPUT_MOUSE_POLL_PERIOD
#define GINPUT_MOUSE_POLL_PERIOD 25 #define GINPUT_MOUSE_POLL_PERIOD 25
#endif #endif
// n - Movement allowed without discarding the CLICK or CLICKCXT event (+/- pixels) // n - Movement allowed without discarding the CLICK or CLICKCXT event (+/- pixels)
#ifndef GINPUT_MOUSE_MAX_CLICK_JITTER #ifndef GINPUT_MOUSE_MAX_CLICK_JITTER
#define GINPUT_MOUSE_MAX_CLICK_JITTER 1 #define GINPUT_MOUSE_MAX_CLICK_JITTER 1
#endif #endif
// n - Movement allowed without discarding the MOVE event (+/- pixels) // n - Movement allowed without discarding the MOVE event (+/- pixels)
#ifndef GINPUT_MOUSE_MAX_MOVE_JITTER #ifndef GINPUT_MOUSE_MAX_MOVE_JITTER
#define GINPUT_MOUSE_MAX_MOVE_JITTER 0 #define GINPUT_MOUSE_MAX_MOVE_JITTER 0
#endif #endif
// ms - Millisecs seperating a CLICK from a CXTCLICK // ms - Millisecs seperating a CLICK from a CXTCLICK
#ifndef GINPUT_MOUSE_CLICK_TIME #ifndef GINPUT_MOUSE_CLICK_TIME
#define GINPUT_MOUSE_CLICK_TIME 700 #define GINPUT_MOUSE_CLICK_TIME 700
#endif #endif
typedef struct MouseReading_t { typedef struct MouseReading_t {
coord_t x, y, z; coord_t x, y, z;
uint16_t buttons; uint16_t buttons;
} MouseReading; } MouseReading;
/*===========================================================================*/ /*===========================================================================*/
/* External declarations. */ /* External declarations. */
/*===========================================================================*/ /*===========================================================================*/
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
void ginput_lld_mouse_init(void); /**
void ginput_lld_mouse_get_reading(MouseReading *pt); * @brief Initialise the mouse/touch.
*
#if GINPUT_MOUSE_LLD_CALIBRATION_LOADSAVE * @notapi
const char *ginput_lld_mouse_calibration_load(uint16_t instance); */
void ginput_lld_mouse_calibration_save(uint16_t instance, const uint8_t *calbuf, size_t sz); void ginput_lld_mouse_init(void);
#endif
/**
/* This routine is provided to low level drivers to wakeup a value read from a thread context. * @brief Read the mouse/touch position.
* Particularly useful if GINPUT_MOUSE_POLL_PERIOD = TIME_INFINITE *
*/ * @param[in] pt A pointer to the structure to fill
void ginputMouseWakeup(void); *
* @note For drivers that don't support returning a position
/* This routine is provided to low level drivers to wakeup a value read from an ISR * when the touch is up (most touch devices), it should
* Particularly useful if GINPUT_MOUSE_POLL_PERIOD = TIME_INFINITE * return the previous position with the new Z value.
*/ * The z value is the pressure for those touch devices
void ginputMouseWakeupI(void); * that support it (-100 to 100 where > 0 is touched)
* or, 0 or 100 for those drivers that don't.
#ifdef __cplusplus *
} * @notapi
#endif */
void ginput_lld_mouse_get_reading(MouseReading *pt);
#endif /* GINPUT_NEED_MOUSE || GINPUT_NEED_TOUCH */
#if GINPUT_MOUSE_LLD_CALIBRATION_LOADSAVE
#endif /* _LLD_GINPUT_MOUSE_H */ /**
/** @} */ * @brief Load calibration data from a storage area on the touch controller.
*
* @param[in] instance The mouse instance number
*
* @note The instance parameter is currently always 0 as we only support
* one mouse/touch device at a time.
* @note This routine should only be provided if the driver has its own
* storage area where calibration data can be stored. The drivers
* option.h file should define GINPUT_MOUSE_LLD_CALIBRATION_LOADSAVE = TRUE
* if it supports this.
*
* @notapi
*/
const char *ginput_lld_mouse_calibration_load(uint16_t instance);
/**
* @brief Save calibration data to a storage area on the touch controller.
*
* @param[in] instance The mouse instance number
* @param[in] calbuf The calibration data to be saved
* @param[in] sz The size of the calibration data
*
* @note The instance parameter is currently always 0 as we only support
* one mouse/touch device at a time.
* @note This routine should only be provided if the driver has its own
* storage area where calibration data can be stored. The drivers
* option.h file should define GINPUT_MOUSE_LLD_CALIBRATION_LOADSAVE = TRUE
* if it supports this.
*
* @notapi
*/
void ginput_lld_mouse_calibration_save(uint16_t instance, const uint8_t *calbuf, size_t sz);
#endif
/**
* @brief Wakeup the high level code so that it attempts another read
*
* @note This routine is provided to low level drivers by the high level code
* @note Particularly useful if GINPUT_MOUSE_POLL_PERIOD = TIME_INFINITE
*
* @notapi
*/
void ginputMouseWakeup(void);
/**
* @brief Wakeup the high level code so that it attempts another read
*
* @note This routine is provided to low level drivers by the high level code
* @note Particularly useful if GINPUT_MOUSE_POLL_PERIOD = TIME_INFINITE
*
* @icode
* @notapi
*/
void ginputMouseWakeupI(void);
#ifdef __cplusplus
}
#endif
#endif /* GINPUT_NEED_MOUSE || GINPUT_NEED_TOUCH */
#endif /* _LLD_GINPUT_MOUSE_H */
/** @} */

View File

@ -180,30 +180,28 @@ void gwinSetButtonCustom(GHandle gh, GButtonDrawFunction fn, void *param);
*/ */
#define gwinGetButtonSource(gh) ((GSourceHandle)(gh)) #define gwinGetButtonSource(gh) ((GSourceHandle)(gh))
#if defined(GINPUT_NEED_MOUSE) && GINPUT_NEED_MOUSE #if GFX_USE_GINPUT && GINPUT_NEED_MOUSE
/** /**
* @brief Attach a mouse source * @brief Attach a mouse to a button
* @details Attach a mouse source to a given button
* *
* @param[in] gh The button handle * @param[in] gh The button handle
* @param[in] gsh The source handle * @param[in] instance The mouse instance
* *
* @api * @api
*/ */
bool_t gwinAttachButtonMouseSource(GHandle gh, GSourceHandle gsh); bool_t gwinAttachButtonMouse(GHandle gh, uint16_t instance);
#endif #endif
#if defined(GINPUT_NEED_TOGGLE) && GINPUT_NEED_TOGGLE #if GFX_USE_GINPUT && GINPUT_NEED_TOGGLE
/** /**
* @brief Attach a toggle source * @brief Attach a toggle to a button
* @details Attach a toggle source to this button
* *
* @param[in] gh The button handle * @param[in] gh The button handle
* @param[in] gsh The source handle * @param[in] instance The toggle instance
* *
* @api * @api
*/ */
bool_t gwinAttachButtonToggleSource(GHandle gh, GSourceHandle gsh); bool_t gwinAttachButtonToggle(GHandle gh, uint16_t instance);
#endif #endif
/** /**

View File

@ -187,17 +187,30 @@ void gwinSetSliderCustom(GHandle gh, GSliderDrawFunction fn, void *param);
*/ */
#define gwinGetSliderSource(gh) ((GSourceHandle)(gh)) #define gwinGetSliderSource(gh) ((GSourceHandle)(gh))
#if defined(GINPUT_NEED_MOUSE) && GINPUT_NEED_MOUSE #if GFX_USE_GINPUT && GINPUT_NEED_MOUSE
/** /**
* @brief Attach a mouse source * @brief Attach a mouse source
* @details Attach a mouse source to a slider * @details Attach a mouse to a slider
* *
* @param[in] gh The slider handle * @param[in] gh The slider handle
* @param[in] gsh The source handle * @param[in] instance The mouse instance
* *
* @api * @api
*/ */
bool_t gwinAttachSliderMouseSource(GHandle gh, GSourceHandle gsh); bool_t gwinAttachSliderMouse(GHandle gh, uint16_t instance);
#endif
#if GFX_USE_GINPUT && GINPUT_NEED_DIAL
/**
* @brief Attach a dial source
* @details Attach a dial to a slider
*
* @param[in] gh The dial handle
* @param[in] instance The dial instance
*
* @api
*/
bool_t gwinAttachSliderDial(GHandle gh, uint16_t instance);
#endif #endif
/** /**

View File

@ -22,6 +22,8 @@ FEATURE: SSD1963 rework by username 'fred'
FEATURE: Added Picture converter tool FEATURE: Added Picture converter tool
FEATURE: Added slider widget FEATURE: Added slider widget
FEATURE: Added gwinDraw() routine FEATURE: Added gwinDraw() routine
FEATURE: Added GINPUT Dial support and driver using GADC
FEATURE: Simplified assigning inputs to buttons and sliders
*** changes after 1.4 *** *** changes after 1.4 ***

View File

@ -1,36 +1,166 @@
/* /*
ChibiOS/GFX - Copyright (C) 2012, 2013 ChibiOS/GFX - Copyright (C) 2012, 2013
Joel Bodenmann aka Tectu <joel@unormal.org> Joel Bodenmann aka Tectu <joel@unormal.org>
This file is part of ChibiOS/GFX. This file is part of ChibiOS/GFX.
ChibiOS/GFX is free software; you can redistribute it and/or modify ChibiOS/GFX is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or the Free Software Foundation; either version 3 of the License, or
(at your option) any later version. (at your option) any later version.
ChibiOS/GFX is distributed in the hope that it will be useful, ChibiOS/GFX is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
/** /**
* @file src/ginput/dial.c * @file src/ginput/dial.c
* @brief GINPUT dial code. * @brief GINPUT dial code.
* *
* @defgroup Dial Dial * @defgroup Dial Dial
* @ingroup GINPUT * @ingroup GINPUT
* @{ * @{
*/ */
#include "ch.h" #include "ch.h"
#include "hal.h" #include "hal.h"
#include "gfx.h" #include "gfx.h"
#if (GFX_USE_GINPUT && GINPUT_NEED_DIAL) || defined(__DOXYGEN__) #if GFX_USE_GINPUT && GINPUT_NEED_DIAL
#error "GINPUT: GINPUT_NEED_DIAL - Not Implemented Yet"
#endif /* GFX_USE_GINPUT && GINPUT_NEED_DIAL */ #include "ginput/lld/dial.h"
/** @} */
static GTIMER_DECL(DialTimer);
static struct DialStatus_t {
uint16_t sensitivity;
uint16_t lastvalue;
uint16_t max;
} DialStatus[GINPUT_DIAL_NUM_PORTS];
// The reading callback function
static void DialCallback(uint16_t instance, uint16_t rawvalue) {
struct DialStatus_t *pds;
GSourceListener *psl;
GEventDial *pe;
/* Get the information we need */
pds = DialStatus+instance;
/* Range scale - if needed */
if (pds->max != GINPUT_DIAL_MAX_VALUE)
rawvalue = (uint16_t)((uint32_t)rawvalue * pds->max / GINPUT_DIAL_MAX_VALUE);
/* Forget about changes below our sensitivity threshold */
if (rawvalue >= pds->lastvalue) {
if (rawvalue - pds->lastvalue < pds->sensitivity) return;
} else {
if (pds->lastvalue - rawvalue < pds->sensitivity) return;
}
/* Save the value */
pds->lastvalue = rawvalue;
// Send the event to the listeners that are interested.
psl = 0;
while ((psl = geventGetSourceListener((GSourceHandle)(DialStatus+instance), psl))) {
if (!(pe = (GEventDial *)geventGetEventBuffer(psl)))
continue;
pe->type = GEVENT_DIAL;
pe->instance = instance;
pe->value = pds->lastvalue;
geventSendEvent(psl);
}
}
GSourceHandle ginputGetDial(uint16_t instance) {
struct DialStatus_t *pds;
if (instance >= GINPUT_DIAL_NUM_PORTS)
return 0;
// Do we need to initialise the dial subsystem?
if (!gtimerIsActive(&DialTimer)) {
for(pds = DialStatus; pds < DialStatus+GINPUT_DIAL_NUM_PORTS; pds++) {
pds->max = GINPUT_DIAL_MAX_VALUE;
#if GINPUT_DIAL_MAX_VALUE < 100
pds->sensitivity = 1;
#else
pds->sensitivity = GINPUT_DIAL_MAX_VALUE/100;
#endif
pds->lastvalue = 0;
}
ginput_lld_dial_init();
gtimerStart(&DialTimer, (GTimerFunction)ginput_lld_dial_poll, DialCallback, TRUE, GINPUT_DIAL_POLL_PERIOD);
}
// OK - return this input
return (GSourceHandle)(DialStatus+instance);
}
void ginputResetDialRange(uint16_t instance) {
if (instance >= GINPUT_DIAL_NUM_PORTS)
return;
ginputSetDialRange(instance, GINPUT_DIAL_MAX_VALUE);
}
uint16_t ginputGetDialRange(uint16_t instance) {
if (instance >= GINPUT_DIAL_NUM_PORTS)
return 0;
return DialStatus[instance].max;
}
void ginputSetDialRange(uint16_t instance, uint16_t max) {
struct DialStatus_t *pds;
if (instance >= GINPUT_DIAL_NUM_PORTS)
return;
pds = DialStatus+instance;
// Rescale the last value and the sensitivity
if (max != pds->max) {
pds->lastvalue = (uint16_t)((uint32_t)pds->lastvalue * max / pds->max);
pds->sensitivity = (uint16_t)((uint32_t)pds->sensitivity * max / pds->max);
pds->max = max;
}
}
/**
* @brief Set the level change required before a dial even is generated (threshold)
* @note This is done after range scaling
*
* @param[in] instance The ID of the dial input instance
* @param[in] diff The amount of level changes
*/
void ginputSetDialSensitivity(uint16_t instance, uint16_t diff) {
if (instance >= GINPUT_DIAL_NUM_PORTS)
return;
DialStatus[instance].sensitivity = diff;
}
/**
* @brief Get the current dial status
*
* @param[in] instance The ID of the dial input instance
* @param[in] pdial The dial event struct
*
* @return Returns FALSE on an error (eg invalid instance)
*/
bool_t ginputGetDialStatus(uint16_t instance, GEventDial *pdial) {
if (instance >= GINPUT_DIAL_NUM_PORTS)
return FALSE;
pdial->type = GEVENT_DIAL;
pdial->instance = instance;
pdial->value = DialStatus[instance].lastvalue;
return TRUE;
}
#endif /* GFX_USE_GINPUT && GINPUT_NEED_DIAL */
/** @} */

View File

@ -68,7 +68,7 @@ static void gwinButtonCallback(void *param, GEvent *pe) {
#define pbe ((GEventGWinButton *)pe) #define pbe ((GEventGWinButton *)pe)
switch (pe->type) { switch (pe->type) {
#if defined(GINPUT_NEED_MOUSE) && GINPUT_NEED_MOUSE #if GFX_USE_GINPUT && GINPUT_NEED_MOUSE
case GEVENT_MOUSE: case GEVENT_MOUSE:
case GEVENT_TOUCH: case GEVENT_TOUCH:
// Ignore anything other than the primary mouse button going up or down // Ignore anything other than the primary mouse button going up or down
@ -108,7 +108,7 @@ static void gwinButtonCallback(void *param, GEvent *pe) {
#endif #endif
#endif #endif
#if defined(GINPUT_NEED_TOGGLE) && GINPUT_NEED_TOGGLE #if GFX_USE_GINPUT && GINPUT_NEED_TOGGLE
case GEVENT_TOGGLE: case GEVENT_TOGGLE:
// State has changed - update the button // State has changed - update the button
gbw->state = pxe->on ? GBTN_DOWN : GBTN_UP; gbw->state = pxe->on ? GBTN_DOWN : GBTN_UP;
@ -375,18 +375,22 @@ void gwinButtonDraw_Square(GHandle gh, bool_t isdown, const char *txt, const GBu
} }
#endif #endif
#if defined(GINPUT_NEED_MOUSE) && GINPUT_NEED_MOUSE #if GFX_USE_GINPUT && GINPUT_NEED_MOUSE
bool_t gwinAttachButtonMouseSource(GHandle gh, GSourceHandle gsh) { bool_t gwinAttachButtonMouse(GHandle gh, uint16_t instance) {
if (gh->type != GW_BUTTON) GSourceHandle gsh;
if (gh->type != GW_BUTTON || !(gsh = ginputGetMouse(instance)))
return FALSE; return FALSE;
return geventAttachSource(&((GButtonObject *)gh)->listener, gsh, GLISTEN_MOUSEMETA); return geventAttachSource(&((GButtonObject *)gh)->listener, gsh, GLISTEN_MOUSEMETA);
} }
#endif #endif
#if defined(GINPUT_NEED_TOGGLE) && GINPUT_NEED_TOGGLE #if GFX_USE_GINPUT && GINPUT_NEED_TOGGLE
bool_t gwinAttachButtonToggleSource(GHandle gh, GSourceHandle gsh) { bool_t gwinAttachButtonToggle(GHandle gh, uint16_t instance) {
if (gh->type != GW_BUTTON) GSourceHandle gsh;
if (gh->type != GW_BUTTON || !(gsh = ginputGetToggle(instance)))
return FALSE; return FALSE;
return geventAttachSource(&((GButtonObject *)gh)->listener, gsh, GLISTEN_TOGGLE_OFF|GLISTEN_TOGGLE_ON); return geventAttachSource(&((GButtonObject *)gh)->listener, gsh, GLISTEN_TOGGLE_OFF|GLISTEN_TOGGLE_ON);

View File

@ -39,7 +39,9 @@
#define GWIN_SLIDER_DEAD_BAND 5 #define GWIN_SLIDER_DEAD_BAND 5
#endif #endif
static void trackSliderDraw(GHandle gh, coord_t x, coord_t y); #if GFX_USE_GINPUT && GINPUT_NEED_MOUSE
static void trackSliderDraw(GHandle gh, coord_t x, coord_t y);
#endif
static const GSliderDrawStyle GSliderDefaultStyle = { static const GSliderDrawStyle GSliderDefaultStyle = {
HTML2COLOR(0x404040), // color_edge; HTML2COLOR(0x404040), // color_edge;
@ -55,10 +57,11 @@ static void gwinSliderCallback(void *param, GEvent *pe) {
#define gsw ((GSliderObject *)param) #define gsw ((GSliderObject *)param)
#define gsh ((GSourceHandle)param) #define gsh ((GSourceHandle)param)
#define pme ((GEventMouse *)pe) #define pme ((GEventMouse *)pe)
#define pde ((GEventDial *)pe)
#define pse ((GEventGWinSlider *)pe) #define pse ((GEventGWinSlider *)pe)
switch (pe->type) { switch (pe->type) {
#if defined(GINPUT_NEED_MOUSE) && GINPUT_NEED_MOUSE #if GFX_USE_GINPUT && GINPUT_NEED_MOUSE
case GEVENT_MOUSE: case GEVENT_MOUSE:
case GEVENT_TOUCH: case GEVENT_TOUCH:
// If not tracking we only only interested in a mouse down over the slider // If not tracking we only only interested in a mouse down over the slider
@ -91,10 +94,10 @@ static void gwinSliderCallback(void *param, GEvent *pe) {
// Set the new position // Set the new position
if (gh->width < gh->height) if (gh->width < gh->height)
gwinSetSliderPosition(gh, gwinSetSliderPosition(gh,
(gh->height-1-pme->y+gh->y-GWIN_SLIDER_DEAD_BAND)*(gsw->max-gsw->min)/(gh->height-2*GWIN_SLIDER_DEAD_BAND) + gsw->min); (uint16_t)((uint32_t)(gh->height-1-pme->y+gh->y-GWIN_SLIDER_DEAD_BAND)*(gsw->max-gsw->min)/(gh->height-2*GWIN_SLIDER_DEAD_BAND) + gsw->min));
else else
gwinSetSliderPosition(gh, gwinSetSliderPosition(gh,
(pme->x-gh->x-GWIN_SLIDER_DEAD_BAND)*(gsw->max-gsw->min)/(gh->width-2*GWIN_SLIDER_DEAD_BAND) + gsw->min); (uint16_t)((uint32_t)(pme->x-gh->x-GWIN_SLIDER_DEAD_BAND)*(gsw->max-gsw->min)/(gh->width-2*GWIN_SLIDER_DEAD_BAND) + gsw->min));
// Update the display // Update the display
gwinSliderDraw(gh); gwinSliderDraw(gh);
@ -109,6 +112,17 @@ static void gwinSliderCallback(void *param, GEvent *pe) {
return; return;
#endif #endif
#if GFX_USE_GINPUT && GINPUT_NEED_DIAL
case GEVENT_DIAL:
// Set the new position
gwinSetSliderPosition(gh, (uint16_t)((uint32_t)pde->value*(gsw->max-gsw->min)/ginputGetDialRange(pde->instance) + gsw->min));
// Update the display
gwinSliderDraw(gh);
// Generate the event
break;
#endif
default: default:
return; return;
@ -194,20 +208,22 @@ void gwinSetSliderStyle(GHandle gh, const GSliderDrawStyle *pStyle) {
#undef gsw #undef gsw
} }
static void trackSliderDraw(GHandle gh, coord_t x, coord_t y) { #if GFX_USE_GINPUT && GINPUT_NEED_MOUSE
#define gsw ((GSliderObject *)gh) static void trackSliderDraw(GHandle gh, coord_t x, coord_t y) {
#define gsw ((GSliderObject *)gh)
#if GDISP_NEED_CLIP #if GDISP_NEED_CLIP
gdispSetClip(gh->x, gh->y, gh->width, gh->height); gdispSetClip(gh->x, gh->y, gh->width, gh->height);
#endif #endif
if (gh->height <= gh->width)
gsw->fn(gh, FALSE, x, &gsw->style, gsw->param);
else
gsw->fn(gh, TRUE, y, &gsw->style, gsw->param);
if (gh->height <= gh->width) #undef gbw
gsw->fn(gh, FALSE, x, &gsw->style, gsw->param); }
else #endif
gsw->fn(gh, TRUE, y, &gsw->style, gsw->param);
#undef gbw
}
void gwinSliderDraw(GHandle gh) { void gwinSliderDraw(GHandle gh) {
#define gsw ((GSliderObject *)gh) #define gsw ((GSliderObject *)gh)
@ -267,15 +283,28 @@ void gwinSliderDraw_Std(GHandle gh, bool_t isVertical, coord_t thumbpos, const G
} }
} }
#if defined(GINPUT_NEED_MOUSE) && GINPUT_NEED_MOUSE #if GFX_USE_GINPUT && GINPUT_NEED_MOUSE
bool_t gwinAttachSliderMouseSource(GHandle gh, GSourceHandle gsh) { bool_t gwinAttachSliderMouse(GHandle gh, uint16_t instance) {
if (gh->type != GW_SLIDER) GSourceHandle gsh;
if (gh->type != GW_SLIDER || !(gsh = ginputGetMouse(instance)))
return FALSE; return FALSE;
return geventAttachSource(&((GSliderObject *)gh)->listener, gsh, GLISTEN_MOUSEMETA|GLISTEN_MOUSEDOWNMOVES); return geventAttachSource(&((GSliderObject *)gh)->listener, gsh, GLISTEN_MOUSEMETA|GLISTEN_MOUSEDOWNMOVES);
} }
#endif #endif
#if GFX_USE_GINPUT && GINPUT_NEED_DIAL
bool_t gwinAttachSliderDial(GHandle gh, uint16_t instance) {
GSourceHandle gsh;
if (gh->type != GW_SLIDER || !(gsh = ginputGetDial(instance)))
return FALSE;
return geventAttachSource(&((GSliderObject *)gh)->listener, gsh, 0);
}
#endif
#endif /* GFX_USE_GWIN && GWIN_NEED_BUTTON */ #endif /* GFX_USE_GWIN && GWIN_NEED_BUTTON */
/** @} */ /** @} */