rotary_encoder: added key events to increase and decrease
Subsystems (2)
PATCH 3/3 rotary_encoder: added key events to increase and decrease
You may now set key events for the increase and decrease events.
For example you could set this to "KEY_VOLUMEUP" and "KEY_VOLUMEDOWN" for a volume encoder.
Signed-off-by Jelle Martijn Kok <[email protected]>
--- drivers/input/misc/rotary_encoder.c | 19 +++++++++++++++++-- include/linux/rotary_encoder.h | 2 ++ 2 files changed, 19 insertions(+), 2 deletions(-)
drivers/input/misc/rotary_encoder.c +17 -2
@@ -56,9 +56,17 @@ static irqreturn_t rotary_encoder_irq(int irq, void *dev_id)int dir =0 ;if (state_exor ==0x01 ) { dir =+1 ; +if (pdata->event_up) { +input_report_key (encoder->input, pdata->event_up,1 ); +input_report_key (encoder->input, pdata->event_up,0 ); + } }else { dir =-1 ; +if (pdata->event_down) { +input_report_key (encoder->input, pdata->event_down,1 ); +input_report_key (encoder->input, pdata->event_down,0 ); + } }if (dir) {
@@ -130,11 +138,18 @@ static int __devinit rotary_encoder_probe(struct platform_device *pdev) input->id.bustype =BUS_HOST ; input->dev.parent = &pdev->dev; +if (pdata->event_up || pdata->event_down) { + input->evbit[0 ] |=BIT (EV_KEY ); +__set_bit (pdata->event_up, input->keybit); +__set_bit (pdata->event_down, input->keybit); +input_set_capability (input,EV_MSC ,MSC_SCAN ); + } +if (pdata->relative_axis) { - input->evbit[0 ] =BIT_MASK (EV_REL ); + input->evbit[0 ] |=BIT_MASK (EV_REL ); input->relbit[0 ] =BIT_MASK (pdata->axis); }else { - input->evbit[0 ] =BIT_MASK (EV_ABS ); + input->evbit[0 ] |=BIT_MASK (EV_ABS ); input_set_abs_params(encoder->input, pdata->axis, pdata->min_value, pdata->max_value,
0, 1);
}include/linux/rotary_encoder.h +2 -0
@@ -7,6 +7,8 @@ struct rotary_encoder_platform_data {unsigned int min_value;unsigned int max_value;unsigned int axis; +unsigned int event_up; +unsigned int event_down;unsigned int gpio_a;unsigned int gpio_b;unsigned int inverted_a;
Signature · 1 line
1.7.0.4