Beispiel #1
0
/*#
    @method new_from_pixmap GdkCursor
    @brief Creates a new cursor from a given pixmap and mask.
    @param source the pixmap specifying the cursor (GdkPixmap).
    @param mask the pixmap specifying the mask, which must be the same size as source (GdkPixmap).
    @param fg the foreground color, used for the bits in the source which are 1 (GdkColor).
    @param bg the background color, used for the bits in the source which are 0 (GdkColor).
    @param x the horizontal offset of the 'hotspot' of the cursor.
    @param y the vertical offset of the 'hotspot' of the cursor.
    @return a new GdkCursor.

    Both the pixmap and mask must have a depth of 1 (i.e. each pixel has only 2
    values - on or off). The standard cursor size is 16 by 16 pixels. You can
    create a bitmap from inline data as in the below example.

    [...]
 */
FALCON_FUNC Cursor::new_from_pixmap( VMARG )
{
    Item* i_src = vm->param( 0 );
    Item* i_mask = vm->param( 1 );
    Item* i_fg = vm->param( 2 );
    Item* i_bg = vm->param( 3 );
    Item* i_x = vm->param( 4 );
    Item* i_y = vm->param( 5 );
#ifndef NO_PARAMETER_CHECK
    if ( !i_src || !i_src->isObject() || !IS_DERIVED( i_src, GdkPixmap )
        || !i_mask || !i_mask->isObject() || !IS_DERIVED( i_mask, GdkPixmap )
        || !i_fg || !i_fg->isObject() || !IS_DERIVED( i_fg, GdkColor )
        || !i_bg || !i_bg->isObject() || !IS_DERIVED( i_bg, GdkColor )
        || !i_x || !i_x->isInteger()
        || !i_y || !i_y->isInteger() )
        throw_inv_params( "GdkPixmap,GdkPixmap,GdkColor,GdkColor,I,I" );
#endif
    vm->retval( new Gdk::Cursor( vm->findWKI( "GdkCursor" )->asClass(),
        gdk_cursor_new_from_pixmap( GET_PIXMAP( *i_src ),
                                    GET_PIXMAP( *i_mask ),
                                    GET_COLOR( *i_fg ),
                                    GET_COLOR( *i_bg ),
                                    i_x->asInteger(),
                                    i_y->asInteger() ) ) );
}
Beispiel #2
0
static void copy_pv_extras( GLcontext *ctx, GLuint dst, GLuint src )
{
    struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;

    if (VB->ColorPtr[1]) {
        COPY_4FV( GET_COLOR(VB->ColorPtr[1], dst),
                  GET_COLOR(VB->ColorPtr[1], src) );
    }

    setup_tab[TDFX_CONTEXT(ctx)->SetupIndex].copy_pv(ctx, dst, src);
}
INTERP_QUALIFIER void TAG(copy_pv_extras)( GLcontext *ctx, 
					   GLuint dst, GLuint src )
{
   LOCALVARS
      struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;

   if (VB->ColorPtr[1]) {
      COPY_4FV( GET_COLOR(VB->ColorPtr[1], dst), 
		GET_COLOR(VB->ColorPtr[1], src) );

      if (VB->SecondaryColorPtr[1]) {
	 COPY_4FV( GET_COLOR(VB->SecondaryColorPtr[1], dst), 
		   GET_COLOR(VB->SecondaryColorPtr[1], src) );
      }
   }

   COPY_PV_VERTEX(ctx, dst, src);
}
Beispiel #4
0
void		draw_next_y(t_datas *datas, t_line *line, t_mlx *mlx)
{
	t_line		*next_y;
	t_alt		alt;

	next_y = find_next_y(&datas, line->x, line->y + 1);
	if (line->color == find_color("0xffffff"))
	{
		alt.col_n = GET_COLOR(find_color(modify_colors(line, mlx)));
		alt.col_p = GET_COLOR(find_color(modify_colors(next_y, mlx)));
	}
	else
	{
		alt.col_n = GET_COLOR(line->color);
		alt.col_p = GET_COLOR(next_y->color);
	}
	mlx_draw_line_2(line, next_y, mlx, alt);
}
Beispiel #5
0
static void copy_pv_extras( GLcontext *ctx, GLuint dst, GLuint src )
{
   struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;

   if (VB->ColorPtr[1]) {
	 COPY_CHAN4( GET_COLOR(VB->ColorPtr[1], dst), 
		     GET_COLOR(VB->ColorPtr[1], src) );
	 
	 if (VB->SecondaryColorPtr[1]) {
	    COPY_3V( GET_COLOR(VB->SecondaryColorPtr[1], dst), 
		     GET_COLOR(VB->SecondaryColorPtr[1], src) );
	 }
   }
   else if (VB->IndexPtr[1]) {
      VB->IndexPtr[1]->data[dst] = VB->IndexPtr[1]->data[src];
   }

   copy_pv_tab[SWSETUP_CONTEXT(ctx)->SetupIndex](ctx, dst, src);
}
Beispiel #6
0
inline int NonSlidingMoves(const BOARD *board, SQUARE orig, MOVE *poss_moves, int nmoves, char noncaptures)
{
    PIECE p = board->squares[orig];
    for(const SQUARE *d = deltas[p]; *d; d++){
        SQUARE dest = orig + *d;
        if(IN_BOARD(dest)){
            if(board->squares[dest] == EMPTY){
                if(noncaptures){
                    if(poss_moves) poss_moves[nmoves] = Move(0, dest, orig);
                    nmoves++;
                }
            }else if(GET_COLOR(board->squares[dest]) != GET_COLOR(p)){
                if(poss_moves) poss_moves[nmoves] = Move(0, dest, orig);
                nmoves++;
            }
        }
    }
    return nmoves;
}
Beispiel #7
0
inline int SlidingMoves(const BOARD *board, SQUARE orig, MOVE *poss_moves, int nmoves, char noncaptures)
{
    PIECE p = board->squares[orig];
    for(const SQUARE *d = deltas[p]; *d; d++){
        for(SQUARE dest = orig + *d; IN_BOARD(dest); dest += *d){
            if(board->squares[dest] == EMPTY){
                if(noncaptures){
                    if(poss_moves) poss_moves[nmoves] = Move(0, dest, orig);
                    nmoves++;
                }
            }else if(GET_COLOR(board->squares[dest]) != GET_COLOR(p)) { 
                /*Different color Piece, capture, stop sliding.*/
                if(poss_moves) poss_moves[nmoves] = Move(0, dest, orig);
                nmoves++;
                break;
            }else break;        /*same color piece, stop sliding.*/
        }
    }
    return nmoves;
}
Beispiel #8
0
inline int BlackPawnMoves(const BOARD *board, SQUARE orig, MOVE *poss_moves, int nmoves, char noncaptures)
{
    SQUARE dest = orig + ROW_DOWN;
    if(noncaptures && IN_BOARD(dest) && board->squares[dest] == EMPTY){
        if(ROW(dest) == FIRST_ROW){
            if(poss_moves) poss_moves[nmoves] = Move(B_QUEEN, dest, orig);
            nmoves++;
            if(poss_moves) poss_moves[nmoves] = Move(B_KNIGHT, dest, orig);
            nmoves++;
            if(poss_moves) poss_moves[nmoves] = Move(B_ROOK, dest, orig);
            nmoves++;
            if(poss_moves) poss_moves[nmoves] = Move(B_BISHOP, dest, orig);
            nmoves++;
        }else{
            if(poss_moves) poss_moves[nmoves] = Move(0, dest, orig);
            nmoves++;
            if(ROW(dest) == SIXTH_ROW){
                dest = dest + ROW_DOWN;
                if(IN_BOARD(dest)){
                    if(board->squares[dest] == EMPTY){
                        if(poss_moves) poss_moves[nmoves] = Move(0, dest, orig);
                        nmoves++;
                    }
                }
            }
        }
    }
    for(int i = 0; b_pawn_capture[i]; i++){
        dest = orig + b_pawn_capture[i];
        if(IN_BOARD(dest)){
            if(board->squares[dest] == EMPTY){
                if(dest == board->en_passant){
                    if(poss_moves) poss_moves[nmoves] = Move(0, dest, orig);
                    nmoves++;
                }
            }else if(GET_COLOR(board->squares[dest])){
                if(ROW(dest) == FIRST_ROW){
                    if(poss_moves) poss_moves[nmoves] = Move(B_QUEEN, dest, orig);   
                    nmoves++;
                    if(poss_moves) poss_moves[nmoves] = Move(B_KNIGHT, dest, orig);
                    nmoves++;
                    if(poss_moves) poss_moves[nmoves] = Move(B_ROOK, dest, orig);
                    nmoves++;
                    if(poss_moves) poss_moves[nmoves] = Move(B_BISHOP, dest, orig);
                    nmoves++;
                }else{
                    if(poss_moves) poss_moves[nmoves] = Move(0, dest, orig);
                    nmoves++;
                }
            }
        }
    }
    return nmoves;
}
Beispiel #9
0
static void interp_extras( GLcontext *ctx,
			   GLfloat t,
			   GLuint dst, GLuint out, GLuint in,
			   GLboolean force_boundary )
{
   struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;

   if (VB->ColorPtr[1]) {
      INTERP_4CHAN( t,
		 GET_COLOR(VB->ColorPtr[1], dst),
		 GET_COLOR(VB->ColorPtr[1], out),
		 GET_COLOR(VB->ColorPtr[1], in) );

      if (VB->SecondaryColorPtr[1]) {
	 INTERP_3CHAN( t,
		    GET_COLOR(VB->SecondaryColorPtr[1], dst),
		    GET_COLOR(VB->SecondaryColorPtr[1], out),
		    GET_COLOR(VB->SecondaryColorPtr[1], in) );
      }
   }
   else if (VB->IndexPtr[1]) {
      VB->IndexPtr[1]->data[dst] = (GLuint) (GLint)
	 LINTERP( t,
		  (GLfloat) VB->IndexPtr[1]->data[out],
		  (GLfloat) VB->IndexPtr[1]->data[in] );
   }

   if (VB->EdgeFlag) {
      VB->EdgeFlag[dst] = VB->EdgeFlag[out] || force_boundary;
   }

   interp_tab[SWSETUP_CONTEXT(ctx)->SetupIndex](ctx, t, dst, out, in,
						force_boundary);
}
Beispiel #10
0
static void interp_extras( GLcontext *ctx,
                           GLfloat t,
                           GLuint dst, GLuint out, GLuint in,
                           GLboolean force_boundary )
{
    struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;

    if (VB->ColorPtr[1]) {
        /* If stride is zero, ColorPtr[1] is constant across the VB, so
         * there is no point interpolating between two values as they will
         * be identical.  This case is handled in t_dd_tritmp.h
         */
        if (VB->ColorPtr[1]->stride) {
            assert(VB->ColorPtr[1]->stride == 4 * sizeof(GLfloat));
            INTERP_4F( t,
                       GET_COLOR(VB->ColorPtr[1], dst),
                       GET_COLOR(VB->ColorPtr[1], out),
                       GET_COLOR(VB->ColorPtr[1], in) );
        }

        if (VB->SecondaryColorPtr[1]) {
            INTERP_3F( t,
                       GET_COLOR(VB->SecondaryColorPtr[1], dst),
                       GET_COLOR(VB->SecondaryColorPtr[1], out),
                       GET_COLOR(VB->SecondaryColorPtr[1], in) );
        }
    }

    if (VB->EdgeFlag) {
        VB->EdgeFlag[dst] = VB->EdgeFlag[out] || force_boundary;
    }

    setup_tab[FX_CONTEXT(ctx)->SetupIndex].interp(ctx, t, dst, out, in,
            force_boundary);
}
INTERP_QUALIFIER void TAG(interp_extras)( GLcontext *ctx,
					  GLfloat t,
					  GLuint dst, GLuint out, GLuint in,
					  GLboolean force_boundary )
{
   LOCALVARS
   struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;

   if (VB->ColorPtr[1]) {
      assert(VB->ColorPtr[1]->stride == 4 * sizeof(GLfloat));
      
      INTERP_4F( t,
		    GET_COLOR(VB->ColorPtr[1], dst),
		    GET_COLOR(VB->ColorPtr[1], out),
		    GET_COLOR(VB->ColorPtr[1], in) );

      if (VB->SecondaryColorPtr[1]) {
	 INTERP_3F( t,
		       GET_COLOR(VB->SecondaryColorPtr[1], dst),
		       GET_COLOR(VB->SecondaryColorPtr[1], out),
		       GET_COLOR(VB->SecondaryColorPtr[1], in) );
      }
   }

   if (VB->EdgeFlag) {
      VB->EdgeFlag[dst] = VB->EdgeFlag[out] || force_boundary;
   }

   INTERP_VERTEX(ctx, t, dst, out, in, force_boundary);
}
Beispiel #12
0
inline int WhitePawnMoves(const BOARD *board, SQUARE orig, MOVE *poss_moves, int nmoves, char noncaptures)
{
    SQUARE dest = orig + ROW_UP;
    if(noncaptures && IN_BOARD(dest) && board->squares[dest] == EMPTY){
        if(ROW(dest) == EIGHT_ROW){            /*Promotions.*/
            if(poss_moves) poss_moves[nmoves] = Move(W_QUEEN, dest, orig);
            nmoves++;
            if(poss_moves) poss_moves[nmoves] = Move(W_KNIGHT, dest, orig);
            nmoves++;
            if(poss_moves) poss_moves[nmoves] = Move(W_ROOK, dest, orig);
            nmoves++;
            if(poss_moves) poss_moves[nmoves] = Move(W_BISHOP, dest, orig);
            nmoves++;
        }else{
            if(poss_moves) poss_moves[nmoves] = Move(0, dest, orig);
            nmoves++;
            if(ROW(dest) == THIRD_ROW){
                dest = dest + ROW_UP;
                if(IN_BOARD(dest) && board->squares[dest] == EMPTY){
                    if(poss_moves) poss_moves[nmoves] = Move(0, dest, orig);
                    nmoves++;
                }
            }
        }
    }
    for(int i = 0; w_pawn_capture[i]; i++){
        dest = orig + w_pawn_capture[i];
        if(IN_BOARD(dest)){
            if(board->squares[dest] == EMPTY){
                if(dest == board->en_passant){        /*Captures en Passant.*/
                    if(poss_moves) poss_moves[nmoves] = Move(0, dest, orig);
                    nmoves++;
                }
            }else if(GET_COLOR(board->squares[dest]) == BLACK){
                if(ROW(dest) == EIGHT_ROW){
                    if(poss_moves) poss_moves[nmoves] = Move(W_QUEEN, dest, orig);
                    nmoves++;
                    if(poss_moves) poss_moves[nmoves] = Move(W_KNIGHT, dest, orig);
                    nmoves++;
                    if(poss_moves) poss_moves[nmoves] = Move(W_ROOK, dest, orig);
                    nmoves++;
                    if(poss_moves) poss_moves[nmoves] = Move(W_BISHOP, dest, orig);
                    nmoves++;
                }else{
                    if(poss_moves) poss_moves[nmoves] = Move(0, dest, orig);
                    nmoves++;
                }
            }
        }
    }
    return nmoves;
}
Beispiel #13
0
static void interp_extras( GLcontext *ctx,
                           GLfloat t,
                           GLuint dst, GLuint out, GLuint in,
                           GLboolean force_boundary )
{
    struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;

    /*fprintf(stderr, "%s\n", __FUNCTION__);*/

    if (VB->ColorPtr[1]) {
        INTERP_4F( t,
                   GET_COLOR(VB->ColorPtr[1], dst),
                   GET_COLOR(VB->ColorPtr[1], out),
                   GET_COLOR(VB->ColorPtr[1], in) );
    }

    if (VB->EdgeFlag) {
        VB->EdgeFlag[dst] = VB->EdgeFlag[out] || force_boundary;
    }

    setup_tab[TDFX_CONTEXT(ctx)->SetupIndex].interp(ctx, t, dst, out, in,
            force_boundary);
}
Beispiel #14
0
int MoveGen(const BOARD *board, MOVE *poss_moves, char noncaptures)
{
    int nmoves = 0;
    for(SQUARE orig = a1; orig <= h8; orig++){
        PIECE p = board->squares[orig];
        if(p && GET_COLOR(p) == board->white_to_move){
            nmoves = piece_moves[p](board, orig, poss_moves, nmoves, noncaptures);
        }
        if(COLUMN(orig) == H_COLUMN) orig += 8;
    }
    if(noncaptures){
        if(board->white_to_move) nmoves = GenerateWhiteCastle(board, poss_moves, nmoves);
        else nmoves = GenerateBlackCastle(board, poss_moves, nmoves);
    }
    return nmoves;
}
Beispiel #15
0
int main(void) {
	color_t color = Black;
	uint16_t pen = 0;

	halInit();
	chSysInit();

	gdispInit();
	ginputGetMouse(0);
	gdispSetOrientation(GDISP_ROTATE_90);

	drawScreen();

	while (TRUE) {
		ginputGetMouseStatus(0, &ev);
		if (!(ev.current_buttons & GINPUT_MOUSE_BTN_LEFT))
			continue;

		/* inside color box ? */
		if(ev.y >= OFFSET && ev.y <= COLOR_SIZE) {
			     if(GET_COLOR(0)) 	color = Black;
			else if(GET_COLOR(1))	color = Red;
			else if(GET_COLOR(2))	color = Yellow;
			else if(GET_COLOR(3))	color = Green;
			else if(GET_COLOR(4))	color = Blue;
			else if(GET_COLOR(5))	color = White;
		
		/* inside pen box ? */
		} else if(ev.x >= OFFSET && ev.x <= PEN_SIZE) {
			     if(GET_PEN(1))		pen = 0;
			else if(GET_PEN(2))		pen = 1;
			else if(GET_PEN(3))		pen = 2;
			else if(GET_PEN(4))		pen = 3;
			else if(GET_PEN(5))		pen = 4;		

		/* inside drawing area ? */
		} else if(DRAW_AREA(ev.x, ev.y)) {
			if(pen == 0)
				gdispDrawPixel(ev.x, ev.y, color);
			else
				gdispFillCircle(ev.x, ev.y, pen, color);
		}
	}
}
void PadConfiguration::drawMapping()
{
  TFTscreen.fillScreen(0);

  // Draw grid

  /*TFTscreen.drawFastHLine(0, 78, 160, 0xFFFF);
  TFTscreen.drawFastHLine(0, 103, 160, 0xFFFF);
  TFTscreen.drawFastVLine(40, 78, 50, 0xFFFF);
  TFTscreen.drawFastVLine(80, 78, 50, 0xFFFF);
  TFTscreen.drawFastVLine(120, 78, 50, 0xFFFF);*/

#define BUTTON_RADIUS 10
#define BUTTON1_X 60
#define BUTTON1_Y 90
#define BUTTON2_X (BUTTON1_X + 2 * BUTTON_RADIUS + 4)
#define BUTTON2_Y (BUTTON1_Y - BUTTON_RADIUS)
#define BUTTON3_X (BUTTON2_X + 2 * BUTTON_RADIUS + 4)
#define BUTTON3_Y (BUTTON2_Y - 0.5 * BUTTON_RADIUS)
#define BUTTON4_X (BUTTON3_X + 2 * BUTTON_RADIUS + 4)
#define BUTTON4_Y BUTTON3_Y
#define BUTTON5_X BUTTON1_X
#define BUTTON5_Y (BUTTON1_Y - 2 * BUTTON_RADIUS - 4)
#define BUTTON6_X BUTTON2_X
#define BUTTON6_Y (BUTTON2_Y - 2 * BUTTON_RADIUS - 4)
#define BUTTON7_X BUTTON3_X
#define BUTTON7_Y (BUTTON3_Y - 2 * BUTTON_RADIUS - 4)
#define BUTTON8_X BUTTON4_X
#define BUTTON8_Y (BUTTON4_Y - 2 * BUTTON_RADIUS - 4)
#define BUTTONSTART_X (BUTTON1_X - 3 * BUTTON_RADIUS)
#define BUTTONSTART_Y (BUTTON1_Y + 2 * BUTTON_RADIUS)
#define Y_OFFSET (-5)
#define ALT_Y_OFFSET 5

#define GET_STRING(i) (_mapping[i] ? _mapping[i]->mappingString() : String("-"))
#define GET_COLOR(i) (_mapping[i] ? _mapping[i]->mappingColor() : 0b1000010000010000)

  TFTscreen.drawCircle(BUTTON1_X, BUTTON1_Y, BUTTON_RADIUS, 0xFFFF);
  drawText(BUTTON1_X, BUTTON1_Y + Y_OFFSET, GET_STRING(BUTTON_1_INDEX), GET_COLOR(BUTTON_1_INDEX));
  drawText(BUTTON1_X, BUTTON1_Y + ALT_Y_OFFSET, GET_STRING(ALT_BUTTON_1_INDEX), GET_COLOR(ALT_BUTTON_1_INDEX));
  
  TFTscreen.drawCircle(BUTTON2_X, BUTTON2_Y, BUTTON_RADIUS, 0xFFFF);
  drawText(BUTTON2_X, BUTTON2_Y + Y_OFFSET, GET_STRING(BUTTON_2_INDEX), GET_COLOR(BUTTON_2_INDEX));
  drawText(BUTTON2_X, BUTTON2_Y + ALT_Y_OFFSET, GET_STRING(ALT_BUTTON_2_INDEX), GET_COLOR(ALT_BUTTON_2_INDEX));
  
  TFTscreen.drawCircle(BUTTON3_X, BUTTON3_Y, BUTTON_RADIUS, 0xFFFF);
  drawText(BUTTON3_X, BUTTON3_Y + Y_OFFSET, GET_STRING(BUTTON_3_INDEX), GET_COLOR(BUTTON_3_INDEX));
  drawText(BUTTON3_X, BUTTON3_Y + ALT_Y_OFFSET, GET_STRING(ALT_BUTTON_3_INDEX), GET_COLOR(ALT_BUTTON_3_INDEX));
  
  TFTscreen.drawCircle(BUTTON4_X, BUTTON4_Y, BUTTON_RADIUS, 0xFFFF);
  drawText(BUTTON4_X, BUTTON4_Y + Y_OFFSET, GET_STRING(BUTTON_4_INDEX), GET_COLOR(BUTTON_4_INDEX));
  drawText(BUTTON4_X, BUTTON4_Y + ALT_Y_OFFSET, GET_STRING(ALT_BUTTON_4_INDEX), GET_COLOR(ALT_BUTTON_4_INDEX));
  
  TFTscreen.drawCircle(BUTTON5_X, BUTTON5_Y, BUTTON_RADIUS, 0xFFFF);
  drawText(BUTTON5_X, BUTTON5_Y + Y_OFFSET, GET_STRING(BUTTON_5_INDEX), GET_COLOR(BUTTON_5_INDEX));
  drawText(BUTTON5_X, BUTTON5_Y + ALT_Y_OFFSET, GET_STRING(ALT_BUTTON_5_INDEX), GET_COLOR(ALT_BUTTON_5_INDEX));
  
  TFTscreen.drawCircle(BUTTON6_X, BUTTON6_Y, BUTTON_RADIUS, 0xFFFF);
  drawText(BUTTON6_X, BUTTON6_Y + Y_OFFSET, GET_STRING(BUTTON_6_INDEX), GET_COLOR(BUTTON_6_INDEX));
  drawText(BUTTON6_X, BUTTON6_Y + ALT_Y_OFFSET, GET_STRING(ALT_BUTTON_6_INDEX), GET_COLOR(ALT_BUTTON_6_INDEX));
  
  TFTscreen.drawCircle(BUTTON7_X, BUTTON7_Y, BUTTON_RADIUS, 0xFFFF);
  drawText(BUTTON7_X, BUTTON7_Y + Y_OFFSET, GET_STRING(BUTTON_7_INDEX), GET_COLOR(BUTTON_7_INDEX));
  drawText(BUTTON7_X, BUTTON7_Y + ALT_Y_OFFSET, GET_STRING(ALT_BUTTON_7_INDEX), GET_COLOR(ALT_BUTTON_7_INDEX));
  
  TFTscreen.drawCircle(BUTTON8_X, BUTTON8_Y, BUTTON_RADIUS, 0xFFFF);
  drawText(BUTTON8_X, BUTTON8_Y + Y_OFFSET, GET_STRING(BUTTON_8_INDEX), GET_COLOR(BUTTON_8_INDEX));
  drawText(BUTTON8_X, BUTTON8_Y + ALT_Y_OFFSET, GET_STRING(ALT_BUTTON_8_INDEX), GET_COLOR(ALT_BUTTON_8_INDEX));
  
  TFTscreen.drawCircle(BUTTONSTART_X, BUTTONSTART_Y, BUTTON_RADIUS, 0xFFFF);
  drawText(BUTTONSTART_X, BUTTONSTART_Y + Y_OFFSET, GET_STRING(BUTTON_START_INDEX), GET_COLOR(BUTTON_START_INDEX));
  drawText(BUTTONSTART_X, BUTTONSTART_Y + ALT_Y_OFFSET, GET_STRING(ALT_BUTTON_START_INDEX), GET_COLOR(ALT_BUTTON_START_INDEX));

#define STICK_X 36
#define STICK_Y 36
#define STICK_WIDTH 6
#define STICK_LENGTH 12

  TFTscreen.drawRect(STICK_X - STICK_LENGTH,
                     STICK_Y - STICK_WIDTH/2,
                     2 * STICK_LENGTH,
                     STICK_WIDTH,
                     0xFFFF);

  TFTscreen.drawRect(STICK_X - STICK_WIDTH/2,
                     STICK_Y - STICK_LENGTH,
                     STICK_WIDTH,
                     2 * STICK_LENGTH,
                     0xFFFF);

  drawText(STICK_X, STICK_Y - STICK_LENGTH - 5, _mapping[0]->mappingString(), _mapping[0]->mappingColor());
  drawText(STICK_X, STICK_Y + STICK_LENGTH + 5, _mapping[1]->mappingString(), _mapping[1]->mappingColor());
  drawText(STICK_X - STICK_LENGTH - 10, STICK_Y, _mapping[2]->mappingString(), _mapping[2]->mappingColor());
  drawText(STICK_X + STICK_LENGTH + 10, STICK_Y, _mapping[3]->mappingString(), _mapping[3]->mappingColor());

}
Beispiel #17
0
/*
 * Application entry point.
 */
int main(void) {
    color_t color = Black;
    uint16_t pen = 0;
    Thread *shelltp = NULL;

  /*
   * System initializations.
   * - HAL initialization, this also initializes the configured device drivers
   *   and performs the board-specific initializations.
   * - Kernel initialization, the main() function becomes a thread and the
   *   RTOS is active.
   */
    halInit();
    chSysInit();

    gdispInit();
    ginputGetMouse(0);
    gdispSetOrientation(GDISP_ROTATE_90);

    drawScreen();

  /*
   * Initializes a serial-over-USB CDC driver.
   */
  sduObjectInit(&SDU1);
  sduStart(&SDU1, &serusbcfg);

  /*
   * Activates the USB driver and then the USB bus pull-up on D+.
   * Note, a delay is inserted in order to not have to disconnect the cable
   * after a reset.
   */
  usbDisconnectBus(serusbcfg.usbp);
  chThdSleepMilliseconds(1000);
  usbStart(serusbcfg.usbp, &usbcfg);
  usbConnectBus(serusbcfg.usbp);

  /*
   * Shell manager initialization.
   */
  shellInit();

  /*
   * Creates the blinker thread.
   */
  chThdCreateStatic(waThread1, sizeof(waThread1), NORMALPRIO, Thread1, NULL);

  /*
   * Normal main() thread activity, in this demo it does nothing except
   * sleeping in a loop and check the button state.
   */
  while (TRUE) {
    if (!shelltp && (SDU1.config->usbp->state == USB_ACTIVE))
      shelltp = shellCreate(&shell_cfg1, SHELL_WA_SIZE, NORMALPRIO);
    else if (chThdTerminated(shelltp)) {
      chThdRelease(shelltp);    /* Recovers memory of the previous shell.   */
      shelltp = NULL;           /* Triggers spawning of a new shell.        */
    }

    ginputGetMouseStatus(0, &ev);
    if (!(ev.current_buttons & GINPUT_MOUSE_BTN_LEFT))
    {
        chThdSleepMicroseconds(500); // Senza questo sleep l'USB non parte
        continue;
    }

    /* inside color box ? */
    if(ev.y >= OFFSET && ev.y <= COLOR_SIZE) {
      if(GET_COLOR(0))   color = Black;
      else if(GET_COLOR(1))   color = Red;
      else if(GET_COLOR(2))   color = Yellow;
      else if(GET_COLOR(3))   color = Green;
      else if(GET_COLOR(4))   color = Blue;
      else if(GET_COLOR(5))   color = White;

    /* inside pen box ? */
    } else if(ev.x >= OFFSET && ev.x <= PEN_SIZE) {
      if(GET_PEN(1))             pen = 0;
      else if(GET_PEN(2))             pen = 1;
      else if(GET_PEN(3))             pen = 2;
      else if(GET_PEN(4))             pen = 3;
      else if(GET_PEN(5))             pen = 4;

    /* inside drawing area ? */
    } else if(DRAW_AREA(ev.x, ev.y)) {
      if(pen == 0)
         gdispDrawPixel(ev.x, ev.y, color);
      else
          gdispFillCircle(ev.x, ev.y, pen, color);
    }
  }
}
Beispiel #18
0
/*
 * Application entry point.
 */
int main(void) {
    color_t color = Black;
    uint16_t pen = 0;

  /*
   * System initializations.
   * - HAL initialization, this also initializes the configured device drivers
   *   and performs the board-specific initializations.
   * - Kernel initialization, the main() function becomes a thread and the
   *   RTOS is active.
   */
    halInit();
    chSysInit();

    gdispInit();
    ginputGetMouse(0);
    gdispSetOrientation(GDISP_ROTATE_90);

    drawScreen();
	
	palSetPadMode(GPIOC, 7, PAL_MODE_OUTPUT_PUSHPULL);
	palSetPadMode(GPIOC, 8, PAL_MODE_OUTPUT_PUSHPULL);
	palSetPadMode(GPIOC, 9, PAL_MODE_OUTPUT_PUSHPULL);

  /*
   * Creates the blinker thread.
   */
  (void)chThdCreateStatic(waThread1, sizeof(waThread1), NORMALPRIO, Thread1, NULL);
  
  while (TRUE) {

    ginputGetMouseStatus(0, &ev);
    if (!(ev.current_buttons & GINPUT_MOUSE_BTN_LEFT))
    {
        chThdSleepMicroseconds(500); // Senza questo sleep l'USB non parte
        continue;
    }

    /* inside color box ? */
    if(ev.y >= OFFSET && ev.y <= COLOR_SIZE) {
      if(GET_COLOR(0))   color = Black;
      else if(GET_COLOR(1))   color = Red;
      else if(GET_COLOR(2))   color = Yellow;
      else if(GET_COLOR(3))   color = Green;
      else if(GET_COLOR(4))   color = Blue;
      else if(GET_COLOR(5))   color = White;

    /* inside pen box ? */
    } else if(ev.x >= OFFSET && ev.x <= PEN_SIZE) {
      if(GET_PEN(1))             pen = 0;
      else if(GET_PEN(2))             pen = 1;
      else if(GET_PEN(3))             pen = 2;
      else if(GET_PEN(4))             pen = 3;
      else if(GET_PEN(5))             pen = 4;

    /* inside drawing area ? */
    } else if(DRAW_AREA(ev.x, ev.y)) {
      if(pen == 0)
         gdispDrawPixel(ev.x, ev.y, color);
      else
          gdispFillCircle(ev.x, ev.y, pen, color);
    }
  }
}