Subversion Repositories shark

Compare Revisions

Regard whitespace Rev 1362 → Rev 1363

/demos/trunk/input/input.c
39,18 → 39,43
#include <string.h>
 
#include <drivers/shark_linuxc26.h>
 
#include <drivers/shark_fb26.h>
 
#include <drivers/shark_input26.h>
#include <drivers/shark_mouse26.h>
#include <drivers/shark_keyb26.h>
#include <drivers/shark_spk26.h>
#include <drivers/shark_joy26.h>
 
#define FRAME_BUFFER_DEVICE 0
 
#define RGB_BLACK rgb16( 0, 0, 0)
#define RGB_GRAY rgb16(127,127,127)
#define RGB_WHITE rgb16(255,255,255)
#define RGB_RED rgb16(255, 0, 0)
#define RGB_GREEN rgb16( 0,255, 0)
#define RGB_BLUE rgb16( 0, 0,255)
#define RGB_YELLOW rgb16(255,255, 0)
#define RGB_MAGENTA rgb16(255, 0,255)
#define RGB_CYAN rgb16( 0,255,255)
#define RGB_D_RED rgb16(127, 0, 0)
#define RGB_D_GREEN rgb16( 0,127, 0)
#define RGB_D_BLUE rgb16( 0, 0,127)
#define RGB_D_YELLOW rgb16(127,127, 0)
#define RGB_D_MAGENTA rgb16(127, 0,127)
#define RGB_D_CYAN rgb16( 0,127,127)
 
void my_sysclose(KEY_EVT *e)
{
//EVBUG26_close();
mouse_grxcursor(DISABLE, 0);
 
FB26_close(FRAME_BUFFER_DEVICE);
 
MOUSE26_close();
KEYB26_close();
MOUSE26_close();
SPEAK26_close();
//JOY26_close();
JOY26_close();
INPUT26_close();
 
kern_printf("S.Ha.R.K. closed.\n\n");
57,8 → 82,59
sys_end();
}
 
TASK my_getjoy(void *arg) {
 
int a0, a1, a2, a3, btn;
char st[20];
 
while (1) {
joy_getstatus(&a0, &a1, &a2, &a3, &btn);
 
sprintf(st, "X Axis : %6d ", a0);
grx_text(st, 100, 64, RGB_CYAN, RGB_BLACK);
sprintf(st, "Y Axis : %6d ", a1);
grx_text(st, 100, 114, RGB_CYAN, RGB_BLACK);
sprintf(st, "Buttons: %2x ", btn);
grx_text(st, 100, 164, RGB_CYAN, RGB_BLACK);
 
task_endcycle();
if (btn == 0xF)
my_sysclose(NULL);
}
}
 
TASK my_getch(void *arg) {
 
BYTE ch;
int i = 0;
char st[20];
 
while (1) {
ch = keyb_getch(NON_BLOCK);
if (ch) {
sprintf(st, "%c", ch);
grx_text(st, 340 + 10 * (i%25), 30 + 20 * (i/25), RGB_BLUE, RGB_BLACK);
 
if (++i >= 200)
i = 0;
}
 
task_endcycle();
}
}
 
void graph_init(void)
{
grx_rect( 4, 4, 634, 474, RGB_WHITE);
grx_rect( 14, 14, 304, 214, RGB_YELLOW);
grx_rect(314, 14, 624, 214, RGB_RED);
}
 
int main(int argc, char **argv)
{
SOFT_TASK_MODEL mp;
PID pid;
 
KEY_EVT ev;
 
ev.ascii = 'c';
69,10 → 145,47
ev.flag = CNTR_BIT;
keyb_hook(ev, my_sysclose, FALSE);
 
while ( (sys_gettime(NULL)/1000) < 20000);
my_sysclose(NULL);
FB26_init();
//while(1);
FB26_open(FRAME_BUFFER_DEVICE);
 
FB26_use_grx(FRAME_BUFFER_DEVICE);
 
FB26_setmode(FRAME_BUFFER_DEVICE,"640x480-16");
 
graph_init();
 
mouse_grxlimits(639, 479);
mouse_setposition(319, 239, 0);
mouse_grxcursor(ENABLE, 2);
 
soft_task_default_model(mp);
soft_task_def_level(mp,2);
soft_task_def_ctrl_jet(mp);
soft_task_def_met(mp,700);
soft_task_def_period(mp,10000);
//soft_task_def_aperiodic(mp);
soft_task_def_usemath(mp);
pid = task_create("Joy_Print", my_getjoy, &mp, NULL);
if (pid == NIL) {
perror("Could not create task <Joy_Print>");
sys_end();
} else
task_activate(pid);
 
soft_task_default_model(mp);
soft_task_def_level(mp,2);
soft_task_def_ctrl_jet(mp);
soft_task_def_met(mp,700);
soft_task_def_period(mp,10000);
//soft_task_def_aperiodic(mp);
soft_task_def_usemath(mp);
pid = task_create("Key_Print", my_getch, &mp, NULL);
if (pid == NIL) {
perror("Could not create task <Key_Print>");
sys_end();
} else
task_activate(pid);
 
return 0;
}