- 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;
This commit is contained in:
parent
c950ca35d8
commit
7ee96932df
|
@ -14,9 +14,6 @@
|
||||||
#include "../sndsdl.h"
|
#include "../sndsdl.h"
|
||||||
#include "../ctrlssdl.h"
|
#include "../ctrlssdl.h"
|
||||||
|
|
||||||
#define DESMUME_NB_KEYS 13
|
|
||||||
#define DESMUME_KEYMASK_(k) (1 << k)
|
|
||||||
|
|
||||||
volatile BOOL execute = FALSE;
|
volatile BOOL execute = FALSE;
|
||||||
|
|
||||||
SDL_Surface * surface;
|
SDL_Surface * surface;
|
||||||
|
@ -28,7 +25,7 @@ SoundInterface_struct *SNDCoreList[] = {
|
||||||
NULL
|
NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
const u16 Default_Joypad_Config[DESMUME_NB_KEYS] =
|
const u16 Default_Joypad_Config[NB_KEYS] =
|
||||||
{ 1, // A
|
{ 1, // A
|
||||||
0, // B
|
0, // B
|
||||||
5, // select
|
5, // select
|
||||||
|
@ -41,6 +38,7 @@ const u16 Default_Joypad_Config[DESMUME_NB_KEYS] =
|
||||||
6, // L
|
6, // L
|
||||||
3, // Y
|
3, // Y
|
||||||
4, // X
|
4, // X
|
||||||
|
-1, // BOOST
|
||||||
-1 // DEBUG
|
-1 // DEBUG
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -102,11 +100,11 @@ int main(int argc, char ** argv) {
|
||||||
/* Look for queued events and update keypad status */
|
/* Look for queued events and update keypad status */
|
||||||
keypad = process_ctrls_events(keypad);
|
keypad = process_ctrls_events(keypad);
|
||||||
/* Update mouse position and click */
|
/* Update mouse position and click */
|
||||||
if(mouse_down) NDS_setTouchPos(mouse_pos.x, mouse_pos.y);
|
if(mouse.down) NDS_setTouchPos(mouse.x, mouse.y);
|
||||||
if(mouse_click)
|
if(mouse.click)
|
||||||
{
|
{
|
||||||
NDS_releasTouch();
|
NDS_releasTouch();
|
||||||
mouse_click = FALSE;
|
mouse.click = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Update keypad */
|
/* Update keypad */
|
||||||
|
|
|
@ -64,24 +64,22 @@ u16 inline lookup_joykey (u16 keyval) {
|
||||||
u16 Key = 0;
|
u16 Key = 0;
|
||||||
for(i = 0; i < NB_KEYS; i++)
|
for(i = 0; i < NB_KEYS; i++)
|
||||||
if(keyval == joypadCfg[i]) break;
|
if(keyval == joypadCfg[i]) break;
|
||||||
if(i < NB_KEYS)
|
if(i < NB_KEYS) Key = KEYMASK_(i);
|
||||||
Key = KEYMASK_(i);
|
|
||||||
printf("Lookup key %d from joypad...%x\n", keyval, Key);
|
|
||||||
return Key;
|
return Key;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef GTK_UI
|
#ifndef GTK_UI
|
||||||
/* Set mouse coordinates */
|
/* 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(x<0) x = 0; else if(x>255) x = 255;
|
||||||
if(y<0) y = 0; else if(y>192) y = 192;
|
if(y<0) y = 0; else if(y>192) y = 192;
|
||||||
mouse_pos.x = x;
|
mouse.x = x;
|
||||||
mouse_pos.y = y;
|
mouse.y = y;
|
||||||
}
|
}
|
||||||
#endif
|
#endif // !GTK_UI
|
||||||
|
|
||||||
/* Manage joystick events */
|
/* Manage input events */
|
||||||
u16 process_ctrls_events(u16 keypad)
|
u16 process_ctrls_events(u16 keypad)
|
||||||
{
|
{
|
||||||
u16 key;
|
u16 key;
|
||||||
|
@ -174,25 +172,25 @@ u16 process_ctrls_events(u16 keypad)
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SDL_MOUSEBUTTONDOWN: // Un bouton fut appuyé
|
case SDL_MOUSEBUTTONDOWN:
|
||||||
if(event.button.button==1)
|
if(event.button.button==1)
|
||||||
mouse_down = TRUE;
|
mouse.down = TRUE;
|
||||||
|
|
||||||
case SDL_MOUSEMOTION: // La souris a été déplacée sur l?écran
|
case SDL_MOUSEMOTION:
|
||||||
if(!mouse_down) break;
|
if(!mouse.down) break;
|
||||||
if(event.button.y>=192)
|
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;
|
break;
|
||||||
|
|
||||||
case SDL_MOUSEBUTTONUP: // Le bouton de la souris a été relaché
|
case SDL_MOUSEBUTTONUP:
|
||||||
if(mouse_down) mouse_click = TRUE;
|
if(mouse.down) mouse.click = TRUE;
|
||||||
mouse_down = FALSE;
|
mouse.down = FALSE;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SDL_QUIT:
|
case SDL_QUIT:
|
||||||
sdl_quit = TRUE;
|
sdl_quit = TRUE;
|
||||||
break;
|
break;
|
||||||
#endif // GTK_UI
|
#endif // !GTK_UI
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -40,20 +40,20 @@
|
||||||
u16 joypadCfg[NB_KEYS];
|
u16 joypadCfg[NB_KEYS];
|
||||||
|
|
||||||
#ifndef GTK_UI
|
#ifndef GTK_UI
|
||||||
struct pos
|
struct mouse_status
|
||||||
{
|
{
|
||||||
signed long x;
|
signed long x;
|
||||||
signed long y;
|
signed long y;
|
||||||
|
BOOL click;
|
||||||
|
BOOL down;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct pos mouse_pos;
|
struct mouse_status mouse;
|
||||||
|
|
||||||
BOOL sdl_quit;
|
BOOL sdl_quit;
|
||||||
BOOL mouse_click;
|
|
||||||
BOOL mouse_down;
|
|
||||||
|
|
||||||
void mouse_set_coord(signed long x,signed long y);
|
void set_mouse_coord(signed long x,signed long y);
|
||||||
#endif
|
#endif // !GTK_UI
|
||||||
|
|
||||||
BOOL init_joy(u16 joyCfg[]);
|
BOOL init_joy(u16 joyCfg[]);
|
||||||
void uninit_joy();
|
void uninit_joy();
|
||||||
|
|
Loading…
Reference in New Issue