|
Joined: Feb 2014
Posts: 802 Likes: 24
Senior Member
|
OP
Senior Member
Joined: Feb 2014
Posts: 802 Likes: 24 |
![[Linked Image from i.imgur.com]](https://i.imgur.com/NQ9rW2N.png) For fun, I thought I'd try to make a drag and drop thing in a web browser to map keys to make a translation list, that you could then compile.
|
|
|
|
Joined: Feb 2014
Posts: 802 Likes: 24
Senior Member
|
OP
Senior Member
Joined: Feb 2014
Posts: 802 Likes: 24 |
Found my Infinity footpedal, looks like it just generates BTN_1, BTN_2, BTN_3 events:
sudo evtest /dev/input/by-id/usb-VEC_VEC_USB_Footpedal-event-if00 --grab
Input driver version is 1.0.1
Input device ID: bus 0x3 vendor 0x5f3 product 0xff version 0x100
Input device name: "VEC VEC USB Footpedal"
Supported events:
Event type 0 (EV_SYN)
Event type 1 (EV_KEY)
Event code 256 (BTN_0)
Event code 257 (BTN_1)
Event code 258 (BTN_2)
Event type 4 (EV_MSC)
Event code 4 (MSC_SCAN)
Properties:
Testing ... (interrupt to exit)
Event: time 1617722876.764232, type 4 (EV_MSC), code 4 (MSC_SCAN), value 90001
Event: time 1617722876.764232, type 1 (EV_KEY), code 256 (BTN_0), value 1
Event: time 1617722876.764232, -------------- SYN_REPORT ------------
Event: time 1617722877.028207, type 4 (EV_MSC), code 4 (MSC_SCAN), value 90001
Event: time 1617722877.028207, type 1 (EV_KEY), code 256 (BTN_0), value 0
Event: time 1617722877.028207, -------------- SYN_REPORT ------------
Event: time 1617722877.796232, type 4 (EV_MSC), code 4 (MSC_SCAN), value 90002
Event: time 1617722877.796232, type 1 (EV_KEY), code 257 (BTN_1), value 1
Event: time 1617722877.796232, -------------- SYN_REPORT ------------
Event: time 1617722878.028207, type 4 (EV_MSC), code 4 (MSC_SCAN), value 90002
Event: time 1617722878.028207, type 1 (EV_KEY), code 257 (BTN_1), value 0
Event: time 1617722878.028207, -------------- SYN_REPORT ------------
Event: time 1617722879.588255, type 4 (EV_MSC), code 4 (MSC_SCAN), value 90003
Event: time 1617722879.588255, type 1 (EV_KEY), code 258 (BTN_2), value 1
Event: time 1617722879.588255, -------------- SYN_REPORT ------------
Event: time 1617722879.812259, type 4 (EV_MSC), code 4 (MSC_SCAN), value 90003
Event: time 1617722879.812259, type 1 (EV_KEY), code 258 (BTN_2), value 0
Event: time 1617722879.812259, -------------- SYN_REPORT ------------
I also found my ION DJ midi controller: Running aseqdump I could figure out all of the button/knob assignments: ![[Linked Image from i.imgur.com]](https://i.imgur.com/1fHjz8B.jpg) I installed vmpk (virtual midi piano keyboard) and if you send midi note down/up messages to the ION DJ that match the buttons, you can get the LEDS turn on and off. Now to translate midi messages into events.
|
|
|
|
Joined: Feb 2014
Posts: 802 Likes: 24
Senior Member
|
OP
Senior Member
Joined: Feb 2014
Posts: 802 Likes: 24 |
So I translate the turntables into relative movements, but the relative event handling never "centers" itself after you stop moving. This keeps the gun turret continually spinning left or right in Tron, or the mouse pointer moving left,right,up,or down in the last direction moved. I've tried to digest how mame handles the movements internally, there's got to be a way to stop the movement. else if (buffer[0]==0xb0) // convert midi controller message into EV_REL events
{
button_event.type = EV_REL;
button_event.code = (buffer[1]==25) ? REL_X : (buffer[1]==24) ? REL_Y : 0; // turntable is 25 and 24
button_event.value = (buffer[2] >= 64) ? buffer[2]-127 : buffer[2]; // turntable moves are signed 7 bit, really never gets higher than +/- 30 with the fastest spin I could do
if(write(fd, &button_event, sizeof button_event) < 0)
{
perror("write");
return 1;
}
// send SYNC event
button_event.type = EV_SYN;
button_event.code = 0;
button_event.value = 0;
if(write(fd, &button_event, sizeof button_event) < 0)
{
perror("write");
return 1;
}
It's interesting how x movement will stop the y movement and vice versa. src/osd/modules/input/input_sdl.cpp
// loop over all (track)balls
for (int ball = 0; ball < SDL_JoystickNumBalls(joy); ball++)
{
int itemid;
if (ball * 2 < INPUT_MAX_ADD_RELATIVE)
itemid = ITEM_ID_ADD_RELATIVE1 + ball * 2;
else
itemid = ITEM_ID_OTHER_AXIS_RELATIVE;
snprintf(tempname, sizeof(tempname), "R%d %s", ball * 2, devinfo->name());
devinfo->device()->add_item(tempname, (input_item_id)itemid, generic_axis_get_state<std::int32_t>, &devinfo->joystick.
balls[ball * 2]);
snprintf(tempname, sizeof(tempname), "R%d %s", ball * 2 + 1, devinfo->name());
devinfo->device()->add_item(tempname, (input_item_id)(itemid + 1), generic_axis_get_state<std::int32_t>, &devinfo->joy
stick.balls[ball * 2 + 1]);
}
}
static int event_types[] = {
static_cast<int>(SDL_JOYAXISMOTION),
static_cast<int>(SDL_JOYBALLMOTION),
static_cast<int>(SDL_JOYHATMOTION),
static_cast<int>(SDL_JOYBUTTONDOWN),
static_cast<int>(SDL_JOYBUTTONUP)
};
src/emu/ioport.cpp
// relative and positional controls all map directly with a 512x scale factor
else
{
// The relative code is set up to allow specifing PORT_MINMAX and default values.
// The validity checks are purposely set up to not allow you to use anything other
// a default of 0 and PORT_MINMAX(0,mask). This is in case the need arises to use
// this feature in the future. Keeping the code in does not hurt anything.
if (m_adjmin > m_adjmax)
// adjust for signed
m_adjmin = -m_adjmin;
if (m_wraps)
m_adjmax++;
m_minimum = (m_adjmin - m_adjdefvalue) * INPUT_RELATIVE_PER_PIXEL;
m_maximum = (m_adjmax - m_adjdefvalue) * INPUT_RELATIVE_PER_PIXEL;
// make the scaling the same for easier coding when we need to scale
m_scaleneg = m_scalepos = compute_scale(1, INPUT_RELATIVE_PER_PIXEL);
if (m_field.analog_reset())
// delta values reverse from center
m_reverse_val = 0;
else
{
// positional controls reverse from their max range
m_reverse_val = m_maximum + m_minimum;
// relative controls reverse from 1 past their max range
if (m_wraps)
{
// FIXME: positional needs -1, using INPUT_RELATIVE_PER_PIXEL skips a position (and reads outside the table array)
if(field.type() == IPT_POSITIONAL || field.type() == IPT_POSITIONAL_V)
m_reverse_val --;
else
m_reverse_val -= INPUT_RELATIVE_PER_PIXEL;
}
}
}
|
|
|
Forums9
Topics9,071
Posts118,945
Members5,014
|
Most Online890 Jan 17th, 2020
|
|
These forums are sponsored by Superior Solitaire, an ad-free card game collection for macOS and iOS. Download it today!
|
|
|
|