mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-12-02 16:44:10 +08:00
HID: wiimote: Add extension handler stubs
All supported extensions report data as 6 byte block. All DRMs with extension data provide at least 6 extension bytes. Hence a generic handler for all extension bytes is sufficient and can be called on all DRMs. The handler distinguishes the input and passes it to the right handler. Motion+ passes data interleaved so we can have Motion+ and a regular extension enabled simultaneously. Signed-off-by: David Herrmann <dh.herrmann@googlemail.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
This commit is contained in:
parent
479901ba18
commit
0b6815d75d
@ -857,6 +857,7 @@ static void handler_drm_KA(struct wiimote_data *wdata, const __u8 *payload)
|
||||
static void handler_drm_KE(struct wiimote_data *wdata, const __u8 *payload)
|
||||
{
|
||||
handler_keys(wdata, payload);
|
||||
wiiext_handle(wdata, &payload[2]);
|
||||
}
|
||||
|
||||
static void handler_drm_KAI(struct wiimote_data *wdata, const __u8 *payload)
|
||||
@ -873,6 +874,7 @@ static void handler_drm_KAI(struct wiimote_data *wdata, const __u8 *payload)
|
||||
static void handler_drm_KEE(struct wiimote_data *wdata, const __u8 *payload)
|
||||
{
|
||||
handler_keys(wdata, payload);
|
||||
wiiext_handle(wdata, &payload[2]);
|
||||
}
|
||||
|
||||
static void handler_drm_KIE(struct wiimote_data *wdata, const __u8 *payload)
|
||||
@ -883,12 +885,14 @@ static void handler_drm_KIE(struct wiimote_data *wdata, const __u8 *payload)
|
||||
ir_to_input2(wdata, &payload[7], false);
|
||||
ir_to_input3(wdata, &payload[9], true);
|
||||
input_sync(wdata->ir);
|
||||
wiiext_handle(wdata, &payload[12]);
|
||||
}
|
||||
|
||||
static void handler_drm_KAE(struct wiimote_data *wdata, const __u8 *payload)
|
||||
{
|
||||
handler_keys(wdata, payload);
|
||||
handler_accel(wdata, payload);
|
||||
wiiext_handle(wdata, &payload[5]);
|
||||
}
|
||||
|
||||
static void handler_drm_KAIE(struct wiimote_data *wdata, const __u8 *payload)
|
||||
@ -900,10 +904,12 @@ static void handler_drm_KAIE(struct wiimote_data *wdata, const __u8 *payload)
|
||||
ir_to_input2(wdata, &payload[10], false);
|
||||
ir_to_input3(wdata, &payload[12], true);
|
||||
input_sync(wdata->ir);
|
||||
wiiext_handle(wdata, &payload[15]);
|
||||
}
|
||||
|
||||
static void handler_drm_E(struct wiimote_data *wdata, const __u8 *payload)
|
||||
{
|
||||
wiiext_handle(wdata, payload);
|
||||
}
|
||||
|
||||
static void handler_drm_SKAI1(struct wiimote_data *wdata, const __u8 *payload)
|
||||
|
@ -204,6 +204,35 @@ bool wiiext_active(struct wiimote_data *wdata)
|
||||
return wdata->ext->motionp || wdata->ext->ext_type;
|
||||
}
|
||||
|
||||
static void handler_motionp(struct wiimote_ext *ext, const __u8 *payload)
|
||||
{
|
||||
}
|
||||
|
||||
static void handler_nunchuck(struct wiimote_ext *ext, const __u8 *payload)
|
||||
{
|
||||
}
|
||||
|
||||
static void handler_classic(struct wiimote_ext *ext, const __u8 *payload)
|
||||
{
|
||||
}
|
||||
|
||||
/* call this with state.lock spinlock held */
|
||||
void wiiext_handle(struct wiimote_data *wdata, const __u8 *payload)
|
||||
{
|
||||
struct wiimote_ext *ext = wdata->ext;
|
||||
|
||||
if (!ext)
|
||||
return;
|
||||
|
||||
if (ext->motionp && (payload[5] & 0x02)) {
|
||||
handler_motionp(ext, payload);
|
||||
} else if (ext->ext_type == WIIEXT_NUNCHUCK) {
|
||||
handler_nunchuck(ext, payload);
|
||||
} else if (ext->ext_type == WIIEXT_CLASSIC) {
|
||||
handler_classic(ext, payload);
|
||||
}
|
||||
}
|
||||
|
||||
static ssize_t wiiext_show(struct device *dev, struct device_attribute *attr,
|
||||
char *buf)
|
||||
{
|
||||
|
@ -125,6 +125,7 @@ extern int wiiext_init(struct wiimote_data *wdata);
|
||||
extern void wiiext_deinit(struct wiimote_data *wdata);
|
||||
extern void wiiext_event(struct wiimote_data *wdata, bool plugged);
|
||||
extern bool wiiext_active(struct wiimote_data *wdata);
|
||||
extern void wiiext_handle(struct wiimote_data *wdata, const __u8 *payload);
|
||||
|
||||
#else
|
||||
|
||||
@ -132,6 +133,7 @@ static inline int wiiext_init(void *u) { return 0; }
|
||||
static inline void wiiext_deinit(void *u) { }
|
||||
static inline void wiiext_event(void *u, bool p) { }
|
||||
static inline bool wiiext_active(void *u) { return false; }
|
||||
static inline void wiiext_handle(void *u, const __u8 *p) { }
|
||||
|
||||
#endif
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user