Commit 064b22f2 authored by Jan Holthuis's avatar Jan Holthuis
Browse files

linux-dist: Harmonize input device fd names

parent 3dc97132
...@@ -112,8 +112,8 @@ enum DCPad ...@@ -112,8 +112,8 @@ enum DCPad
void emit_WriteCodeCache(); void emit_WriteCodeCache();
static int JoyFD = -1; // Joystick file descriptor static int joystick_fd = -1; // Joystick file descriptor
static int kbfd = -1; static int evdev_fd = -1;
#define MAP_SIZE 32 #define MAP_SIZE 32
...@@ -196,15 +196,15 @@ void SetupInput() ...@@ -196,15 +196,15 @@ void SetupInput()
#else #else
#define EVDEV_DEVICE "/dev/event2" #define EVDEV_DEVICE "/dev/event2"
#endif #endif
kbfd = setup_input_evdev(EVDEV_DEVICE); evdev_fd = setup_input_evdev(EVDEV_DEVICE);
JoyFD = setup_input_joystick("/dev/input/js0"); joystick_fd = setup_input_joystick("/dev/input/js0");
#endif #endif
} }
bool HandleKb(u32 port) bool HandleKb(u32 port)
{ {
#if HOST_OS != OS_DARWIN && !defined(TARGET_EMSCRIPTEN) #if HOST_OS != OS_DARWIN && !defined(TARGET_EMSCRIPTEN)
if (kbfd < 0) if (evdev_fd < 0)
{ {
return false; return false;
} }
...@@ -227,7 +227,7 @@ bool HandleKb(u32 port) ...@@ -227,7 +227,7 @@ bool HandleKb(u32 port)
#define KEY_LOCK 0x77 // Note that KEY_LOCK is a switch and remains pressed until it's switched back #define KEY_LOCK 0x77 // Note that KEY_LOCK is a switch and remains pressed until it's switched back
static int keys[13]; static int keys[13];
while(read(kbfd, &ie, sizeof(ie)) == sizeof(ie)) while(read(evdev_fd, &ie, sizeof(ie)) == sizeof(ie))
{ {
//printf("type %i key %i state %i\n", ie.type, ie.code, ie.value); //printf("type %i key %i state %i\n", ie.type, ie.code, ie.value);
if (ie.type = EV_KEY) if (ie.type = EV_KEY)
...@@ -264,7 +264,7 @@ bool HandleKb(u32 port) ...@@ -264,7 +264,7 @@ bool HandleKb(u32 port)
#elif defined(TARGET_PANDORA) #elif defined(TARGET_PANDORA)
static int keys[13]; static int keys[13];
while(read(kbfd,&ie,sizeof(ie))==sizeof(ie)) while(read(evdev_fd,&ie,sizeof(ie))==sizeof(ie))
{ {
if (ie.type=EV_KEY) if (ie.type=EV_KEY)
//printf("type %i key %i state %i\n", ie.type, ie.code, ie.value); //printf("type %i key %i state %i\n", ie.type, ie.code, ie.value);
...@@ -301,7 +301,7 @@ bool HandleKb(u32 port) ...@@ -301,7 +301,7 @@ bool HandleKb(u32 port)
return true; return true;
#else #else
while(read(kbfd, &ie, sizeof(ie)) == sizeof(ie)) while(read(evdev_fd, &ie, sizeof(ie)) == sizeof(ie))
{ {
printf("type %i key %i state %i\n", ie.type, ie.code, ie.value); printf("type %i key %i state %i\n", ie.type, ie.code, ie.value);
} }
...@@ -314,13 +314,13 @@ bool HandleKb(u32 port) ...@@ -314,13 +314,13 @@ bool HandleKb(u32 port)
bool HandleJoystick(u32 port) bool HandleJoystick(u32 port)
{ {
// Joystick must be connected // Joystick must be connected
if(JoyFD < 0) { if(joystick_fd < 0) {
return false; return false;
} }
#if HOST_OS != OS_DARWIN && !defined(TARGET_EMSCRIPTEN) #if HOST_OS != OS_DARWIN && !defined(TARGET_EMSCRIPTEN)
struct js_event JE; struct js_event JE;
while(read(JoyFD, &JE, sizeof(JE)) == sizeof(JE)) while(read(joystick_fd, &JE, sizeof(JE)) == sizeof(JE))
if (JE.number < MAP_SIZE) if (JE.number < MAP_SIZE)
{ {
switch(JE.type & ~JS_EVENT_INIT) switch(JE.type & ~JS_EVENT_INIT)
...@@ -794,8 +794,8 @@ void dc_run(); ...@@ -794,8 +794,8 @@ void dc_run();
size_t size; size_t size;
// close files // close files
if (JoyFD >= 0) { close(JoyFD); } if (joystick_fd >= 0) { close(joystick_fd); }
if (kbfd >= 0) { close(kbfd); } if (evdev_fd >= 0) { close(evdev_fd); }
// Close EGL context ??? // Close EGL context ???
if (sig_num!=0) if (sig_num!=0)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment