Giter Site home page Giter Site logo

Comments (5)

darthcloud avatar darthcloud commented on June 14, 2024

I'm very open to receiving PRs ;) Hopefully this help a bit:

Usage page is only stored as a 8bits value in the hid_parser stack:

struct hid_stack_element {
uint32_t report_size;
uint32_t report_cnt;
int32_t logical_min;
int32_t logical_max;
uint8_t usage_page;
};

Would make sense to upgrade it to 32bits since everything else is that, including the global structure used in all other module:

struct hid_usage {
uint32_t usage_page;
uint32_t usage;
uint32_t flags;
uint32_t bit_offset;
uint32_t bit_size;
int32_t logical_min;
int32_t logical_max;
};

You would need to cast the pointer to uint16_t * to grab the full value.

hid_stack[hid_stack_idx].usage_page = *(uint16_t *)desc;;
desc += 2;

Then after that you would likely need to edit the generic rumble code to support that usage_page/usage combination:

void hid_fb_from_generic(struct generic_fb *fb_data, struct bt_data *bt_data) {
struct generic_rumble *rumble = (struct generic_rumble *)bt_data->base.output;
rumble->report_size = 0;
uint32_t bytes_count = 0;
uint32_t tmp_value = 0;
uint32_t offset = 0;
uint32_t counter = 0;
bool is_rumble_usage = false;
for (uint32_t i = 0; i < bt_data->reports[RUMBLE].usage_cnt; i++)
{
is_rumble_usage = false;
switch (bt_data->reports[RUMBLE].usages[i].usage)
{
case 0x50: /* Duration */
bytes_count = (bt_data->reports[RUMBLE].usages[i].bit_size + 7) / 8;
rumble->report_size += bytes_count;
if (fb_data->state) {
tmp_value = bt_data->reports[RUMBLE].usages[i].logical_max;
}
else {
tmp_value = bt_data->reports[RUMBLE].usages[i].logical_min;
}
is_rumble_usage = true;
break;
case 0x70: /* Magnitude */
case 0x97: /* Enable Actuators */
bytes_count = (bt_data->reports[RUMBLE].usages[i].bit_size + 7) / 8;
rumble->report_size += bytes_count;
if (fb_data->state) {
tmp_value = bt_data->reports[RUMBLE].usages[i].logical_max * RUMBLE_ON_MULTIPLIER;
}
else {
tmp_value = bt_data->reports[RUMBLE].usages[i].logical_min;
}
is_rumble_usage = true;
break;
case 0x7C: /* Loop Count */
bytes_count = (bt_data->reports[RUMBLE].usages[i].bit_size + 7) / 8;
rumble->report_size += bytes_count;
if (fb_data->state) {
if (fb_data->cycles) {
tmp_value = fb_data->cycles;
}
else {
tmp_value = bt_data->reports[RUMBLE].usages[i].logical_max;
}
}
else {
tmp_value = bt_data->reports[RUMBLE].usages[i].logical_min;
}
is_rumble_usage = true;
break;
case 0xA7: /* Start Delay */
bytes_count = (bt_data->reports[RUMBLE].usages[i].bit_size + 7) / 8;
rumble->report_size += bytes_count;
tmp_value = fb_data->start;
is_rumble_usage = true;
break;
}
if (is_rumble_usage) {
counter = 0;
while(tmp_value)
{
rumble->state[offset++] = tmp_value;
tmp_value >>= 8;
counter++;
}
for (uint32_t refill = counter; refill < bytes_count; refill++) {
rumble->state[offset++] = 0;
}
}
}
rumble->report_id = bt_data->reports[RUMBLE].id;
}

from blueretro.

asweintraub avatar asweintraub commented on June 14, 2024

Thanks for the pointers! I probably won't have time to get around to this for a few weeks, since I don't have the ESP-IDF environment set up and will be quite busy. That said, it looks like a good idea to support 32-bit usage pages, so I'll give that a shot when I have the chance.

Either way, it looks as if the values are little-endian, so 0x06, 0x0F, 0x00 should be synonymous with 0x05, 0x0F, meaning we shouldn't have to modify anything else for this to work with Stadia. In fact, the largest usage page I can find in the HID docs is 0x91, so switching this to 32-bits (instead of dropping the extra bytes) is good for future-proofing, but otherwise unnecessary.

from blueretro.

darthcloud avatar darthcloud commented on June 14, 2024

Yes indeed it was simply the same value using a bigger sized var.

Rumble.work now!

https://github.com/darthcloud/BlueRetro/actions/runs/8808673421

from blueretro.

asweintraub avatar asweintraub commented on June 14, 2024

Nice! I didn't realize you had already merged the fix in. I modified the code earlier today but wasn't able to test it until just now. Thank you!

from blueretro.

darthcloud avatar darthcloud commented on June 14, 2024

Fixed in v24.04

from blueretro.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.