4dsdev
Views: 1,609,144 Main | Rules/FAQ | Memberlist | Active users | Last posts | Calendar | Stats | Online users | Search 11-21-24 10:02 AM
Guest:

0 users reading Code for HID | 1 bot

Main - Trash - Code for HID Hide post layouts | Thread closed


kasai07
Posted on 09-11-16 01:59 PM (rev. 9 of 09-11-16 04:56 PM) Link | #1089
Hello
sorry for my english
i'm french and I do not know too much English
here's what I did

Code HID for A9LH

"fs.c"

size_t Level3D()
{
return i2cReadRegister(I2C_DEV_MCU, 0x08);
}
size_t VolumeLevel()
{
return i2cReadRegister(I2C_DEV_MCU, 0x09);
}
size_t HID_Flag()
{
return i2cReadRegister(I2C_DEV_MCU, 0x10);
}
size_t BatteryLevel()
{
return i2cReadRegister(I2C_DEV_MCU, 0x0B);
}

"hid.h"
#define BUTTON_POWER 1
#define BUTTON_HOME 2
#define BUTTON_WIFI 3
u32 padflag_state;

"hid.c"
u32 InputWait() {
static u64 delay = 0;
u32 pad_state_old = HID_STATE;
delay = (delay) ? 72 : 128;
timer_start();
u32 HIDFlag = 0;

while (true) {

padflag_state = 0;
HIDFlag = HID_Flag();
if (HIDFlag == 0x01){ padflag_state = BUTTON_POWER; return 0; }
if (HIDFlag == 0x04){ padflag_state = BUTTON_HOME; return 0; }
if (HIDFlag == 0x10){ padflag_state = BUTTON_WIFI; return 0; }

u32 pad_state = HID_STATE;
if (!(~pad_state & BUTTON_ANY)) { // no buttons pressed
pad_state_old = pad_state;
delay = 0;
continue;
}

if ((pad_state == pad_state_old) && (!(~pad_state & BUTTON_ARROW) ||
(delay && (timer_msec() < delay)))) continue;

//Make sure the key is pressed
u32 t_pressed = 0;
for(; (t_pressed < 0x13000) && (pad_state == HID_STATE); t_pressed++);

if (t_pressed >= 0x13000)return ~pad_state;

}
}


"menu.c"
} else if (padflag_state == BUTTON_POWER) {
DeinitFS();
PowerOff();
} else if (padflag_state == BUTTON_HOME) {
DeinitFS();
Reboot();
}

missing buttons works


http://3dbrew.org/wiki/I2C_Registers


Main - Trash - Code for HID Hide post layouts | Thread closed

Page rendered in 0.013 seconds. (2048KB of memory used)
MySQL - queries: 28, rows: 65/65, time: 0.006 seconds.
[powered by Acmlm] Acmlmboard 2.064 (2018-07-20)
© 2005-2008 Acmlm, Xkeeper, blackhole89 et al.