SGDK
A free and open development kit for the Sega Mega Drive
Loading...
Searching...
No Matches
joy.h
Go to the documentation of this file.
1
32
33#ifndef _JOY_H_
34#define _JOY_H_
35
36
37#define PORT_1 0x0000
38#define PORT_2 0x0001
39
40
41#define JOY_1 0x0000
42#define JOY_2 0x0001
43#define JOY_3 0x0002
44#define JOY_4 0x0003
45#define JOY_5 0x0004
46#define JOY_6 0x0005
47#define JOY_7 0x0006
48#define JOY_8 0x0007
49#define JOY_NUM 0x0008
50#define JOY_ALL 0xFFFF
51
52
53#define BUTTON_UP 0x0001
54#define BUTTON_DOWN 0x0002
55#define BUTTON_LEFT 0x0004
56#define BUTTON_RIGHT 0x0008
57#define BUTTON_A 0x0040
58#define BUTTON_B 0x0010
59#define BUTTON_C 0x0020
60#define BUTTON_START 0x0080
61#define BUTTON_X 0x0400
62#define BUTTON_Y 0x0200
63#define BUTTON_Z 0x0100
64#define BUTTON_MODE 0x0800
65
66#define BUTTON_LMB 0x0040
67#define BUTTON_MMB 0x0010
68#define BUTTON_RMB 0x0020
69
70#define BUTTON_DIR 0x000F
71#define BUTTON_BTN 0x0FF0
72#define BUTTON_ALL 0x0FFF
73
74#define JOY_TYPE_PAD3 0x00
75#define JOY_TYPE_PAD6 0x01
76#define JOY_TYPE_MOUSE 0x02
77#define JOY_TYPE_TRACKBALL 0x03
78#define JOY_TYPE_MENACER 0x04
79#define JOY_TYPE_JUSTIFIER 0x05
80#define JOY_TYPE_PHASER 0x06
81#define JOY_TYPE_UNKNOWN 0x0F
82
83#define PORT_TYPE_MENACER 0x00
84#define PORT_TYPE_JUSTIFIER 0x01
85#define PORT_TYPE_MOUSE 0x03
86#define PORT_TYPE_TEAMPLAYER 0x07
87#define PORT_TYPE_PAD 0x0D
88#define PORT_TYPE_UNKNOWN 0x0F
89#define PORT_TYPE_EA4WAYPLAY 0x10
90
91#define JOY_SUPPORT_OFF 0x00
92#define JOY_SUPPORT_3BTN 0x01
93#define JOY_SUPPORT_6BTN 0x02
94#define JOY_SUPPORT_MOUSE 0x03
95#define JOY_SUPPORT_TRACKBALL 0x04
96#define JOY_SUPPORT_TEAMPLAYER 0x05
97#define JOY_SUPPORT_EA4WAYPLAY 0x06
98#define JOY_SUPPORT_MENACER 0x07
99#define JOY_SUPPORT_JUSTIFIER_BLUE 0x08
100#define JOY_SUPPORT_JUSTIFIER_BOTH 0x09
101#define JOY_SUPPORT_PHASER 0x0A
102#define JOY_SUPPORT_ANALOGJOY 0x0B
103#define JOY_SUPPORT_KEYBOARD 0x0C
104
105
140typedef void JoyEventCallback(u16 joy, u16 changed, u16 state);
141
142
150void JOY_init(void);
151
159void JOY_reset(void);
160
221void JOY_setSupport(u16 port, u16 support);
222
250
274
309
333
347s16 JOY_writeJoypadX(u16 joy, u16 pos);
348
372
386s16 JOY_writeJoypadY(u16 joy, u16 pos);
387
392void JOY_waitPressBtn(void);
432u16 JOY_waitPress(u16 joy, u16 btn);
470u16 JOY_waitPressTime(u16 joy, u16 btn, u16 ms);
471
479void JOY_update(void);
480
481
482#endif // _JOY_H_
u16 JOY_waitPressBtnTime(u16 ms)
Wait the specified amount of time or until a button is pressed on any connected controller.
Definition joy.c:583
s16 JOY_readJoypadX(u16 joy)
Get joypad X axis.
Definition joy.c:549
void JOY_setSupport(u16 port, u16 support)
Set peripheral support for the specified port. By default ports are configured to only enable supp...
Definition joy.c:316
s16 JOY_writeJoypadX(u16 joy, u16 pos)
Write joypad X axis.
Definition joy.c:556
JoyEventCallback * JOY_getEventHandler()
Returns the current set callback function for controller state change. SGDK provides an event syst...
Definition joy.c:270
void JoyEventCallback(u16 joy, u16 changed, u16 state)
Joypad event callback.
Definition joy.h:140
s16 JOY_writeJoypadY(u16 joy, u16 pos)
Write joypad Y axis.
Definition joy.c:570
void JOY_update(void)
Manual update joypad state. By default the library update joypad state on V interrupt process....
Definition joy.c:1248
u8 JOY_getPortType(u16 port)
Get peripheral type for the specified port. The peripheral type for each port is automatically det...
Definition joy.c:515
u8 JOY_getJoypadType(u16 joy)
Get joypad peripheral type connected to the specified joypad port. The joypad peripheral type for ea...
Definition joy.c:522
void JOY_setEventHandler(JoyEventCallback *CB)
Set the callback function for controller state changed. SGDK provides an event system to detect st...
Definition joy.c:275
u16 JOY_waitPressTime(u16 joy, u16 btn, u16 ms)
Wait for specified button(s) to be pressed on specified joypad.
Definition joy.c:593
u16 JOY_waitPress(u16 joy, u16 btn)
Wait for specified button to be pressed on specified joypad.
Definition joy.c:588
u16 JOY_readJoypad(u16 joy)
Get joypad state.
Definition joy.c:530
void JOY_init(void)
Initialize the controller sub system.
Definition joy.c:50
void JOY_reset(void)
Reset the controller sub system.
Definition joy.c:59
void JOY_waitPressBtn(void)
Wait until a button is pressed on any connected controller.
Definition joy.c:578
s16 JOY_readJoypadY(u16 joy)
Get joypad Y axis.
Definition joy.c:563
short s16
Definition types.h:84
unsigned short u16
Definition types.h:100
unsigned char u8
Definition types.h:95