diff --git a/xwords4/common/board.c b/xwords4/common/board.c index 511ef33ab..bfa46c2ce 100644 --- a/xwords4/common/board.c +++ b/xwords4/common/board.c @@ -3109,8 +3109,9 @@ moveKeyTileToBoard( BoardCtxt* board, XP_Key cursorKey, XP_Bool* gotArrow ) /* keep compiler happy: assign defaults */ Tile tile, blankFace = EMPTY_TILE; /* make compiler happy */ XP_U16 col, row; - DictionaryCtxt* dict = model_getDictionary( board->model ); - XP_S16 turn = board->selPlayer; + ModelCtxt* model = board->model; + DictionaryCtxt* dict = model_getDictionary( model ); + const XP_S16 turn = board->selPlayer; XP_S16 tileIndex; XP_UCHAR buf[2]; XP_Bool success; @@ -3139,12 +3140,12 @@ moveKeyTileToBoard( BoardCtxt* board, XP_Key cursorKey, XP_Bool* gotArrow ) } if ( success ) { - tileIndex = model_trayContains( board->model, turn, tile ); + tileIndex = model_trayContains( model, turn, tile ); if ( tileIndex >= 0 ) { // blankFace = EMPTY_TILE; /* already set (and will be ignored) */ } else { Tile blankTile = dict_getBlankTile( dict ); - tileIndex = model_trayContains( board->model, turn, blankTile ); + tileIndex = model_trayContains( model, turn, blankTile ); if ( tileIndex >= 0 ) { /* there's a blank for it */ blankFace = tile; } else { @@ -3153,6 +3154,18 @@ moveKeyTileToBoard( BoardCtxt* board, XP_Key cursorKey, XP_Bool* gotArrow ) } } +#ifdef NUMBER_KEY_AS_INDEX + /* Map numbers 1-7 to tiles in tray. This is a hack to workaround + temporary lack of key input on smartphone. */ + if ( !success ) { + tileIndex = cursorKey - '0' - 1; /* user's model is 1-based, ours is 0-based */ + if ( (tileIndex >= 0) && + (tileIndex < model_getNumTilesInTray( model, turn ) ) ) { + success = XP_TRUE; + } + } +#endif + if ( success ) { success = moveTileToBoard( board, col, row, tileIndex, blankFace ); } diff --git a/xwords4/linux/Makefile b/xwords4/linux/Makefile index 6f6955532..b6faefb12 100644 --- a/xwords4/linux/Makefile +++ b/xwords4/linux/Makefile @@ -17,7 +17,7 @@ # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ifeq ($(MEMDEBUG),TRUE) -DEFINES = -DMEM_DEBUG -DDEBUG -DENABLE_LOGGING +DEFINES = -DMEM_DEBUG -DDEBUG -DENABLE_LOGGING -DNUMBER_KEY_AS_INDEX CFLAGS += -g $(GPROFFLAG) -Wall -Wunused-parameter -Wcast-align -Werror CFLAGS += -DDEBUG_TS PLATFORM = obj_linux_memdbg diff --git a/xwords4/linux/gtkmain.c b/xwords4/linux/gtkmain.c index d1cb32afb..9dc824f54 100644 --- a/xwords4/linux/gtkmain.c +++ b/xwords4/linux/gtkmain.c @@ -212,6 +212,11 @@ evtToXPKey( GdkEventKey* event, XP_Bool* movesCursorP ) if ( isalpha( keyval ) ) { xpkey = toupper(keyval); break; +#ifdef NUMBER_KEY_AS_INDEX + } else if ( isdigit( keyval ) ) { + xpkey = keyval; + break; +#endif } } *movesCursorP = movesCursor; diff --git a/xwords4/wince/Makefile b/xwords4/wince/Makefile index 95fd8d677..cfff4d1d3 100644 --- a/xwords4/wince/Makefile +++ b/xwords4/wince/Makefile @@ -97,6 +97,9 @@ CFLAGS += -DDICTS_MOVED_ALERT CFLAGS += -DKEYBOARD_NAV CFLAGS += -DPERIMETER_FOCUS +# Hack until figure out how to turn off IME (12-key-to-text) on CE. +CFLAGS += -DNUMBER_KEY_AS_INDEX + # This is normally part of MEM_DEBUG, but sometimes we want logging in # a release build, e.g. to figure out why opening a saved game isn't # working. So normally it's commented out here. diff --git a/xwords4/wince/cemain.c b/xwords4/wince/cemain.c index ca1ecd670..732a9f0d2 100755 --- a/xwords4/wince/cemain.c +++ b/xwords4/wince/cemain.c @@ -29,6 +29,7 @@ #ifdef _WIN32_WCE # include #endif +/* #include */ #include "strutils.h" #include "memstream.h" @@ -2240,6 +2241,39 @@ WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) } break; +#ifdef _WIN32_WCE +/* case WM_SETFOCUS: */ +/* hC = ImmGetContext( hWnd ); */ +/* globals->imeWasOpen = ImmGetOpenStatus( hC ); */ +/* ImmSetOpenStatus( hC, TRUE ); */ +/* ImmEscape( NULL, hC, IME_ESC_SET_MODE, (LPVOID)IM_SPELL ); */ +/* break; */ +/* case WM_KILLFOCUS: */ +/* ImmSetOpenStatus( hC, globals->imeWasOpen ); */ +/* break; */ + + /* The code above this point works to turn 12-key->text + translation on, but not to turn it off, so other apps wind up + with it on after Crosswords quits. The recommended code is + below, but includes constants on in the version of cegcc I'm + using. Need to look into upgrading, but that requires a lot + of changes. Post B2.... */ + +/* DWORD dwRes = SendMessage((HWND)wParam, WM_IME_REQUEST, IMR_ISIMEAWARE, 0); */ +/* hC = ImmGetContext( hWnd ); */ +/* if ( (dwRes & IMEAF_AWARE) == IMEAF_AWARE ) { */ +/* ImmEscape( NULL, hC, IME_ESC_RETAIN_MODE_ICON, (LPVOID)TRUE); */ +/* } */ +/* ImmSetOpenStatus( hC, FALSE); */ +/* } */ +/* break; */ +/* case WM_IME_REQUEST: */ +/* if ( wParam == IMR_ISIMEAWARE ) { */ +/* return IMEAF_AWARE; */ +/* } */ +/* break; */ +#endif + case WM_DESTROY: #ifdef _WIN32_WCE CommandBar_Destroy(globals->hwndCB); /* supposedly not needed */ diff --git a/xwords4/wince/debhacks.h b/xwords4/wince/debhacks.h index a41454ee2..1e9327252 100644 --- a/xwords4/wince/debhacks.h +++ b/xwords4/wince/debhacks.h @@ -67,4 +67,21 @@ BOOL DH(ResetEvent)(HANDLE); #endif /* USE_RAW_MINGW */ +#if 0 + /* http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1591512&SiteID=1 */ +#define IM_SPELL 0 +#define IME_ESC_SET_MODE 0x0800 +/* http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1476620&SiteID=1 */ +#define EIM_SPELL IM_SPELL +/* http://wolfpack.twu.net/docs/gtkwin32/gdkprivate-win32.h */ +#define WM_IME_REQUEST 0x0288 + +/* http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1476620&SiteID=1 */ +#define EM_SETINPUTMODE 0x00DE + +/* #define IMR_ISIMEAWARE 0 */ +/* #define IMEAF_AWARE 0 */ +/* #define IME_ESC_RETAIN_MODE_ICON 0 */ +#endif + #endif