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 Copyright (C) 2025 Donald Haase
7
8*/
9
10/** \file dc/maple/purupuru.h
11 \brief Definitions for using the Puru Puru (Jump) Pack.
12 \ingroup peripherals_rumble
13
14 This file contains the definitions needed to access maple jump pack devices.
15 Puru Puru was Sega's internal name for the device, hence why its referred to
16 in this way here.
17
18 This driver is largely based off of information provided by Kamjin on the
19 DCEmulation forums. See
20 http://dcemulation.org/phpBB/viewtopic.php?f=29&t=48462 if you're interested
21 in the original documentation.
22
23 Also, its important to note that not all Jump Packs are created equal. Some
24 of the stuff in here does not do what it seems like it should on many
25 devices. The "decay" setting, for instance, does not seem to work on Sega
26 Puru Purus, and actually makes most (if not all) effects do absolutely
27 nothing. Basically, its all a big guess-and-test game to get things to work
28 the way you might like. Don't be surprised if you manage to set up something
29 that does absolutely nothing on the first try.
30
31 \author Lawrence Sebald
32 \author Donald Haase
33*/
34
35#ifndef __DC_MAPLE_PURUPURU_H
36#define __DC_MAPLE_PURUPURU_H
37
38#include <kos/cdefs.h>
39__BEGIN_DECLS
40
41#include <stdbool.h>
42#include <stdint.h>
43#include <dc/maple.h>
44
45/** \defgroup peripherals_rumble Rumble Pack
46 \brief Maple driver for vibration pack peripherals
47 \ingroup peripherals
48
49 @{
50*/
51
52/** \brief Effect generation structure.
53
54 This structure is used for convenience to send an effect to the jump pack.
55 The members in the structure note general explanations of their use as well
56 as some limitations and suggestions. There shouldn't be a need to use the
57 raw accessor with the new fully specified members.
58*/
59typedef union purupuru_effect {
60 /** \brief Access the raw 32-bit value to be sent to the puru */
62 /** \brief Deprecated old structure which has been inverted now to union with raw. */
63 struct {
64 uint8_t special __depr("Please see purupuru_effect_t which has new members.");
65 uint8_t effect1 __depr("Please see purupuru_effect_t which has new members.");
66 uint8_t effect2 __depr("Please see purupuru_effect_t which has new members.");
67 uint8_t duration __depr("Please see purupuru_effect_t which has new members.");
68 };
69 struct {
70 /** \brief Continuous Vibration. When set vibration will continue until stopped */
71 bool cont : 1;
72 /** \brief Reserved. Always 0s */
74 /** \brief Motor number. 0 will cause an error. 1 is the typical setting. */
76
77 /** \brief Backward direction (- direction) intensity setting bits. 0 stops vibration. */
79 /** \brief Divergent vibration. The rumble will get stronger until it stops. */
80 bool div : 1;
81 /** \brief Forward direction (+ direction) intensity setting bits. 0 stops vibration. */
83 /** \brief Convergent vibration. The rumble will get weaker until it stops. */
84 bool conv : 1;
85
86 /** \brief Vibration frequency. for most purupuru 4-59. */
87 uint8_t freq;
88 /** \brief Vibration inclination period. */
89 uint8_t inc;
90 };
92
93_Static_assert(sizeof(purupuru_effect_t) == 4, "Invalid effect size");
94
95 /* Compat */
96static inline uint32_t __depr("Please see purupuru_effect_t for modern equivalent.") PURUPURU_EFFECT2_UINTENSITY(uint8_t x) {return (x << 4);}
97static inline uint32_t __depr("Please see purupuru_effect_t for modern equivalent.") PURUPURU_EFFECT2_LINTENSITY(uint8_t x) {return (x);}
98static inline uint32_t __depr("Please see purupuru_effect_t for modern equivalent.") PURUPURU_EFFECT1_INTENSITY(uint8_t x) {return (x << 4);}
99
100static const uint8_t PURUPURU_EFFECT2_DECAY __depr("Please see purupuru_effect_t for modern equivalent.") = (8 << 4);
101static const uint8_t PURUPURU_EFFECT2_PULSE __depr("Please see purupuru_effect_t for modern equivalent.") = (8);
102static const uint8_t PURUPURU_EFFECT1_PULSE __depr("Please see purupuru_effect_t for modern equivalent.") = (8 << 4);
103static const uint8_t PURUPURU_EFFECT1_POWERSAVE __depr("Please see purupuru_effect_t for modern equivalent.") = (15);
104static const uint8_t PURUPURU_SPECIAL_MOTOR1 __depr("Please see purupuru_effect_t for modern equivalent.") = (1 << 4);
105static const uint8_t PURUPURU_SPECIAL_MOTOR2 __depr("Please see purupuru_effect_t for modern equivalent.") = (1 << 7);
106static const uint8_t PURUPURU_SPECIAL_PULSE __depr("Please see purupuru_effect_t for modern equivalent.") = (1);
107
108/** \brief Send an effect to a jump pack.
109
110 This function sends an effect created with the purupuru_effect_t structure
111 to a jump pack to be executed.
112
113 \param dev The device to send the command to.
114 \param effect The effect to send.
115 \retval MAPLE_EOK On success.
116 \retval MAPLE_EAGAIN If the command couldn't be sent. Try again later.
117 \retval MAPLE_EINVALID The command is not being sent due to invalid input.
118*/
120
121/** \brief Send a raw effect to a jump pack.
122
123 This function sends an effect to a jump pack to be executed. This is for if
124 you want to bypass KOS-based error checking. This is not recommended except
125 for testing purposes.
126
127 \param dev The device to send the command to.
128 \param effect The effect to send.
129 \retval MAPLE_EOK On success.
130 \retval MAPLE_EAGAIN If the command couldn't be sent. Try again later.
131*/
133
134/* \cond */
135/* Init / Shutdown */
136void purupuru_init(void);
137void purupuru_shutdown(void);
138/* \endcond */
139
140/** @} */
141
142__END_DECLS
143
144#endif /* __DC_MAPLE_PURUPURU_H */
145
Various common macros used throughout the codebase.
static uint32_t("Please see purupuru_effect_t for modern equivalent.") PURUPURU_EFFECT2_UINTENSITY(uint8_t x)
Definition purupuru.h:96
static const uint8_t PURUPURU_SPECIAL_MOTOR2("Please see purupuru_effect_t for modern equivalent.")
int purupuru_rumble_raw(maple_device_t *dev, uint32_t effect)
Send a raw effect to a jump pack.
int purupuru_rumble(maple_device_t *dev, const purupuru_effect_t *effect)
Send an effect to a jump pack.
static const uint8_t PURUPURU_SPECIAL_PULSE("Please see purupuru_effect_t for modern equivalent.")
static const uint8_t PURUPURU_EFFECT2_DECAY("Please see purupuru_effect_t for modern equivalent.")
static const uint8_t PURUPURU_EFFECT2_PULSE("Please see purupuru_effect_t for modern equivalent.")
static const uint8_t PURUPURU_EFFECT1_POWERSAVE("Please see purupuru_effect_t for modern equivalent.")
static const uint8_t PURUPURU_EFFECT1_PULSE("Please see purupuru_effect_t for modern equivalent.")
static const uint8_t PURUPURU_SPECIAL_MOTOR1("Please see purupuru_effect_t for modern equivalent.")
Maple Bus driver interface.
One maple device.
Definition maple.h:271
Effect generation structure.
Definition purupuru.h:59
uint8_t freq
Vibration frequency.
Definition purupuru.h:87
uint32_t fpow
Forward direction (+ direction) intensity setting bits.
Definition purupuru.h:82
uint32_t res
Reserved.
Definition purupuru.h:73
uint8_t inc
Vibration inclination period.
Definition purupuru.h:89
uint32_t motor
Motor number.
Definition purupuru.h:75
uint32_t raw
Access the raw 32-bit value to be sent to the puru.
Definition purupuru.h:61
bool div
Divergent vibration.
Definition purupuru.h:80
uint32_t bpow
Backward direction (- direction) intensity setting bits.
Definition purupuru.h:78
bool conv
Convergent vibration.
Definition purupuru.h:84
bool cont
Continuous Vibration.
Definition purupuru.h:71