[Armadeus-commitlog] SF.net SVN: armadeus: [812] trunk/target/demos
Brought to you by:
sszy
|
From: <ar...@us...> - 2008-05-21 20:51:38
|
Revision: 812
http://armadeus.svn.sourceforge.net/armadeus/?rev=812&view=rev
Author: artemys
Date: 2008-05-21 13:51:34 -0700 (Wed, 21 May 2008)
Log Message:
-----------
[TARGET] Add a small userspace tool to test keypad driver
Added Paths:
-----------
trunk/target/demos/keypad_test/
trunk/target/demos/keypad_test/Makefile
trunk/target/demos/keypad_test/README
trunk/target/demos/keypad_test/keypad.c
Added: trunk/target/demos/keypad_test/Makefile
===================================================================
--- trunk/target/demos/keypad_test/Makefile (rev 0)
+++ trunk/target/demos/keypad_test/Makefile 2008-05-21 20:51:34 UTC (rev 812)
@@ -0,0 +1,44 @@
+
+ifeq ($(TARGET),)
+ BUILDROOT_DIR:=../../../buildroot/
+ BUILD_DIR_EXT:=$(shell ls $(BUILDROOT_DIR) | grep -e "^build_arm*")
+ BUILD_DIR:=$(BUILDROOT_DIR)/$(BUILD_DIR_EXT)
+
+ SDL_DIR:=$(BUILD_DIR)/SDL-1.2.11/
+ STAGING_DIR:=$(BUILD_DIR)/staging_dir/
+ ROOT_DIR:=$(BUILDROOT_DIR)/project_$(BUILD_DIR_EXT)/armadeus/root/
+ INSTALL_DIR:=$(ROOT_DIR)/usr/bin/
+
+ CC:=$(STAGING_DIR)/bin/arm-linux-gcc
+ DEFINES="TARGET"
+ CFLAGS:=$(shell STAGING_DIR=$(STAGING_DIR) sh $(SDL_DIR)/sdl-config --cflags)
+ LIBS:=$(shell STAGING_DIR=$(STAGING_DIR) sh $(SDL_DIR)/sdl-config --libs)
+else
+ INSTALL_DIR="./install"
+ CFLAGS=`/usr/bin/sdl-config --cflags`
+ LIBS=`/usr/bin/sdl-config --libs`
+ CC=gcc
+ DEFINES="HOST"
+endif
+
+CFLAGS+="-g"
+
+default: keypad_test
+
+all: keypad_test
+
+
+keypad.o: keypad.c
+ $(CC) $(CFLAGS) -c -o $@ $^
+
+keypad_test: keypad.o
+ $(CC) $(LIBS) -o $@ $^
+
+install: keypad_test
+ mkdir -p $(INSTALL_DIR)
+ cp $^ $(INSTALL_DIR)
+
+clean:
+ rm -rf keypad_test
+ rm -rf *.o
+
Added: trunk/target/demos/keypad_test/README
===================================================================
--- trunk/target/demos/keypad_test/README (rev 0)
+++ trunk/target/demos/keypad_test/README 2008-05-21 20:51:34 UTC (rev 812)
@@ -0,0 +1,6 @@
+
+* ARM compiling:
+ $ make clean; make install
+* x86 compiling (SDL devt package should be installed on your system)
+ $ make TARGET=x86 clean; make TARGET=x86
+
Added: trunk/target/demos/keypad_test/keypad.c
===================================================================
--- trunk/target/demos/keypad_test/keypad.c (rev 0)
+++ trunk/target/demos/keypad_test/keypad.c 2008-05-21 20:51:34 UTC (rev 812)
@@ -0,0 +1,107 @@
+/*
+ * Small tool to test keypad (with the use of SDL library)
+ * for the Armadeus project. www.armadeus.org
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h> // for sleep()
+
+#include "SDL.h"
+
+#define SCREEN_WIDTH 480
+#define SCREEN_HEIGHT 270
+
+#ifdef DEBUG
+#define debug( args...) printf( ## args )
+#else
+#define debug( args...) do {;} while(0);
+#endif
+
+#define bool unsigned int
+#define false 0
+#define true 1
+
+SDL_Surface *screen;
+
+
+//---- Main ----
+
+int main(int argc, char *argv[])
+{
+ Uint8* keys;
+ int nbFrames = 0;
+ int cursorPos = 0;
+
+ // Initialize SDL
+ if( SDL_Init( SDL_INIT_VIDEO | SDL_INIT_TIMER /*| SDL_INIT_EVENTTHREAD |SDL_INIT_NOPARACHUTE*/) < 0 )
+ {
+ printf("Unable to init SDL: %s\n", SDL_GetError());
+ exit(1);
+ }
+ // Ask SDL to cleanup when exiting
+ atexit(SDL_Quit);
+
+ // Get a screen to display some stuff
+ screen=SDL_SetVideoMode( SCREEN_WIDTH, SCREEN_HEIGHT, 16, 0/*SDL_HWPALETTE*//*SDL_HWSURFACE|| SDL_DOUBLEBUF*/ );
+ if( screen == NULL )
+ {
+ printf("Unable to set %dx%dvideo mode: %s\n", SCREEN_WIDTH, SCREEN_HEIGHT, SDL_GetError());
+ exit(1);
+ }
+
+ int done=0, move=0;
+
+ // Hide mouse
+ SDL_ShowCursor(0);
+
+ // Main loop
+ while(done == 0)
+ {
+ SDL_Event event;
+ // Wait for SDL events
+ while ( SDL_PollEvent(&event) )
+ {
+ cursorPos = 0;
+ switch( event.type )
+ {
+ case SDL_QUIT: { done = 1; break; }
+
+ case SDL_KEYDOWN:
+ {
+ //if ( event.key.keysym.sym == SDLK_ESCAPE ) { done = 1; }
+ printf("Key down: %s\n", SDL_GetKeyName(event.key.keysym.sym));
+ break;
+ }
+
+ case SDL_KEYUP:
+ {
+ //if ( event.key.keysym.sym == SDLK_ESCAPE ) { done = 1; }
+ printf("Key up: %s\n", SDL_GetKeyName(event.key.keysym.sym));
+ break;
+ }
+
+ default:
+ break;
+ }
+ }
+
+ SDL_Delay(50);
+ }
+
+ return 0;
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|