Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7443 from zackhow/device-rumble
Android: Add controller rumble support
- Loading branch information
Showing
12 changed files
with
339 additions
and
98 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
75 changes: 75 additions & 0 deletions
75
...ain/java/org/dolphinemu/dolphinemu/features/settings/model/view/RumbleBindingSetting.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
package org.dolphinemu.dolphinemu.features.settings.model.view; | ||
|
||
import android.content.SharedPreferences; | ||
import android.content.res.Resources; | ||
import android.os.Vibrator; | ||
import android.view.InputDevice; | ||
import android.view.KeyEvent; | ||
|
||
import org.dolphinemu.dolphinemu.DolphinApplication; | ||
import org.dolphinemu.dolphinemu.R; | ||
import org.dolphinemu.dolphinemu.features.settings.model.Setting; | ||
import org.dolphinemu.dolphinemu.features.settings.model.StringSetting; | ||
import org.dolphinemu.dolphinemu.utils.Rumble; | ||
|
||
public class RumbleBindingSetting extends InputBindingSetting | ||
{ | ||
|
||
public RumbleBindingSetting(String key, String section, int titleId, Setting setting) | ||
{ | ||
super(key, section, titleId, setting); | ||
} | ||
|
||
@Override | ||
public String getValue() | ||
{ | ||
if (getSetting() == null) | ||
{ | ||
return ""; | ||
} | ||
|
||
StringSetting setting = (StringSetting) getSetting(); | ||
return setting.getValue(); | ||
} | ||
|
||
/** | ||
* Just need the device when saving rumble. | ||
*/ | ||
@Override | ||
public void onKeyInput(KeyEvent keyEvent) | ||
{ | ||
saveRumble(keyEvent.getDevice()); | ||
} | ||
|
||
/** | ||
* Just need the device when saving rumble. | ||
*/ | ||
@Override | ||
public void onMotionInput(InputDevice device, | ||
InputDevice.MotionRange motionRange, | ||
char axisDir) | ||
{ | ||
saveRumble(device); | ||
} | ||
|
||
private void saveRumble(InputDevice device) | ||
{ | ||
Vibrator vibrator = device.getVibrator(); | ||
if (vibrator != null && vibrator.hasVibrator()) | ||
{ | ||
setValue(device.getDescriptor(), device.getName()); | ||
Rumble.doRumble(vibrator); | ||
} | ||
else | ||
{ | ||
setValue("", | ||
DolphinApplication.getAppContext().getString(R.string.rumble_not_found)); | ||
} | ||
} | ||
|
||
@Override | ||
public int getType() | ||
{ | ||
return TYPE_RUMBLE_BINDING; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.