mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-01 06:19:57 +01:00
Add quick hack to show BT connect state on main board, to be replace
by icons or something prettier later. For new games dialog, replace hard-coded list of controls to ignore with a runtime list. This allows checkboxes and fields to be enabled and disabled more easily. Works around Palm's lack of a control state meaning "visible but inactive" that works for all form elements.
This commit is contained in:
parent
22b9ace9da
commit
7cbc781a07
5 changed files with 258 additions and 134 deletions
|
@ -56,6 +56,11 @@ static XP_Bool considerGadgetFocus( PalmNewGameState* state, EventType* event );
|
||||||
# define tryDuoRockerKey(g,key) XP_FALSE
|
# define tryDuoRockerKey(g,key) XP_FALSE
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
static XP_Bool onDisabledList( const PalmNewGameState* state,
|
||||||
|
XP_U16 controlID );
|
||||||
|
static void modDisabledList( PalmNewGameState* state, XP_U16 controlID,
|
||||||
|
NewGameEnable enable );
|
||||||
|
|
||||||
static void palmEnableColProc( void* closure, XP_U16 player,
|
static void palmEnableColProc( void* closure, XP_U16 player,
|
||||||
NewGameColumn col, NewGameEnable enable );
|
NewGameColumn col, NewGameEnable enable );
|
||||||
static void palmEnableAttrProc( void* closure, NewGameAttr attr,
|
static void palmEnableAttrProc( void* closure, NewGameAttr attr,
|
||||||
|
@ -127,6 +132,9 @@ newGameHandleEvent( EventPtr event )
|
||||||
XW_SOLO_GADGET_ID );
|
XW_SOLO_GADGET_ID );
|
||||||
#endif
|
#endif
|
||||||
loadNewGameState( globals );
|
loadNewGameState( globals );
|
||||||
|
if ( !globals->isNewGame ) {
|
||||||
|
modDisabledList( state, XW_DICT_SELECTOR_ID, NGEnableDisabled );
|
||||||
|
}
|
||||||
|
|
||||||
XP_ASSERT( !!state->dictName );
|
XP_ASSERT( !!state->dictName );
|
||||||
setNameThatFits( state );
|
setNameThatFits( state );
|
||||||
|
@ -168,21 +176,11 @@ newGameHandleEvent( EventPtr event )
|
||||||
state->forwardChange = true;
|
state->forwardChange = true;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case fldEnterEvent:
|
||||||
case ctlEnterEvent:
|
case ctlEnterEvent:
|
||||||
switch ( event->data.ctlEnter.controlID ) {
|
if ( onDisabledList( state, event->data.ctlEnter.controlID ) ) {
|
||||||
#ifndef XWFEATURE_STANDALONE_ONLY
|
result = true;
|
||||||
case XW_REMOTE_1_CHECKBOX_ID:
|
beep();
|
||||||
case XW_REMOTE_2_CHECKBOX_ID:
|
|
||||||
case XW_REMOTE_3_CHECKBOX_ID:
|
|
||||||
case XW_REMOTE_4_CHECKBOX_ID:
|
|
||||||
#endif
|
|
||||||
case XW_GINFO_JUGGLE_ID:
|
|
||||||
case XW_DICT_SELECTOR_ID:
|
|
||||||
case XW_NPLAYERS_SELECTOR_ID:
|
|
||||||
if ( !globals->isNewGame ) {
|
|
||||||
result = true;
|
|
||||||
beep();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -576,7 +574,8 @@ changeGadgetHilite( PalmAppGlobals* globals, UInt16 hiliteID )
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef BEYOND_IR
|
#ifdef BEYOND_IR
|
||||||
/* Even if it didn't change, pop the connections form */
|
/* Even if it didn't change, pop the connections form. It's only
|
||||||
|
informational in the non-new-game case; nothing can be changed. */
|
||||||
if ( hiliteID != SERVER_STANDALONE ) {
|
if ( hiliteID != SERVER_STANDALONE ) {
|
||||||
if ( isNewGame || hiliteID==globals->newGameState.curServerHilite ) {
|
if ( isNewGame || hiliteID==globals->newGameState.curServerHilite ) {
|
||||||
PopupConnsForm( globals, hiliteID, &state->addr );
|
PopupConnsForm( globals, hiliteID, &state->addr );
|
||||||
|
@ -648,6 +647,46 @@ unloadNewGameState( PalmAppGlobals* globals )
|
||||||
state->ngc = NULL;
|
state->ngc = NULL;
|
||||||
} /* unloadNewGameState */
|
} /* unloadNewGameState */
|
||||||
|
|
||||||
|
static XP_S16
|
||||||
|
findDisabled( const PalmNewGameState* state, XP_U16 controlID )
|
||||||
|
{
|
||||||
|
XP_U16 i;
|
||||||
|
XP_S16 loc = -1;
|
||||||
|
for ( i = 0; i < state->nDisabled; ++i ) {
|
||||||
|
if ( state->disabled[i] == controlID ) {
|
||||||
|
loc = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return loc;
|
||||||
|
}
|
||||||
|
|
||||||
|
static XP_Bool
|
||||||
|
onDisabledList( const PalmNewGameState* state, XP_U16 controlID )
|
||||||
|
{
|
||||||
|
return 0 <= findDisabled( state, controlID );
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
modDisabledList( PalmNewGameState* state, XP_U16 controlID,
|
||||||
|
NewGameEnable enable )
|
||||||
|
{
|
||||||
|
XP_S16 loc = findDisabled( state, controlID );
|
||||||
|
XP_Bool include = enable != NGEnableEnabled;
|
||||||
|
if ( loc < 0 && include ) {
|
||||||
|
/* not there but should be; add it */
|
||||||
|
state->disabled[state->nDisabled++] = controlID;
|
||||||
|
XP_ASSERT( state->nDisabled < MAX_DISABLED );
|
||||||
|
} else if ( loc >= 0 && !include ) {
|
||||||
|
/* is there; shouldn't be; remove it */
|
||||||
|
state->disabled[loc] = state->disabled[--state->nDisabled];
|
||||||
|
} else {
|
||||||
|
/* all's well */
|
||||||
|
XP_ASSERT( (loc >= 0 && include)
|
||||||
|
|| ( loc < 0 && !include ) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static XP_U16
|
static XP_U16
|
||||||
getBaseForCol( NewGameColumn col )
|
getBaseForCol( NewGameColumn col )
|
||||||
{
|
{
|
||||||
|
@ -696,7 +735,8 @@ palmEnableColProc( void* closure, XP_U16 player, NewGameColumn col,
|
||||||
PalmAppGlobals* globals = (PalmAppGlobals*)closure;
|
PalmAppGlobals* globals = (PalmAppGlobals*)closure;
|
||||||
PalmNewGameState* state = &globals->newGameState;
|
PalmNewGameState* state = &globals->newGameState;
|
||||||
XP_U16 objID = objIDForCol( player, col );
|
XP_U16 objID = objIDForCol( player, col );
|
||||||
disOrEnable( state->form, objID, enable == NGEnableEnabled );
|
disOrEnable( state->form, objID, enable != NGEnableHidden );
|
||||||
|
modDisabledList( state, objID, enable );
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Palm doesn't really do "disabled." Things are visible or not. But we
|
/* Palm doesn't really do "disabled." Things are visible or not. But we
|
||||||
|
@ -737,6 +777,7 @@ palmEnableAttrProc(void* closure, NewGameAttr attr, NewGameEnable ngEnable )
|
||||||
|
|
||||||
if ( objID != 0 ) {
|
if ( objID != 0 ) {
|
||||||
disOrEnable( state->form, objID, enable );
|
disOrEnable( state->form, objID, enable );
|
||||||
|
modDisabledList( state, objID, ngEnable );
|
||||||
}
|
}
|
||||||
} /* palmEnableAttrProc */
|
} /* palmEnableAttrProc */
|
||||||
|
|
||||||
|
|
261
palm/palmbt.c
261
palm/palmbt.c
|
@ -29,7 +29,7 @@
|
||||||
#define L2CAPSOCKETMTU 500
|
#define L2CAPSOCKETMTU 500
|
||||||
#define SOCK_INVAL 0XFFFF
|
#define SOCK_INVAL 0XFFFF
|
||||||
|
|
||||||
typedef enum { PBT_UNINIT = 0, PBT_MASTER, PBT_SLAVE } PBT_SetState;
|
typedef enum { PBT_UNINIT = 0, PBT_MASTER, PBT_SLAVE } PBT_PicoRole;
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
PBT_ACT_NONE
|
PBT_ACT_NONE
|
||||||
|
@ -50,7 +50,12 @@ typedef enum {
|
||||||
|
|
||||||
#define PBT_MAX_ACTS 4
|
#define PBT_MAX_ACTS 4
|
||||||
#define HASWORK(s) ((s)->queueCur != (s)->queueNext)
|
#define HASWORK(s) ((s)->queueCur != (s)->queueNext)
|
||||||
#define MAX_INCOMING 4
|
#define MAX_PACKETS 4
|
||||||
|
|
||||||
|
typedef struct PBT_queue {
|
||||||
|
XP_U16 lens[MAX_PACKETS];
|
||||||
|
XP_U8 bufs[L2CAPSOCKETMTU*2]; /* what's the mmu? */
|
||||||
|
} PBT_queue;
|
||||||
|
|
||||||
typedef struct PalmBTStuff {
|
typedef struct PalmBTStuff {
|
||||||
DataCb cb;
|
DataCb cb;
|
||||||
|
@ -59,20 +64,17 @@ typedef struct PalmBTStuff {
|
||||||
XP_U16 btLibRefNum;
|
XP_U16 btLibRefNum;
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
XP_U16 lenOut;
|
PBT_queue in;
|
||||||
XP_UCHAR bufOut[L2CAPSOCKETMTU]; /* what's the mmu? */
|
PBT_queue out;
|
||||||
XP_U16 lens[MAX_INCOMING];
|
|
||||||
XP_U8 bufIn[L2CAPSOCKETMTU*2]; /* what's the mmu? */
|
|
||||||
|
|
||||||
XP_Bool sendInProgress;
|
XP_Bool sendInProgress;
|
||||||
XP_Bool sendPending;
|
|
||||||
} vol;
|
} vol;
|
||||||
|
|
||||||
/* peer's addr: passed in by UI in case of slave, received via connection
|
/* peer's addr: passed in by UI in case of slave, received via connection
|
||||||
in case of master. Piconet master will need an array of these. */
|
in case of master. Piconet master will need an array of these. */
|
||||||
BtLibDeviceAddressType otherAddr;
|
BtLibDeviceAddressType otherAddr;
|
||||||
BtLibSocketRef dataSocket;
|
BtLibSocketRef dataSocket;
|
||||||
PBT_SetState setState;
|
PBT_PicoRole picoRole;
|
||||||
PBT_STATE p_connState;
|
PBT_STATE p_connState;
|
||||||
BtLibAccessibleModeEnum accState;
|
BtLibAccessibleModeEnum accState;
|
||||||
|
|
||||||
|
@ -122,8 +124,9 @@ static void pbt_setup_master( PalmBTStuff* btStuff );
|
||||||
static void pbt_takedown_master( PalmBTStuff* btStuff );
|
static void pbt_takedown_master( PalmBTStuff* btStuff );
|
||||||
static void pbt_do_work( PalmBTStuff* btStuff );
|
static void pbt_do_work( PalmBTStuff* btStuff );
|
||||||
static void pbt_postpone( PalmBTStuff* btStuff, PBT_ACTION act );
|
static void pbt_postpone( PalmBTStuff* btStuff, PBT_ACTION act );
|
||||||
static void pbt_enqueIncoming( PalmBTStuff* btStuff, XP_U8* data, XP_U16 len );
|
static XP_S16 pbt_enque( PBT_queue* queue, const XP_U8* data, XP_S16 len );
|
||||||
static void pbt_processIncoming( PalmBTStuff* btStuff );
|
static void pbt_processIncoming( PalmBTStuff* btStuff );
|
||||||
|
|
||||||
static void pbt_reset( PalmBTStuff* btStuff );
|
static void pbt_reset( PalmBTStuff* btStuff );
|
||||||
static void pbt_killL2C( PalmBTStuff* btStuff, BtLibSocketRef sock );
|
static void pbt_killL2C( PalmBTStuff* btStuff, BtLibSocketRef sock );
|
||||||
static void pbt_checkAddress( PalmBTStuff* btStuff, const CommsAddrRec* addr );
|
static void pbt_checkAddress( PalmBTStuff* btStuff, const CommsAddrRec* addr );
|
||||||
|
@ -179,9 +182,9 @@ palm_bt_close( PalmAppGlobals* globals )
|
||||||
if ( btLibRefNum != 0 ) {
|
if ( btLibRefNum != 0 ) {
|
||||||
Err err;
|
Err err;
|
||||||
|
|
||||||
if ( btStuff->setState == PBT_MASTER ) {
|
if ( btStuff->picoRole == PBT_MASTER ) {
|
||||||
pbt_takedown_master( btStuff );
|
pbt_takedown_master( btStuff );
|
||||||
} else if ( btStuff->setState == PBT_SLAVE ) {
|
} else if ( btStuff->picoRole == PBT_SLAVE ) {
|
||||||
pbt_takedown_slave( btStuff );
|
pbt_takedown_slave( btStuff );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -208,7 +211,7 @@ palm_bt_amendWaitTicks( PalmAppGlobals* globals, Int32* result )
|
||||||
}
|
}
|
||||||
|
|
||||||
XP_Bool
|
XP_Bool
|
||||||
palm_bt_doWork( PalmAppGlobals* globals )
|
palm_bt_doWork( PalmAppGlobals* globals, BtUIState* btUIStateP )
|
||||||
{
|
{
|
||||||
PalmBTStuff* btStuff = globals->btStuff;
|
PalmBTStuff* btStuff = globals->btStuff;
|
||||||
XP_Bool haveWork = !!btStuff && HASWORK(btStuff);
|
XP_Bool haveWork = !!btStuff && HASWORK(btStuff);
|
||||||
|
@ -216,8 +219,28 @@ palm_bt_doWork( PalmAppGlobals* globals )
|
||||||
if ( haveWork ) {
|
if ( haveWork ) {
|
||||||
pbt_do_work( btStuff );
|
pbt_do_work( btStuff );
|
||||||
}
|
}
|
||||||
|
if ( !!btStuff && !!btUIStateP ) {
|
||||||
|
BtUIState btUIState = BTUI_NONE; /* default */
|
||||||
|
switch( GET_STATE(btStuff) ) {
|
||||||
|
case PBTST_NONE:
|
||||||
|
break;
|
||||||
|
case PBTST_LISTENING:
|
||||||
|
btUIState = BTUI_LISTENING;
|
||||||
|
break;
|
||||||
|
case PBTST_ACL_CONNECTING:
|
||||||
|
case PBTST_ACL_CONNECTED:
|
||||||
|
case PBTST_L2C_CONNECTING:
|
||||||
|
btUIState = BTUI_CONNECTING;
|
||||||
|
break;
|
||||||
|
case PBTST_L2C_CONNECTED:
|
||||||
|
btUIState = btStuff->picoRole == PBT_MASTER?
|
||||||
|
BTUI_SERVING : BTUI_CONNECTED;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
*btUIStateP = btUIState;
|
||||||
|
}
|
||||||
return haveWork;
|
return haveWork;
|
||||||
}
|
} /* palm_bt_doWork */
|
||||||
|
|
||||||
void
|
void
|
||||||
palm_bt_addrString( PalmAppGlobals* globals, XP_BtAddr* btAddr,
|
palm_bt_addrString( PalmAppGlobals* globals, XP_BtAddr* btAddr,
|
||||||
|
@ -285,7 +308,8 @@ palm_bt_getStats( PalmAppGlobals* globals, XWStreamCtxt* stream )
|
||||||
XP_U16 cur;
|
XP_U16 cur;
|
||||||
|
|
||||||
XP_SNPRINTF( buf, sizeof(buf), "Role: %s\n",
|
XP_SNPRINTF( buf, sizeof(buf), "Role: %s\n",
|
||||||
btStuff->setState == PBT_MASTER? "master":"slave" );
|
btStuff->picoRole == PBT_MASTER? "master":
|
||||||
|
(btStuff->picoRole == PBT_SLAVE? "slave":"unknown") );
|
||||||
stream_putString( stream, buf );
|
stream_putString( stream, buf );
|
||||||
XP_SNPRINTF( buf, sizeof(buf), "State: %s\n",
|
XP_SNPRINTF( buf, sizeof(buf), "State: %s\n",
|
||||||
stateToStr( GET_STATE(btStuff)) );
|
stateToStr( GET_STATE(btStuff)) );
|
||||||
|
@ -312,29 +336,44 @@ palm_bt_getStats( PalmAppGlobals* globals, XWStreamCtxt* stream )
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
static XP_U16
|
||||||
|
pbt_peekQueue( const PBT_queue* queue, const XP_U8** bufp )
|
||||||
|
{
|
||||||
|
XP_U16 len = queue->lens[0];
|
||||||
|
if ( len > 0 ) {
|
||||||
|
*bufp = &queue->bufs[0];
|
||||||
|
}
|
||||||
|
return len;
|
||||||
|
}
|
||||||
|
|
||||||
|
static XP_U16
|
||||||
|
pbt_shiftQueue( PBT_queue* queue )
|
||||||
|
{
|
||||||
|
XP_U16 len = queue->lens[0];
|
||||||
|
XP_ASSERT( len != 0 );
|
||||||
|
XP_MEMCPY( &queue->lens[0], &queue->lens[1],
|
||||||
|
sizeof(queue->lens) - sizeof(queue->lens[0]) );
|
||||||
|
queue->lens[MAX_PACKETS-1] = 0; /* be safe */
|
||||||
|
XP_MEMCPY( queue->bufs, queue->bufs + len,
|
||||||
|
sizeof(queue->bufs) - len );
|
||||||
|
return len;
|
||||||
|
} /* pbt_shiftQueue */
|
||||||
|
|
||||||
static void
|
static void
|
||||||
pbt_send_pending( PalmBTStuff* btStuff, const CommsAddrRec* addr )
|
pbt_send_pending( PalmBTStuff* btStuff )
|
||||||
{
|
{
|
||||||
Err err;
|
Err err;
|
||||||
LOG_FUNC();
|
LOG_FUNC();
|
||||||
if ( btStuff->vol.sendPending && !btStuff->vol.sendInProgress ) {
|
|
||||||
if ( btStuff->dataSocket != SOCK_INVAL ) {
|
if ( !btStuff->vol.sendInProgress ) {
|
||||||
/* hack: zero-len send to cause connect */
|
const XP_U8* buf;
|
||||||
if ( btStuff->vol.lenOut > 0 ) {
|
XP_U16 len = pbt_peekQueue( &btStuff->vol.out, &buf );
|
||||||
CALL_ERR( err, BtLibSocketSend, btStuff->btLibRefNum,
|
|
||||||
btStuff->dataSocket,
|
if ( len > 0 ) {
|
||||||
btStuff->vol.bufOut, btStuff->vol.lenOut );
|
CALL_ERR( err, BtLibSocketSend, btStuff->btLibRefNum,
|
||||||
if ( err == errNone ) {
|
btStuff->dataSocket, (char*)buf, len );
|
||||||
// clear on receipt of btLibSocketEventSendComplete
|
if ( btLibErrPending == err ) {
|
||||||
btStuff->vol.sendInProgress = XP_TRUE;
|
btStuff->vol.sendInProgress = XP_TRUE;
|
||||||
}
|
|
||||||
} else {
|
|
||||||
btStuff->vol.sendPending = XP_FALSE;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
/* No data socket? */
|
|
||||||
if ( btStuff->setState == PBT_SLAVE ) {
|
|
||||||
pbt_setup_slave( btStuff, addr );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -347,7 +386,7 @@ palm_bt_send( const XP_U8* buf, XP_U16 len, const CommsAddrRec* addr,
|
||||||
XP_S16 nSent = -1;
|
XP_S16 nSent = -1;
|
||||||
PalmBTStuff* btStuff;
|
PalmBTStuff* btStuff;
|
||||||
CommsAddrRec remoteAddr;
|
CommsAddrRec remoteAddr;
|
||||||
PBT_SetState setState;
|
PBT_PicoRole picoRole;
|
||||||
XP_LOGF( "%s(len=%d)", __FUNCTION__, len );
|
XP_LOGF( "%s(len=%d)", __FUNCTION__, len );
|
||||||
|
|
||||||
btStuff = pbt_checkInit( globals );
|
btStuff = pbt_checkInit( globals );
|
||||||
|
@ -363,34 +402,23 @@ palm_bt_send( const XP_U8* buf, XP_U16 len, const CommsAddrRec* addr,
|
||||||
}
|
}
|
||||||
XP_ASSERT( !!addr );
|
XP_ASSERT( !!addr );
|
||||||
|
|
||||||
setState = btStuff->setState;
|
picoRole = btStuff->picoRole;
|
||||||
if ( setState == PBT_UNINIT ) {
|
if ( picoRole == PBT_UNINIT ) {
|
||||||
XP_Bool amMaster = comms_getIsServer( globals->game.comms );
|
XP_Bool amMaster = comms_getIsServer( globals->game.comms );
|
||||||
setState = amMaster? PBT_MASTER : PBT_SLAVE;
|
picoRole = amMaster? PBT_MASTER : PBT_SLAVE;
|
||||||
}
|
}
|
||||||
|
|
||||||
pbt_checkAddress( btStuff, addr );
|
pbt_checkAddress( btStuff, addr );
|
||||||
|
|
||||||
if ( !!btStuff ) {
|
if ( !!btStuff ) {
|
||||||
if ( setState == PBT_MASTER ) {
|
if ( picoRole == PBT_MASTER ) {
|
||||||
pbt_setup_master( btStuff );
|
pbt_setup_master( btStuff );
|
||||||
} else {
|
} else {
|
||||||
pbt_setup_slave( btStuff, addr );
|
pbt_setup_slave( btStuff, addr );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !btStuff->vol.sendInProgress ) {
|
nSent = pbt_enque( &btStuff->vol.out, buf, len );
|
||||||
if ( len > sizeof( btStuff->vol.bufOut ) ) {
|
pbt_send_pending( btStuff );
|
||||||
len = sizeof( btStuff->vol.bufOut );
|
|
||||||
}
|
|
||||||
XP_MEMCPY( btStuff->vol.bufOut, buf, len );
|
|
||||||
btStuff->vol.lenOut = len;
|
|
||||||
btStuff->vol.sendPending = XP_TRUE;
|
|
||||||
|
|
||||||
pbt_send_pending( btStuff, addr );
|
|
||||||
nSent = len;
|
|
||||||
} else {
|
|
||||||
XP_LOGF( "%s: send ALREADY in progress", __FUNCTION__ );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
LOG_RETURNF( "%d", nSent );
|
LOG_RETURNF( "%d", nSent );
|
||||||
return nSent;
|
return nSent;
|
||||||
|
@ -399,10 +427,10 @@ palm_bt_send( const XP_U8* buf, XP_U16 len, const CommsAddrRec* addr,
|
||||||
static void
|
static void
|
||||||
pbt_setup_master( PalmBTStuff* btStuff )
|
pbt_setup_master( PalmBTStuff* btStuff )
|
||||||
{
|
{
|
||||||
if ( btStuff->setState == PBT_SLAVE ) {
|
if ( btStuff->picoRole == PBT_SLAVE ) {
|
||||||
pbt_takedown_slave( btStuff );
|
pbt_takedown_slave( btStuff );
|
||||||
}
|
}
|
||||||
btStuff->setState = PBT_MASTER;
|
btStuff->picoRole = PBT_MASTER;
|
||||||
|
|
||||||
if ( btStuff->u.master.listenSocket == SOCK_INVAL ) {
|
if ( btStuff->u.master.listenSocket == SOCK_INVAL ) {
|
||||||
/* Will eventually want to create a piconet here for more than two
|
/* Will eventually want to create a piconet here for more than two
|
||||||
|
@ -433,6 +461,17 @@ pbt_setup_master( PalmBTStuff* btStuff )
|
||||||
}
|
}
|
||||||
} /* pbt_setup_master */
|
} /* pbt_setup_master */
|
||||||
|
|
||||||
|
static void
|
||||||
|
pbt_close_datasocket( PalmBTStuff* btStuff )
|
||||||
|
{
|
||||||
|
if ( SOCK_INVAL != btStuff->dataSocket ) {
|
||||||
|
Err err;
|
||||||
|
CALL_ERR( err, BtLibSocketClose, btStuff->btLibRefNum,
|
||||||
|
btStuff->dataSocket );
|
||||||
|
btStuff->dataSocket = SOCK_INVAL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
pbt_takedown_master( PalmBTStuff* btStuff )
|
pbt_takedown_master( PalmBTStuff* btStuff )
|
||||||
{
|
{
|
||||||
|
@ -441,13 +480,10 @@ pbt_takedown_master( PalmBTStuff* btStuff )
|
||||||
|
|
||||||
LOG_FUNC();
|
LOG_FUNC();
|
||||||
|
|
||||||
XP_ASSERT( btStuff->setState == PBT_MASTER );
|
XP_ASSERT( btStuff->picoRole == PBT_MASTER );
|
||||||
btLibRefNum = btStuff->btLibRefNum;
|
btLibRefNum = btStuff->btLibRefNum;
|
||||||
|
|
||||||
if ( SOCK_INVAL != btStuff->dataSocket ) {
|
pbt_close_datasocket( btStuff );
|
||||||
CALL_ERR( err, BtLibSocketClose, btLibRefNum,
|
|
||||||
btStuff->dataSocket );
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( SOCK_INVAL != btStuff->u.master.listenSocket ) {
|
if ( SOCK_INVAL != btStuff->u.master.listenSocket ) {
|
||||||
CALL_ERR( err, BtLibSocketClose, btLibRefNum,
|
CALL_ERR( err, BtLibSocketClose, btLibRefNum,
|
||||||
|
@ -455,7 +491,7 @@ pbt_takedown_master( PalmBTStuff* btStuff )
|
||||||
btStuff->u.master.listenSocket = SOCK_INVAL;
|
btStuff->u.master.listenSocket = SOCK_INVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
btStuff->setState = PBT_UNINIT;
|
btStuff->picoRole = PBT_UNINIT;
|
||||||
SET_STATE( btStuff, PBTST_NONE );
|
SET_STATE( btStuff, PBTST_NONE );
|
||||||
} /* pbt_takedown_master */
|
} /* pbt_takedown_master */
|
||||||
|
|
||||||
|
@ -464,6 +500,7 @@ pbt_do_work( PalmBTStuff* btStuff )
|
||||||
{
|
{
|
||||||
PBT_ACTION act;
|
PBT_ACTION act;
|
||||||
Err err;
|
Err err;
|
||||||
|
XP_U16 btLibRefNum = btStuff->btLibRefNum;
|
||||||
|
|
||||||
act = btStuff->actQueue[btStuff->queueCur++];
|
act = btStuff->actQueue[btStuff->queueCur++];
|
||||||
btStuff->queueCur %= PBT_MAX_ACTS;
|
btStuff->queueCur %= PBT_MAX_ACTS;
|
||||||
|
@ -475,7 +512,7 @@ pbt_do_work( PalmBTStuff* btStuff )
|
||||||
case PBT_ACT_CONNECT_ACL:
|
case PBT_ACT_CONNECT_ACL:
|
||||||
if ( GET_STATE(btStuff) == PBTST_NONE ) {
|
if ( GET_STATE(btStuff) == PBTST_NONE ) {
|
||||||
/* sends btLibManagementEventACLConnectOutbound */
|
/* sends btLibManagementEventACLConnectOutbound */
|
||||||
CALL_ERR( err, BtLibLinkConnect, btStuff->btLibRefNum,
|
CALL_ERR( err, BtLibLinkConnect, btLibRefNum,
|
||||||
&btStuff->otherAddr );
|
&btStuff->otherAddr );
|
||||||
if ( btLibErrPending == err ) {
|
if ( btLibErrPending == err ) {
|
||||||
SET_STATE( btStuff, PBTST_ACL_CONNECTING );
|
SET_STATE( btStuff, PBTST_ACL_CONNECTING );
|
||||||
|
@ -487,9 +524,10 @@ pbt_do_work( PalmBTStuff* btStuff )
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PBT_ACT_CONNECT_L2C:
|
case PBT_ACT_CONNECT_L2C:
|
||||||
|
XP_ASSERT( btStuff->picoRole == PBT_SLAVE );
|
||||||
if ( GET_STATE(btStuff) == PBTST_ACL_CONNECTED ) {
|
if ( GET_STATE(btStuff) == PBTST_ACL_CONNECTED ) {
|
||||||
XP_ASSERT( SOCK_INVAL == btStuff->dataSocket ); /* fired */
|
pbt_close_datasocket( btStuff );
|
||||||
CALL_ERR( err, BtLibSocketCreate, btStuff->btLibRefNum,
|
CALL_ERR( err, BtLibSocketCreate, btLibRefNum,
|
||||||
&btStuff->dataSocket,
|
&btStuff->dataSocket,
|
||||||
l2SocketCallback, (UInt32)btStuff,
|
l2SocketCallback, (UInt32)btStuff,
|
||||||
btLibL2CapProtocol );
|
btLibL2CapProtocol );
|
||||||
|
@ -502,7 +540,7 @@ pbt_do_work( PalmBTStuff* btStuff )
|
||||||
connInfo.remoteDeviceP = &btStuff->otherAddr;
|
connInfo.remoteDeviceP = &btStuff->otherAddr;
|
||||||
|
|
||||||
/* sends btLibSocketEventConnectedOutbound */
|
/* sends btLibSocketEventConnectedOutbound */
|
||||||
CALL_ERR( err, BtLibSocketConnect, btStuff->btLibRefNum,
|
CALL_ERR( err, BtLibSocketConnect, btLibRefNum,
|
||||||
btStuff->dataSocket, &connInfo );
|
btStuff->dataSocket, &connInfo );
|
||||||
if ( errNone == err ) {
|
if ( errNone == err ) {
|
||||||
SET_STATE( btStuff, PBTST_L2C_CONNECTED );
|
SET_STATE( btStuff, PBTST_L2C_CONNECTED );
|
||||||
|
@ -524,7 +562,7 @@ pbt_do_work( PalmBTStuff* btStuff )
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PBT_ACT_TRYSEND:
|
case PBT_ACT_TRYSEND:
|
||||||
pbt_send_pending( btStuff, NULL );
|
pbt_send_pending( btStuff );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
@ -546,52 +584,48 @@ pbt_postpone( PalmBTStuff* btStuff, PBT_ACTION act )
|
||||||
XP_ASSERT( btStuff->queueNext != btStuff->queueCur );
|
XP_ASSERT( btStuff->queueNext != btStuff->queueCur );
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static XP_S16
|
||||||
pbt_enqueIncoming( PalmBTStuff* btStuff, XP_U8* indata, XP_U16 inlen )
|
pbt_enque( PBT_queue* queue, const XP_U8* data, XP_S16 len )
|
||||||
{
|
{
|
||||||
XP_U16 i;
|
XP_U16 i;
|
||||||
XP_U16 total = 0;
|
XP_U16 total = 0;
|
||||||
|
|
||||||
for ( i = 0; i < MAX_INCOMING; ++i ) {
|
for ( i = 0; i < MAX_PACKETS; ++i ) {
|
||||||
XP_U16 len = btStuff->vol.lens[i];
|
XP_U16 curlen = queue->lens[i];
|
||||||
if ( !len ) {
|
if ( !curlen ) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
total += len;
|
total += curlen;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( (i < MAX_INCOMING) &&
|
if ( (i < MAX_PACKETS) && ((total + len) < sizeof(queue->bufs)) ) {
|
||||||
((total + inlen) < sizeof(btStuff->vol.bufIn)) ) {
|
queue->lens[i] = len;
|
||||||
btStuff->vol.lens[i] = inlen;
|
XP_MEMCPY( &queue->bufs[total], data, len );
|
||||||
XP_MEMCPY( &btStuff->vol.bufIn[total], indata, inlen );
|
|
||||||
pbt_postpone( btStuff, PBT_ACT_GOTDATA );
|
|
||||||
#ifdef DEBUG
|
|
||||||
btStuff->stats.totalRcvd += inlen;
|
|
||||||
#endif
|
|
||||||
} else {
|
} else {
|
||||||
XP_LOGF( "%s: dropping packet of len %d", __FUNCTION__, inlen );
|
XP_LOGF( "%s: dropping packet of len %d", __FUNCTION__, len );
|
||||||
|
len = -1;
|
||||||
}
|
}
|
||||||
} /* pbt_enqueIncoming */
|
return len;
|
||||||
|
} /* pbt_enque */
|
||||||
|
|
||||||
static void
|
static void
|
||||||
pbt_processIncoming( PalmBTStuff* btStuff )
|
pbt_processIncoming( PalmBTStuff* btStuff )
|
||||||
{
|
{
|
||||||
XP_U16 len = btStuff->vol.lens[0];
|
const XP_U8* buf;
|
||||||
XP_ASSERT( !!btStuff->cb );
|
|
||||||
if ( !!btStuff->cb ) {
|
|
||||||
CommsAddrRec fromAddr;
|
|
||||||
fromAddr.conType = COMMS_CONN_BT;
|
|
||||||
XP_MEMCPY( &fromAddr.u.bt.btAddr, &btStuff->otherAddr,
|
|
||||||
sizeof(fromAddr.u.bt.btAddr) );
|
|
||||||
|
|
||||||
(*btStuff->cb)( btStuff->globals, &fromAddr, btStuff->vol.bufIn, len );
|
XP_U16 len = pbt_peekQueue( &btStuff->vol.in, &buf );
|
||||||
|
|
||||||
/* slide the remaining packets down */
|
if ( len > 0 ) {
|
||||||
XP_MEMCPY( &btStuff->vol.lens[0], &btStuff->vol.lens[1],
|
XP_ASSERT( !!btStuff->cb );
|
||||||
sizeof(btStuff->vol.lens) - sizeof(btStuff->vol.lens[0]) );
|
if ( !!btStuff->cb ) {
|
||||||
btStuff->vol.lens[MAX_INCOMING-1] = 0; /* be safe */
|
CommsAddrRec fromAddr;
|
||||||
XP_MEMCPY( btStuff->vol.bufIn, btStuff->vol.bufIn + len,
|
fromAddr.conType = COMMS_CONN_BT;
|
||||||
sizeof(btStuff->vol.bufIn) - len );
|
XP_MEMCPY( &fromAddr.u.bt.btAddr, &btStuff->otherAddr,
|
||||||
|
sizeof(fromAddr.u.bt.btAddr) );
|
||||||
|
|
||||||
|
(*btStuff->cb)( btStuff->globals, &fromAddr, buf, len );
|
||||||
|
pbt_shiftQueue( &btStuff->vol.in );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} /* pbt_processIncoming */
|
} /* pbt_processIncoming */
|
||||||
|
|
||||||
|
@ -623,10 +657,10 @@ pbt_setup_slave( PalmBTStuff* btStuff, const CommsAddrRec* addr )
|
||||||
{
|
{
|
||||||
XP_LOGF( "%s; state=%s", __FUNCTION__, stateToStr(GET_STATE(btStuff)));
|
XP_LOGF( "%s; state=%s", __FUNCTION__, stateToStr(GET_STATE(btStuff)));
|
||||||
|
|
||||||
if ( btStuff->setState == PBT_MASTER ) {
|
if ( btStuff->picoRole == PBT_MASTER ) {
|
||||||
pbt_takedown_master( btStuff );
|
pbt_takedown_master( btStuff );
|
||||||
}
|
}
|
||||||
btStuff->setState = PBT_SLAVE;
|
btStuff->picoRole = PBT_SLAVE;
|
||||||
|
|
||||||
if ( !!addr ) {
|
if ( !!addr ) {
|
||||||
char buf[64];
|
char buf[64];
|
||||||
|
@ -652,7 +686,7 @@ static void
|
||||||
pbt_takedown_slave( PalmBTStuff* btStuff )
|
pbt_takedown_slave( PalmBTStuff* btStuff )
|
||||||
{
|
{
|
||||||
pbt_killL2C( btStuff, btStuff->dataSocket );
|
pbt_killL2C( btStuff, btStuff->dataSocket );
|
||||||
btStuff->setState = PBT_UNINIT;
|
btStuff->picoRole = PBT_UNINIT;
|
||||||
}
|
}
|
||||||
|
|
||||||
static PalmBTStuff*
|
static PalmBTStuff*
|
||||||
|
@ -693,10 +727,7 @@ pbt_killL2C( PalmBTStuff* btStuff, BtLibSocketRef sock )
|
||||||
XP_U16 btLibRefNum = btStuff->btLibRefNum;
|
XP_U16 btLibRefNum = btStuff->btLibRefNum;
|
||||||
|
|
||||||
XP_ASSERT( sock == btStuff->dataSocket );
|
XP_ASSERT( sock == btStuff->dataSocket );
|
||||||
if ( sock != SOCK_INVAL ) {
|
pbt_close_datasocket( btStuff );
|
||||||
CALL_ERR( err, BtLibSocketClose, btLibRefNum, sock );
|
|
||||||
btStuff->dataSocket = SOCK_INVAL;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Harm in calling this when not connected? */
|
/* Harm in calling this when not connected? */
|
||||||
if ( GET_STATE(btStuff) != PBTST_NONE ) {
|
if ( GET_STATE(btStuff) != PBTST_NONE ) {
|
||||||
|
@ -744,13 +775,13 @@ l2SocketCallback( BtLibSocketEventType* sEvent, UInt32 refCon )
|
||||||
|
|
||||||
switch( event ) {
|
switch( event ) {
|
||||||
case btLibSocketEventConnectRequest:
|
case btLibSocketEventConnectRequest:
|
||||||
XP_ASSERT( btStuff->setState == PBT_MASTER );
|
XP_ASSERT( btStuff->picoRole == PBT_MASTER );
|
||||||
/* sends btLibSocketEventConnectedInbound */
|
/* sends btLibSocketEventConnectedInbound */
|
||||||
CALL_ERR( err, BtLibSocketRespondToConnection, btStuff->btLibRefNum,
|
CALL_ERR( err, BtLibSocketRespondToConnection, btStuff->btLibRefNum,
|
||||||
sEvent->socket, true );
|
sEvent->socket, true );
|
||||||
break;
|
break;
|
||||||
case btLibSocketEventConnectedInbound:
|
case btLibSocketEventConnectedInbound:
|
||||||
XP_ASSERT( btStuff->setState == PBT_MASTER );
|
XP_ASSERT( btStuff->picoRole == PBT_MASTER );
|
||||||
if ( sEvent->status == errNone ) {
|
if ( sEvent->status == errNone ) {
|
||||||
btStuff->dataSocket = sEvent->eventData.newSocket;
|
btStuff->dataSocket = sEvent->eventData.newSocket;
|
||||||
XP_LOGF( "we have a data socket!!!" );
|
XP_LOGF( "we have a data socket!!!" );
|
||||||
|
@ -767,15 +798,22 @@ l2SocketCallback( BtLibSocketEventType* sEvent, UInt32 refCon )
|
||||||
case btLibSocketEventData:
|
case btLibSocketEventData:
|
||||||
XP_ASSERT( sEvent->status == errNone );
|
XP_ASSERT( sEvent->status == errNone );
|
||||||
XP_ASSERT( sEvent->socket == btStuff->dataSocket );
|
XP_ASSERT( sEvent->socket == btStuff->dataSocket );
|
||||||
pbt_enqueIncoming( btStuff, sEvent->eventData.data.data,
|
|
||||||
sEvent->eventData.data.dataLen );
|
if ( 0 < pbt_enque( &btStuff->vol.in, sEvent->eventData.data.data,
|
||||||
|
sEvent->eventData.data.dataLen ) ) {
|
||||||
|
pbt_postpone( btStuff, PBT_ACT_GOTDATA );
|
||||||
|
}
|
||||||
|
#ifdef DEBUG
|
||||||
|
btStuff->stats.totalRcvd += sEvent->eventData.data.dataLen;
|
||||||
|
#endif
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case btLibSocketEventSendComplete:
|
case btLibSocketEventSendComplete:
|
||||||
btStuff->vol.sendInProgress = XP_FALSE;
|
btStuff->vol.sendInProgress = XP_FALSE;
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
btStuff->stats.totalSent += btStuff->vol.lenOut;
|
btStuff->stats.totalSent +=
|
||||||
#endif
|
#endif
|
||||||
|
pbt_shiftQueue( &btStuff->vol.out );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case btLibSocketEventDisconnected:
|
case btLibSocketEventDisconnected:
|
||||||
|
@ -786,14 +824,11 @@ l2SocketCallback( BtLibSocketEventType* sEvent, UInt32 refCon )
|
||||||
* home. But there should probably be UI warning users that it's
|
* home. But there should probably be UI warning users that it's
|
||||||
* trying to connect....
|
* trying to connect....
|
||||||
*/
|
*/
|
||||||
if ( PBT_SLAVE == btStuff->setState ) {
|
if ( PBT_SLAVE == btStuff->picoRole ) {
|
||||||
pbt_killL2C( btStuff, sEvent->socket );
|
pbt_killL2C( btStuff, sEvent->socket );
|
||||||
pbt_postpone( btStuff, PBT_ACT_CONNECT_ACL );
|
pbt_postpone( btStuff, PBT_ACT_CONNECT_ACL );
|
||||||
} else if ( PBT_MASTER == btStuff->setState ) {
|
} else if ( PBT_MASTER == btStuff->picoRole ) {
|
||||||
XP_ASSERT( btStuff->dataSocket == sEvent->socket );
|
pbt_close_datasocket( btStuff );
|
||||||
CALL_ERR( err, BtLibSocketClose, btStuff->btLibRefNum,
|
|
||||||
sEvent->socket );
|
|
||||||
btStuff->dataSocket = SOCK_INVAL;
|
|
||||||
SET_STATE( btStuff, PBTST_LISTENING );
|
SET_STATE( btStuff, PBTST_LISTENING );
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -866,7 +901,7 @@ libMgmtCallback( BtLibManagementEventType* mEvent, UInt32 refCon )
|
||||||
}
|
}
|
||||||
SET_STATE( btStuff, PBTST_NONE );
|
SET_STATE( btStuff, PBTST_NONE );
|
||||||
/* See comment at btLibSocketEventDisconnected */
|
/* See comment at btLibSocketEventDisconnected */
|
||||||
if ( PBT_SLAVE == btStuff->setState ) {
|
if ( PBT_SLAVE == btStuff->picoRole ) {
|
||||||
pbt_postpone( btStuff, PBT_ACT_CONNECT_ACL );
|
pbt_postpone( btStuff, PBT_ACT_CONNECT_ACL );
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -42,7 +42,7 @@
|
||||||
* reduce waitTicks if have work to do
|
* reduce waitTicks if have work to do
|
||||||
*/
|
*/
|
||||||
void palm_bt_amendWaitTicks( PalmAppGlobals* globals, Int32* result );
|
void palm_bt_amendWaitTicks( PalmAppGlobals* globals, Int32* result );
|
||||||
XP_Bool palm_bt_doWork( PalmAppGlobals* globals );
|
XP_Bool palm_bt_doWork( PalmAppGlobals* globals, BtUIState* btState );
|
||||||
|
|
||||||
typedef void (*DataCb)( PalmAppGlobals* globals,
|
typedef void (*DataCb)( PalmAppGlobals* globals,
|
||||||
const CommsAddrRec* fromAddr,
|
const CommsAddrRec* fromAddr,
|
||||||
|
|
|
@ -1135,7 +1135,7 @@ saveOpenGame( PalmAppGlobals* globals )
|
||||||
if ( !!globals->game.server ) {
|
if ( !!globals->game.server ) {
|
||||||
XWStreamCtxt* memStream;
|
XWStreamCtxt* memStream;
|
||||||
DictionaryCtxt* dict;
|
DictionaryCtxt* dict;
|
||||||
XP_UCHAR* dictName;
|
const XP_UCHAR* dictName;
|
||||||
char namebuf[MAX_GAMENAME_LENGTH];
|
char namebuf[MAX_GAMENAME_LENGTH];
|
||||||
|
|
||||||
if ( gi_countHumans( &globals->gameInfo ) > 1 ) {
|
if ( gi_countHumans( &globals->gameInfo ) > 1 ) {
|
||||||
|
@ -1463,6 +1463,32 @@ timeForTimer( PalmAppGlobals* globals, XWTimerReason* why, XP_U32* when )
|
||||||
return found;
|
return found;
|
||||||
} /* timeForTimer */
|
} /* timeForTimer */
|
||||||
|
|
||||||
|
#ifdef XWFEATURE_BLUETOOTH
|
||||||
|
static void
|
||||||
|
showBTState( PalmAppGlobals* globals )
|
||||||
|
{
|
||||||
|
if ( COMMS_CONN_BT == comms_getConType( globals->game.comms ) ) {
|
||||||
|
char ch = 'x';
|
||||||
|
switch( globals->btUIState ) {
|
||||||
|
case BTUI_NONE:
|
||||||
|
/* ch = 'x'; */ break;
|
||||||
|
case BTUI_LISTENING:
|
||||||
|
ch = 'L'; break;
|
||||||
|
case BTUI_CONNECTING:
|
||||||
|
ch = 'c'; break;
|
||||||
|
case BTUI_CONNECTED:
|
||||||
|
ch = 'C'; break;
|
||||||
|
case BTUI_SERVING:
|
||||||
|
ch = 'S'; break;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Looks ok on T650, bad on lowres. Need to replace with gadget or
|
||||||
|
icon or something long before ship. */
|
||||||
|
WinDrawChars( &ch, 1, 160-7, 160-25 );
|
||||||
|
}
|
||||||
|
} /* showBTState */
|
||||||
|
#endif
|
||||||
|
|
||||||
static Boolean
|
static Boolean
|
||||||
handleNilEvent( PalmAppGlobals* globals )
|
handleNilEvent( PalmAppGlobals* globals )
|
||||||
{
|
{
|
||||||
|
@ -1478,8 +1504,8 @@ handleNilEvent( PalmAppGlobals* globals )
|
||||||
&& (when <= TimGetTicks()) ) {
|
&& (when <= TimGetTicks()) ) {
|
||||||
palmFireTimer( globals, why );
|
palmFireTimer( globals, why );
|
||||||
#ifdef XWFEATURE_BLUETOOTH
|
#ifdef XWFEATURE_BLUETOOTH
|
||||||
} else if ( palm_bt_doWork( globals ) ) {
|
} else if ( palm_bt_doWork( globals, &globals->btUIState ) ) {
|
||||||
/* nothing to do */
|
showBTState( globals );
|
||||||
#endif
|
#endif
|
||||||
} else if ( globals->timeRequested ) {
|
} else if ( globals->timeRequested ) {
|
||||||
globals->timeRequested = false;
|
globals->timeRequested = false;
|
||||||
|
@ -1492,6 +1518,11 @@ handleNilEvent( PalmAppGlobals* globals )
|
||||||
} else {
|
} else {
|
||||||
handled = false;
|
handled = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef XWFEATURE_BLUETOOTH /* don't check this in */
|
||||||
|
showBTState( globals );
|
||||||
|
#endif
|
||||||
|
|
||||||
return handled;
|
return handled;
|
||||||
} /* handleNilEvent */
|
} /* handleNilEvent */
|
||||||
|
|
||||||
|
@ -1767,7 +1798,7 @@ initAndStartBoard( PalmAppGlobals* globals, XP_Bool newGame )
|
||||||
dict = model_getDictionary( globals->game.model );
|
dict = model_getDictionary( globals->game.model );
|
||||||
|
|
||||||
if ( !!dict ) {
|
if ( !!dict ) {
|
||||||
XP_UCHAR* dictName = dict_getName( dict );
|
const XP_UCHAR* dictName = dict_getName( dict );
|
||||||
if ( !!newDictName && 0 != XP_STRCMP( (const char*)dictName,
|
if ( !!newDictName && 0 != XP_STRCMP( (const char*)dictName,
|
||||||
(const char*)newDictName ) ) {
|
(const char*)newDictName ) ) {
|
||||||
dict_destroy( dict );
|
dict_destroy( dict );
|
||||||
|
|
|
@ -191,6 +191,8 @@ typedef struct DictState {
|
||||||
XP_U16 nDicts;
|
XP_U16 nDicts;
|
||||||
} DictState;
|
} DictState;
|
||||||
|
|
||||||
|
#define MAX_DISABLED 24 /* I've seen 19.... */
|
||||||
|
|
||||||
typedef struct PalmNewGameState {
|
typedef struct PalmNewGameState {
|
||||||
FormPtr form;
|
FormPtr form;
|
||||||
ListPtr playerNumList;
|
ListPtr playerNumList;
|
||||||
|
@ -198,6 +200,10 @@ typedef struct PalmNewGameState {
|
||||||
XP_UCHAR passwds[MAX_PASSWORD_LENGTH+1][MAX_NUM_PLAYERS];
|
XP_UCHAR passwds[MAX_PASSWORD_LENGTH+1][MAX_NUM_PLAYERS];
|
||||||
XP_UCHAR* dictName;
|
XP_UCHAR* dictName;
|
||||||
XP_UCHAR shortDictName[32]; /* as long as a dict name can be */
|
XP_UCHAR shortDictName[32]; /* as long as a dict name can be */
|
||||||
|
|
||||||
|
XP_U16 disabled[MAX_DISABLED];
|
||||||
|
XP_U16 nDisabled;
|
||||||
|
|
||||||
XP_Bool forwardChange;
|
XP_Bool forwardChange;
|
||||||
Connectedness curServerHilite;
|
Connectedness curServerHilite;
|
||||||
#ifdef BEYOND_IR
|
#ifdef BEYOND_IR
|
||||||
|
@ -219,6 +225,16 @@ typedef struct NetLibStuff {
|
||||||
|
|
||||||
#define MAX_DLG_PARAMS 2
|
#define MAX_DLG_PARAMS 2
|
||||||
|
|
||||||
|
#ifdef XWFEATURE_BLUETOOTH
|
||||||
|
typedef enum {
|
||||||
|
BTUI_NONE
|
||||||
|
, BTUI_LISTENING
|
||||||
|
, BTUI_CONNECTING
|
||||||
|
, BTUI_CONNECTED /* slave */
|
||||||
|
, BTUI_SERVING /* master */
|
||||||
|
} BtUIState;
|
||||||
|
#endif
|
||||||
|
|
||||||
struct PalmAppGlobals {
|
struct PalmAppGlobals {
|
||||||
FormPtr mainForm;
|
FormPtr mainForm;
|
||||||
PrefsDlgState* prefsDlgState;
|
PrefsDlgState* prefsDlgState;
|
||||||
|
@ -305,6 +321,7 @@ struct PalmAppGlobals {
|
||||||
XP_U32 heartTimerFireAt;
|
XP_U32 heartTimerFireAt;
|
||||||
# ifdef XWFEATURE_BLUETOOTH
|
# ifdef XWFEATURE_BLUETOOTH
|
||||||
struct PalmBTStuff* btStuff;
|
struct PalmBTStuff* btStuff;
|
||||||
|
BtUIState btUIState; /* For showing user what's up */
|
||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue