Toggle fixes.

remotes/origin_old/ugfx_release_2.6
inmarket 2015-02-14 09:16:28 +10:00
parent e14fb8cfa0
commit 7c7459f1d2
3 changed files with 27 additions and 14 deletions

View File

@ -80,6 +80,9 @@
#if GINPUT_NEED_TOGGLE #if GINPUT_NEED_TOGGLE
/* Include toggle support code */ /* Include toggle support code */
#include "src/ginput/ginput_driver_toggle.h" #include "src/ginput/ginput_driver_toggle.h"
// Hack until toggle use gdriver.
static GDisplay *toggleWindow;
#endif #endif
#if GINPUT_NEED_MOUSE #if GINPUT_NEED_MOUSE
@ -649,13 +652,13 @@ static LRESULT myWindowProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
// Paint the toggle area // Paint the toggle area
#if GINPUT_NEED_TOGGLE #if GINPUT_NEED_TOGGLE
if (ps.rcPaint.bottom >= GDISP_SCREEN_HEIGHT && (g->flags & GDISP_FLG_HASTOGGLE)) { if (ps.rcPaint.bottom >= GDISP_SCREEN_HEIGHT && (g->flags & GDISP_FLG_HASTOGGLE)) {
pen = CreatePen(PS_SOLID, 1, gdispColor2Native(Black)); pen = CreatePen(PS_SOLID, 1, RGB(0, 0, 0));
hbrOn = CreateSolidBrush(gdispColor2Native(Blue)); hbrOn = CreateSolidBrush(RGB(0, 0, 255));
hbrOff = CreateSolidBrush(gdispColor2Native(Gray)); hbrOff = CreateSolidBrush(RGB(128, 128, 128));
old = SelectObject(dc, pen); old = SelectObject(dc, pen);
MoveToEx(dc, 0, GDISP_SCREEN_HEIGHT, &p); MoveToEx(dc, 0, GDISP_SCREEN_HEIGHT, &p);
LineTo(dc, GDISP_SCREEN_WIDTH, GDISP_SCREEN_HEIGHT); LineTo(dc, GDISP_SCREEN_WIDTH, GDISP_SCREEN_HEIGHT);
for(pos = 0, bit=1; pos < wWidth; pos=rect.right, bit <<= 1) { for(pos = 0, bit=1; pos < GDISP_SCREEN_WIDTH; pos=rect.right, bit <<= 1) {
rect.left = pos; rect.left = pos;
rect.right = pos + GDISP_SCREEN_WIDTH/8; rect.right = pos + GDISP_SCREEN_WIDTH/8;
rect.top = GDISP_SCREEN_HEIGHT; rect.top = GDISP_SCREEN_HEIGHT;
@ -804,8 +807,10 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) {
// Turn on toggles for the first GINPUT_TOGGLE_CONFIG_ENTRIES windows // Turn on toggles for the first GINPUT_TOGGLE_CONFIG_ENTRIES windows
#if GINPUT_NEED_TOGGLE #if GINPUT_NEED_TOGGLE
if (g->controllerdisplay < GINPUT_TOGGLE_CONFIG_ENTRIES) if (g->controllerdisplay < GINPUT_TOGGLE_CONFIG_ENTRIES) {
g->flags |= GDISP_FLG_HASTOGGLE; g->flags |= GDISP_FLG_HASTOGGLE;
toggleWindow = g;
}
#endif #endif
// Create a private area for this window // Create a private area for this window
@ -1571,25 +1576,32 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) {
#endif #endif
#if GINPUT_NEED_TOGGLE #if GINPUT_NEED_TOGGLE
#if GINPUT_TOGGLE_CONFIG_ENTRIES > GDISP_DRIVER_COUNT_WIN32 #if GINPUT_TOGGLE_CONFIG_ENTRIES > 1
#error "GDISP Win32: GINPUT_TOGGLE_CONFIG_ENTRIES must not be greater than GDISP_DRIVER_COUNT_WIN32" #error "GDISP Win32: GINPUT_TOGGLE_CONFIG_ENTRIES must be 1 until Toggles can use GDriver"
#endif #endif
GToggleConfig GInputToggleConfigTable[GINPUT_TOGGLE_CONFIG_ENTRIES]; const GToggleConfig GInputToggleConfigTable[GINPUT_TOGGLE_CONFIG_ENTRIES];
void ginput_lld_toggle_init(const GToggleConfig *ptc) { void ginput_lld_toggle_init(const GToggleConfig *ptc) {
// Save the associated window struct // Save the associated window struct
ptc->id = &GDISP_WIN32[ptc - GInputToggleConfigTable]; //ptc->id = &GDISP_WIN32[ptc - GInputToggleConfigTable];
((GToggleConfig *)ptc)->id = 0;
// We have 8 buttons per window. // We have 8 buttons per window.
ptc->mask = 0xFF; ((GToggleConfig *)ptc)->mask = 0xFF;
// No inverse or special mode // No inverse or special mode
ptc->invert = 0x00; ((GToggleConfig *)ptc)->invert = 0x00;
ptc->mode = 0; ((GToggleConfig *)ptc)->mode = 0;
} }
unsigned ginput_lld_toggle_getbits(const GToggleConfig *ptc) { unsigned ginput_lld_toggle_getbits(const GToggleConfig *ptc) {
return ((GDisplay *)(ptc->id))->priv->toggles; (void) ptc;
// This should use ID
if (!toggleWindow)
return 0;
return ((winPriv *)toggleWindow->priv)->toggles;
//return ((winPriv *)((GDisplay *)(ptc->id))->priv)->toggles;
} }
#endif /* GINPUT_NEED_TOGGLE */ #endif /* GINPUT_NEED_TOGGLE */

View File

@ -14,6 +14,7 @@
// This driver is unique in that it can support 8 buttons per window across multiple windows. // This driver is unique in that it can support 8 buttons per window across multiple windows.
// GINPUT_TOGGLE_CONFIG_ENTRIES just must be less than the number of GDISP windows (GDISP_DRIVER_COUNT_WIN32). // GINPUT_TOGGLE_CONFIG_ENTRIES just must be less than the number of GDISP windows (GDISP_DRIVER_COUNT_WIN32).
// DEPRECATED: Currently only supports a single window with buttons until toggles use GDriver
#ifndef GINPUT_TOGGLE_CONFIG_ENTRIES #ifndef GINPUT_TOGGLE_CONFIG_ENTRIES
#define GINPUT_TOGGLE_CONFIG_ENTRIES 1 // The total number of GToggleConfig entries #define GINPUT_TOGGLE_CONFIG_ENTRIES 1 // The total number of GToggleConfig entries
#endif #endif

View File

@ -229,7 +229,7 @@ static void gwinListDefaultDraw(GWidgetObject* gw, void* param);
qix = 0; qix = 0;
for (i = 0; qi; qix = qi, qi = gfxQueueASyncNext(qi), i++) { for (i = 0; qi; qix = qi, qi = gfxQueueASyncNext(qi), i++) {
if ((qi2li->flags & GLIST_FLG_SELECTED)) if ((qi2li->flags & GLIST_FLG_SELECTED)) {
if (qix) { if (qix) {
qi2li->flags &=~ GLIST_FLG_SELECTED; qi2li->flags &=~ GLIST_FLG_SELECTED;
qix2li->flags |= GLIST_FLG_SELECTED; qix2li->flags |= GLIST_FLG_SELECTED;