기존 이솝 임베디드 포럼의 지식인 서비스가 게시판 형태로 변경되었습니다.

먹어야 정상인데요....음...

/* Simple program:  Loop, watching keystrokes
   Note that you need to call SDL_PollEvent() or SDL_WaitEvent() to
   pump the event loop and catch keystrokes.
*/


/*

SDL for arm920t가 /root/g2player/install 디렉토리에 설치되어 잇을 경우

arm_sa_le-gcc -I. -I/root/g2player/install/include/SDL -D_REENTRANT  -c ckkey.c
arm_sa_le-gcc -I/root/g2player/install/include/SDL -D_REENTRANT -o ckkey  ckkey.o  -L/root/g2player/install/lib -Wl,-rpath,/root/g2player/install/lib -lSDL -lpthread
cp -a ckkey /root/mmsp2nfs/root

한꺼번에
arm_sa_le-gcc -I. -I/root/g2player/install/include/SDL -D_REENTRANT  -c ckkey.c;arm_sa_le-gcc -I/root/g2player/install/include/SDL -D_REENTRANT -o ckkey  ckkey.o  -L/root/g2player/install/lib -Wl,-rpath,/root/g2player/install/lib -lSDL -lpthread;cp -a ckkey /root/mmsp2nfs/root
*/

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <SDL.h>

static void print_modifiers(void)
{
        int mod;
        printf(" modifiers:");
        mod = SDL_GetModState();
        if(!mod) {
                printf(" (none)");
                return;
        }
        if(mod & KMOD_LSHIFT)
                printf(" LSHIFT");
        if(mod & KMOD_RSHIFT)
                printf(" RSHIFT");
        if(mod & KMOD_LCTRL)
                printf(" LCTRL");
        if(mod & KMOD_RCTRL)
                printf(" RCTRL");
        if(mod & KMOD_LALT)
                printf(" LALT");
        if(mod & KMOD_RALT)
                printf(" RALT");
        if(mod & KMOD_LMETA)
                printf(" LMETA");
        if(mod & KMOD_RMETA)
                printf(" RMETA");
        if(mod & KMOD_NUM)
                printf(" NUM");
        if(mod & KMOD_CAPS)
                printf(" CAPS");
        if(mod & KMOD_MODE)
                printf(" MODE");
}

static void PrintKey(SDL_keysym *sym, int pressed)
{
        /* Print the keycode, name and state */
        if ( sym->sym ) {
                printf("Key %s:  %d-%s ", pressed ?  "pressed" : "released",
                                        sym->sym, SDL_GetKeyName(sym->sym));
        } else {
                printf("Unknown Key (scancode = %d) %s ", sym->scancode,
                                        pressed ?  "pressed" : "released");
        }

        /* Print the translated character, if one exists */
        if ( sym->unicode ) {
                /* Is it a control-character? */
                if ( sym->unicode < ' ' ) {
                        printf(" (^%c)", sym->unicode+'@');
                } else {
#ifdef UNICODE
                        printf(" (%c)", sym->unicode);
#else
                        /* This is a Latin-1 program, so only show 8-bits */
                        if ( !(sym->unicode & 0xFF00) )
                                printf(" (%c)", sym->unicode);
#endif
                }
        }
        print_modifiers();
        printf("n");
}

int main(int argc, char *argv[])
{
        SDL_Event event;
        int done;
        Uint32 videoflags;
        
        int flags;

    flags = SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_TIMER;
    flags |= SDL_INIT_EVENTTHREAD; /* Not supported on win32 */

        /* Initialize SDL */
        if ( SDL_Init(flags) < 0 ) {
                fprintf(stderr, "Couldn't initialize SDL: %sn",SDL_GetError());
                exit(1);
        }
        atexit(SDL_Quit);

        videoflags = SDL_SWSURFACE;
        while( argc > 1 ) {
                --argc;
                if ( argv[argc] && !strcmp(argv[argc], "-fullscreen") ) {
                        videoflags |= SDL_FULLSCREEN;
                } else {
                        fprintf(stderr, "Usage: %s [-fullscreen]n", argv[0]);
                        exit(1);
                }
        }

        /* Set 640x480 video mode */
        if ( SDL_SetVideoMode(480, 272, 0, videoflags) == NULL ) {
                fprintf(stderr, "Couldn't set 640x480 video mode: %sn",
                                                        SDL_GetError());
                exit(2);
        }

        /* Enable UNICODE translation for keyboard input */
        SDL_EnableUNICODE(1);

        /* Enable auto repeat for keyboard input */
        SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY,
                            SDL_DEFAULT_REPEAT_INTERVAL);

        /* Watch keystrokes */
        done = 0;
        while ( !done ) {
                /* Check for events */
                SDL_WaitEvent(&event);
                switch (event.type) {
                        case SDL_KEYDOWN:
                                PrintKey(&event.key.keysym, 1);
                                break;
                        case SDL_KEYUP:
                                PrintKey(&event.key.keysym, 0);
                                break;
                        case SDL_MOUSEBUTTONDOWN:
                                /* Any button press quits the app... */
                        case SDL_QUIT:
                                done = 1;
                                break;
                        default:
                                break;
                }
        }
        return(0);
}



이 소스를 가지고 테스트해보세요. 예전 1차보드때서부터 테스트 sw로 사용했던겁니다.

오용석

2006.05.30 07:21:38
*.82.97.213

고도리님~ 감사합니다.

테스트해 보려믄 부대 들어가야해서 아직 못해봤습니다.
지금 휴가중이거든요~

바로바로 답변 주셔서 너무 감사드립니다~ ^^
List of Articles
번호 제목 글쓴이 날짜sort 조회 수

커널 2.6.13 컴파일 할때요<--완료 [7]

[질문] jffs2 mount 에러 [2]

질문입니다.<--완료 [5]

무선랜 관련 에러 질문드립니다 <-[완료] [6]

[re] sdl key 버튼 안 먹네요... [1]

openssl 크로스 컴파일중에 대해 질문드립니다. <-- 완료 [4]

sdl key 버튼 안 먹네요...[완료] [3]

usb무선랜 관련 질문입니다<--완료 [2]

노트북에 사용할 USB to Parallel 포트 추천요 [2]

무선랜 올리신적 있지 않은가염..? <==완료 [1]

2440이 PLL을 세팅 못하고 죽어버리네요.. <<== 완료 [2]

[re] nand 제어부에 있는 NCON 핀 질문. [1]

nand 제어부에 있는 NCON 핀 질문. < 완료.

커널컴파일중 오류입니다. -> 완료 [6]

보드를 서버로 돌리려면..?<==ㄹ완료 [6]

QT문서 정리하면서 테스트하고있는데 또 안되는..ㅡ.ㅡ;이에러 좀 봐... [4]

ffplay sync 문제[미해결] [1]

올리신 Toolchain 으로 busybox 가 컴파일이 안돼네요. [5]

  • 임현
  • 2006-05-18
  • 조회 수 1200

Qtopia 2.1.1 ARM용으로 컴파일시 에러...ㅡ.ㅡ; <--[완료] [5]

커널 소스에 있는 드라이버에 대해서...<--완료 [1]

사용자 로그인