diff options
author | Aun-Ali Zaidi <admin@kodeit.net> | 2015-12-10 18:29:55 -0600 |
---|---|---|
committer | Gedare Bloom <gedare@rtems.org> | 2015-12-11 09:20:34 -0500 |
commit | 32c2cd2be1067ebe32cdabccbc8aa16126ae3a32 (patch) | |
tree | 7c4e2f70630f4849308cf2cfe22a796098188e54 /c/src/lib/libbsp/arm/nds/touchscreen | |
parent | score: Untangle thread actions (diff) | |
download | rtems-32c2cd2be1067ebe32cdabccbc8aa16126ae3a32.tar.bz2 |
arm/nds: Remove
updates #2450.
Diffstat (limited to 'c/src/lib/libbsp/arm/nds/touchscreen')
-rw-r--r-- | c/src/lib/libbsp/arm/nds/touchscreen/README.reco | 3 | ||||
-rw-r--r-- | c/src/lib/libbsp/arm/nds/touchscreen/parser.c | 205 | ||||
-rw-r--r-- | c/src/lib/libbsp/arm/nds/touchscreen/reco.c | 245 | ||||
-rw-r--r-- | c/src/lib/libbsp/arm/nds/touchscreen/reco.h | 137 | ||||
-rw-r--r-- | c/src/lib/libbsp/arm/nds/touchscreen/touchscreen.c | 133 | ||||
-rw-r--r-- | c/src/lib/libbsp/arm/nds/touchscreen/touchscreen.h | 60 |
6 files changed, 0 insertions, 783 deletions
diff --git a/c/src/lib/libbsp/arm/nds/touchscreen/README.reco b/c/src/lib/libbsp/arm/nds/touchscreen/README.reco deleted file mode 100644 index 6a1a0b30e1..0000000000 --- a/c/src/lib/libbsp/arm/nds/touchscreen/README.reco +++ /dev/null @@ -1,3 +0,0 @@ -Files reco.c and reco.h come from PALib. - -Visit http://www.palib.info/ for more information. diff --git a/c/src/lib/libbsp/arm/nds/touchscreen/parser.c b/c/src/lib/libbsp/arm/nds/touchscreen/parser.c deleted file mode 100644 index b103c615d1..0000000000 --- a/c/src/lib/libbsp/arm/nds/touchscreen/parser.c +++ /dev/null @@ -1,205 +0,0 @@ -/* - * RTEMS for Nintendo DS input parser. - * - * Copyright (c) 2008 by Matthieu Bucchianeri <mbucchia@gmail.com> - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * - * http://www.rtems.org/license/LICENSE - */ - -#include <stdio.h> -#include <stdlib.h> -#include <rtems.h> - -#include <nds.h> - -#include <rtems/mw_uid.h> - -/* - * from console/console.c - */ - -extern void console_push (char c); -extern void register_kbd_msg_queue (char *q_name); -extern void unregister_kbd_msg_queue (void); - -/* - * from reco.c - */ - -extern char PA_CheckLetter (int down, int x, int y); - -/* - * message queue for touchscreen and graffiti events. - */ -extern void register_mou_msg_queue (char *q_name); -extern void unregister_mou_msg_queue (void); -static rtems_id mou_queue_id = 0; -static rtems_id kbd_queue_id = 0; - -/* - * old position. - */ - -static int old_x = 0; -static int old_y = 0; -static int old_btns = 0; - -/* - * hand mode. - */ - -static int hand = 0; - -/* - * Shared methods - */ -void update_touchscreen (void); -void touchscreen_sethand (int h); - -/* - * update touchscreen position - */ -void -update_touchscreen (void) -{ - static int graffiti = 0; - struct MW_UID_MESSAGE m; - int x, y, k, kh, btns = 0; - touchPosition pos; - char c; - - /* update keypad & touchscreen */ - scanKeys (); - pos = touchReadXY (); - x = pos.px; - y = pos.py; - k = keysDown (); - kh = keysHeld (); - - /* check for character recognition */ - if ((kh & KEY_L) || (kh & KEY_R)) { - graffiti = 1; - c = PA_CheckLetter ((kh & KEY_TOUCH ? 1 : 0), x, y); - if (c) { - /* signal the console driver */ - console_push (c); - if (kbd_queue_id != 0) { - /* send the read character */ - m.type = MV_UID_KBD; - m.m.kbd.code = c; - m.m.kbd.modifiers = 0; - m.m.kbd.mode = MV_KEY_MODE_ASCII; - rtems_message_queue_send (kbd_queue_id, (void *) &m, - sizeof (struct MW_UID_MESSAGE)); - } - } - } else { - if (graffiti == 1) { - x = old_x; - y = old_y; - } - graffiti = 0; - } - - if (mou_queue_id == 0) - return; - - if (hand == 1) { - if (k & KEY_LEFT) { - btns = MV_BUTTON_LEFT; - } - if (k & KEY_RIGHT) { - btns = MV_BUTTON_RIGHT; - } - } else { - if (k & KEY_A) { - btns = MV_BUTTON_LEFT; - } - if (k & KEY_B) { - btns = MV_BUTTON_RIGHT; - } - } - - if (!((kh & KEY_L) || (kh & KEY_R)) && (kh & KEY_TOUCH) - && (x != old_x || y != old_y || btns)) { - /* send the read position */ - m.type = MV_UID_ABS_POS; - old_btns = m.m.pos.btns = btns; - old_x = m.m.pos.x = x; - old_y = m.m.pos.y = y; - m.m.pos.z = 0; - rtems_message_queue_send (mou_queue_id, (void *) &m, - sizeof (struct MW_UID_MESSAGE)); - } -} - -/* - * register a message queue for touchscreen events. - */ - -void -register_mou_msg_queue (char *q_name) -{ - rtems_name queue_name; - rtems_status_code status; - - queue_name = rtems_build_name (q_name[0], q_name[1], q_name[2], q_name[3]); - status = rtems_message_queue_ident (queue_name, RTEMS_LOCAL, &mou_queue_id); - if (status != RTEMS_SUCCESSFUL) { - printk ("[!] cannot create queue %d\n", status); - return; - } - - update_touchscreen (); -} - -/* - * unregister the message queue. - */ - -void -unregister_mou_msg_queue (void) -{ - /* nothing here */ -} - -/* - * register a message queue for graffiti events. - */ - -void -register_kbd_msg_queue (char *q_name) -{ - rtems_name queue_name; - rtems_status_code status; - - queue_name = rtems_build_name (q_name[0], q_name[1], q_name[2], q_name[3]); - status = rtems_message_queue_ident (queue_name, RTEMS_LOCAL, &kbd_queue_id); - if (status != RTEMS_SUCCESSFUL) { - printk ("[!] cannot create queue %d\n", status); - return; - } -} - -/* - * unregister the message queue. - */ - -void -unregister_kbd_msg_queue (void) -{ - /* nothing here */ -} - -/* - * set hand mode. - */ - -void -touchscreen_sethand (int h) -{ - hand = h; -} diff --git a/c/src/lib/libbsp/arm/nds/touchscreen/reco.c b/c/src/lib/libbsp/arm/nds/touchscreen/reco.c deleted file mode 100644 index 540720038f..0000000000 --- a/c/src/lib/libbsp/arm/nds/touchscreen/reco.c +++ /dev/null @@ -1,245 +0,0 @@ -#include <nds.h> -#include "reco.h" - -/* - * Prototype - * - * NOTE: These appear to be part of a public interface. - */ -char PA_CheckLetter(int down, int x, int y); - -PA_StylusPosition PA_StylusPos[20000]; - -PA_RecoValues PA_Reco; - -char PA_RecoShape[16]; - -u8 PA_UseGraffiti = true; - -u8 PA_CustomReco = 0; // number of custom shapes -PA_FormType PA_CustomShape[200]; - -PA_RecoInfos PA_RecoInfo; - -PA_FormType PA_Graffiti[PA_RECOTESTS] = { - {' ', "AAAAAAAAAAAAAAA"}, - {'a', "FGGGGGFB;:;;;;;"}, - {'b', "JJJJJIGC>:8=<62"}, - {'c', "01234689;<>?@BC"}, - {'d', "=995KJIFB?=;853"}, - {'e', "1236;>@136;=?@A"}, - {'f', "121111399998779"}, - {'g', "235689;=@CFIJEA"}, - {'h', "8999999;HFEA><:"}, - {'i', "999999999999999"}, - {'j', "999999998653100"}, - {'k', "654320NIDCA?==="}, - {'l', "999999988<AA@@@"}, - {'m', "HGGEA<;EFDA=;99"}, - {'n', "HHHIE<;;;<GIHHH"}, - {'o', "4689;<?BDFHKMO0"}, - {'p', "<KJIIIHGEB>;853"}, - {'q', "4679<?CDFHKMJBA"}, - {'r', "999IIIIGC?:53<="}, - {'s', "0235:>?>>;73100"}, - {'t', "AAAA@@@;8999999"}, - {'u', "899:;<>ACEGHHIH"}, - {'v', ";;:::::?FGGHHGF"}, - {'w', "::;=BA<<@CDEFGH"}, - {'x', ";;;;;;;;;;;;;;;"}, - {'y', ">;=AFF899974OIF"}, - {'z', ">A@@>843348?@AA"}, - {'0', "35789;=AEGHIJKM"}, - {'1', "CDEFFE988889999"}, - {'2', "GDB@>:6546>AAAA"}, - {'3', "CA>833A@=953210"}, - {'4', "55558>@A@>97778"}, - {'5', "00037:@@=;7310O"}, - {'6', "346779;>@CFKN02"}, - {'7', "AAAAAA@>9655556"}, - {'8', "37;=;71MIECCGM1"}, - {'9', "8<@CGL28<<;6311"}, - {PA_BACKSPACE, "000000000000000"}, - {PA_ENTER, "555555555555555"}, - // {'?', "FCA@><8655799::"}, - {'.', "LLLLLLLLLLLLLLL"} -}; - - - -static void PA_AddStylusPos(u8 x, u8 y){ - if (!((x == PA_StylusPos[PA_Reco.nvalues-1].x) && (y == PA_StylusPos[PA_Reco.nvalues-1].y))){ - PA_StylusPos[PA_Reco.nvalues].x = x; - PA_StylusPos[PA_Reco.nvalues].y = y; - PA_Reco.nvalues++; - } -} - - -static void PA_StylusLine(u8 x1, u8 y1, u8 x2, u8 y2){ - int i,dx,dy,sdx,sdy,dxabs,dyabs,x,y,px,py; - - dx=x2-x1; /* the horizontal distance of the line */ - dy=y2-y1; /* the vertical distance of the line */ - dxabs = dx; - sdx = 1; - if (dx < 0) { - dxabs = -dx; - sdx = -1; - } - dyabs = dy; - sdy = 1; - if (dy < 0) { - dyabs = -dy; - sdy = -1; - } - - x=dyabs>>1; - y=dxabs>>1; - px=x1; - py=y1; - - PA_AddStylusPos(px, py); - - - if (dxabs>=dyabs) { - for(i=0;i<dxabs;i++) { - y+=dyabs; - if (y>=dxabs) { - y-=dxabs; - py+=sdy; - } - px+=sdx; - PA_AddStylusPos(px, py); - } - } - else { - for(i=0;i<dyabs;i++) { - x+=dxabs; - if (x>=dyabs) { - x-=dyabs; - px+=sdx; - } - py+=sdy; - PA_AddStylusPos(px, py); - } - } -} - - -#define PA_ShapeAddPoint(i, value){ \ - points[i] = PA_StylusPos[value]; \ - if (points[i].x < PA_RecoInfo.minX) PA_RecoInfo.minX = points[i].x; \ - else if (points[i].x > PA_RecoInfo.maxX) PA_RecoInfo.maxX = points[i].x; \ - if (points[i].y < PA_RecoInfo.minY) PA_RecoInfo.minY = points[i].y; \ - else if (points[i].y > PA_RecoInfo.maxY) PA_RecoInfo.maxY = points[i].y; } - - - - -static char PA_AnalyzeShape(void){ - s32 i; - // for (i = 0; i < 32; i++) PA_OutputSimpleText(1, 0, i, " "); - - PA_StylusPosition points[17]; - for (i = 0; i < 16; i++){ - PA_ShapeAddPoint(i, (PA_Reco.nvalues*i)>>4) - } - PA_ShapeAddPoint(16, PA_Reco.nvalues-1) - //points[16] = PA_StylusPos[PA_Reco.nvalues-1]; - PA_RecoInfo.endX = PA_StylusPos[PA_Reco.nvalues-1].x; // last values - PA_RecoInfo.endY = PA_StylusPos[PA_Reco.nvalues-1].y; // last values - PA_RecoInfo.Length = PA_Reco.nvalues; // Total length - PA_RecoInfo.Angle = PA_GetAngle(points[0].x, points[0].y, points[16].x, points[16].y); - - //Better values - if (PA_RecoInfo.minX > 1) PA_RecoInfo.minX-=2; - if (PA_RecoInfo.maxX <254) PA_RecoInfo.maxX+=2; - if (PA_RecoInfo.minY > 1) PA_RecoInfo.minY-=2; - if (PA_RecoInfo.maxY <190) PA_RecoInfo.maxY+=2; - - u16 angles[15]; - for (i = 0; i < 15; i++) angles[i] = PA_GetAngle(points[i+2].x, points[i+2].y, points[i].x, points[i].y); - - for (i = 0; i < 15; i++) PA_RecoShape[i] = '0' + (((angles[i]+16)&511)>>4); - PA_RecoShape[15] = 0; - // printk("%s\n", PA_RecoShape); - - u8 letter = 0; // 0 par défaut - s32 diff = 65000; // Diff max par défaut - - u8 j; - - if(PA_UseGraffiti){ - for (j = 0; j < PA_RECOTESTS; j++){ - s32 tempvalue = 0; - s32 tempdiff = 0; - for (i = 0; i < 15; i++) { - tempvalue = (PA_RecoShape[i]-PA_Graffiti[j].code[i])&31; - tempvalue -= (tempvalue >> 4)<<5; // normalise - if (tempvalue < 0) tempvalue = -tempvalue; - tempdiff += tempvalue; // value - } - - if (tempdiff < diff){ // Nouvelle lettre ! - diff = tempdiff; - letter = PA_Graffiti[j].letter; - } - } - } - if (PA_CustomReco > 0){ - for (j = 0; j < PA_CustomReco; j++){ - s32 tempvalue = 0; - s32 tempdiff = 0; - for (i = 0; i < 15; i++) { - tempvalue = (PA_RecoShape[i]-PA_CustomShape[j].code[i])&31; - tempvalue -= (tempvalue >> 4)<<5; // normalise - if (tempvalue < 0) tempvalue = -tempvalue; - tempdiff += tempvalue; // value - } - - if (tempdiff < diff){ // Nouvelle lettre ! - diff = tempdiff; - letter = PA_CustomShape[j].letter; - } - } - - } - PA_RecoInfo.Difference = diff; // Difference to perfect shape - PA_RecoInfo.Shape = letter; - - return letter; -} - -int old_down = 0; - -char PA_CheckLetter(int down, int x, int y){ - if(!old_down && down){ - PA_Reco.nvalues = 0; // Start over again - PA_Reco.oldn = 0; - PA_Reco.veryold = 0; - - PA_RecoInfo.startX = PA_StylusPos[PA_Reco.nvalues].x = x; // start values - PA_RecoInfo.startY = PA_StylusPos[PA_Reco.nvalues].y = y; - PA_RecoInfo.minX = PA_RecoInfo.maxX = PA_RecoInfo.startX; - PA_RecoInfo.minY = PA_RecoInfo.maxY = PA_RecoInfo.startY; - PA_Reco.nvalues++; - } - else if(old_down && down) { - PA_StylusLine(PA_StylusPos[PA_Reco.nvalues-1].x, PA_StylusPos[PA_Reco.nvalues-1].y, x, y); - - } - - - if(old_down && !down){ // Start analyzing... - PA_Reco.nvalues = PA_Reco.veryold; - old_down = down; - return PA_AnalyzeShape(); - } - PA_Reco.veryold = PA_Reco.oldn; - PA_Reco.oldn = PA_Reco.nvalues; - old_down = down; - return 0; -} - - diff --git a/c/src/lib/libbsp/arm/nds/touchscreen/reco.h b/c/src/lib/libbsp/arm/nds/touchscreen/reco.h deleted file mode 100644 index d9c00cd6e7..0000000000 --- a/c/src/lib/libbsp/arm/nds/touchscreen/reco.h +++ /dev/null @@ -1,137 +0,0 @@ -#ifndef RECO_H -#define RECO_H - -#include <nds.h> - -#define PA_RECOTESTS 40 - -#define PA_BACKSPACE 1 // On va dire que la touche backspace a pour valeur 1... -#define PA_ENTER '\n' // 3 pour Enter - - -typedef struct{ - u8 x, y; -} PA_StylusPosition; - -typedef struct{ - u32 nvalues, oldn, veryold; -} PA_RecoValues; - -typedef struct{ - u32 Length; - u8 minX, minY, maxX, maxY; // Shape limits - u8 startX, startY, endX, endY; // Start and end position - s16 Angle; - s32 Difference; - u8 Shape; -} PA_RecoInfos; - -typedef struct{ - char letter; - char code[16]; -} PA_FormType; - -static inline u64 PA_Distance(s32 x1, s32 y1, s32 x2, s32 y2) { - s64 h = x1 - x2; - s64 v = y1 - y2; - return(h*h + v*v); -} - -#define PA_Cos(angle) PA_SIN[((angle) + 128)&511] -#define PA_Sin(angle) PA_SIN[((angle))&511] - -static const s16 PA_SIN[512] = { - 0x0000,0x0003,0x0006,0x0009,0x000D,0x0010,0x0013,0x0016, 0x0019,0x001C,0x001F,0x0022,0x0026,0x0029,0x002C,0x002F, - 0x0032,0x0035,0x0038,0x003B,0x003E,0x0041,0x0044,0x0047, 0x004A,0x004D,0x0050,0x0053,0x0056,0x0059,0x005C,0x005F, - 0x0062,0x0065,0x0068,0x006B,0x006D,0x0070,0x0073,0x0076, 0x0079,0x007B,0x007E,0x0081,0x0084,0x0086,0x0089,0x008C, - 0x008E,0x0091,0x0093,0x0096,0x0098,0x009B,0x009D,0x00A0, 0x00A2,0x00A5,0x00A7,0x00AA,0x00AC,0x00AE,0x00B1,0x00B3, - - 0x00B5,0x00B7,0x00B9,0x00BC,0x00BE,0x00C0,0x00C2,0x00C4, 0x00C6,0x00C8,0x00CA,0x00CC,0x00CE,0x00CF,0x00D1,0x00D3, - 0x00D5,0x00D7,0x00D8,0x00DA,0x00DC,0x00DD,0x00DF,0x00E0, 0x00E2,0x00E3,0x00E5,0x00E6,0x00E7,0x00E9,0x00EA,0x00EB, - 0x00ED,0x00EE,0x00EF,0x00F0,0x00F1,0x00F2,0x00F3,0x00F4, 0x00F5,0x00F6,0x00F7,0x00F8,0x00F8,0x00F9,0x00FA,0x00FA, - 0x00FB,0x00FC,0x00FC,0x00FD,0x00FD,0x00FE,0x00FE,0x00FE, 0x00FF,0x00FF,0x00FF,0x0100,0x0100,0x0100,0x0100,0x0100, - - 0x0100,0x0100,0x0100,0x0100,0x0100,0x0100,0x00FF,0x00FF, 0x00FF,0x00FE,0x00FE,0x00FE,0x00FD,0x00FD,0x00FC,0x00FC, - 0x00FB,0x00FA,0x00FA,0x00F9,0x00F8,0x00F8,0x00F7,0x00F6, 0x00F5,0x00F4,0x00F3,0x00F2,0x00F1,0x00F0,0x00EF,0x00EE, - 0x00ED,0x00EB,0x00EA,0x00E9,0x00E7,0x00E6,0x00E5,0x00E3, 0x00E2,0x00E0,0x00DF,0x00DD,0x00DC,0x00DA,0x00D8,0x00D7, - 0x00D5,0x00D3,0x00D1,0x00CF,0x00CE,0x00CC,0x00CA,0x00C8, 0x00C6,0x00C4,0x00C2,0x00C0,0x00BE,0x00BC,0x00B9,0x00B7, - - 0x00B5,0x00B3,0x00B1,0x00AE,0x00AC,0x00AA,0x00A7,0x00A5, 0x00A2,0x00A0,0x009D,0x009B,0x0098,0x0096,0x0093,0x0091, - 0x008E,0x008C,0x0089,0x0086,0x0084,0x0081,0x007E,0x007B, 0x0079,0x0076,0x0073,0x0070,0x006D,0x006B,0x0068,0x0065, - 0x0062,0x005F,0x005C,0x0059,0x0056,0x0053,0x0050,0x004D, 0x004A,0x0047,0x0044,0x0041,0x003E,0x003B,0x0038,0x0035, - 0x0032,0x002F,0x002C,0x0029,0x0026,0x0022,0x001F,0x001C, 0x0019,0x0016,0x0013,0x0010,0x000D,0x0009,0x0006,0x0003, - - 0x0000,0xFFFD,0xFFFA,0xFFF7,0xFFF3,0xFFF0,0xFFED,0xFFEA, 0xFFE7,0xFFE4,0xFFE1,0xFFDE,0xFFDA,0xFFD7,0xFFD4,0xFFD1, - 0xFFCE,0xFFCB,0xFFC8,0xFFC5,0xFFC2,0xFFBF,0xFFBC,0xFFB9, 0xFFB6,0xFFB3,0xFFB0,0xFFAD,0xFFAA,0xFFA7,0xFFA4,0xFFA1, - 0xFF9E,0xFF9B,0xFF98,0xFF95,0xFF93,0xFF90,0xFF8D,0xFF8A, 0xFF87,0xFF85,0xFF82,0xFF7F,0xFF7C,0xFF7A,0xFF77,0xFF74, - 0xFF72,0xFF6F,0xFF6D,0xFF6A,0xFF68,0xFF65,0xFF63,0xFF60, 0xFF5E,0xFF5B,0xFF59,0xFF56,0xFF54,0xFF52,0xFF4F,0xFF4D, - - 0xFF4B,0xFF49,0xFF47,0xFF44,0xFF42,0xFF40,0xFF3E,0xFF3C, 0xFF3A,0xFF38,0xFF36,0xFF34,0xFF32,0xFF31,0xFF2F,0xFF2D, - 0xFF2B,0xFF29,0xFF28,0xFF26,0xFF24,0xFF23,0xFF21,0xFF20, 0xFF1E,0xFF1D,0xFF1B,0xFF1A,0xFF19,0xFF17,0xFF16,0xFF15, - 0xFF13,0xFF12,0xFF11,0xFF10,0xFF0F,0xFF0E,0xFF0D,0xFF0C, 0xFF0B,0xFF0A,0xFF09,0xFF08,0xFF08,0xFF07,0xFF06,0xFF06, - 0xFF05,0xFF04,0xFF04,0xFF03,0xFF03,0xFF02,0xFF02,0xFF02, 0xFF01,0xFF01,0xFF01,0xFF00,0xFF00,0xFF00,0xFF00,0xFF00, - - 0xFF00,0xFF00,0xFF00,0xFF00,0xFF00,0xFF00,0xFF01,0xFF01, 0xFF01,0xFF02,0xFF02,0xFF02,0xFF03,0xFF03,0xFF04,0xFF04, - 0xFF05,0xFF06,0xFF06,0xFF07,0xFF08,0xFF08,0xFF09,0xFF0A, 0xFF0B,0xFF0C,0xFF0D,0xFF0E,0xFF0F,0xFF10,0xFF11,0xFF12, - 0xFF13,0xFF15,0xFF16,0xFF17,0xFF19,0xFF1A,0xFF1B,0xFF1D, 0xFF1E,0xFF20,0xFF21,0xFF23,0xFF24,0xFF26,0xFF28,0xFF29, - 0xFF2B,0xFF2D,0xFF2F,0xFF31,0xFF32,0xFF34,0xFF36,0xFF38, 0xFF3A,0xFF3C,0xFF3E,0xFF40,0xFF42,0xFF44,0xFF47,0xFF49, - - 0xFF4B,0xFF4D,0xFF4F,0xFF52,0xFF54,0xFF56,0xFF59,0xFF5B, 0xFF5E,0xFF60,0xFF63,0xFF65,0xFF68,0xFF6A,0xFF6D,0xFF6F, - 0xFF72,0xFF74,0xFF77,0xFF7A,0xFF7C,0xFF7F,0xFF82,0xFF85, 0xFF87,0xFF8A,0xFF8D,0xFF90,0xFF93,0xFF95,0xFF98,0xFF9B, - 0xFF9E,0xFFA1,0xFFA4,0xFFA7,0xFFAA,0xFFAD,0xFFB0,0xFFB3, 0xFFB6,0xFFB9,0xFFBC,0xFFBF,0xFFC2,0xFFC5,0xFFC8,0xFFCB, - 0xFFCE,0xFFD1,0xFFD4,0xFFD7,0xFFDA,0xFFDE,0xFFE1,0xFFE4, 0xFFE7,0xFFEA,0xFFED,0xFFF0,0xFFF3,0xFFF7,0xFFFA,0xFFFD}; - - -static u16 PA_AdjustAngle(u16 angle, s16 anglerot, s32 startx, s32 starty, s32 targetx, s32 targety) { -u64 distances[3]; - - startx = startx << 8; // Fixed point... - starty = starty << 8; // Fixed point... - targetx = targetx << 8; // Fixed point... - targety = targety << 8; // Fixed point... - - u16 tempangle = (angle - anglerot) & 511; - - - // Calcul des distances en fonction des angles - distances[0] = PA_Distance(startx + PA_Cos(tempangle), starty - PA_Sin(tempangle), targetx, targety); - tempangle += anglerot; - tempangle &= 511; - distances[1] = PA_Distance(startx + PA_Cos(tempangle), starty - PA_Sin(tempangle), targetx, targety); - tempangle += anglerot; - tempangle &= 511; - distances[2] = PA_Distance(startx + PA_Cos(tempangle), starty - PA_Sin(tempangle), targetx, targety); - - - - // On regarde si l'angle est optimal. Si ce n'est pas le cas, - // on fait tourner toujours dans le meme sens... - if (distances[0] < distances[1]) angle -= anglerot; - else if (distances[2] < distances[1]) angle += anglerot; - - return (angle&511); -} - -static inline u16 PA_GetAngle(s32 startx, s32 starty, s32 targetx, s32 targety) { -u16 angle = 0; -u16 anglerot = 180; - - -while(anglerot > 5) { - angle = PA_AdjustAngle(angle, anglerot, startx, starty, targetx, targety); - anglerot = (anglerot - ((3 * anglerot) >> 3)); // On diminue petit à petit la rotation... -} - -// Ajustement encore plus précis... -anglerot = 4; -angle = PA_AdjustAngle(angle, anglerot, startx, starty, targetx, targety); -anglerot = 2; -angle = PA_AdjustAngle(angle, anglerot, startx, starty, targetx, targety); -anglerot = 1; -angle = PA_AdjustAngle(angle, anglerot, startx, starty, targetx, targety); - -return angle; -} - - -#endif /* RECO_H */ diff --git a/c/src/lib/libbsp/arm/nds/touchscreen/touchscreen.c b/c/src/lib/libbsp/arm/nds/touchscreen/touchscreen.c deleted file mode 100644 index 868fccb9af..0000000000 --- a/c/src/lib/libbsp/arm/nds/touchscreen/touchscreen.c +++ /dev/null @@ -1,133 +0,0 @@ -/* - * RTEMS for Nintendo DS touchscreen driver. - * - * Copyright (c) 2008 by Matthieu Bucchianeri <mbucchia@gmail.com> - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * - * http://www.rtems.org/license/LICENSE - */ - -#include <stdlib.h> -#include <stdio.h> -#include <errno.h> -#include <sys/types.h> - -#include <bsp.h> -#include <rtems/irq.h> -#include <rtems/libio.h> -#include <nds.h> - -#include <rtems/mw_uid.h> -#include "touchscreen.h" - -/* - * from parser.c - */ - -void register_mou_msg_queue (char *q_name); -void unregister_mou_msg_queue (void); -void touchscreen_sethand (int); - -/* - * touchscreen device driver initialize entry point. - */ - -rtems_device_driver -touchscreen_initialize (rtems_device_major_number major, - rtems_device_minor_number minor, void *arg) -{ - rtems_status_code status; - - printk ("[+] touchscreen started\n"); - - touchscreen_sethand (1); - - /* register the device */ - status = rtems_io_register_name ("/dev/mouse", major, 0); - if (status != RTEMS_SUCCESSFUL) { - printk ("[!] error registering touchscreen\n"); - rtems_fatal_error_occurred (status); - } - return RTEMS_SUCCESSFUL; -} - -/* - * touchscreen device driver open operation. - */ - -rtems_device_driver -touchscreen_open (rtems_device_major_number major, - rtems_device_minor_number minor, void *arg) -{ - return RTEMS_SUCCESSFUL; -} - -/* - * touchscreen device driver close operation. - */ - -rtems_device_driver -touchscreen_close (rtems_device_major_number major, - rtems_device_minor_number minor, void *arg) -{ - return RTEMS_SUCCESSFUL; -} - -/* - * touchscreen device driver read operation. - */ - -rtems_device_driver -touchscreen_read (rtems_device_major_number major, - rtems_device_minor_number minor, void *arg) -{ - rtems_libio_rw_args_t *rw_args = (rtems_libio_rw_args_t *) arg; - rw_args->bytes_moved = 0; - - return RTEMS_SUCCESSFUL; -} - -/* - * touchscreen device driver write operation. - */ - -rtems_device_driver -touchscreen_write (rtems_device_major_number major, - rtems_device_minor_number minor, void *arg) -{ - rtems_libio_rw_args_t *rw_args = (rtems_libio_rw_args_t *) arg; - rw_args->bytes_moved = 0; - - return RTEMS_SUCCESSFUL; -} - -/* - * ioctl entry point. - */ - -rtems_device_driver -touchscreen_control (rtems_device_major_number major, - rtems_device_minor_number minor, void *arg) -{ - rtems_libio_ioctl_args_t *args = arg; - - switch (args->command) { - case MW_UID_REGISTER_DEVICE: - register_mou_msg_queue (args->buffer); - break; - case MW_UID_UNREGISTER_DEVICE: - unregister_mou_msg_queue (); - break; - case MW_UID_SET_LEFTHANDED: - touchscreen_sethand (0); - break; - case MW_UID_SET_RIGHTHANDED: - touchscreen_sethand (1); - break; - } - args->ioctl_return = 0; - - return RTEMS_SUCCESSFUL; -} diff --git a/c/src/lib/libbsp/arm/nds/touchscreen/touchscreen.h b/c/src/lib/libbsp/arm/nds/touchscreen/touchscreen.h deleted file mode 100644 index d9a854c270..0000000000 --- a/c/src/lib/libbsp/arm/nds/touchscreen/touchscreen.h +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (c) 2008 by Matthieu Bucchianeri <mbucchia@gmail.com> - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * - * http://www.rtems.org/license/LICENSE - */ - -#ifndef _TOUCHSCREEN_H_ -#define _TOUCHSCREEN_H_ - -#ifdef __cplusplus -extern "C" -{ -#endif - - /* - * ioctl for lefthanded/righthanded mode. - */ - -#define MW_UID_SET_RIGHTHANDED 0x4108 -#define MW_UID_SET_LEFTHANDED 0x4109 - - /* - * touchscreen prototype entry points - */ - - rtems_device_driver touchscreen_initialize (rtems_device_major_number, - rtems_device_minor_number, - void *); - - rtems_device_driver touchscreen_open (rtems_device_major_number, - rtems_device_minor_number, void *); - - rtems_device_driver touchscreen_control (rtems_device_major_number, - rtems_device_minor_number, void *); - - rtems_device_driver touchscreen_close (rtems_device_major_number, - rtems_device_minor_number, void *); - - rtems_device_driver touchscreen_read (rtems_device_major_number, - rtems_device_minor_number, void *); - - rtems_device_driver touchscreen_write (rtems_device_major_number, - rtems_device_minor_number, void *); - - rtems_device_driver touchscreen_control (rtems_device_major_number, - rtems_device_minor_number, void *); - -#define TOUCHSCREEN_DRIVER_TABLE_ENTRY \ - { touchscreen_initialize, touchscreen_open, touchscreen_close, \ - touchscreen_read, touchscreen_write, touchscreen_control } - - -#ifdef __cplusplus -} -#endif - -#endif |