/shark/trunk/config/libdep.mk |
---|
375,7 → 375,7 |
# ---------------------------------------------------------------- |
ifeq ($(findstring __JOY__, $(USELIB)), __JOY__) |
INCL += -I$(BASE)/ports/joy/include |
INCL += -I$(BASE)/drivers/joy/include |
# JOY |
ifeq ($(LIB_PATH)/libjoy.a,$(wildcard $(LIB_PATH)/libjoy.a)) |
/shark/trunk/ports/joy/readme |
---|
File deleted |
/shark/trunk/ports/joy/makefile |
---|
File deleted |
/shark/trunk/ports/joy/joy.c |
---|
File deleted |
/shark/trunk/ports/joy/include/joy.h |
---|
File deleted |
/shark/trunk/drivers/joy/joy.c |
---|
0,0 → 1,203 |
/* |
* Project: S.Ha.R.K. |
* |
* Coordinators: Giorgio Buttazzo <giorgio@sssup.it> |
* |
* Authors : Mauro Marinoni <mauro.marinoni@unipv.it> |
* (see authors.txt for full list of hartik's authors) |
* |
* ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
* |
* http://www.sssup.it |
* http://retis.sssup.it |
* http://shark.sssup.it |
*/ |
/* |
* Copyright (C) 2000 Paolo Gai |
* |
* 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 "kernel/kern.h" |
#include "joy.h" |
void get_joystick_buttons(JOY_BUTTONS *jb) |
{ |
int j; |
outp(JPORT, 0); |
j = inp(JPORT); |
jb->b1 = !(j & 0x10); |
jb->b2 = !(j & 0x20); |
jb->b3 = !(j & 0x40); |
jb->b4 = !(j & 0x80); |
} |
int get_joystick_AB(JOY_STATE *jsa, JOY_STATE *jsb) |
{ |
int i, j; |
int mask = 15; |
SYS_FLAGS f; |
outp(JPORT, 0); |
f = kern_fsave(); |
for (i=1; mask && i<CMAX; i++) { |
j = inp(JPORT) ^ mask; |
if (j & 1) { jsa->x = i; mask ^= 1; } |
if (j & 2) { jsa->y = i; mask ^= 2; } |
if (j & 4) { jsb->x = i; mask ^= 4; } |
if (j & 8) { jsb->y = i; mask ^= 8; } |
} |
kern_frestore(f); |
j = inp(JPORT); |
jsa->b1 = !(j & 0x10); |
jsa->b2 = !(j & 0x20); |
jsb->b1 = !(j & 0x40); |
jsb->b2 = !(j & 0x80); |
return i==CMAX ? -1 : 0; |
} |
int get_joystick_A(JOY_STATE *js) |
{ |
int i, j; |
int mask = 3; |
SYS_FLAGS f; |
outp(JPORT, 0); |
f = kern_fsave(); |
for (i=1; mask && i<CMAX; i++) { |
j = inp(JPORT) ^ mask; |
if (j & 1) { js->x = i; mask ^= 1; } |
if (j & 2) { js->y = i; mask ^= 2; } |
} |
kern_frestore(f); |
j = inp(JPORT); |
js->b1 = !(j & 0x10); |
js->b2 = !(j & 0x20); |
return i==CMAX ? -1 : 0; |
} |
int get_joystick_B(JOY_STATE *js) |
{ |
int i, j; |
int mask = 12; |
SYS_FLAGS f; |
outp(JPORT, 0); |
f = kern_fsave(); |
for (i=1; mask && i<CMAX; i++) { |
j = inp(JPORT) ^ mask; |
if (j & 4) { js->x = i; mask ^= 4; } |
if (j & 8) { js->y = i; mask ^= 8; } |
} |
kern_frestore(f); |
j = inp(JPORT); |
js->b1 = !(j & 0x40); |
js->b2 = !(j & 0x80); |
return i==CMAX ? -1 : 0; |
} |
int get_joystick_bound_A(JOY_BOUND *jb) |
{ |
int i, j; |
int mask = 3; |
int xmin = CMAX, ymin = CMAX; |
int xmax = 0, ymax = 0; |
int btn = 0; |
SYS_FLAGS f; |
while (!btn) { |
mask = 3; |
outp(JPORT, 0); |
f = kern_fsave(); |
for (i=1; mask && i<CMAX; i++) { |
j = inp(JPORT) ^ mask; |
if (j & 1) { |
if (i < xmin) xmin = i; |
if (i > xmax) xmax = i; |
mask ^= 1; |
} |
if (j & 2) { |
if (i < ymin) ymin = i; |
if (i > ymax) ymax = i; |
mask ^= 2; |
} |
} |
kern_frestore(f); |
if (i==CMAX) return -1; |
j = inp(JPORT); |
btn += !(j & 0x10); |
btn += !(j & 0x20); |
} |
jb->x_min = xmin; |
jb->y_min = ymin; |
jb->x_max = xmax; |
jb->y_max = ymax; |
return 0; |
} |
int get_joystick_bound_B(JOY_BOUND *jb) |
{ |
int i, j; |
int mask; |
int xmin = CMAX, ymin = CMAX; |
int xmax = 0, ymax = 0; |
int btn = 0; |
SYS_FLAGS f; |
while (!btn) { |
mask = 12; |
outp(JPORT, 0); |
f = kern_fsave(); |
for (i=1; mask && i<CMAX; i++) { |
j = inp(JPORT) ^ mask; |
if (j & 4) { |
if (i < xmin) xmin = i; |
if (i > xmax) xmax = i; |
mask ^= 4; |
} |
if (j & 8) { |
if (i < ymin) ymin = i; |
if (i > ymax) ymax = i; |
mask ^= 8; |
} |
} |
kern_frestore(f); |
if (i==CMAX) return -1; |
j = inp(JPORT); |
btn += !(j & 0x40); |
btn += !(j & 0x80); |
} |
jb->x_min = xmin; |
jb->y_min = ymin; |
jb->x_max = xmax; |
jb->y_max = ymax; |
return 0; |
} |
/shark/trunk/drivers/joy/include/joy.h |
---|
0,0 → 1,79 |
/* |
* Project: HARTIK (HA-rd R-eal TI-me K-ernel) |
* |
* Coordinators: Giorgio Buttazzo <giorgio@sssup.it> |
* Gerardo Lamastra <gerardo@sssup.it> |
* |
* Authors : Mauro MArinoni <mauro.marinoni@unipv.it> |
* (see authors.txt for full list of hartik's authors) |
* |
* ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
* |
* http://www.sssup.it |
* http://retis.sssup.it |
* http://hartik.sssup.it |
*/ |
/* |
* Copyright (C) 2000 Paolo Gai |
* |
* 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 |
* |
*/ |
#ifndef __JOY_H__ |
#define __JOY_H__ |
/* standard I/O port address for the PC joystick */ |
#define JPORT 0x201 |
/* |
* max counts to wait for joystick. In normal usage, you don't |
* want this too large, so that the program doesn't hang up too long |
* if no joystick is attached. But if you make it too small, a |
* program that works on a slow machine may fail on a faster CPU |
* (unless you have a "speed adjustable" game card). |
*/ |
#define CMAX 9999 |
typedef struct { /*describe the position and buttons state of a joystick*/ |
int x; |
int y; |
char b1; |
char b2; |
} JOY_STATE; |
typedef struct { /*describe the four buttons state of a joystick*/ |
char b1; |
char b2; |
char b3; |
char b4; |
} JOY_BUTTONS; |
typedef struct { /*describe the position boundaries of a joystick*/ |
int x_min; |
int y_min; |
int x_max; |
int y_max; |
} JOY_BOUND; |
void get_joystick_buttons(JOY_BUTTONS *jb); |
int get_joystick_AB(JOY_STATE *jsa, JOY_STATE *jsb); |
int get_joystick_A(JOY_STATE *js); |
int get_joystick_B(JOY_STATE *js); |
int get_joystick_bound_A(JOY_BOUND *jb); |
int get_joystick_bound_B(JOY_BOUND *jb); |
#endif |
/shark/trunk/drivers/joy/makefile |
---|
0,0 → 1,20 |
# Joystick Control |
ifndef BASE |
BASE=../.. |
endif |
include $(BASE)/config/config.mk |
LIBRARY = joy |
OBJS_PATH = $(BASE)/drivers/joy |
JOY = joy.o |
OBJS = $(JOY) |
C_OPT += -I./include -I. -I.. |
include $(BASE)/config/lib.mk |
/shark/trunk/drivers/joy/readme |
---|
0,0 → 1,37 |
Joystick port driver for Shark |
Structures: |
JOY_STATE = Describe the position and buttons state of a joystick |
int x; |
int y; |
char b1; |
char b2; |
JOY_BUTTONS = Describe the four buttons state of a joystick |
char b1; |
char b2; |
char b3; |
char b4; |
JOY_BOUND = Describe the position boundaries of a joystick |
int x_min; |
int y_min; |
int x_max; |
int y_max; |
Functions: |
int get_joystick_bound_A(JOY_BOUND *jb); |
int get_joystick_bound_B(JOY_BOUND *jb); |
Read, in a loop, x and y position of a joystick until a joystick button is pressed. Usefull to acquire min and max value for x and y axis. |
int get_joystick_A(JOY_STATE *js); |
int get_joystick_B(JOY_STATE *js); |
Get (x,y) position and buttons status of a joystick. |
int get_joystick_AB(JOY_STATE *jsa, JOY_STATE *jsb); |
Get (x,y) position and buttons status of both joysticks. |
void get_joystick_buttons(JOY_BUTTONS *jb); |
Get buttons status. |