From 5db27f23fd55a8c7a3c303caced9922c79772cfc Mon Sep 17 00:00:00 2001 From: punkrockguy318 Date: Thu, 17 Jul 2008 04:39:28 +0000 Subject: [PATCH] code cleanup --- get_key/main.cpp | 67 ++++++++++++++++++++++++------------------------ 1 file changed, 34 insertions(+), 33 deletions(-) diff --git a/get_key/main.cpp b/get_key/main.cpp index c9a77845..bb52f03b 100644 --- a/get_key/main.cpp +++ b/get_key/main.cpp @@ -22,53 +22,54 @@ int main(int argc, char* argv[]) { // the caption doesn't set on intrepid // TODO: test on ubuntu 8.04 - SDL_WM_SetCaption("Press any key. . .", 0); + SDL_WM_SetCaption("Press any key. . .", 0); - SDL_Surface *screen; - SDL_Event event; + SDL_Surface *screen; + SDL_Event event; - // open any joysticks - for(int i = 0; i < SDL_NumJoysticks(); i++) - SDL_JoystickOpen(i); + // open any joysticks + for(int i = 0; i < SDL_NumJoysticks(); i++) + SDL_JoystickOpen(i); - if (!(screen = SDL_SetVideoMode(WIDTH, HEIGHT, DEPTH, SDL_SWSURFACE))) + if (!(screen = SDL_SetVideoMode(WIDTH, HEIGHT, DEPTH, SDL_SWSURFACE))) { SDL_Quit(); return 1; } - while(1) - { - while(SDL_PollEvent(&event)) - { - switch (event.type) - { - case SDL_QUIT: - return 0; + while(1) + { + while(SDL_PollEvent(&event)) + { + switch (event.type) + { + case SDL_QUIT: + return 0; // this code was modified from drivers/sdl/input.cpp in fceu so // that the same values will be written in the config as fceux --inputcfg - case SDL_KEYDOWN: - cout << "BUTTC_KEYBOARD" << endl; - cout << 0 << endl; - cout << event.key.keysym.sym << endl; - return 1; - case SDL_JOYBUTTONDOWN: + case SDL_KEYDOWN: + cout << "BUTTC_KEYBOARD" << endl; + cout << 0 << endl; + cout << event.key.keysym.sym << endl; + return 1; + case SDL_JOYBUTTONDOWN: + cout << "BUTTC_JOYSTICK" << endl; + cout << event.jbutton.which << endl; + cout << event.jbutton.button << endl; + return 1; + case SDL_JOYHATMOTION: + if(event.jhat.value != SDL_HAT_CENTERED) + { cout << "BUTTC_JOYSTICK" << endl; - cout << event.jbutton.which << endl; - cout << event.jbutton.button << endl; + cout << event.jhat.which << endl; + cout << (0x2000 | ((event.jhat.hat & 0x1F) << 8) | + event.jhat.value) << endl; return 1; - case SDL_JOYHATMOTION: - if(event.jhat.value != SDL_HAT_CENTERED) { - cout << "BUTTC_JOYSTICK" << endl; - cout << event.jhat.which << endl; - cout << (0x2000 | ((event.jhat.hat & 0x1F) << 8) | - event.jhat.value) << endl; - return 1; - } + } break; - } } - } + } + } return 0; }