mirror of
https://github.com/XProger/OpenLara.git
synced 2025-08-14 17:14:29 +02:00
Merge pull request #112 from pablomaiolo/axis-mapping
Use Linux kernel axis mapping for gamepad
This commit is contained in:
@@ -112,6 +112,7 @@ struct JoyDevice {
|
|||||||
float oL, oR; // last applied value
|
float oL, oR; // last applied value
|
||||||
int time; // time when we can send effect update
|
int time; // time when we can send effect update
|
||||||
ff_effect fx; // effect structure
|
ff_effect fx; // effect structure
|
||||||
|
uint8_t axismap[ABS_CNT]; // axis mapping
|
||||||
} joyDevice[INPUT_JOY_COUNT];
|
} joyDevice[INPUT_JOY_COUNT];
|
||||||
|
|
||||||
bool osJoyReady(int index) {
|
bool osJoyReady(int index) {
|
||||||
@@ -141,6 +142,7 @@ void joyInit() {
|
|||||||
int8 axes, buttons;
|
int8 axes, buttons;
|
||||||
ioctl(joy.fd, JSIOCGAXES, &axes);
|
ioctl(joy.fd, JSIOCGAXES, &axes);
|
||||||
ioctl(joy.fd, JSIOCGBUTTONS, &buttons);
|
ioctl(joy.fd, JSIOCGBUTTONS, &buttons);
|
||||||
|
ioctl(joy.fd, JSIOCGAXMAP, joy.axismap);
|
||||||
|
|
||||||
if (axes < 4 || buttons < 11) { // is it really a gamepad?
|
if (axes < 4 || buttons < 11) { // is it really a gamepad?
|
||||||
close(joy.fd);
|
close(joy.fd);
|
||||||
@@ -275,7 +277,7 @@ void joyUpdate() {
|
|||||||
// axes
|
// axes
|
||||||
if (event.type & JS_EVENT_AXIS) {
|
if (event.type & JS_EVENT_AXIS) {
|
||||||
|
|
||||||
switch (event.number) {
|
switch (joy.axismap[event.number]) {
|
||||||
// Left stick
|
// Left stick
|
||||||
case ABS_X : joy.L.x = joyAxisValue(event.value); break;
|
case ABS_X : joy.L.x = joyAxisValue(event.value); break;
|
||||||
case ABS_Y : joy.L.y = joyAxisValue(event.value); break;
|
case ABS_Y : joy.L.y = joyAxisValue(event.value); break;
|
||||||
|
Reference in New Issue
Block a user