KallistiOS git master
Independent SDK for the Sega Dreamcast
Loading...
Searching...
No Matches
purupuru.h
Go to the documentation of this file.
1/* KallistiOS ##version##
2
3 dc/maple/purupuru.h
4 Copyright (C) 2003 Megan Potter
5 Copyright (C) 2005, 2010 Lawrence Sebald
6
7*/
8
9/** \file dc/maple/purupuru.h
10 \brief Definitions for using the Puru Puru (Jump) Pack.
11 \ingroup peripherals_rumble
12
13 This file contains the definitions needed to access maple jump pack devices.
14 Puru Puru was Sega's internal name for the device, hence why its referred to
15 in this way here.
16
17 This driver is largely based off of information provided by Kamjin on the
18 DCEmulation forums. See
19 http://dcemulation.org/phpBB/viewtopic.php?f=29&t=48462 if you're interested
20 in the original documentation.
21
22 Also, its important to note that not all Jump Packs are created equal. Some
23 of the stuff in here does not do what it seems like it should on many
24 devices. The "decay" setting, for instance, does not seem to work on Sega
25 Puru Purus, and actually makes most (if not all) effects do absolutely
26 nothing. Basically, its all a big guess-and-test game to get things to work
27 the way you might like. Don't be surprised if you manage to set up something
28 that does absolutely nothing on the first try.
29
30 \author Lawrence Sebald
31*/
32
33#ifndef __DC_MAPLE_PURUPURU_H
34#define __DC_MAPLE_PURUPURU_H
35
36#include <sys/cdefs.h>
37__BEGIN_DECLS
38
39#include <arch/types.h>
40#include <dc/maple.h>
41
42/** \defgroup peripherals_rumble Rumble Pack
43 \brief Maple driver for vibration pack peripherals
44 \ingroup peripherals
45
46 @{
47*/
48
49/** \brief Effect generation structure.
50
51 This structure is used for convenience to send an effect to the jump pack.
52 This, along with the various macros in this file can give a slightly better
53 idea of the effect being generated than using the raw values.
54*/
55typedef struct purupuru_effect {
56 /** \brief The duration of the effect. No idea on units... */
58
59 /** \brief 2nd effect field. */
61
62 /** \brief 1st effect field. */
64
65 /** \brief Special effects field. */
68
69/* Set one of each of the following in the effect2 field of the
70 purupuru_effect_t. Valid values for each are 0-7. The LINTENSITY
71 value works with the INTENSITY of effect1 to increase the intensity
72 of the rumble, where UINTENSITY apparently lowers the rumble's
73 intensity somewhat. */
74
75/** \brief Upper-nibble of effect2 convenience macro.
76
77 This macro is for setting the upper nibble of the effect2 field of the
78 purupuru_effect_t. This apparently lowers the rumble's intensity somewhat.
79 Valid values are 0-7.
80*/
81#define PURUPURU_EFFECT2_UINTENSITY(x) (x << 4)
82
83/** \brief Lower-nibble of effect2 convenience macro.
84
85 This macro is for setting the lower nibble of the effect2 field of the
86 purupuru_effect_t. This value works with the upper nibble of the effect1
87 field to increase the intensity of the rumble effect. Valid values are 0-7.
88
89 \see PURUPURU_EFFECT1_INTENSITY
90*/
91#define PURUPURU_EFFECT2_LINTENSITY(x) (x)
92
93/* OR these in with your effect2 value if you feel so inclined.
94 if you or the PULSE effect in here, you probably should also
95 do so with the effect1 one below. */
96/** \brief Give a decay effect to the rumble on some packs. */
97#define PURUPURU_EFFECT2_DECAY (8 << 4)
98
99/** \brief Give a pulse effect to the rumble.
100
101 This probably should be used with PURUPURU_EFFECT1_PULSE as well.
102
103 \see PURUPURU_EFFECT1_PULSE
104*/
105#define PURUPURU_EFFECT2_PULSE (8)
106
107/* Set one value for this in the effect1 field of the effect structure. */
108/** \brief Upper nibble of effect1 convenience macro.
109
110 This macro is for setting the upper nibble of the effect1 field of the
111 purupuru_effect_t. This value works with the lower nibble of the effect2
112 field to increase the intensity of the rumble effect. Valid values are 0-7.
113
114 \see PURUPURU_EFFECT2_LINTENSITY
115*/
116#define PURUPURU_EFFECT1_INTENSITY(x) (x << 4)
117
118/* OR these in with your effect1 value, if you need them. PULSE
119 should probably be used with the PULSE in effect2, as well.
120 POWERSAVE will probably make your purupuru ignore that command. */
121/** \brief Give a pulse effect to the rumble.
122
123 This probably should be used with PURUPURU_EFFECT2_PULSE as well.
124
125 \see PURUPURU_EFFECT2_PULSE
126*/
127#define PURUPURU_EFFECT1_PULSE (8 << 4)
128
129/** \brief Ignore this command.
130
131 Most jump packs will ignore commands with this set in effect1, apparently.
132*/
133#define PURUPURU_EFFECT1_POWERSAVE (15)
134
135/* Special Effects and motor select. The normal purupuru packs will
136 only have one motor. Selecting MOTOR2 for these is probably not
137 a good idea. The PULSE setting here supposably creates a sharp
138 pulse effect, when ORed with the special field. */
139/** \brief Select motor #1.
140
141 Most jump packs only have one motor, but on things that do have more than
142 one motor (like PS1->Dreamcast controller adapters that support rumble),
143 this selects the first motor.
144*/
145#define PURUPURU_SPECIAL_MOTOR1 (1 << 4)
146
147/** \brief Select motor #2.
148
149 Most jump packs only have one motor, but on things that do have more than
150 one motor (like PS1->Dreamcast controller adapters that support rumble),
151 this selects the second motor.
152*/
153#define PURUPURU_SPECIAL_MOTOR2 (1 << 7)
154
155/** \brief Yet another pulse effect.
156
157 This supposedly creates a sharp pulse effect.
158*/
159#define PURUPURU_SPECIAL_PULSE (1)
160
161/** \brief Send an effect to a jump pack.
162
163 This function sends an effect created with the purupuru_effect_t structure
164 to a jump pack to be executed.
165
166 \param dev The device to send the command to.
167 \param effect The effect to send.
168 \retval MAPLE_EOK On success.
169 \retval MAPLE_EAGAIN If the command couldn't be sent. Try again later.
170 \retval MAPLE_ETIMEOUT If the command timed out while blocking.
171*/
173
174/** \brief Send a raw effect to a jump pack.
175
176 This function sends an effect to a jump pack to be executed. This is for if
177 you (for some reason) don't want to use purupuru_effect_t to build the
178 effect up.
179
180 \param dev The device to send the command to.
181 \param effect The effect to send.
182 \retval MAPLE_EOK On success.
183 \retval MAPLE_EAGAIN If the command couldn't be sent. Try again later.
184 \retval MAPLE_ETIMEOUT If the command timed out while blocking.
185*/
187
188/* \cond */
189/* Init / Shutdown */
190void purupuru_init(void);
191void purupuru_shutdown(void);
192/* \endcond */
193
194/** @} */
195
196__END_DECLS
197
198#endif /* __DC_MAPLE_PURUPURU_H */
199
int purupuru_rumble(maple_device_t *dev, purupuru_effect_t *effect)
Send an effect to a jump pack.
int purupuru_rumble_raw(maple_device_t *dev, uint32 effect)
Send a raw effect to a jump pack.
unsigned long uint32
32-bit unsigned integer
Definition types.h:33
unsigned char uint8
8-bit unsigned integer
Definition types.h:35
Maple Bus driver interface.
One maple device.
Definition maple.h:270
Effect generation structure.
Definition purupuru.h:55
uint8 duration
The duration of the effect.
Definition purupuru.h:57
uint8 effect2
2nd effect field.
Definition purupuru.h:60
uint8 effect1
1st effect field.
Definition purupuru.h:63
uint8 special
Special effects field.
Definition purupuru.h:66
Common integer types.