27 #define POS_MAX (Screen_Width - POINTER_WIDTH - 1)
29 #define POINTER_DEFAULT_COLOR RGB_BLUE
32 #define ANGLEPAUSE 500
33 #define DEFAULT_ANGLESTART 25
34 #define MIN_ANGLE_FOR_SHIFT_UP (ANGLEPAUSE+CurrentAngleStart)
35 #define MIN_ANGLE_FOR_SHIFT_DOWN (ANGLEPAUSE-CurrentAngleStart)
36 #define MIN_ANGLE_FOR_SHIFT_RIGHT (signed)(0+CurrentAngleStart)
37 #define MIN_ANGLE_FOR_SHIFT_LEFT (signed)(0-CurrentAngleStart)
38 #define DEFAULT_SPEED_ON_ANGLE 60
41 #define JOY_MAXBTIME 20
42 #define JOY_HIGH_SPEED 5
43 #define JOY_LOW_SPEED 1
46 CONST_DATA u8 BallPointerBmp[POINTER_WIDTH] = { 0x38, 0x7C, 0xFF, 0xFF, 0xFF, 0x7C, 0x38 } ;
50 u8 DefaultAreaStore[2 * POINTER_WIDTH* POINTER_WIDTH];
53 const u8* CurrentPointerBmp = 0;
54 coord_t CurrentPointerWidth = 0;
55 coord_t CurrentPointerHeight = 3;
56 s16 CurrentSpeedOnAngle = DEFAULT_SPEED_ON_ANGLE;
57 s32 CurrentAngleStart = DEFAULT_ANGLESTART;
58 u8* ptrAreaStore = DefaultAreaStore;
59 color_t CurrentPointerColor = POINTER_DEFAULT_COLOR;
91 NODEBUG2 s32 POINTER_JoyTch(
void )
95 if ( JoystickAsInput )
141 if ( JoyDelay >= WEIGHTED_TIME( JOY_MAXBTIME ) )
142 JoyInc = JOY_HIGH_SPEED;
144 JoyInc = JOY_LOW_SPEED;
146 #endif //JOYSTICK_AVAIL
148 #if TOUCHSCREEN_AVAIL
153 if ( ( TOUCHSCR_Info.xPos > 2 ) || ( TOUCHSCR_Info.yPos > 2 ) )
158 if ( TOUCHSCR_Info.xPos < PHYS_SCREEN_WIDTH + CurrentPointerWidth )
160 TOUCHSCR_SetMode( TS_POINTER );
161 POINTER_Info.
xPos = TOUCHSCR_Info.xPos - 2 * POINTER_WIDTH / 3 ;
162 POINTER_Info.
yPos = TOUCHSCR_Info.yPos - 2 * POINTER_WIDTH / 3 ;
166 if ( TOUCHSCR_Info.yPos > 0 )
168 TOUCHSCR_SetMode( TS_POINTER );
169 POINTER_Info.
xPos = TOUCHSCR_Info.xPos - 2 * POINTER_WIDTH / 3 ;
170 POINTER_Info.
yPos = TOUCHSCR_Info.yPos - 2 * POINTER_WIDTH / 3 ;
174 if ( TOUCHSCR_Info.xPos > 0 )
176 TOUCHSCR_SetMode( TS_POINTER );
177 POINTER_Info.
xPos = TOUCHSCR_Info.xPos - 2 * POINTER_WIDTH / 3 ;
178 POINTER_Info.
yPos = TOUCHSCR_Info.yPos - 2 * POINTER_WIDTH / 3 ;
183 if ( TOUCHSCR_Info.yPos < PHYS_SCREEN_HEIGHT + CurrentPointerHeight )
185 TOUCHSCR_SetMode( TS_POINTER );
186 POINTER_Info.
xPos = TOUCHSCR_Info.xPos - 2 * POINTER_WIDTH / 3 ;
187 POINTER_Info.
yPos = TOUCHSCR_Info.yPos - 2 * POINTER_WIDTH / 3 ;
197 #endif //TOUCHSCREEN_AVAIL
200 if ( ( ( MEMSASINPUT && ( JoyPos ==
JOYSTICK_RELEASED ) ) || !JoystickAsInput ) && !( TchscrAsInput ) )
226 static bool POINTER_Move(
void )
228 s16 oldPointer_xPos = POINTER_Info.
xPos;
229 s16 oldPointer_yPos = POINTER_Info.
yPos;
230 signed outx = MEMS_Info.OutX;
231 signed outy = MEMS_Info.OutY;
235 if ( POINTER_JoyTch() != 0 )
242 MEMS_Info.RELATIVE_X = outx;
243 MEMS_Info.RELATIVE_Y = outy;
245 if ( outx > MIN_ANGLE_FOR_SHIFT_RIGHT )
247 POINTER_Info.
shift_PosX = ( outx - MIN_ANGLE_FOR_SHIFT_RIGHT );
249 else if ( outx < MIN_ANGLE_FOR_SHIFT_LEFT )
251 POINTER_Info.
shift_PosX = ( outx - MIN_ANGLE_FOR_SHIFT_LEFT );
254 if ( outy < -MIN_ANGLE_FOR_SHIFT_UP )
256 POINTER_Info.
shift_PosY = ( outy + MIN_ANGLE_FOR_SHIFT_UP );
258 else if ( outy > -MIN_ANGLE_FOR_SHIFT_DOWN )
260 POINTER_Info.
shift_PosY = ( outy + MIN_ANGLE_FOR_SHIFT_DOWN );
266 MEMS_Info.RELATIVE_X = -( outy );
267 MEMS_Info.RELATIVE_Y = outx;
269 if ( outy > MIN_ANGLE_FOR_SHIFT_RIGHT )
271 POINTER_Info.
shift_PosX = -( outy - MIN_ANGLE_FOR_SHIFT_RIGHT );
273 else if ( outy < MIN_ANGLE_FOR_SHIFT_LEFT )
275 POINTER_Info.
shift_PosX = -( outy - MIN_ANGLE_FOR_SHIFT_LEFT );
278 if ( outx < -MIN_ANGLE_FOR_SHIFT_UP )
280 POINTER_Info.
shift_PosY = ( outx + MIN_ANGLE_FOR_SHIFT_UP );
282 else if ( outx > -MIN_ANGLE_FOR_SHIFT_DOWN )
284 POINTER_Info.
shift_PosY = ( outx + MIN_ANGLE_FOR_SHIFT_DOWN );
290 MEMS_Info.RELATIVE_X = -( outx );
291 MEMS_Info.RELATIVE_Y = -( outy );
293 if ( outx > MIN_ANGLE_FOR_SHIFT_RIGHT )
295 POINTER_Info.
shift_PosX = ( MIN_ANGLE_FOR_SHIFT_RIGHT - outx );
297 else if ( outx < MIN_ANGLE_FOR_SHIFT_LEFT )
299 POINTER_Info.
shift_PosX = ( MIN_ANGLE_FOR_SHIFT_LEFT - outx );
302 if ( outy > MIN_ANGLE_FOR_SHIFT_UP )
304 POINTER_Info.
shift_PosY = -( outy - MIN_ANGLE_FOR_SHIFT_UP );
306 else if ( outy < MIN_ANGLE_FOR_SHIFT_DOWN )
308 POINTER_Info.
shift_PosY = +( MIN_ANGLE_FOR_SHIFT_DOWN - outy );
314 MEMS_Info.RELATIVE_X = outy;
315 MEMS_Info.RELATIVE_Y = -( outx );
317 if ( outy > MIN_ANGLE_FOR_SHIFT_RIGHT )
319 POINTER_Info.
shift_PosX = ( outy - MIN_ANGLE_FOR_SHIFT_RIGHT );
321 else if ( outy < MIN_ANGLE_FOR_SHIFT_LEFT )
323 POINTER_Info.
shift_PosX = ( outy - MIN_ANGLE_FOR_SHIFT_LEFT );
326 if ( outx > MIN_ANGLE_FOR_SHIFT_UP )
328 POINTER_Info.
shift_PosY = ( MIN_ANGLE_FOR_SHIFT_UP - outx );
330 else if ( outx < MIN_ANGLE_FOR_SHIFT_DOWN )
332 POINTER_Info.
shift_PosY = ( MIN_ANGLE_FOR_SHIFT_DOWN - outx );
339 POINTER_Info.
shift_PosX /= CurrentSpeedOnAngle;
340 POINTER_Info.
shift_PosY /= CurrentSpeedOnAngle;
345 if ( Application_Pointer_Mgr )
377 ( ( oldPointer_xPos != POINTER_Info.
xPos ) || ( oldPointer_yPos != POINTER_Info.
yPos ) ) )
383 POINTER_Restore( oldPointer_xPos, oldPointer_yPos, POINTER_WIDTH, POINTER_WIDTH );
387 POINTER_Draw( POINTER_Info.
xPos, POINTER_Info.
yPos, POINTER_WIDTH, POINTER_WIDTH, CurrentPointerBmp );
391 ( ( oldPointer_xPos != POINTER_Info.
xPos ) || ( oldPointer_yPos != POINTER_Info.
yPos ) ) )
397 POINTER_Restore( oldPointer_xPos, oldPointer_yPos, CurrentPointerWidth, CurrentPointerHeight );
400 POINTER_Save( POINTER_Info.
xPos, POINTER_Info.
yPos, CurrentPointerWidth, CurrentPointerHeight );
401 POINTER_Draw( POINTER_Info.
xPos, POINTER_Info.
yPos, CurrentPointerWidth, CurrentPointerHeight, CurrentPointerBmp );
405 if ( ( POINTER_Info.
xPos == POS_MIN ) || ( POINTER_Info.
yPos == POS_MIN ) ||
406 ( POINTER_Info.
xPos == POS_MAX ) || ( POINTER_Info.
yPos == POS_MAX ) )
429 NODEBUG
void POINTER_Init(
void )
431 POINTER_Info.
xPos = ( Screen_Width / 2 ) - ( POINTER_WIDTH / 2 ) - 1;
432 POINTER_Info.
yPos = ( Screen_Width / 2 ) - ( POINTER_WIDTH / 2 ) - 1;
445 CurrentPointerColor = POINTER_DEFAULT_COLOR;
461 void POINTER_Handler(
void )
471 switch ( Pointer_Mode )
482 #if MEMS_POINTER // Not necessary if no MEMS menu handling
524 bmp = BallPointerBmp;
529 POINTER_Info.
X_PosMax - POINTER_Info.
X_PosMin + CurrentPointerWidth - width,
530 POINTER_Info.
Y_PosMax - POINTER_Info.
Y_PosMin + CurrentPointerHeight - height );
532 CurrentPointerWidth = width;
533 CurrentPointerHeight = height;
534 CurrentPointerBmp = bmp;
552 return CurrentAngleStart;
570 CurrentAngleStart = newangle;
588 return CurrentSpeedOnAngle;
606 CurrentSpeedOnAngle = newspeed;
629 ptrAreaStore = ( ptr == 0 ) ? DefaultAreaStore : ptr;
653 if ( Pointer_Mode == mode )
659 ptr = ( u16* )DefaultAreaStore;
662 for ( i = 0; i < ( CurrentPointerWidth * CurrentPointerHeight ) ; i++ )
667 POINTER_Draw( POINTER_Info.
xPos, POINTER_Info.
yPos, CurrentPointerWidth, CurrentPointerHeight, CurrentPointerBmp );
671 POINTER_Draw( POINTER_Info.
xPos, POINTER_Info.
yPos, CurrentPointerWidth, CurrentPointerHeight, CurrentPointerBmp );
677 POINTER_Draw( POINTER_Info.
xPos, POINTER_Info.
yPos, CurrentPointerWidth, CurrentPointerHeight, CurrentPointerBmp );
678 POINTER_Draw( POINTER_Info.
xPos, POINTER_Info.
yPos, CurrentPointerWidth, CurrentPointerHeight, CurrentPointerBmp );
682 POINTER_Info.
xPos = ( Screen_Width - POINTER_WIDTH ) / 2;
683 POINTER_Info.
yPos = ( Screen_Width - POINTER_WIDTH ) / 2;
733 return Pointer_State;
798 POINTER_SetRect( 0, 0, Screen_Width - CurrentPointerWidth, Screen_Height - CurrentPointerHeight );
817 return ( POINTER_Info.
xPos | ( POINTER_Info.
yPos << 8 ) );
838 POINTER_Info.
xPos = x;
839 POINTER_Info.
yPos = y;
863 void POINTER_Draw( coord_t x, coord_t y, coord_t width, coord_t height,
const u8* bmp )
868 u8* ptr = ptrAreaStore;
875 bmp = BallPointerBmp;
882 LCD_SendLCDCmd_RAM_Access();
884 while ( n < ( width * height ) )
900 val = ( bmp[l + ( i / 8 )] & ( 1 << ( 7 - ( i % 8 ) ) ) ) ?
POINTER_GetColor() : c;
920 LCD_SendLCDCmd_RAM_Access_End();
945 void POINTER_Save( coord_t x, coord_t y, coord_t width, coord_t height )
980 u8* ptr = ptrAreaStore;
981 u16 bytesize = ( width * height ) * 2;
987 LCD_SendLCDCmd_RAM_Access();
989 for ( i = 0; i < bytesize; i++ )
1003 LCD_SendLCDCmd_RAM_Access_End();
1022 Application_Pointer_Mgr = mgr;
1040 CurrentPointerColor = color;
1058 return CurrentPointerColor;
1076 return &POINTER_Info;