00001
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046 #include <string.h>
00047 #include <stdio.h>
00048
00049 #include "compiler.h"
00050 #include "s_joystick.h"
00051 #include "joystick.h"
00052 #include "FreeRTOS.h"
00053
00054
00055
00056
00058 #define JS_NB_EVENT 32
00059
00061 #define JS_EVENT_PUSH 0x01
00062 #define JS_EVENT_LEFT 0x02
00063 #define JS_EVENT_RIGHT 0x04
00064 #define JS_EVENT_UP 0x08
00065 #define JS_EVENT_DOWN 0x10
00066
00067
00068
00070 const signed portCHAR *acpc_js_events[JS_NB_EVENT] = {
00071 (signed portCHAR *)"RELEASE",(signed portCHAR *)"PRESS",(signed portCHAR *)"LEFT",(signed portCHAR *)"LEFT/PRESS",
00072 (signed portCHAR *)"RIGHT",(signed portCHAR *)"RIGHT/PRESS",(signed portCHAR *)"?",(signed portCHAR *)"?",
00073 (signed portCHAR *)"UP",(signed portCHAR *)"UP/PRESS",(signed portCHAR *)"UP/LEFT",(signed portCHAR *)"UP/LEFT/PRESS",
00074 (signed portCHAR *)"UP/RIGHT",(signed portCHAR *)"UP/RIGHT/PRESS",(signed portCHAR *)"?",(signed portCHAR *)"?",
00075 (signed portCHAR *)"DOWN",(signed portCHAR *)"DOWN/PRESS",(signed portCHAR *)"DOWN/LEFT",(signed portCHAR *)"DOWN/LEFT/PRESS",
00076 (signed portCHAR *)"DOWN/RIGHT",(signed portCHAR *)"DOWN/RIGHT/PRESS",(signed portCHAR *)"?",(signed portCHAR *)"?",
00077 (signed portCHAR *)"?",(signed portCHAR *)"?",(signed portCHAR *)"?",(signed portCHAR *)"?",
00078 (signed portCHAR *)"?",(signed portCHAR *)"?",(signed portCHAR *)"?",(signed portCHAR *)"?",
00079 };
00080
00082 static unsigned short x_joystick = 0;
00083
00084
00085
00086
00094 Bool b_joystick_get_value( char* buf )
00095 {
00096
00097 if ( !is_joystick_up() ) { Clr_bits(x_joystick, JS_EVENT_UP); }
00098 else { Set_bits(x_joystick, JS_EVENT_UP); }
00099
00100 if ( !is_joystick_down() ) { Clr_bits(x_joystick, JS_EVENT_DOWN); }
00101 else { Set_bits(x_joystick, JS_EVENT_DOWN); }
00102
00103 if ( !is_joystick_left() ) { Clr_bits(x_joystick, JS_EVENT_LEFT); }
00104 else { Set_bits(x_joystick, JS_EVENT_LEFT); }
00105
00106 if ( !is_joystick_right() ) { Clr_bits(x_joystick, JS_EVENT_RIGHT); }
00107 else { Set_bits(x_joystick, JS_EVENT_RIGHT); }
00108
00109 if ( !is_joystick_pressed() ) { Clr_bits(x_joystick, JS_EVENT_PUSH); }
00110 else { Set_bits(x_joystick, JS_EVENT_PUSH); }
00111
00112
00113 sprintf( buf, "%s\r\n", (portCHAR *)acpc_js_events[x_joystick]);
00114 return TRUE;
00115 }