Skip to content

Commit

Permalink
Rework led setting for the event interface
Browse files Browse the repository at this point in the history
  • Loading branch information
amadvance committed Jun 2, 2017
1 parent 9ac03de commit 480ad7c
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
7 changes: 6 additions & 1 deletion advance/linux/event.c
Original file line number Diff line number Diff line change
Expand Up @@ -1323,7 +1323,12 @@ int event_open(const char* file, unsigned char* evtype_bitmask, unsigned evtype_
{
int f;

f = open(file, O_RDONLY | O_NONBLOCK);
/* keyboards need write access to control the leds */
f = open(file, O_RDWR | O_NONBLOCK);
if (f == -1) {
/* on failure, retry for read-only */
f = open(file, O_RDONLY | O_NONBLOCK);
}
if (f == -1) {
if (errno != ENODEV) {
log_std(("event: error opening device %s, errno %d (%s)\n", file, errno, strerror(errno)));
Expand Down
7 changes: 5 additions & 2 deletions advance/linux/kevent.c
Original file line number Diff line number Diff line change
Expand Up @@ -1137,12 +1137,15 @@ void keyb_event_all_get(unsigned keyboard, unsigned char* code_map)

void keyb_event_led_set(unsigned keyboard, unsigned led_mask)
{
unsigned led_state = event_state.map[keyboard].led_state;
int f = event_state.map[keyboard].fe;

log_debug(("keyb:event: keyb_event_led_set(keyboard:%d,mask:%d)\n", keyboard, led_mask));

#define led_update(i, k) \
do { \
if (((led_mask ^ event_state.map[keyboard].led_state) & k) != 0) \
event_write(event_state.map[keyboard].fe, EV_LED, i, (led_mask & k) != 0); \
if (((led_mask ^ led_state) & k) != 0) \
event_write(f, EV_LED, i, (led_mask & k) != 0); \
} while (0)

#ifdef LED_NUML
Expand Down
5 changes: 4 additions & 1 deletion doc/history.d
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
Name
history - History For AdvanceMAME/MESS

AdvanceMENU Version 3.5 2017/04
AdvanceMAME/MESS Version 3.5 2017/06
) Fixed led control for the Linux event keyboard interface.

AdvanceMENU Version 3.5 2017/06
) Added a new option 'ui_scrollbar' to disable the lateral scroll
bars.
) Added a new option 'ui_name' to disable the display of the game
Expand Down

0 comments on commit 480ad7c

Please sign in to comment.