mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-02 09:52:27 -04:00
device: recognize digitizers and pressure axis as well in evdev
Note that the Y axis is still inverted compared to on Windows; we need to decide what convention to follow here.
This commit is contained in:
parent
b67c7dd84f
commit
986b803e71
@ -364,7 +364,7 @@ init_device() {
|
|||||||
|
|
||||||
// Try to detect which type of device we have here
|
// Try to detect which type of device we have here
|
||||||
if (_device_class == DeviceClass::unknown) {
|
if (_device_class == DeviceClass::unknown) {
|
||||||
int device_scores[(size_t)DeviceClass::spatial_mouse] = {0};
|
int device_scores[(size_t)DeviceClass::digitizer + 1] = {0};
|
||||||
|
|
||||||
// Test for specific keys
|
// Test for specific keys
|
||||||
if (test_bit(BTN_GAMEPAD, keys) && test_bit(ABS_X, axes) && test_bit(ABS_RX, axes)) {
|
if (test_bit(BTN_GAMEPAD, keys) && test_bit(ABS_X, axes) && test_bit(ABS_RX, axes)) {
|
||||||
@ -385,6 +385,9 @@ init_device() {
|
|||||||
if (test_bit(BTN_MOUSE, keys) && test_bit(EV_REL, evtypes)) {
|
if (test_bit(BTN_MOUSE, keys) && test_bit(EV_REL, evtypes)) {
|
||||||
device_scores[(size_t)DeviceClass::mouse] += 20;
|
device_scores[(size_t)DeviceClass::mouse] += 20;
|
||||||
}
|
}
|
||||||
|
if (test_bit(BTN_DIGI, keys) && test_bit(EV_ABS, evtypes)) {
|
||||||
|
device_scores[(size_t)DeviceClass::digitizer] += 20;
|
||||||
|
}
|
||||||
uint8_t unknown_keys[] = {KEY_POWER};
|
uint8_t unknown_keys[] = {KEY_POWER};
|
||||||
for (int i = 0; i < 1; i++) {
|
for (int i = 0; i < 1; i++) {
|
||||||
if (test_bit(unknown_keys[i], keys)) {
|
if (test_bit(unknown_keys[i], keys)) {
|
||||||
@ -424,7 +427,7 @@ init_device() {
|
|||||||
|
|
||||||
// Check which device type got the most points
|
// Check which device type got the most points
|
||||||
int highest_score = 0;
|
int highest_score = 0;
|
||||||
for (size_t i = 0; i < (size_t)DeviceClass::spatial_mouse; i++) {
|
for (size_t i = 0; i <= (size_t)DeviceClass::digitizer; i++) {
|
||||||
if (device_scores[i] > highest_score) {
|
if (device_scores[i] > highest_score) {
|
||||||
highest_score = device_scores[i];
|
highest_score = device_scores[i];
|
||||||
_device_class = (DeviceClass)i;
|
_device_class = (DeviceClass)i;
|
||||||
@ -619,6 +622,9 @@ init_device() {
|
|||||||
have_analog_triggers = true;
|
have_analog_triggers = true;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case ABS_PRESSURE:
|
||||||
|
axis = InputDevice::Axis::pressure;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check the initial value and ranges.
|
// Check the initial value and ranges.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user