mirror of https://github.com/inolen/redream.git
return the maple frame was unhandled if sub-device doesn't exist
This commit is contained in:
parent
00e5376562
commit
f18f684b2f
|
@ -34,9 +34,9 @@ struct controller {
|
||||||
struct maple_cond cnd;
|
struct maple_cond cnd;
|
||||||
};
|
};
|
||||||
|
|
||||||
static void controller_frame(struct maple_device *dev,
|
static int controller_frame(struct maple_device *dev,
|
||||||
const union maple_frame *req,
|
const union maple_frame *req,
|
||||||
union maple_frame *res) {
|
union maple_frame *res) {
|
||||||
struct controller *ctrl = (struct controller *)dev;
|
struct controller *ctrl = (struct controller *)dev;
|
||||||
|
|
||||||
/* forward to sub-device if specified */
|
/* forward to sub-device if specified */
|
||||||
|
@ -45,8 +45,7 @@ static void controller_frame(struct maple_device *dev,
|
||||||
|
|
||||||
struct maple_device *sub = maple_get_device(dev->mp, port, unit);
|
struct maple_device *sub = maple_get_device(dev->mp, port, unit);
|
||||||
if (sub != dev) {
|
if (sub != dev) {
|
||||||
sub->frame(sub, req, res);
|
return sub && sub->frame(sub, req, res);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (req->command) {
|
switch (req->command) {
|
||||||
|
@ -98,6 +97,8 @@ static void controller_frame(struct maple_device *dev,
|
||||||
|
|
||||||
res->src_addr |= 1 << i;
|
res->src_addr |= 1 << i;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int controller_input(struct maple_device *dev, int button,
|
static int controller_input(struct maple_device *dev, int button,
|
||||||
|
|
|
@ -49,12 +49,7 @@ int maple_handle_frame(struct maple *mp, int port, union maple_frame *frame,
|
||||||
frame data bswap'd. for this reason, it's not valid to inspect the frame
|
frame data bswap'd. for this reason, it's not valid to inspect the frame
|
||||||
data in order to send the frame directly to the correct sub-device */
|
data in order to send the frame directly to the correct sub-device */
|
||||||
struct maple_device *dev = mp->devs[port][MAPLE_MAX_UNITS - 1];
|
struct maple_device *dev = mp->devs[port][MAPLE_MAX_UNITS - 1];
|
||||||
if (!dev) {
|
return dev && dev->frame(dev, frame, res);
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
dev->frame(dev, frame, res);
|
|
||||||
return 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void maple_handle_input(struct maple *mp, int port, int button,
|
void maple_handle_input(struct maple *mp, int port, int button,
|
||||||
|
|
|
@ -11,8 +11,8 @@ struct maple_device {
|
||||||
struct maple *mp;
|
struct maple *mp;
|
||||||
void (*destroy)(struct maple_device *);
|
void (*destroy)(struct maple_device *);
|
||||||
int (*input)(struct maple_device *, int, uint16_t);
|
int (*input)(struct maple_device *, int, uint16_t);
|
||||||
void (*frame)(struct maple_device *, const union maple_frame *,
|
int (*frame)(struct maple_device *, const union maple_frame *,
|
||||||
union maple_frame *);
|
union maple_frame *);
|
||||||
};
|
};
|
||||||
|
|
||||||
uint8_t maple_encode_addr(int port, int unit);
|
uint8_t maple_encode_addr(int port, int unit);
|
||||||
|
|
|
@ -53,8 +53,8 @@ static void vmu_parse_block_param(uint32_t data, int *partition, int *block,
|
||||||
*phase = (data >> 8) & 0xff;
|
*phase = (data >> 8) & 0xff;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void vmu_frame(struct maple_device *dev, const union maple_frame *req,
|
static int vmu_frame(struct maple_device *dev, const union maple_frame *req,
|
||||||
union maple_frame *res) {
|
union maple_frame *res) {
|
||||||
struct vmu *vmu = (struct vmu *)dev;
|
struct vmu *vmu = (struct vmu *)dev;
|
||||||
|
|
||||||
switch (req->command) {
|
switch (req->command) {
|
||||||
|
@ -155,6 +155,8 @@ static void vmu_frame(struct maple_device *dev, const union maple_frame *req,
|
||||||
res->num_words = 0;
|
res->num_words = 0;
|
||||||
} break;
|
} break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void vmu_destroy(struct maple_device *dev) {
|
static void vmu_destroy(struct maple_device *dev) {
|
||||||
|
|
Loading…
Reference in New Issue