From 7ee96932dfdf8655eaf7d9e8f7e4cec6e45c6d15 Mon Sep 17 00:00:00 2001 From: evilynux Date: Wed, 10 Jan 2007 17:29:47 +0000 Subject: [PATCH] - Removed joypad debug message; - Renamed mouse_set_coord() to set_mouse_coord() for naming consistency; - Added mouse_status structure to handle all mouse informations; - Clarified some #endif for easier reading; - Removed some french comments; Only in src/cli/main.c: - Removed 2 useless #define; --- desmume/src/cli/main.c | 12 +++++------- desmume/src/ctrlssdl.c | 32 +++++++++++++++----------------- desmume/src/ctrlssdl.h | 12 ++++++------ 3 files changed, 26 insertions(+), 30 deletions(-) diff --git a/desmume/src/cli/main.c b/desmume/src/cli/main.c index f9f5f01d8..f5d89d0dd 100644 --- a/desmume/src/cli/main.c +++ b/desmume/src/cli/main.c @@ -14,9 +14,6 @@ #include "../sndsdl.h" #include "../ctrlssdl.h" -#define DESMUME_NB_KEYS 13 -#define DESMUME_KEYMASK_(k) (1 << k) - volatile BOOL execute = FALSE; SDL_Surface * surface; @@ -28,7 +25,7 @@ SoundInterface_struct *SNDCoreList[] = { NULL }; -const u16 Default_Joypad_Config[DESMUME_NB_KEYS] = +const u16 Default_Joypad_Config[NB_KEYS] = { 1, // A 0, // B 5, // select @@ -41,6 +38,7 @@ const u16 Default_Joypad_Config[DESMUME_NB_KEYS] = 6, // L 3, // Y 4, // X + -1, // BOOST -1 // DEBUG }; @@ -102,11 +100,11 @@ int main(int argc, char ** argv) { /* Look for queued events and update keypad status */ keypad = process_ctrls_events(keypad); /* Update mouse position and click */ - if(mouse_down) NDS_setTouchPos(mouse_pos.x, mouse_pos.y); - if(mouse_click) + if(mouse.down) NDS_setTouchPos(mouse.x, mouse.y); + if(mouse.click) { NDS_releasTouch(); - mouse_click = FALSE; + mouse.click = FALSE; } /* Update keypad */ diff --git a/desmume/src/ctrlssdl.c b/desmume/src/ctrlssdl.c index 2c2727be6..fc4005e32 100644 --- a/desmume/src/ctrlssdl.c +++ b/desmume/src/ctrlssdl.c @@ -64,24 +64,22 @@ u16 inline lookup_joykey (u16 keyval) { u16 Key = 0; for(i = 0; i < NB_KEYS; i++) if(keyval == joypadCfg[i]) break; - if(i < NB_KEYS) - Key = KEYMASK_(i); - printf("Lookup key %d from joypad...%x\n", keyval, Key); + if(i < NB_KEYS) Key = KEYMASK_(i); return Key; } #ifndef GTK_UI /* Set mouse coordinates */ -void mouse_set_coord(signed long x,signed long y) +void set_mouse_coord(signed long x,signed long y) { if(x<0) x = 0; else if(x>255) x = 255; if(y<0) y = 0; else if(y>192) y = 192; - mouse_pos.x = x; - mouse_pos.y = y; + mouse.x = x; + mouse.y = y; } -#endif +#endif // !GTK_UI -/* Manage joystick events */ +/* Manage input events */ u16 process_ctrls_events(u16 keypad) { u16 key; @@ -174,25 +172,25 @@ u16 process_ctrls_events(u16 keypad) } break; - case SDL_MOUSEBUTTONDOWN: // Un bouton fut appuyé + case SDL_MOUSEBUTTONDOWN: if(event.button.button==1) - mouse_down = TRUE; + mouse.down = TRUE; - case SDL_MOUSEMOTION: // La souris a été déplacée sur l?écran - if(!mouse_down) break; + case SDL_MOUSEMOTION: + if(!mouse.down) break; if(event.button.y>=192) - mouse_set_coord(event.button.x, event.button.y - 192); + set_mouse_coord(event.button.x, event.button.y - 192); break; - case SDL_MOUSEBUTTONUP: // Le bouton de la souris a été relaché - if(mouse_down) mouse_click = TRUE; - mouse_down = FALSE; + case SDL_MOUSEBUTTONUP: + if(mouse.down) mouse.click = TRUE; + mouse.down = FALSE; break; case SDL_QUIT: sdl_quit = TRUE; break; -#endif // GTK_UI +#endif // !GTK_UI default: break; diff --git a/desmume/src/ctrlssdl.h b/desmume/src/ctrlssdl.h index 1c57ad6f0..32e366fad 100644 --- a/desmume/src/ctrlssdl.h +++ b/desmume/src/ctrlssdl.h @@ -40,20 +40,20 @@ u16 joypadCfg[NB_KEYS]; #ifndef GTK_UI -struct pos +struct mouse_status { signed long x; signed long y; + BOOL click; + BOOL down; }; -struct pos mouse_pos; +struct mouse_status mouse; BOOL sdl_quit; -BOOL mouse_click; -BOOL mouse_down; -void mouse_set_coord(signed long x,signed long y); -#endif +void set_mouse_coord(signed long x,signed long y); +#endif // !GTK_UI BOOL init_joy(u16 joyCfg[]); void uninit_joy();