Mercurial > hg > old > magoroku_racing.bad
changeset 107:5d231c9754d1
change controler.cc
author | Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp> |
---|---|
date | Thu, 09 Jun 2011 00:09:57 +0900 |
parents | 0c4b7d74e292 |
children | 68e6cc686f48 |
files | TAGS controler.cc controler.h test_vector |
diffstat | 4 files changed, 684 insertions(+), 33 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/TAGS Thu Jun 09 00:09:57 2011 +0900 @@ -0,0 +1,498 @@ + +Magoroku.cc,815 +static int use_keybord 35,666 +static int i;37,745 +static int rswait 39,760 +static int cf 40,783 +static int cc 41,802 +static int test_mode 43,822 +static const char *test_object test_object44,848 +int runmode;68,1651 +SDL_Joystick *joy;joy70,1665 +const char *usr_help_str usr_help_str74,1687 +Viewer *droot;droot78,1873 +static int screen_w;80,1889 +static int screen_h;81,1913 +Magoroku::init(85,1998 +application(94,2138 +Magoroku::app_loop(109,2565 +static int gamef 115,2677 +Magoroku::application_task(119,2819 +task_init(135,3230 +TMmain(140,3252 +TMend(160,3586 +static int light_sysswitch 165,3645 +static int light_num 166,3677 +LightSysSwitch(169,3717 +dandy_main_init(186,4141 +dandy_main_loop(252,5664 +dandy_closing(311,6573 +gamesyokika(325,6831 +opening(367,7576 +game_pause(408,8460 + +camera.cc,138 +static CAMERA camera,13,214 +static CAMERA camera, def_camera;13,214 +camera_init(17,255 +void set_camera(53,1122 +camera_update(65,1465 + +car.cc,383 +#define DEFAULT_SET 15,233 +#define BUFSIZE 16,322 +static FVECTOR location 19,377 +static FVECTOR direction 20,418 +car_create(25,497 +car_new_readCSV(73,1792 +CarPtr car_init(115,2664 +car_swerve(136,3085 +car_accelerate(156,3636 +car_field_check(174,4241 +car_move(216,5306 +car_axis_rotation(232,5694 +void car_update(264,6592 +car_destroy(279,6825 +void car_id_update(296,7117 + +carNode.cc,99 +static CarPtr car_list;12,188 +carNode_append(15,218 +carNode_draw(29,389 +carNode_destroy(41,505 + +col.cc,90 +col_detect_approx(20,430 +col_orthocenter(46,1161 +col_detect(71,1818 +col_init(105,2584 + +controler.cc,42 +SGO_PAD pad;21,329 +bool padCheck(23,343 + +field.cc,419 +#define BUFSIZE 13,222 +static int field_num_max 18,287 +static int field_num 19,317 +static FieldPtr field_list;21,344 +static FieldPtr field_actual;22,372 +PolygonInfo xml_read_file(25,427 +field_create(35,553 +field_new_readCSV(82,1834 +field_init(151,3348 +field_draw(166,3622 +void field_update(178,3911 +field_destroy(212,4582 +field_rap_increment(243,5090 +field_set_actual(255,5242 +field_get_actual(261,5305 + +gFont.cc,647 +#define DEFOBJ 15,332 +#define SPRITE_COL 16,351 +#define SCREEN_HALF_W 17,375 +#define SCREEN_HALF_H 18,401 +#define CHAR_W_SIZE 19,427 +#define CHAR_H_SIZE 20,450 +static SpriteTable sptable[sptable22,474 +static ps2utilSprite sp[sp23,512 +static unsigned int sp_counter;24,587 +static bool flag_spriteInited 25,620 +static TEXTURE *font_tex;font_tex27,706 +gFont_Init_Png(30,745 +gFont_Create(48,1124 +gFont_DefSprite(66,1452 +gFont_Init(75,1622 +gFont_PutSprite(93,1890 +gFont_Clear(114,2369 +gFont_Draw_Reset(125,2502 +get_number_char(133,2601 +gFont_SetString(142,2696 +gFont_SetStringInt(158,2969 +gFont_SetFont_OP(167,3105 + +gSprite.cc,562 +#define DEFOBJ 8,123 +#define SPRITE_COL 9,142 +#define SCREEN_HALF_W 10,166 +#define SCREEN_HALF_H 11,192 +static SpriteTable sptable[sptable13,219 +static ps2utilSprite sp[sp14,257 +static unsigned int sp_counter;15,330 +static bool flag_spriteInited 16,363 +static TEXTURE *sprite_tex;sprite_tex18,449 +gSprite_DefSprite(22,484 +gSprite_PutSprite(31,664 +gSprite_PutSpriteEx(48,1140 +gSprite_Init_Png(66,1644 +gSprite_Create(85,2018 +gSprite_Init(104,2355 +gSprite_Clear(132,3412 +gSprite_Draw_Reset(145,3541 +gSprite_PutSprite_Pause(155,3634 + +game.cc,50 +#define linda_init 20,288 +void game_main(23,317 + +game_time.cc,169 +int game_time_get_msec(6,67 +int game_time_conv_ms2cs 29,516 +int game_time_conv_ms2sec 34,603 +int game_time_conv_ms2minute 39,672 +void game_time_set_raptime 56,1044 + +light.cc,187 +FMATRIX normal_light;9,124 +FMATRIX light_color;10,146 +void init_light(13,169 +void ps2_vu0_normal_light_matrix(60,1060 +void ps2_vu0_light_color_matrix(66,1190 +void set_light(71,1316 + +linda.cc,967 +static int my_id;18,343 +static CarPtr linda_carlist[linda_carlist19,361 +static int linda_seq[linda_seq20,404 +set_header(25,485 +get_header(35,658 +make_packet(49,879 +send_packet(71,1369 +get_packet(99,2012 +linda_set_schedule(119,2580 +static bool linda_sche_wait0(128,2777 +linda_sche_wait1(153,3304 +linda_sche_wait_ready0(168,3581 +linda_sche_wait_ready1(197,4119 +linda_sche_opening0(212,4392 +linda_sche_opening1(236,4874 +linda_sche_select_car0(251,5155 +linda_sche_select_car1(275,5649 +linda_sche_select_course0(290,5941 +linda_sche_select_course1(324,6648 +linda_sche_ready0(343,7031 +linda_sche_ready1(367,7506 +linda_sche_main_init(382,7780 +linda_sche_main_ready0(417,8526 +linda_sche_main_ready1(441,9001 +linda_sche_main(456,9265 +linda_update(502,10408 +linda_jiki_compareLocation(514,10583 +linda_jiki_compare(541,11108 +linda_jiki_update(555,11399 +linda_update(580,11965 +get_id(677,14415 +void linda_env_init(694,14743 +linda_init(706,14862 + +main.cc,39 +FILE *main_fp;main_fp6,79 +main(9,99 + +mytype.cc,139 +static clock_t start;10,137 +static clock_t race_start;11,159 +wait_init(14,192 +wait(24,315 +time_RaceStart(39,480 +time_RaceTime(45,533 + +name_dictionary.cc,307 +#define NAME_HASH_SIZE 6,80 +#define REHASH_NUM 7,131 +typedef struct name_dic 9,173 +} NAME_DIC;12,238 +static NAME_DIC *name_hash=name_hash14,251 +int hash_func(16,285 +const char *refer_name_dictionary(refer_name_dictionary32,541 +void delete_name_dictionary(62,1356 +int init_name_dictionary(87,1914 + +ps2util.cc,1294 +OBJECT *ps2util_obj_Create_fromXML(ps2util_obj_Create_fromXML16,366 +void ps2util_obj_Set_effect(33,645 +void ps2_vu0_copy_vector(39,767 +void ps2util_obj_Renew_transMatrix(45,889 +TEXTURE* read_png_file(53,987 +int ps2util_tex_Set(64,1159 +int ps2util_sprite_Create(69,1211 +void ps2util_obj_Set_texture(75,1296 +void ps2_vu0_unit_matrix(81,1426 +void ps2_vu0_rot_matrix_y(95,2019 +void ps2_vu0_apply_matrix(119,2653 +void ps2_vu0_scale_vector(128,3051 +void ps2_vu0_add_vector(138,3402 +void ps2_vu0_outer_product(148,3622 +float ps2_vu0_inner_product(157,3859 +void ps2_vu0_mul_matrix(163,3973 +void ps2_vu0_copy_matrix(187,5710 +void ps2util_obj_Free(192,5815 +void ps2_vu0_sub_vector(199,5870 +void ps2_vu0_normalize(209,6060 +void xml_free(220,6307 +void ps2util_obj_Draw(226,6353 +void ps2util_sprite_Destroy(232,6406 +void ps2util_sprite_Set_basicAttribute(240,6482 +void ps2util_sprite_Request(250,6788 +void ps2util_sprite_Unuse_alpha(256,6849 +void ps2util_graphic_Init(261,6914 +#define SPRITE_HAS_4VERTEXIS 270,7010 +#define PS2_GS_XYZ3 272,7042 +sprite_disappear(275,7134 +void free_texture(289,7461 +int malloc_align16(305,7793 +void ps2util_tex_Exclude(329,8321 +void ps2util_sprite_Draw(334,8394 +void ps2util_graphic_Finish(339,8463 +void ps2util_sprite_Use_alpha(346,8565 + +quotanion.cc,69 +quotanion(11,226 +quotanion_rotmatrix(25,529 +degree2radian(47,1167 + +schedule.cc,1007 +#define linda_update(31,521 +#define MAXCAR 34,575 +#define MAXFIELD 35,616 +#define MAXRAP 36,660 +#define SP_SEL_CAR 37,695 +#define SP_SEL_COURSE 38,720 +static int start_time,63,1507 +static int start_time,time_count;63,1507 +static int RUNNIG=64,1541 +char raptime[raptime65,1562 +static int ranking 67,1581 +static LIGHT l;68,1605 +static int i=69,1621 +static int change_state 73,1733 +set_schedule_assumption(79,1837 +unset_schedule(86,1953 +set_schedule(92,2007 +graphic_init(99,2105 +play_init(106,2248 +void linda_env_init(114,2402 +static void game_env_init 119,2465 +sche_game_init(136,2698 +sche_game_opening(191,3755 +sche_game_select_car(224,4276 +sche_game_select_course(255,4915 +sche_game_ready(286,5586 +sche_game_main_init(313,6202 +sche_game_main_ready(323,6353 +sche_game_main(330,6490 +sche_game_main_pause(396,8016 +sche_game_main_goal(430,8716 +sche_game_main_finish(460,9394 +sche_game_main_finish2(470,9553 +void wait_sync(482,9743 +void swap_dbuff(488,9813 +schedule(494,9869 + +sjoy.cc,437 +#define N_JOY 14,195 +static const char *g_devName[g_devName16,214 +static int g_fd[g_fd21,286 +int sjoy_open(29,527 +int sjoy_close(52,1101 +struct js_event68,1349 +int g_button[g_button75,1410 +int g_axis[g_axis76,1428 +#define JS_EVENT_INIT 78,1449 +#define JS_EVENT_BUTTON 79,1473 +#define JS_EVENT_AXIS 80,1499 +void sjoy_poll(85,1637 +int sjoy_get_button(119,2314 +int sjoy_get_axis(125,2445 +int sjoy_get_ps2_button(131,2588 + +test_vector.cc,157 +int main(16,358 +void init_FVECTOR(134,2887 +void init_FMATRIX(144,3081 +void output_FVECTOR(159,3395 +void output_FMATRIX(169,3558 +void all_init(184,3789 + +title_scene.cc,360 + TITLE_INIT,::TITLE_INIT10,123 + TITLE_MAIN,::TITLE_MAIN11,139 + TITLE_FINISH::TITLE_FINISH12,155 +} TITLE_STATE;13,172 +static ps2utilSprite title_sprite;15,188 +static TEXTURE *title_img;title_img17,224 +#define TITLE_IMG_FILE 19,252 +title_init(23,305 +title_init_call(44,735 +title_finish(50,786 +title_finish_call(58,919 +title_scene(64,966 + +Magoroku.h,121 +#define INCLUDE_MAGOROKU_H2,27 +class Magoroku 10,170 +typedef void (*move)move18,384 +typedef void (*coll)coll19,455 + +camera.h,74 +#define CAMERA_H2,17 +typedef struct camera{camera7,74 +} CAMERA;12,158 + +car.h,74 +#define CAR_H4,27 +typedef struct car 8,63 +} Car, *CarPtr;CarPtr21,460 + +carNode.h,23 +#define CARNODE_H2,18 + +col.h,157 +#define COL_H2,14 +typedef struct detection_face 8,72 +} ColFace, *ColFacePtr;ColFacePtr13,164 +typedef struct col_face_handler 15,189 +} ColFaceHd;19,285 + +controler.h,48 +typedef struct SGO_PAD 9,131 +} SGO_PAD;24,376 + +field.h,225 +#define FIELD_H2,16 +#define EFFECT_TEXTURE_USE 14,336 +#define EFFECT_ALPHABLEND_UNUSE 15,365 +#define EFFECT_SHADING_FLAT 16,399 +#define DEFAULT_SET 18,430 +typedef struct field 19,519 +} Field, *FieldPtr;FieldPtr27,705 + +gSprite.h,112 +#define GSPRITE_H2,18 +#define SPRITE_PRIO_FOREGROUND 5,81 +typedef struct sptable 7,115 +} SpriteTable;12,188 + +game.h,81 +#define GAME_H4,29 +typedef struct game 14,148 +} Game, *GamePtr;GamePtr21,332 + +libps2.h,360 +#define LIBPS2_H3,18 +typedef float FVECTOR[FVECTOR7,50 +typedef float FMATRIX[FMATRIX8,106 +typedef struct texture 13,195 +} TEXTURE;21,601 +typedef struct surface 25,648 +} SURFACE;34,1191 +typedef struct object 38,1244 +} OBJECT;45,1513 +} GsPrim;58,1690 +} GsSpritePacket;67,1810 +} SPRITE;79,2112 +typedef struct popygon 88,2208 +} PolygonInfo;91,2260 + +light.h,16 +} LIGHT;11,159 + +linda.h,723 +#define LINDA_H2,16 +#define MODE_INIT 21,547 +#define MODE_WAIT 22,579 +#define MODE_WAIT_READY 23,611 +#define MODE_OPENING 24,643 +#define MODE_SELECT_CAR 25,675 +#define MODE_SELECT_COURSE 26,707 +#define MODE_READY 27,739 +#define MODE_MAIN_INIT 28,771 +#define MODE_MAIN_READY 29,803 +#define MODE_MAIN 30,835 +#define MODE_MAIN_PAUSE 31,867 +#define MODE_MAIN_GOAL 32,899 +#define MODE_MAIN_FINISH 33,931 +#define MODE_FINISH 34,963 +#define PLAYER_1P 36,996 +#define CLIENT_MAX 38,1017 +#define LINDA_ASK_ID 39,1038 +#define LINDA_HOST 40,1065 +#define PKT_MODE_OFFSET 43,1117 +#define PKT_CARID_OFFSET 44,1148 +#define PKT_COURSEID_OFFSET 45,1179 +#define PKT_DATA_OFFSET 46,1210 +#define PKT_HEADER_SIZE 48,1242 + +mytype.h,211 +#define RADIAN(4,33 +#define INIT_VECTOR(5,68 +#define NORM(6,137 +enum { X_AXIS=8,215 +enum { X_AXIS=0, Y_AXIS=8,215 +enum { X_AXIS=0, Y_AXIS=1, Z_AXIS=8,215 +enum { X_AXIS=0, Y_AXIS=1, Z_AXIS=2, W_AXIS=8,215 + +name_dictionary.h,31 +#define NAME_DICTIONARY_H2,26 + +ps2util.h,142 +#define JOYPAD_1 4,48 +#define PS2UTIL_H8,87 +#define ALIGN_16BYTE 14,153 +typedef struct ps2sprite{ps2sprite28,427 +} ps2utilSprite;30,473 + +quotanion.h,25 +#define QUOTANION_H2,20 + +schedule.h,24 +#define SCHEDULE_H3,36 + +sjoy.h,681 +#define SJOY_PS2_R_LEFT 10,273 +#define SJOY_PS2_R_DOWN 11,309 +#define SJOY_PS2_R_UP 12,350 +#define SJOY_PS2_R_RIGHT 13,391 +#define SJOY_PS2_L1 14,432 +#define SJOY_PS2_R1 15,473 +#define SJOY_PS2_L2 16,514 +#define SJOY_PS2_R2 17,555 +#define SJOY_PS2_SELECT 18,596 +#define SJOY_PS2_START 19,637 +#define SJOY_PS2_L_LEFT 20,678 +#define SJOY_PS2_L_DOWN 21,720 +#define SJOY_PS2_L_UP 22,762 +#define SJOY_PS2_L_RIGHT 23,804 +#define SJOY_PS2_SQUARE 26,862 +#define SJOY_PS2_CROSS 27,898 +#define SJOY_PS2_TRIANGLE 28,939 +#define SJOY_PS2_CIRCLE 29,980 +#define SJOY_PS2_LEFT 30,1021 +#define SJOY_PS2_DOWN 31,1063 +#define SJOY_PS2_UP 32,1105 +#define SJOY_PS2_RIGHT 33,1147 + +sprite.h,508 +#define FRAME_ANGLE_NORMAL 1,0 +#define FRAME_ANGLE_REVERSE_HORIZON 2,39 +#define FRAME_ANGLE_REVERSE_VERTICAL 3,78 +#define FRAME_ANGLE_ROTATE_180 4,117 +#define UNVISIBLE 7,190 +#define VISIBLE 8,210 +typedef struct sprite_frame 11,237 +} SPRITE_FRAME;21,401 +typedef struct sprite_polygon 23,418 +} SPRITE_POLYGON;36,679 +typedef struct sprite_polygon_head 38,698 +} SPRITE_POLYGON_HEAD;44,897 +#define free_sprite_frame 49,1067 +} GsPrim;69,1649 +} GsSpritePacket;87,2043 +} SpritePacketHeader;102,2557 + +title_scene.h,0 + +game_time.h,0 + +gFont.h,0
--- a/controler.cc Wed Jun 08 13:16:25 2011 +0900 +++ b/controler.cc Thu Jun 09 00:09:57 2011 +0900 @@ -4,106 +4,229 @@ #include "ps2util.h" #include "controler.h" #include <stdbool.h> +#include <SDL.h> + +#include "matrix_calc.h" +#include "TaskManager.h" +#include "SceneGraph.h" +#include "Application.h" #include "sjoy.h" // ps2関連ファイルから -// 使っていないっぽい? どこで宣言してるかわからない -/* -#ifdef DEMO_CREATE -qextern void setPadValue(int pad); -#endif -extern int getPadValue(); -*/ - +struct SGO_PAD pad; -SGO_PAD pad; - -bool padCheck() { +/* + SgoexCerium をみながら、改変。 + 引数を追加して、変数名以外の書き方を似せた +*/ +bool pad(SDL_Joystick *joy) { - int pad1; + SDL_JoystickUpdate(); - pad1 = sjoy_get_ps2_button( JOYPAD_1 ); - - if (pad1 & SJOY_PS2_START) { + if (SDL_JoystickGetButton(joy,PS2_START)==SDL_PRESSED) { pad.st += (pad.st < 2) ? 1 : 0; } else { pad.st = 0; } - if (pad1 & SJOY_PS2_SELECT) { + if (SDL_JoystickGetButton(joy,PS2_SELECT)==SDL_PRESSED) { pad.se += (pad.se < 2) ? 1 : 0; } else { pad.se = 0; } - if (pad1 & SJOY_PS2_LEFT) { + if (SDL_JoystickGetButton(joy,PS2_LEFT)==SDL_PRESSED) { pad.left += (pad.left < 2) ? 1 : 0; } else { pad.left = 0; } - if (pad1 & SJOY_PS2_RIGHT) { + if (SDL_JoystickGetButton(joy,PS2_RIGHT)==SDL_PRESSED) { pad.right += (pad.right < 2) ? 1 : 0; } else { pad.right = 0; } - if (pad1 & SJOY_PS2_UP) { + if (SDL_JoystickGetButton(joy,PS2_UP)==SDL_PRESSED) { pad.up += (pad.up < 2) ? 1 : 0; } else { pad.up = 0; } - if (pad1 & SJOY_PS2_DOWN) { + if (SDL_JoystickGetButton(joy,PS2_DOWN)==SDL_PRESSED) { pad.down += (pad.down < 2) ? 1 : 0; } else { pad.down = 0; } - if (pad1 & SJOY_PS2_R1) { + if (SDL_JoystickGetButton(joy,PS2_R1)==SDL_PRESSED) { pad.r1 += (pad.r1 < 2) ? 1 : 0; } else { pad.r1 = 0; } - if (pad1 & SJOY_PS2_R2) { + if (SDL_JoystickGetButton(joy,PS2_R2)==SDL_PRESSED) { pad.r2 += (pad.r2 < 2) ? 1 : 0; } else { pad.r2 = 0; } - if (pad1 & SJOY_PS2_L1) { + if (SDL_JoystickGetButton(joy,PS2_L1)==SDL_PRESSED) { pad.l1 += (pad.l1 < 2) ? 1 : 0; } else { pad.l1 = 0; } - if (pad1 & SJOY_PS2_L2) { + if (SDL_JoystickGetButton(joy,PS2_L2)==SDL_PRESSED) { pad.l2 += (pad.l2 < 2) ? 1 : 0; } else { pad.l2 = 0; } - if (pad1 & SJOY_PS2_CROSS) { + if (SDL_JoystickGetButton(joy,PS2_CROSS)==SDL_PRESSED) { pad.cross += (pad.cross < 2) ? 1 : 0; } else { pad.cross = 0; } - if (pad1 & SJOY_PS2_CIRCLE) { + if (SDL_JoystickGetButton(joy,PS2_CIRCLE)==SDL_PRESSED) { pad.circle += (pad.circle < 2) ? 1 : 0; } else { pad.circle = 0; } - if (pad1 & SJOY_PS2_TRIANGLE) { + if (SDL_JoystickGetButton(joy,PS2_TRIANGLE)==SDL_PRESSED) { pad.triangle += (pad.triangle < 2) ? 1 : 0; } else { pad.triangle = 0; } - if (pad1 & SJOY_PS2_SQUARE) { + if (SDL_JoystickGetButton(joy,PS2_SQUARE)==SDL_PRESSED) { pad.square += (pad.square < 2) ? 1 : 0; } else { pad.square = 0; } - if ( (pad1 & SJOY_PS2_SELECT) && (pad1 & SJOY_PS2_START) && - (pad1 & SJOY_PS2_L1) && (pad1 & SJOY_PS2_R1) && - (pad1 & SJOY_PS2_L2) && (pad1 & SJOY_PS2_R2)) { + if ( (SDL_JoystickGetButton(joy,PS2_SELECT)==SDL_PRESSED) + && (SDL_JoystickGetButton(joy,PS2_START)==SDL_PRESSED) + && (SDL_JoystickGetButton(joy,PS2_L1)==SDL_PRESSED) + && (SDL_JoystickGetButton(joy,PS2_R1)==SDL_PRESSED) + && (SDL_JoystickGetButton(joy,PS2_L2)==SDL_PRESSED) + && (SDL_JoystickGetButton(joy,PS2_R2)==SDL_PRESSED) + { return false; } return true; } + + +bool keybord() +{ + SDL_PumpEvents(); + Uint8 *keys = SDL_GetKeyState(NULL); + + if (keys[SDLK_UP]) { + pad.up += (pad.up < 2) ? 1 : 0; + } else { + pad.up = 0; + } + if (keys[SDLK_DOWN]) { + pad.down += (pad.down < 2) ? 1 : 0; + } else { + pad.down = 0; + } + + if (keys[SDLK_RIGHT]) { + pad.right += (pad.right < 2) ? 1 : 0; + } else { + pad.right = 0; + } + + if (keys[SDLK_LEFT]) { + pad.left += (pad.left < 2) ? 1 : 0; + } else { + pad.left = 0; + } + + if (keys[SDLK_a]) { + pad.cross += (pad.cross < 2) ? 1 : 0; + } else { + pad.cross = 0; + } + + if (keys[SDLK_z]) { + pad.circle += (pad.circle < 2) ? 1 : 0; + } else { + pad.circle = 0; + } + + if (keys[SDLK_s]) { + pad.square += (pad.square < 2) ? 1 : 0; + } else { + pad.square = 0; + } + + if (keys[SDLK_x]) { + pad.triangle += (pad.triangle < 2) ? 1 : 0; + } else { + pad.triangle = 0; + } + + if (keys[SDLK_r]) { + pad.r2 += (pad.r2 < 2) ? 1 : 0; + } else { + pad.r2 = 0; + } + + if (keys[SDLK_e]) { + pad.r1 += (pad.r1 < 2) ? 1 : 0; + } else { + pad.r1 = 0; + } + + if (keys[SDLK_w]) { + pad.l1 += (pad.l1 < 2) ? 1 : 0; + } else { + pad.l1 = 0; + } + + if (keys[SDLK_q]) { + pad.l1 += (pad.l2 < 2) ? 1 : 0; + } else { + pad.l2 = 0; + } + + // START ボタンは Return が似合う気がする + //if(keys[SDLK_1]) + if (keys[SDLK_RETURN]) { + pad.st += (pad.st < 2) ? 1 : 0; + } else { + pad.st = 0; + } + + if (keys[SDLK_2]) { + pad.se += (pad.se < 2) ? 1 : 0; + } else { + pad.se = 0; + } + + if (keys[SDLK_ESCAPE]) { + SDL_Quit(); + exit(1); + //pad[0].st = 1; + //pad[0].se = 1; + } + + if (keys[SDLK_0]) { + pad[0].quit = 1; + } else { + pad[0].quit = 0; + } + + //SELECT, START, L1, R1, L2, R2 + { + if ( (keys[SDLK_2]) + && (keys[SDLK_RETURN]) + && (keys[SDLK_w]) + && (keys[SDLK_e]) + && (keys[SDLK_q]) + && (keys[SDLK_r]) + { + return false; + } + + return true; +} +
--- a/controler.h Wed Jun 08 13:16:25 2011 +0900 +++ b/controler.h Thu Jun 09 00:09:57 2011 +0900 @@ -1,3 +1,27 @@ +#ifndef CONTROLER_H +#define CONTROLER_H + +/*PS2_PAD*/ +#define PS2_CROSS 0 +#define PS2_CIRCLE 1 +#define PS2_SQUARE 2 +#define PS2_TRIANGLE 3 + +#define PS2_L1 4 +#define PS2_R1 5 +#define PS2_L2 6 +#define PS2_R2 7 +#define PS2_START 8 +#define PS2_SELECT 9 +#define PS2_L3 10 +#define PS2_R3 11 + +#define PS2_LEFT 12 +#define PS2_RIGHT 13 +#define PS2_UP 14 +#define PS2_DOWN 15 + + /* * チャタリング防止 * value = 0: 押してない @@ -23,6 +47,12 @@ short square; } SGO_PAD; -//extern SGO_PAD pad; + + +extern struct SGO_PAD pad; -bool padCheck( void ); +//padCheck を rename +extern bool pad(SDL_Joystick *joy);; +extern bool keybord( void ); + +#endif