Skip to content

odroidgo2-joypad: only flush once if an event occurred #399

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: odroidgoA-4.4.y
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 15 additions & 8 deletions drivers/input/joystick/odroidgo2-joypad.c
Original file line number Diff line number Diff line change
Expand Up @@ -387,10 +387,10 @@ static struct attribute_group joypad_attr_group = {

/*----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------*/
static void joypad_gpio_check(struct input_polled_dev *poll_dev)
static int joypad_gpio_check(struct input_polled_dev *poll_dev)
{
struct joypad *joypad = poll_dev->private;
int nbtn, value;
int nbtn, value, changed = 0;

for (nbtn = 0; nbtn < joypad->bt_gpio_count; nbtn++) {
struct bt_gpio *gpio = &joypad->gpios[nbtn];
Expand All @@ -406,16 +406,17 @@ static void joypad_gpio_check(struct input_polled_dev *poll_dev)
gpio->linux_code,
(value == gpio->active_level) ? 1 : 0);
gpio->old_value = value;
changed = 1;
}
}
input_sync(poll_dev->input);
return changed;
}

/*----------------------------------------------------------------------------*/
static void joypad_adc_check(struct input_polled_dev *poll_dev)
static int joypad_adc_check(struct input_polled_dev *poll_dev)
{
struct joypad *joypad = poll_dev->private;
int nbtn, value;
int nbtn, value, changed = 0;

for (nbtn = 0; nbtn < joypad->bt_adc_count; nbtn++) {
struct bt_adc *adc = &joypad->adcs[nbtn];
Expand All @@ -442,25 +443,31 @@ static void joypad_adc_check(struct input_polled_dev *poll_dev)
// adc-x value is default inverted(h/w)
input_report_abs(poll_dev->input,
adc->report_type, value * (-1));
changed = 1;
}
else
{
input_report_abs(poll_dev->input,
adc->report_type, value);
changed = 1;
}
adc->old_value = value;
}
input_sync(poll_dev->input);
return changed;
}

/*----------------------------------------------------------------------------*/
static void joypad_poll(struct input_polled_dev *poll_dev)
{
struct joypad *joypad = poll_dev->private;
int changed;

if (joypad->enable) {
joypad_adc_check(poll_dev);
joypad_gpio_check(poll_dev);
changed = joypad_adc_check(poll_dev);
changed |= joypad_gpio_check(poll_dev);
if (changed) {
input_sync(poll_dev->input);
}
}
if (poll_dev->poll_interval != joypad->poll_interval) {
mutex_lock(&joypad->lock);
Expand Down